时间同步已经完成

This commit is contained in:
2026-08-28 16:42:44 +08:00
parent 615a9b13e9
commit 4e9ac0d9c3
20 changed files with 771 additions and 1282 deletions

40
App/time_sync.h Normal file
View File

@@ -0,0 +1,40 @@
/*
* 模块名称Time Sync — PC 本地时间推送接收TCP
* 模块功能:以 TCP Server 方式监听 TIME_SYNC_PORT接收 PC 推送的本地时间包,
* 更新系统墙钟并写回 SD2506 RTC
* 适用平台STM32F407ZGTx + CH395F
* 作者:王建锋
* 创建日期2026-08-27
* 修改记录:
* v1.0 2026-08-27 王建锋 创建初始版本UDP 推送)
* v1.1 2026-08-28 王建锋 改为 TCP Server迁入独立任务 timeSyncTask
*/
#ifndef __TIME_SYNC_H
#define __TIME_SYNC_H
#include <stdint.h>
#ifdef __cplusplus
extern "C" {
#endif
/* 监听端口PC 推送端TCP 客户端)需连到本端口 */
#define TIME_SYNC_PORT 8888
/*
* 函数功能:时间同步任务主体(独立 FreeRTOS 任务)
* 入口参数argument - FreeRTOS 传入参数(未使用)
* 返回值:无
* 限定条件net_init() 已由 netTask 完成;网络消息队列由 netTask 处理
* 函数说明:以 TCP Server 方式监听 TIME_SYNC_PORT接收 PC 推送的本地时间包,
* 经消息队列(由 netTask 串行执行)完成 socket 操作,更新系统墙钟。
* 该任务与 FTP 等其它网络任务并发安全。
*/
void timeSyncTask(void *argument);
#ifdef __cplusplus
}
#endif
#endif /* __TIME_SYNC_H */