Initial import of firmware and host projects
This commit is contained in:
33
inc/time_sync_protocol.h
Normal file
33
inc/time_sync_protocol.h
Normal file
@@ -0,0 +1,33 @@
|
||||
#ifndef TIME_SYNC_PROTOCOL_H__
|
||||
#define TIME_SYNC_PROTOCOL_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <zephyr/sys/util.h>
|
||||
|
||||
/*
|
||||
* 统一定义时间同步协议帧格式,方便 BLE/USB 两条链路共享:
|
||||
*
|
||||
* byte 0 : version
|
||||
* byte 1 : flags
|
||||
* byte 2-3 : timezone_min (little-endian, int16)
|
||||
* byte 4-11: utc_ms (little-endian, uint64)
|
||||
* byte 12-15: accuracy_ms (little-endian, uint32)
|
||||
*/
|
||||
#define TIME_SYNC_PROTOCOL_VERSION 1U
|
||||
#define TIME_SYNC_PROTOCOL_PAYLOAD_SIZE 16U
|
||||
|
||||
#define TIME_SYNC_PROTOCOL_OFFSET_VERSION 0U
|
||||
#define TIME_SYNC_PROTOCOL_OFFSET_FLAGS 1U
|
||||
#define TIME_SYNC_PROTOCOL_OFFSET_TIMEZONE 2U
|
||||
#define TIME_SYNC_PROTOCOL_OFFSET_UTC_MS 4U
|
||||
#define TIME_SYNC_PROTOCOL_OFFSET_ACCURACY_MS 12U
|
||||
|
||||
/*
|
||||
* 预留 flags 字段:
|
||||
* - 当前版本只要求时区字段有效;
|
||||
* - 后续如果要加 DST、闰秒或来源质量扩展,可以继续复用这个字节。
|
||||
*/
|
||||
#define TIME_SYNC_PROTOCOL_FLAG_TIMEZONE_VALID BIT(0)
|
||||
|
||||
#endif /* TIME_SYNC_PROTOCOL_H__ */
|
||||
Reference in New Issue
Block a user