dcf77.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019 HAW Hamburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
9 #pragma once
10 
24 #include <stdint.h>
25 #include <stdlib.h>
26 #include <inttypes.h>
27 #include "xtimer.h"
28 #include "time.h"
29 #include "periph/gpio.h"
30 #include "dcf77_internal.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
36 /* forward-declaration for dcf77_tick_cb_t */
37 struct dcf77;
38 
45 typedef void(*dcf77_tick_cb_t)(struct dcf77 *dev, void *arg);
46 
50 enum {
51  DCF77_OK = 0,
52  DCF77_NOCSUM = -1,
54  DCF77_INIT_ERROR = -3
55 };
56 
60 typedef struct {
61  gpio_t pin;
65 
69 typedef struct dcf77 {
73  uint32_t startTime;
74  uint8_t internal_state;
75  uint8_t bitCounter;
77  void *tick_cb_args;
79 
89 int dcf77_init(dcf77_t *dev, const dcf77_params_t *params);
90 
102 int dcf77_get_time(dcf77_t *dev, struct tm *time);
103 
113 void dcf77_set_tick_cb(dcf77_t *dev, dcf77_tick_cb_t cb, void *arg);
114 
115 #ifdef __cplusplus
116 }
117 #endif
118 
Bit definitions for DCF77 transmission.
Low-level GPIO peripheral driver interface definitions.
gpio_mode_t
Available pin modes.
Definition: periph_cpu.h:91
void dcf77_set_tick_cb(dcf77_t *dev, dcf77_tick_cb_t cb, void *arg)
Set a tick callback for DCF77.
int dcf77_init(dcf77_t *dev, const dcf77_params_t *params)
Initialize a new DCF77 device.
void(* dcf77_tick_cb_t)(struct dcf77 *dev, void *arg)
Signature for tick callback.
Definition: dcf77.h:45
struct dcf77 dcf77_t
Device descriptor for DCF77 sensor devices.
int dcf77_get_time(dcf77_t *dev, struct tm *time)
get a new timestamp from the device.
@ DCF77_INIT_ERROR
Initialization error.
Definition: dcf77.h:54
@ DCF77_OK
all good
Definition: dcf77.h:51
@ DCF77_NOCSUM
checksum error
Definition: dcf77.h:52
@ DCF77_TIMEOUT
communication timed out
Definition: dcf77.h:53
Adds include for missing inttype definitions.
Configuration parameters for DCF77 devices.
Definition: dcf77.h:60
gpio_t pin
GPIO pin of the device's data pin.
Definition: dcf77.h:61
gpio_mode_t in_mode
input pin configuration from the device, without pull resistor
Definition: dcf77.h:62
Device descriptor for DCF77 sensor devices.
Definition: dcf77.h:69
dcf77_bits_t last_bitseq
contains all Bits from a last cycle
Definition: dcf77.h:72
void * tick_cb_args
Arguments for the tick callback.
Definition: dcf77.h:77
dcf77_tick_cb_t tick_cb
Callback to be called if a new minute starts.
Definition: dcf77.h:76
dcf77_params_t params
Device parameters.
Definition: dcf77.h:70
dcf77_bits_t bitseq
contains all Bits from a current cycle
Definition: dcf77.h:71
uint8_t bitCounter
Counter of the Bits in a Bitsequenz.
Definition: dcf77.h:75
uint32_t startTime
Timestamp to measure the term of the level.
Definition: dcf77.h:73
uint8_t internal_state
internal States
Definition: dcf77.h:74
Timeinformation bitfields for DCF77 devices.
xtimer interface definitions