Conversation
|
I wonder if we should do it how the Pico SDK does it, to avoid the confusion. |
|
We can implement |
|
I think that would be good. I'd we use a scratch that someone else is using, they can switch to one of yes others easily enough - or just call a different reboot function that doesn't set the register. |
|
I'm currently using a scratch register in my project to catch whether we've had a Core 0 restart (thanks to probe-rs) or a full system restart. If I detect the former, I use the watchdog to force the latter, so that Core 1 also gets reset. I'd have no problem changing that if required. |
This PR adds a
reason()method torp235x_hal::watchdog::Watchdog, returning the reset reason from the watchdog peripheral.Both the force and timer bits could technically be set simultaneously, but I've not been able to reproduce this.
One thing to note is that some ways to reboot the RP2350 give unexpected reasons:
reboot(RebootKind::Normal, RebootArch::Normal)explicit_buyThe official SDK avoids this confusion by not exposing the reason directly and instead providing
watchdog_caused_reboot(which checks reason and boot type) andwatchdog_enable_caused_reboot(which checks reason and a scratch register set bywatchdog_enable).