JeeLib
An easy interface to the port headers, the RF12 driver library, timers, low-power code, and more.
 All Classes Files Functions Variables Enumerations Macros Pages
Sleepy Class Reference

Low-power utility code using the Watchdog Timer (WDT). More...

#include <Ports.h>

Static Public Member Functions

static void watchdogInterrupts (char mode)
 start the watchdog timer (or disable it if mode < 0) More...
 
static void powerDown ()
 enter low-power mode, wake up with watchdog, INT0/1, or pin-change More...
 
static byte loseSomeTime (word msecs)
 Spend some time in low-power mode, the timing is only approximate. More...
 
static void watchdogEvent ()
 This must be called from your watchdog interrupt code.
 

Detailed Description

Low-power utility code using the Watchdog Timer (WDT).

Requires a WDT interrupt handler, e.g. EMPTY_INTERRUPT(WDT_vect);

Member Function Documentation

byte Sleepy::loseSomeTime ( word  msecs)
static

Spend some time in low-power mode, the timing is only approximate.

Parameters
msecsNumber of milliseconds to sleep, in range 0..65535.
Returns
1 if all went normally, or 0 if some other interrupt occurred
Note
If you use this function, you MUST included a definition of a WDT interrupt handler in your code. The simplest is to include this line:
ISR(WDT_vect) { Sleepy::watchdogEvent(); }

This will get called when the watchdog fires.

void Sleepy::powerDown ( )
static

enter low-power mode, wake up with watchdog, INT0/1, or pin-change

Take the ATmega into the deepest possible power down state.

Getting out of this state requires setting up the watchdog beforehand, or making sure that suitable interrupts will occur once powered down. Disables the Brown Out Detector (BOD), the A/D converter (ADC), and other peripheral functions such as TWI, SPI, and UART before sleeping, and restores their previous state when back up.

See Also
http://www.nongnu.org/avr-libc/user-manual/group__avr__sleep.html
void Sleepy::watchdogInterrupts ( char  mode)
static

start the watchdog timer (or disable it if mode < 0)

Parameters
modeEnable watchdog trigger after "16 << mode" milliseconds (mode 0..9), or disable it (mode < 0).
Note
If you use this function, you MUST included a definition of a WDT interrupt handler in your code. The simplest is to include this line:
ISR(WDT_vect) { Sleepy::watchdogEvent(); }

This will get called when the watchdog fires.


The documentation for this class was generated from the following files: