-
Notifications
You must be signed in to change notification settings - Fork 9
Add Watchdog trait #13
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| //! Traits for interactions with a processor's watchdog timer. | ||
|
|
||
| /// Feeds an existing watchdog to ensure the processor isn't reset. | ||
| pub trait Watchdog: Send { | ||
| /// An enumeration of `Watchdog` errors. | ||
| /// | ||
| type Error: core::fmt::Debug; | ||
|
|
||
| /// Restarts the countdown on the watchdog. This must be done once the watchdog is started | ||
| /// to prevent the processor being reset. | ||
| /// | ||
| fn feed(&mut self) -> Result<(), Self::Error>; | ||
jerrysxie marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| impl<T: Watchdog> Watchdog for &mut T { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looked odd to my eye, but apparently this pattern was established in embedded-hal by rust-embedded/embedded-hal#310. I guess the idea is that this lets a function that takes an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah as we discussed offline, I think this pattern makes sense in some contexts/for some traits, but for a Watchdog specifically I can't think of a particular use case. Though I don't think it will necessarily hurt to have it here anyway as if someone really wants to pass an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Though I do understand your concern that the blanket impl means a function that takes an |
||
| type Error = T::Error; | ||
|
|
||
| fn feed(&mut self) -> Result<(), Self::Error> { | ||
| T::feed(self) | ||
| } | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.