pub struct Watchdog<I, const N: usize, W, C>{ /* private fields */ }
Expand description
A version of the Watchdog that doesn’t require heap allocation. This uses a fixed-size array for task storage.
Implementations§
Source§impl<I: Id, W: HardwareWatchdog<C>, C: Clock, const N: usize> Watchdog<I, N, W, C>
impl<I: Id, W: HardwareWatchdog<C>, C: Clock, const N: usize> Watchdog<I, N, W, C>
Sourcepub fn new(hw_watchdog: W, config: WatchdogConfig<C>, clock: C) -> Self
pub fn new(hw_watchdog: W, config: WatchdogConfig<C>, clock: C) -> Self
Create a new watchdog with the given hardware watchdog and configuration.
Arguments:
hw_watchdog
- The hardware watchdog to use.config
- The configuration for the watchdog.clock
- The clock implementation to use for time-keeping.
Sourcepub fn register_task(
&mut self,
id: &I,
max_duration: C::Duration,
) -> Result<(), Error>
pub fn register_task( &mut self, id: &I, max_duration: C::Duration, ) -> Result<(), Error>
Register a task with the watchdog.
The task will be monitored by the watchdog.
Arguments:
id
- The task identifier.max_duration
- The maximum duration between feeds. If there is a gap longer than this, the watchdog will trigger.
§Errors
If there are no available slots to register the task, an error will be returned.
Sourcepub fn deregister_task(&mut self, id: &I)
pub fn deregister_task(&mut self, id: &I)
Deregister a task from the watchdog.
The task will no longer be monitored by the watchdog.
Arguments:
id
- The task identifier.
Sourcepub fn start(&mut self)
pub fn start(&mut self)
Start the watchdog.
This starts the hardware watchdog. You must run the watchdog task now to monitor the tasks.
Sourcepub fn check(&mut self) -> bool
pub fn check(&mut self) -> bool
Check if any tasks have starved the watchdog and take appropriate action.
Sourcepub fn trigger_reset(&mut self) -> !
pub fn trigger_reset(&mut self) -> !
Trigger a system reset.
Sourcepub fn reset_reason(&self) -> Option<ResetReason>
pub fn reset_reason(&self) -> Option<ResetReason>
Get the reason for the last reset.
Auto Trait Implementations§
impl<I, const N: usize, W, C> Freeze for Watchdog<I, N, W, C>
impl<I, const N: usize, W, C> RefUnwindSafe for Watchdog<I, N, W, C>where
W: RefUnwindSafe,
C: RefUnwindSafe,
<C as Clock>::Duration: RefUnwindSafe,
I: RefUnwindSafe,
<C as Clock>::Instant: RefUnwindSafe,
impl<I, const N: usize, W, C> Send for Watchdog<I, N, W, C>
impl<I, const N: usize, W, C> Sync for Watchdog<I, N, W, C>
impl<I, const N: usize, W, C> Unpin for Watchdog<I, N, W, C>
impl<I, const N: usize, W, C> UnwindSafe for Watchdog<I, N, W, C>where
W: UnwindSafe,
C: UnwindSafe,
<C as Clock>::Duration: UnwindSafe,
I: UnwindSafe,
<C as Clock>::Instant: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
Source§impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
impl<Choices> CoproductSubsetter<CNil, HNil> for Choices
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
impl<Src, Dst> LosslessTryInto<Dst> for Srcwhere
Dst: LosslessTryFrom<Src>,
Source§fn lossless_try_into(self) -> Option<Dst>
fn lossless_try_into(self) -> Option<Dst>
Performs the conversion.
Source§impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
impl<Src, Dst> LossyInto<Dst> for Srcwhere
Dst: LossyFrom<Src>,
Source§fn lossy_into(self) -> Dst
fn lossy_into(self) -> Dst
Performs the conversion.
Source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
Source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
Source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
Source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
Source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
Source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
Source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
Source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.