Hi, nice project, thanks for sharing!
I believe the cli() and sei() calls are not necessary, as they are implemented in the LowPower library by rocketscream. Not really a problem, I was just a bit confused and wanted to mention it for future reference.
do{
cli();
if(digitalRead(CAN0_INT)) // last check for messages before going to sleep
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
sei();
analogRead(BAT_AIN); // dummy readout after powering ADC
} while (analogRead(BAT_AIN) <= LOWVOLT_THRESH || digitalRead(CAN0_INT));
Refer to the following code from LowPower.cpp, which gets indirectly executed if LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF) is called:
#define lowPowerBodOff(mode)
do {
set_sleep_mode(mode);
cli();
sleep_enable();
sleep_bod_disable();
sei();
sleep_cpu();
sleep_disable();
sei();
} while (0);
#endif
Hi, nice project, thanks for sharing! I believe the cli() and sei() calls are not necessary, as they are implemented in the LowPower library by rocketscream. Not really a problem, I was just a bit confused and wanted to mention it for future reference.
Refer to the following code from LowPower.cpp, which gets indirectly executed if LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF) is called: