avr-hal icon indicating copy to clipboard operation
avr-hal copied to clipboard

Watchdog intterupt mode

Open JonasFocke01 opened this issue 1 year ago • 1 comments

Hello,

i have a intentional deadlock, that is resolved by the watchdog of the arduino. The deadlock occurs, because i want my arduino to restart, if my host computer crashes (happens quite frequently...). The watchtog restarts the board, but i also need to keep some variables accross this restart. I could resolve my issue, if i could set the watchdog to interrupt-mode, as that would tell it to not restart the board and give me time to do something about it, but i have not found a way to do that.
Is this possible with this crate?
If yes, it would be very cool, if you could hint me in the right direction! If not, see this as a friendly feature request.

Regards, Jonas

Edit: This is the atmega doc on setting watchdog to interrupt mode (page 65)

JonasFocke01 avatar May 27 '24 12:05 JonasFocke01

Unfortunately, this is not yet supported in the HAL. You can of course implement this by directly interfacing with the registers, but there is no nice abstraction for it yet...

Let's use this issue to track implementation of this feature. I guess the best way to do this is adding a second constructor next to the existing one which enables the watchdog with interrupt-mode instead of soft-resetting the MCU.

https://github.com/Rahix/avr-hal/blob/38549cc4142881d302374535b3621578ffccaff2/avr-hal-generic/src/wdt.rs#L64-L67

Rahix avatar May 31 '24 13:05 Rahix