-
Notifications
You must be signed in to change notification settings - Fork 223
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
impl wdt modes #556
base: main
Are you sure you want to change the base?
impl wdt modes #556
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks a lot for the contribution!
Please have a look at the CI failures. Is this something you need to fix on your side or is it about bad register definitions that need to be fixed in avr-device
?
Additionally, please add an example to examples/arduino-uno
which demonstrates the use of the WDT interrupt.
@@ -66,6 +87,14 @@ impl<H, WDT: WdtOps<H>> Wdt<H, WDT> { | |||
Self { p, _h: PhantomData } | |||
} | |||
|
|||
pub fn rearm(&mut self, m: &WDT::MCUSR) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add documentation: What is this function used for? What effects does it have?
self.p.raw_init(m); | ||
} | ||
|
||
pub fn set_mode(&mut self, mode: WdtMode) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add documentation.
@@ -55,6 +61,21 @@ pub trait WdtOps<H> { | |||
fn raw_stop(&mut self); | |||
} | |||
|
|||
#[derive(Copy, Clone)] | |||
/// The mode that dictates how the watchdog should behave. | |||
/// This needs to be called **after** the `start` function. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You cannot "call" an enum. This statement probably belongs into the documentation of one of the methods?
/// **Warning**: On many `atmega` devices, a watchdog timeout resets the mode automatically, to | ||
/// prevent the microcontroller from getting stuck in a infinite loop. So subsequent timeouts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please be specific here: Which MCUs actually behave like this and which don't? Is it even a good idea to distingush about this or should we rather require the call of rearm()
on every AVR microcontroller?
This adds the ability to set the mode for the watchdog.
Previously the wdt mode was enforced to softreset the board.
Now we can also set it to trigger the
WDT
interrupt by callingwatchdog.set_mode()
.This PR closes #552
Please let me know if there is anything i need to change!