mirror of
https://git.aixiao.me/aixiao/Danger-alarm.git
synced 2025-07-29 19:13:39 +08:00
FreeRTOS Add Boot Time
This commit is contained in:
39
SOFTWARE-FreeRTOS/Source/boot_time.cpp
Normal file
39
SOFTWARE-FreeRTOS/Source/boot_time.cpp
Normal file
@@ -0,0 +1,39 @@
|
||||
|
||||
#include "common.hpp"
|
||||
#include "HC-12.hpp"
|
||||
#include "boot_time.hpp"
|
||||
|
||||
|
||||
void BOOT_TIME(void *pvParameters)
|
||||
{
|
||||
(void)pvParameters;
|
||||
|
||||
_printTaskStackHighWaterMark("BOOT_TIME");
|
||||
|
||||
int _HC_12_SEND_NUM = 0;
|
||||
char BOOT_TIME_TEMP[BUFER] = { 0 };
|
||||
|
||||
|
||||
while (1) {
|
||||
// 获取自开机以来的微秒数
|
||||
uint64_t uptime_us = time_us_64();
|
||||
uint64_t total_uptime_sec = uptime_us / 1000000;
|
||||
|
||||
// 打印开机秒数
|
||||
printf("Boot Time: %llu seconds\n", total_uptime_sec);
|
||||
|
||||
{
|
||||
_HC_12_SEND_NUM++;
|
||||
if (_HC_12_SEND_NUM > 5) {
|
||||
sprintf(BOOT_TIME_TEMP, "Boot Time: %llu seconds\n", total_uptime_sec);
|
||||
_HC_12(BOOT_TIME_TEMP);
|
||||
memset(BOOT_TIME_TEMP, 0, BUFER);
|
||||
_HC_12_SEND_NUM = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
_printTaskStackHighWaterMark("BOOT_TIME");
|
||||
vTaskDelay(pdMS_TO_TICKS(1000)); // 每秒延迟
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user