1
0
mirror of https://github.com/taigrr/arduinolibs synced 2025-01-18 04:33:12 -08:00

Add a mode parameter to sleepFor()

This commit is contained in:
Rhys Weatherley 2012-05-22 14:45:10 +10:00
parent 849c776a3d
commit 9c29ee5b17
2 changed files with 6 additions and 3 deletions

View File

@ -125,8 +125,11 @@ ISR(WDT_vect)
* *
* The analog to digital converter and the brown out detector will * The analog to digital converter and the brown out detector will
* be disabled during sleep mode. * be disabled during sleep mode.
*
* The \a mode parameter indicates the mode to use when the device is
* sleeping. The default is SLEEP_MODE_IDLE.
*/ */
void sleepFor(SleepDuration duration) void sleepFor(SleepDuration duration, uint8_t mode)
{ {
// Turn off the analog to digital converter. // Turn off the analog to digital converter.
ADCSRA &= ~(1 << ADEN); ADCSRA &= ~(1 << ADEN);
@ -137,7 +140,7 @@ void sleepFor(SleepDuration duration)
WDTCSR |= (1 << WDIE); WDTCSR |= (1 << WDIE);
// Put the device to sleep, including turning off the Brown Out Detector. // Put the device to sleep, including turning off the Brown Out Detector.
set_sleep_mode(SLEEP_MODE_IDLE); set_sleep_mode(mode);
cli(); cli();
sleep_enable(); sleep_enable();
#if defined(sleep_bod_disable) #if defined(sleep_bod_disable)

View File

@ -45,6 +45,6 @@ enum SleepDuration
SLEEP_8_SEC SLEEP_8_SEC
}; };
void sleepFor(SleepDuration duration); void sleepFor(SleepDuration duration, uint8_t mode = 0);
#endif #endif