Skip to content

Commit 040a633

Browse files
committed
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.
1 parent 0bbb915 commit 040a633

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,7 @@ pub mod prelude;
690690
pub mod serial;
691691
pub mod spi;
692692
pub mod timer;
693+
pub mod watchdog;
693694

694695
/// Input capture
695696
///

src/watchdog.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//! Traits for interactions with a processors watchdog timer.
2+
3+
4+
5+
/// Feeds an existing watchdog to ensure the processor isn't reset. Sometimes
6+
/// commonly referred to as "kicking" or "refreshing".
7+
#[cfg(feature = "unproven")]
8+
pub trait Watchdog {
9+
/// Triggers the watchdog. This must be done once the watchdog is started
10+
/// to prevent the processor being reset.
11+
fn feed(&mut self);
12+
}
13+
14+
15+
/// Enables A watchdog timer to reset the processor if software is frozen or
16+
/// stalled.
17+
#[cfg(feature = "unproven")]
18+
pub trait WatchdogEnable {
19+
/// Unit of time used by the watchdog
20+
type Time;
21+
/// Starts the watchdog with a given period, typically once this is done
22+
/// the watchdog needs to be kicked periodically or the processor is reset.
23+
fn start<T>(&mut self, period: T) where T: Into<Self::Time>;
24+
}
25+
26+
27+
/// Disables a running watchdog timer so the processor won't be reset.
28+
#[cfg(feature = "unproven")]
29+
pub trait WatchdogDisable {
30+
/// Disables the watchdog
31+
fn disable(&mut self);
32+
}

0 commit comments

Comments
 (0)