raspberrypi / pico-examples

BSD 3-Clause "New" or "Revised" License
2.83k stars 820 forks source link

Update hello_watchdog to detect reboot only by watchdog #484

Open CorentinLemaitre opened 6 months ago

CorentinLemaitre commented 6 months ago

Hello,

I have changed the hello_watchdog.c example to detect only reboot caused by watchdog.

I have used the original example program and there was a wrong detection of watchdog caused reboot. For example, when a program was load on the RP2040 through uf2 file, then the RP2040 restart and the result of watchdog_caused_reboot() is true.

I have changed it to watchdog_enable_caused_reboot() cause based on the documentation found here.

I have tested it on my own project, the detection was fine without detection of reboot caused by program upload, that is why i do a pull request to help others to use watchdog.