添加看门狗

This commit is contained in:
2024-03-25 15:09:55 +08:00
parent 564de1dab2
commit ca33b6e342
2 changed files with 13 additions and 0 deletions

10
main.c
View File

@@ -65,6 +65,15 @@ int main(void)
{
stdio_init_all();
sleep_ms(1000);
set_sys_clock_khz(250000, true);
if (watchdog_caused_reboot()) { // 判断是否从看门狗启动或者正常启动
printf("Rebooted by Watchdog!\n");
} else {
printf("Clean boot\n");
}
watchdog_enable(8300, 1); // 8秒检测是否重新加载看门狗计数器. (不更新计数器则重启硬件, 最高8秒)
watchdog_start_tick(12);
printf("EC800M\n");
EC800M_INIT();
@@ -73,6 +82,7 @@ int main(void)
GPS_ gps_;
while (1) {
watchdog_update(); // 喂狗
strcpy(gps_data, EC800M());
Data_parsing(gps_data, &gps_);
printf(" T: %s\n N: %s\n E: %s\n", gps_.time, gps_.N, gps_.E);

3
main.h
View File

@@ -7,4 +7,7 @@
#include "pico/stdlib.h"
#include "hardware/uart.h"
#include "hardware/clocks.h"
#include "hardware/watchdog.h"
#endif