|
| 1 | +From 0d1e7e451736c26fa22f459914fa0e09f0949f38 Mon Sep 17 00:00:00 2001 |
| 2 | +From: giulcioffi < [email protected]> |
| 3 | +Date: Fri, 4 Jun 2021 14:45:38 +0200 |
| 4 | +Subject: [PATCH] Save watchdog timeout in a static variable accessible from |
| 5 | + Arduino APIs |
| 6 | + |
| 7 | +--- |
| 8 | + targets/TARGET_RASPBERRYPI/TARGET_RP2040/watchdog_api.c | 9 ++++++++- |
| 9 | + 1 file changed, 8 insertions(+), 1 deletion(-) |
| 10 | + |
| 11 | +diff --git a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/watchdog_api.c b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/watchdog_api.c |
| 12 | +index b7abac8917..9263eb48d5 100644 |
| 13 | +--- a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/watchdog_api.c |
| 14 | ++++ b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/watchdog_api.c |
| 15 | +@@ -4,8 +4,11 @@ |
| 16 | + |
| 17 | + #if DEVICE_WATCHDOG |
| 18 | + |
| 19 | ++static watchdog_config_t watchdogConfig; |
| 20 | ++ |
| 21 | + watchdog_status_t hal_watchdog_init(const watchdog_config_t *config) |
| 22 | + { |
| 23 | ++ watchdogConfig = *config; |
| 24 | + // The pico watchdogs accept a maximum value of 0x7fffff |
| 25 | + if ( config->timeout_ms < 0x1 && config->timeout_ms > 0x7FFFFF ) { |
| 26 | + return WATCHDOG_STATUS_INVALID_ARGUMENT; |
| 27 | +@@ -29,7 +32,11 @@ watchdog_status_t hal_watchdog_stop(void) |
| 28 | + |
| 29 | + uint32_t hal_watchdog_get_reload_value(void) |
| 30 | + { |
| 31 | +- return (watchdog_hw->load / 2000U); |
| 32 | ++ uint32_t load_value = watchdogConfig.timeout_ms * 1000 * 2; |
| 33 | ++ if (load_value > 0xffffffu) { |
| 34 | ++ load_value = 0xffffffu; |
| 35 | ++ } |
| 36 | ++ return load_value; |
| 37 | + } |
| 38 | + |
| 39 | + watchdog_features_t hal_watchdog_get_platform_features(void) |
| 40 | +-- |
| 41 | +2.32.0 |
| 42 | + |
0 commit comments