Updated Drivers

This commit is contained in:
Kevin Thomas
2026-03-23 09:33:04 -04:00
parent 6ee30d0520
commit 91faba6800
31 changed files with 827 additions and 337 deletions
+32 -13
View File
@@ -41,21 +41,40 @@
#include "pico/stdlib.h"
#include "watchdog.h"
/**
* @brief Print whether the system booted normally or from a watchdog reset
*/
static void _print_reset_reason(void) {
if (watchdog_driver_caused_reboot())
printf("System rebooted by watchdog timeout\r\n");
else
printf("Normal power-on reset\r\n");
}
/**
* @brief Feed the watchdog and log over UART, then wait 1 second
*/
static void _feed_and_report(void) {
watchdog_driver_feed();
printf("Watchdog fed\r\n");
sleep_ms(1000);
}
/**
* @brief Application entry point for the watchdog demo
*
* Enables the watchdog with a 3-second timeout and feeds it every
* 1 second. Reports the reset reason on startup.
*
* @return int Does not return
*/
int main(void) {
stdio_init_all();
if (watchdog_driver_caused_reboot()) {
printf("System rebooted by watchdog timeout\r\n");
} else {
printf("Normal power-on reset\r\n");
}
_print_reset_reason();
watchdog_driver_enable(3000);
printf("Watchdog enabled (3s timeout). Feeding every 1s...\r\n");
while (true) {
watchdog_driver_feed();
printf("Watchdog fed\r\n");
sleep_ms(1000);
}
while (true)
_feed_and_report();
}
+2
View File
@@ -34,10 +34,12 @@ void watchdog_driver_enable(uint32_t timeout_ms) {
watchdog_enable(timeout_ms, true);
}
void watchdog_driver_feed(void) {
watchdog_update();
}
bool watchdog_driver_caused_reboot(void) {
return watchdog_caused_reboot();
}