From 040a633081462ff61cfb62194332a7b58711650a Mon Sep 17 00:00:00 2001 From: xd009642 Date: Tue, 17 Apr 2018 21:45:06 +0100 Subject: [PATCH] Added initial watchdog proposal. This proposes 3 watchdog traits, one to enable the watchdog, one to disable and another to feed or "kick" the watchdog. Traits are currently unproven. --- src/lib.rs | 1 + src/watchdog.rs | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 src/watchdog.rs diff --git a/src/lib.rs b/src/lib.rs index 6e36046f5..f3c63243c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -690,6 +690,7 @@ pub mod prelude; pub mod serial; pub mod spi; pub mod timer; +pub mod watchdog; /// Input capture /// diff --git a/src/watchdog.rs b/src/watchdog.rs new file mode 100644 index 000000000..ee8cefc32 --- /dev/null +++ b/src/watchdog.rs @@ -0,0 +1,32 @@ +//! Traits for interactions with a processors watchdog timer. + + + +/// Feeds an existing watchdog to ensure the processor isn't reset. Sometimes +/// commonly referred to as "kicking" or "refreshing". +#[cfg(feature = "unproven")] +pub trait Watchdog { + /// Triggers the watchdog. This must be done once the watchdog is started + /// to prevent the processor being reset. + fn feed(&mut self); +} + + +/// Enables A watchdog timer to reset the processor if software is frozen or +/// stalled. +#[cfg(feature = "unproven")] +pub trait WatchdogEnable { + /// Unit of time used by the watchdog + type Time; + /// Starts the watchdog with a given period, typically once this is done + /// the watchdog needs to be kicked periodically or the processor is reset. + fn start(&mut self, period: T) where T: Into; +} + + +/// Disables a running watchdog timer so the processor won't be reset. +#[cfg(feature = "unproven")] +pub trait WatchdogDisable { + /// Disables the watchdog + fn disable(&mut self); +}