diff options
author | Thomas White <taw@physics.org> | 2023-02-26 17:01:47 +0100 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2023-02-26 17:01:47 +0100 |
commit | 2f3955aa509e594d9bf122519a8fe24ac0cb3577 (patch) | |
tree | 940c1e5988768003e6162b55f904431ca70cc1d6 | |
parent | 7352ae0cb2baad0c7f72febf85362c544442d5ea (diff) |
Add watchdog
-rw-r--r-- | morningtown.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/morningtown.c b/morningtown.c index 5f26626..f201abb 100644 --- a/morningtown.c +++ b/morningtown.c @@ -24,6 +24,7 @@ #include <pico/stdlib.h> #include <hardware/rtc.h> +#include <hardware/watchdog.h> #include <pico/cyw43_arch.h> #include "ntp_client.h" @@ -134,6 +135,7 @@ int main() cyw43_arch_enable_sta_mode(); stdio_init_all(); + watchdog_enable(0x7fffff, 1); cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1); gpio_put(LED_RED, 1); @@ -149,11 +151,13 @@ int main() last_conn = 10; while (1) { + watchdog_update(); + int st = cyw43_wifi_link_status(&cyw43_state, CYW43_ITF_STA); cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, !ntp_ok && (st == CYW43_LINK_JOIN)); - if ( (st != CYW43_LINK_JOIN) && (last_conn > 10) ) { + if ( (st != CYW43_LINK_JOIN) && (last_conn > 100) ) { cyw43_arch_wifi_connect_async(WIFI_SSID, WIFI_PASSWORD, CYW43_AUTH_WPA2_AES_PSK); @@ -177,11 +181,7 @@ int main() debug_print("tick\n"); last_conn += 1; - if ( ntp_ok ) { - sleep_ms(10000); - } else { - sleep_ms(1000); - } + sleep_ms(100); } } |