2019-03-31 19:13:06 +02:00
|
|
|
#ifndef _TIMESYNC_H
|
|
|
|
#define _TIMESYNC_H
|
2019-03-09 00:53:11 +01:00
|
|
|
|
|
|
|
#include "globals.h"
|
2019-03-31 19:13:06 +02:00
|
|
|
#include "irqhandler.h"
|
2019-03-09 00:53:11 +01:00
|
|
|
#include "timekeeper.h"
|
|
|
|
|
2020-03-07 23:18:36 +01:00
|
|
|
#define TIME_SYNC_FRAME_LENGTH 6 // timeserver answer frame length [bytes]
|
2021-07-23 19:10:41 +02:00
|
|
|
#define TIME_SYNC_FIXUP 25 // compensation for processing time [milliseconds]
|
2020-03-08 16:15:46 +01:00
|
|
|
#define TIME_SYNC_MAX_SEQNO 0xfe // threshold for wrap around time_sync_seqNo
|
|
|
|
#define TIME_SYNC_END_FLAG (TIME_SYNC_MAX_SEQNO + 1) // end of handshake marker
|
2019-03-09 00:53:11 +01:00
|
|
|
|
2020-03-03 12:54:42 +01:00
|
|
|
enum timesync_t {
|
|
|
|
timesync_tx,
|
|
|
|
timesync_rx,
|
|
|
|
gwtime_sec,
|
|
|
|
gwtime_msec,
|
|
|
|
no_of_timestamps
|
|
|
|
};
|
|
|
|
|
2019-04-07 16:13:04 +02:00
|
|
|
void timesync_init(void);
|
2020-03-11 23:49:06 +01:00
|
|
|
void timesync_request(void);
|
|
|
|
void timesync_store(uint32_t timestamp, timesync_t timestamp_type);
|
2020-03-06 19:24:58 +01:00
|
|
|
void IRAM_ATTR timesync_processReq(void *taskparameter);
|
2020-03-07 19:41:08 +01:00
|
|
|
void IRAM_ATTR timesync_serverAnswer(void *pUserData, int flag);
|
2019-03-09 00:53:11 +01:00
|
|
|
|
2019-09-03 16:28:11 +02:00
|
|
|
#endif
|