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); +}