34 lines
743 B
C
34 lines
743 B
C
#include <stdint.h>
|
||
#include <stdbool.h>
|
||
#include <stddef.h>
|
||
#include <stdio.h>
|
||
#include <string.h>
|
||
|
||
#include "UartTask.h"
|
||
#include "RTCTask.h"
|
||
#include "os_cfg.h"
|
||
|
||
#include "DrvRtcI2c.h"
|
||
#include "BSPUart.h"
|
||
|
||
#include "driverlib/uart.h"
|
||
#include "inc/hw_memmap.h"
|
||
|
||
// UART任务,周期性发送时间
|
||
void UartTask(void *p_arg)
|
||
{
|
||
char timeStr[12];
|
||
|
||
while (1) {
|
||
// 从全局变量读取时间
|
||
sprintf(timeStr, "%02u:%02u:%02u", time.hour, time.minute, time.second); // 格式化时间字符串
|
||
|
||
// 发送格式化的时间字符串到UART
|
||
for (int i = 0; timeStr[i] != '\0'; i++) {
|
||
UARTCharPut(UART1_BASE, timeStr[i]);
|
||
}
|
||
|
||
OSTimeDlyHMSM(0, 0, 1, 0); // 延迟1秒
|
||
}
|
||
}
|