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 
22 #ifndef DCF77_H
23 #define DCF77_H
24 
25 #include <stdint.h>
26 #include <stdlib.h>
27 #include <inttypes.h>
28 #include "xtimer.h"
29 #include "time.h"
30 #include "periph/gpio.h"
31 #include "dcf77_internal.h"
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 /* forward-declaration for dcf77_tick_cb_t */
38 struct dcf77;
39 
46 typedef void(*dcf77_tick_cb_t)(struct dcf77 *dev, void *arg);
47 
51 enum {
52  DCF77_OK = 0,
53  DCF77_NOCSUM = -1,
56 };
57 
61 typedef struct {
62  gpio_t pin;
66 
67 
71 typedef struct dcf77 {
75  uint32_t startTime;
76  uint8_t internal_state;
77  uint8_t bitCounter;
79  void *tick_cb_args;
80 } dcf77_t;
81 
91 int dcf77_init(dcf77_t *dev, const dcf77_params_t *params);
92 
104 int dcf77_get_time(dcf77_t *dev, struct tm *time);
105 
115 void dcf77_set_tick_cb(dcf77_t *dev, dcf77_tick_cb_t cb, void *arg);
116 
117 #ifdef __cplusplus
118 }
119 #endif
120 
121 #endif /* DCF77_H */
122 
DCF77_TIMEOUT
@ DCF77_TIMEOUT
communication timed out
Definition: dcf77.h:54
dcf77::tick_cb
dcf77_tick_cb_t tick_cb
Callback to be called if a new minute starts.
Definition: dcf77.h:78
dcf77_internal.h
Bit definitions for DCF77 transmission.
dcf77_init
int dcf77_init(dcf77_t *dev, const dcf77_params_t *params)
Initialize a new DCF77 device.
dcf77_get_time
int dcf77_get_time(dcf77_t *dev, struct tm *time)
get a new timestamp from the device.
dcf77::bitCounter
uint8_t bitCounter
Counter of the Bits in a Bitsequenz.
Definition: dcf77.h:77
dcf77::last_bitseq
dcf77_bits_t last_bitseq
contains all Bits from a last cycle
Definition: dcf77.h:74
dcf77
Device descriptor for DCF77 sensor devices.
Definition: dcf77.h:71
dcf77::tick_cb_args
void * tick_cb_args
Arguments for the tick callback.
Definition: dcf77.h:79
DCF77_INIT_ERROR
@ DCF77_INIT_ERROR
Initialization error.
Definition: dcf77.h:55
dcf77_set_tick_cb
void dcf77_set_tick_cb(dcf77_t *dev, dcf77_tick_cb_t cb, void *arg)
Set a tick callback for DCF77.
dcf77_params_t
Configuration parameters for DCF77 devices.
Definition: dcf77.h:61
DCF77_NOCSUM
@ DCF77_NOCSUM
checksum error
Definition: dcf77.h:53
dcf77_params_t::pin
gpio_t pin
GPIO pin of the device's data pin.
Definition: dcf77.h:62
gpio.h
Low-level GPIO peripheral driver interface definitions.
gpio_mode_t
gpio_mode_t
Available pin modes.
Definition: periph_cpu.h:70
dcf77::bitseq
dcf77_bits_t bitseq
contains all Bits from a current cycle
Definition: dcf77.h:73
dcf77::internal_state
uint8_t internal_state
internal States
Definition: dcf77.h:76
dcf77_params_t::in_mode
gpio_mode_t in_mode
input pin configuration from the device, without pull resistor
Definition: dcf77.h:63
dcf77_t
struct dcf77 dcf77_t
Device descriptor for DCF77 sensor devices.
dcf77_bits_t
Timeinformation bitfields for DCF77 devices.
Definition: dcf77_internal.h:29
inttypes.h
Adds include for missing inttype definitions.
dcf77_tick_cb_t
void(* dcf77_tick_cb_t)(struct dcf77 *dev, void *arg)
Signature for tick callback.
Definition: dcf77.h:46
dcf77::startTime
uint32_t startTime
Timestamp to measure the term of the level.
Definition: dcf77.h:75
xtimer.h
xtimer interface definitions
dcf77::params
dcf77_params_t params
Device parameters.
Definition: dcf77.h:72
DCF77_OK
@ DCF77_OK
all good
Definition: dcf77.h:52