From a71a9c9bf06a30276dfb8292589c4592f9fe55fc Mon Sep 17 00:00:00 2001 From: Billy Price Date: Mon, 9 Mar 2026 16:30:30 -0700 Subject: [PATCH 1/2] Trait to feed watchdog --- embedded-mcu-hal/src/lib.rs | 2 ++ embedded-mcu-hal/src/watchdog.rs | 21 +++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 embedded-mcu-hal/src/watchdog.rs diff --git a/embedded-mcu-hal/src/lib.rs b/embedded-mcu-hal/src/lib.rs index 0b7ae05..f148106 100644 --- a/embedded-mcu-hal/src/lib.rs +++ b/embedded-mcu-hal/src/lib.rs @@ -5,3 +5,5 @@ pub mod time; /// Traits for NVRAM (Non-Volatile Random Access Memory) storage and management. mod nvram; pub use nvram::{Nvram, NvramStorage}; + +pub mod watchdog; diff --git a/embedded-mcu-hal/src/watchdog.rs b/embedded-mcu-hal/src/watchdog.rs new file mode 100644 index 0000000..f0bf69f --- /dev/null +++ b/embedded-mcu-hal/src/watchdog.rs @@ -0,0 +1,21 @@ +//! Traits for interactions with a processor's watchdog timer. + +/// Feeds an existing watchdog to ensure the processor isn't reset. +pub trait Watchdog { + /// An enumeration of `Watchdog` errors. + /// + type Error: core::fmt::Debug; + + /// Restarts the countdown on the watchdog. This must be done once the watchdog is started + /// to prevent the processor being reset. + /// + fn feed(&mut self) -> Result<(), Self::Error>; +} + +impl Watchdog for &mut T { + type Error = T::Error; + + fn feed(&mut self) -> Result<(), Self::Error> { + T::feed(self) + } +} From 8dcd438e49daba5bded8594101b1fd13cfa8e6fb Mon Sep 17 00:00:00 2001 From: Billy Price Date: Mon, 9 Mar 2026 16:51:44 -0700 Subject: [PATCH 2/2] send --- embedded-mcu-hal/src/watchdog.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/embedded-mcu-hal/src/watchdog.rs b/embedded-mcu-hal/src/watchdog.rs index f0bf69f..eb6ce65 100644 --- a/embedded-mcu-hal/src/watchdog.rs +++ b/embedded-mcu-hal/src/watchdog.rs @@ -1,7 +1,7 @@ //! Traits for interactions with a processor's watchdog timer. /// Feeds an existing watchdog to ensure the processor isn't reset. -pub trait Watchdog { +pub trait Watchdog: Send { /// An enumeration of `Watchdog` errors. /// type Error: core::fmt::Debug;