From a71a9c9bf06a30276dfb8292589c4592f9fe55fc Mon Sep 17 00:00:00 2001 From: Billy Price Date: Mon, 9 Mar 2026 16:30:30 -0700 Subject: [PATCH 1/4] 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/4] 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; From e4205d9289d7bc7fc0290c43d09e6d784c2fb70e Mon Sep 17 00:00:00 2001 From: Billy Price Date: Mon, 16 Mar 2026 11:33:19 -0700 Subject: [PATCH 3/4] remove ref impl for watchdog trait --- embedded-mcu-hal/src/watchdog.rs | 8 -------- 1 file changed, 8 deletions(-) diff --git a/embedded-mcu-hal/src/watchdog.rs b/embedded-mcu-hal/src/watchdog.rs index eb6ce65..8d94be1 100644 --- a/embedded-mcu-hal/src/watchdog.rs +++ b/embedded-mcu-hal/src/watchdog.rs @@ -11,11 +11,3 @@ pub trait Watchdog: Send { /// 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 43259ac270d3c811ea8d41ae6c4769d296a5c076 Mon Sep 17 00:00:00 2001 From: Billy Price Date: Tue, 17 Mar 2026 09:09:03 -0700 Subject: [PATCH 4/4] Revert "send" This reverts commit 8dcd438e49daba5bded8594101b1fd13cfa8e6fb. --- 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 8d94be1..18a7979 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: Send { +pub trait Watchdog { /// An enumeration of `Watchdog` errors. /// type Error: core::fmt::Debug;