Skip to content
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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

JonasFocke01
Copy link

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 calling watchdog.set_mode().

This PR closes #552

Please let me know if there is anything i need to change!

Copy link
Owner

@Rahix Rahix left a 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) {
Copy link
Owner

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) {
Copy link
Owner

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.
Copy link
Owner

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?

Comment on lines +69 to +70
/// **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
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Watchdog intterupt mode
2 participants