Skip to content

Commit

Permalink
Add sleep forever by sleep(0);
Browse files Browse the repository at this point in the history
For battery powered sensors which wake up by the RST Pin its useful
to sleep the cpu forever. When using this command:
sleep(INTERRUPT_NOT_DEFINED, MODE_NOT_DEFINED, 0, false);
the code will be stripped down to hwSleep(0);.
But this will not sleep the cpu forever.
  • Loading branch information
Tombula committed Apr 22, 2018
1 parent e0988e6 commit a2a9fa8
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions hal/architecture/AVR/MyHwAVR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,14 @@ void hwInternalSleep(uint32_t ms)

int8_t hwSleep(uint32_t ms)
{
hwInternalSleep(ms);
return MY_WAKE_UP_BY_TIMER;
if (ms > 0u) {
// sleep for defined time
hwInternalSleep(ms);
return MY_WAKE_UP_BY_TIMER;
} else {
// sleep until ext interrupt triggered
hwPowerDown(WDTO_SLEEP_FOREVER);
}
}

int8_t hwSleep(const uint8_t interrupt, const uint8_t mode, uint32_t ms)
Expand Down

0 comments on commit a2a9fa8

Please sign in to comment.