1
1
//! Traits for interactions with a processors watchdog timer.
2
2
3
3
/// Feeds an existing watchdog to ensure the processor isn't reset. Sometimes
4
- /// commonly referred to as "kicking" or "refreshing".
4
+ /// the "feeding" operation is also referred to as "refreshing".
5
5
pub trait Watchdog {
6
6
/// An enumeration of `Watchdog` errors.
7
7
///
@@ -21,23 +21,28 @@ pub trait Enable {
21
21
/// For infallible implementations, will be `Infallible`
22
22
type Error ;
23
23
24
- /// Unit of time used by the watchdog
24
+ /// Unit of time used by the watchdog.
25
25
type Time ;
26
26
27
- /// The started watchdog that should be `feed()`
27
+ /// The started watchdog that should be `feed()`.
28
28
type Target : Watchdog ;
29
29
30
- /// Starts the watchdog with a given period, typically once this is done
31
- /// the watchdog needs to be kicked periodically or the processor is reset.
30
+ /// Starts the watchdog with a given period, typically once this is done
31
+ /// the watchdog needs to be `feed()` periodically, or the processor would be
32
+ /// reset.
32
33
///
33
34
/// This consumes the value and returns the `Watchdog` trait that you must
34
35
/// `feed()`.
35
- fn try_start < T > ( & mut self , period : T ) -> Result < Self :: Target , Self :: Error >
36
+ fn try_start < T > ( self , period : T ) -> Result < Self :: Target , Self :: Error >
36
37
where
37
38
T : Into < Self :: Time > ;
38
39
}
39
40
40
41
/// Disables a running watchdog timer so the processor won't be reset.
42
+ ///
43
+ /// Not all watchdog timers support disable operation after they've been enabled.
44
+ /// In this case, hardware support libraries would not implement this trait
45
+ /// and hardware-agnostic libraries should consider not requiring it.
41
46
pub trait Disable {
42
47
/// An enumeration of `Disable` errors.
43
48
///
@@ -47,9 +52,9 @@ pub trait Disable {
47
52
/// Disabled watchdog instance that can be enabled.
48
53
type Target : Enable ;
49
54
50
- /// Disables the watchdog
55
+ /// Disables the watchdog.
51
56
///
52
- /// This stops the watchdog and returns the `Enable` trait so that
53
- /// it can be started again.
54
- fn try_disable ( & mut self ) -> Result < Self :: Target , Self :: Error > ;
57
+ /// This stops the watchdog and returns an instance implementing the
58
+ /// `Enable` trait so that it can be started again.
59
+ fn try_disable ( self ) -> Result < Self :: Target , Self :: Error > ;
55
60
}
0 commit comments