dcf routines for microbit
Fork of microbit-dcf by
Diff: dcf.h
- Revision:
- 4:eda8c18d0564
- Parent:
- 3:baecb5137d1a
--- a/dcf.h Fri Feb 24 07:52:08 2017 +0000 +++ b/dcf.h Sat Feb 25 16:57:37 2017 +0000 @@ -1,10 +1,14 @@ -// dcf V0.3 170224 qrt@qland.de +// dcf V0.6 170225 qrt@qland.de #ifndef _DCF_H_ #define _DCF_H_ #include "MicroBit.h" +// DISPLAY_MODE_BLACK_AND_WHITE_LIGHT_SENSE -> 5 + 1 -> 10 ms periods (funny, but oscilloscopes don't lie) +// DISPLAY_MODE_BLACK_AND_WHITE -> 6 + 1 -> 12 ms +#define TICK_PERIOD_MS (SYSTEM_TICK_PERIOD_MS + 1) + #define DCF_INPUT_PIN MICROBIT_ID_IO_P16 // DCF input pin #define PIN P16 // @@ -14,12 +18,14 @@ #define POSITIVE 1 #define DCF_LOGIC POSITIVE -#define SYNCINI (1<<0) // DCF sync init -#define SYNCSEC (1<<1) // second -#define SYNC59 (1<<2) // second 59 -#define SYNCDAT (1<<3) // data taken -#define SYNCDAV (1<<4) // verified -#define SYNCDAR (1<<5) // ready to take +#define IGNOPU 10 // ignore pulses after poweron + +#define SYNCINI (1<<0) // DCF sync init +#define SYNCSEC (1<<1) // second +#define SYNC59 (1<<2) // second 59 +#define SYNCDAT (1<<3) // data taken +#define SYNCDAV (1<<4) // verified +#define SYNCDAR (1<<5) // ready to take #define SYNCRES ~(SYNCSEC | SYNC59 | SYNCDAT | SYNCDAV | SYNCDAR) // sync restart @@ -35,7 +41,6 @@ static uint8_t year; static uint8_t status; // DCF status - static uint16_t secMs; // second in system ms static void init(MicroBit *uBit); static void receive(); @@ -54,14 +59,9 @@ static uint8_t bit; static uint8_t parity; - static uint32_t nextSec; - static uint32_t secStart; - static uint32_t secStartL; - static uint32_t bitEnd; - static uint32_t incStart; - static uint32_t ct; static uint32_t dt; + static void service(); static void secPulse(MicroBitEvent e); static void bitPulse(MicroBitEvent e);