Skip to content

Added initial watchdog proposal. #76

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 28, 2018
Merged
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
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -690,6 +690,7 @@ pub mod prelude;
pub mod serial;
pub mod spi;
pub mod timer;
pub mod watchdog;

/// Input capture
///
Expand Down
32 changes: 32 additions & 0 deletions src/watchdog.rs
Original file line number Diff line number Diff line change
@@ -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<T>(&mut self, period: T) where T: Into<Self::Time>;
}


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