Skip to content

Commit f91fc4b

Browse files
bors[bot]xd009642
andcommitted
Merge #76
76: Added initial watchdog proposal. r=therealprof a=xd009642 Added initial trait proposal for watchdog timer as mentioned in #75 Co-authored-by: xd009642 <[email protected]>
2 parents 30b6451 + 040a633 commit f91fc4b

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

src/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ pub mod prelude;
695695
pub mod serial;
696696
pub mod spi;
697697
pub mod timer;
698+
pub mod watchdog;
698699

699700
/// Input capture
700701
///

src/watchdog.rs

+32
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)