Merge pull request #270 from cyberman54/development
bugfix IF482 RTC start
This commit is contained in:
commit
616d2bd8de
@ -6,5 +6,7 @@
|
||||
|
||||
int if482_init(void);
|
||||
void if482_loop(void *pvParameters);
|
||||
TickType_t tx_time(unsigned long baud, uint32_t config, int8_t rxPin,
|
||||
int8_t txPins);
|
||||
|
||||
#endif
|
@ -39,6 +39,7 @@ int dcf77_init(void) {
|
||||
|
||||
pinMode(HAS_DCF77, OUTPUT);
|
||||
set_DCF77_pin(dcf_low);
|
||||
timepulse_init(PPS); // setup timepulse
|
||||
|
||||
xTaskCreatePinnedToCore(dcf77_loop, // task function
|
||||
"dcf77loop", // name of task
|
||||
@ -49,8 +50,6 @@ int dcf77_init(void) {
|
||||
0); // CPU core
|
||||
|
||||
assert(ClockTask); // has clock task started?
|
||||
|
||||
timepulse_init(PPS); // setup pulse
|
||||
DCF_Out(sync_clock(now())); // sync DCF time on next second
|
||||
timepulse_start(); // start pulse
|
||||
|
||||
|
@ -107,6 +107,8 @@ int if482_init(void) {
|
||||
|
||||
// open serial interface
|
||||
IF482.begin(HAS_IF482);
|
||||
// setup timepulse
|
||||
timepulse_init(PPS);
|
||||
|
||||
// start if482 serial output feed task
|
||||
xTaskCreatePinnedToCore(if482_loop, // task function
|
||||
@ -118,8 +120,6 @@ int if482_init(void) {
|
||||
0); // CPU core
|
||||
|
||||
assert(ClockTask); // has clock task started?
|
||||
|
||||
timepulse_init(PPS); // setup pulse
|
||||
timepulse_start(); // start pulse
|
||||
|
||||
return 1; // success
|
||||
@ -161,7 +161,7 @@ void if482_loop(void *pvParameters) {
|
||||
|
||||
TickType_t wakeTime;
|
||||
const TickType_t timeOffset =
|
||||
pdMS_TO_TICKS(IF482_OFFSET); // duration of telegram transmit
|
||||
tx_time(HAS_IF482); // duration of telegram transmit
|
||||
const TickType_t startTime = xTaskGetTickCount(); // now
|
||||
|
||||
sync_clock(now()); // wait until begin of a new second
|
||||
@ -196,4 +196,15 @@ void if482_loop(void *pvParameters) {
|
||||
}
|
||||
} // if482_loop()
|
||||
|
||||
// helper function to calculate IF482 telegram serial tx time from serial
|
||||
// settings
|
||||
TickType_t tx_time(unsigned long baud, uint32_t config, int8_t rxPin,
|
||||
int8_t txPins) {
|
||||
|
||||
uint32_t datenbits = ((config & 0x0c) >> 2) + 5;
|
||||
uint32_t startbits = ((config & 0x20) >> 5) + 1;
|
||||
return pdMS_TO_TICKS(
|
||||
round(((datenbits + startbits + 1) * IF482_FRAME_SIZE * 1000.0 / baud)));
|
||||
}
|
||||
|
||||
#endif // HAS_IF482
|
@ -82,12 +82,11 @@
|
||||
#define RESPONSE_TIMEOUT_MS 60000 // firmware binary server connection timeout [milliseconds]
|
||||
|
||||
// settings for syncing time of node and external time sources
|
||||
#define TIME_SYNC_INTERVAL_GPS 60 // sync time each .. minutes from source GPS [default = 60], comment out means off
|
||||
#define TIME_SYNC_INTERVAL_GPS 5 // sync time each .. minutes from source GPS [default = 5], comment out means off
|
||||
#define TIME_SYNC_INTERVAL_RTC 60 // sync time each .. minutes from RTC [default = 60], comment out means off
|
||||
#define TIME_WRITE_INTERVAL_RTC 60 // write time each .. minutes from GPS/LORA to RTC [default = 60], comment out means off
|
||||
//#define TIME_SYNC_INTERVAL_LORA 60 // sync time each .. minutes from LORA network [default = 60], comment out means off
|
||||
#define TIME_SYNC_INTERVAL_DCF 60 // sync DCF signal time each .. minutes from internal time [default = 60], comment out means off
|
||||
#define IF482_OFFSET 16 // IF482 serial transmit time [ms]: e.g. 9 bits * 17 bytes * 1/9600 bps = 16ms
|
||||
|
||||
// time zone, see https://github.com/JChristensen/Timezone/blob/master/examples/WorldClock/WorldClock.ino
|
||||
#define DAYLIGHT_TIME {"CEST", Last, Sun, Mar, 2, 120} // Central European Summer Time
|
||||
|
@ -136,6 +136,7 @@ int timepulse_init(uint32_t pulse_period_ms) {
|
||||
Rtc.SetSquareWavePinClockFrequency(DS3231SquareWaveClock_1kHz);
|
||||
break;
|
||||
default:
|
||||
I2C_MUTEX_UNLOCK();
|
||||
goto pulse_period_error;
|
||||
}
|
||||
Rtc.SetSquareWavePin(DS3231SquareWavePin_ModeClock);
|
||||
|
Loading…
Reference in New Issue
Block a user