79 lines
2.0 KiB
Diff
79 lines
2.0 KiB
Diff
From 282b6b6e0b148d426c5c729b557fa397a66f9cdc Mon Sep 17 00:00:00 2001
|
|
From: giulcioffi <g.cioffi@arduino.cc>
|
|
Date: Mon, 15 Mar 2021 16:33:00 +0100
|
|
Subject: [PATCH 048/204] RP2040: Implement watchdog
|
|
|
|
---
|
|
.../TARGET_RP2040/watchdog_api.c | 46 +++++++++++++++++++
|
|
targets/targets.json | 1 +
|
|
2 files changed, 47 insertions(+)
|
|
create mode 100644 targets/TARGET_RASPBERRYPI/TARGET_RP2040/watchdog_api.c
|
|
|
|
diff --git a/targets/TARGET_RASPBERRYPI/TARGET_RP2040/watchdog_api.c b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/watchdog_api.c
|
|
new file mode 100644
|
|
index 0000000000..007b79c322
|
|
--- /dev/null
|
|
+++ b/targets/TARGET_RASPBERRYPI/TARGET_RP2040/watchdog_api.c
|
|
@@ -0,0 +1,46 @@
|
|
+#include "watchdog_api.h"
|
|
+#include "hardware/watchdog.h"
|
|
+#include "structs/watchdog.h"
|
|
+
|
|
+#if DEVICE_WATCHDOG
|
|
+
|
|
+watchdog_status_t hal_watchdog_init(const watchdog_config_t *config)
|
|
+{
|
|
+ // The pico watchdogs accept a maximum value of 0x7fffff
|
|
+ if ( config->timeout_ms < 0x1 && config->timeout_ms > 0x7FFFFF ) {
|
|
+ return WATCHDOG_STATUS_INVALID_ARGUMENT;
|
|
+ }
|
|
+
|
|
+ watchdog_enable(config->timeout_ms, true);
|
|
+
|
|
+ return WATCHDOG_STATUS_OK;
|
|
+}
|
|
+
|
|
+void hal_watchdog_kick(void)
|
|
+{
|
|
+ watchdog_update();
|
|
+}
|
|
+
|
|
+watchdog_status_t hal_watchdog_stop(void)
|
|
+{
|
|
+ hw_clear_bits(&watchdog_hw->ctrl, WATCHDOG_CTRL_ENABLE_BITS);
|
|
+ return WATCHDOG_STATUS_OK;
|
|
+}
|
|
+
|
|
+uint32_t hal_watchdog_get_reload_value(void)
|
|
+{
|
|
+ return (watchdog_hw->load / 2000U);
|
|
+}
|
|
+
|
|
+watchdog_features_t hal_watchdog_get_platform_features(void)
|
|
+{
|
|
+ watchdog_features_t features;
|
|
+
|
|
+ features.max_timeout = 0x7FFFFF;
|
|
+ features.update_config = true;
|
|
+ features.disable_watchdog = true;
|
|
+ return features;
|
|
+
|
|
+}
|
|
+
|
|
+#endif // DEVICE_WATCHDOG
|
|
diff --git a/targets/targets.json b/targets/targets.json
|
|
index 5e2aa5baaa..87b25d0c3b 100644
|
|
--- a/targets/targets.json
|
|
+++ b/targets/targets.json
|
|
@@ -9432,6 +9432,7 @@
|
|
"SERIAL_FC",
|
|
"SPI",
|
|
"USTICKER",
|
|
+ "WATCHDOG",
|
|
"USBDEVICE"
|
|
]
|
|
},
|
|
--
|
|
2.39.1
|
|
|