Skip to content

Commit 0d1e7e4

Browse files
giulcioffifacchinm
authored andcommitted
Save watchdog timeout in a static variable accessible from Arduino APIs
1 parent 45445a4 commit 0d1e7e4

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

targets/TARGET_RASPBERRYPI/TARGET_RP2040/watchdog_api.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
#if DEVICE_WATCHDOG
66

7+
static watchdog_config_t watchdogConfig;
8+
79
watchdog_status_t hal_watchdog_init(const watchdog_config_t *config)
810
{
11+
watchdogConfig = *config;
912
// The pico watchdogs accept a maximum value of 0x7fffff
1013
if ( config->timeout_ms < 0x1 && config->timeout_ms > 0x7FFFFF ) {
1114
return WATCHDOG_STATUS_INVALID_ARGUMENT;
@@ -29,7 +32,11 @@ watchdog_status_t hal_watchdog_stop(void)
2932

3033
uint32_t hal_watchdog_get_reload_value(void)
3134
{
32-
return (watchdog_hw->load / 2000U);
35+
uint32_t load_value = watchdogConfig.timeout_ms * 1000 * 2;
36+
if (load_value > 0xffffffu) {
37+
load_value = 0xffffffu;
38+
}
39+
return load_value;
3340
}
3441

3542
watchdog_features_t hal_watchdog_get_platform_features(void)

0 commit comments

Comments
 (0)