rocketscream / Low-Power

Low Power Library for Arduino
www.rocketscream.com
1.26k stars 345 forks source link

resolves #112 Restart sleep if WDT not what awakened CPU. #113

Open MojaveTom opened 3 years ago

MojaveTom commented 3 years ago

A volatile flag is set in the WDT ISR to show that the WDT interrupt happened. The flag is cleared in functions when not SLEEP_FOREVER before the interrupt is enabled. When an interrupt awakens the CPU, the flag is checked and the CPU put back to sleep if the WDT interrupt was not the cause of the awakening. For the case of SLEEP_FOREVER, the flag is set to "true" before the CPU is slept, and the functions return when awakened by any interrupt.

MojaveTom commented 3 years ago

Apologies for the white-space variances.

I suggest that the sources be consistent on white-space policy. The current sources have both tab and space on the same line.