Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions embedded-mcu-hal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
13 changes: 13 additions & 0 deletions embedded-mcu-hal/src/watchdog.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//! Traits for interactions with a processor's watchdog timer.
/// Feeds an existing watchdog to ensure the processor isn't reset.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want a secondary trait for Watchdogs that are cancelable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I thought about this a bit but I think right now we're targeting embassy-imxrt and embassy-mcxa, and I know that at least the imxrt board doesn't support cancellation of watchdogs; haven't looked at the sheet for mcxa yet, though.
I figured if we need to publish to crates.io, it's a breaking change to get it wrong and need to modify the trait, but adding a new 'CancelableWatchdog : Watchdog' trait is just a minor version, so I thought we might defer that until we have a hardware platform that actually has cancellation support to implement against.

pub trait Watchdog: Send {
/// 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>;
}
Loading