#include <avr/power.h>
There are many macros in this header file that provide an easy interface to enable or disable on-board peripherals to reduce power. See the table below.
Not all AVR devices contain the same peripherals (for example, the LCD interface), or they will be named differently (for example, USART and USART0). Please consult your device's datasheet, or the header file, to find out which macros are applicable to your device.
typedef enum { clock_div_1 = 0, clock_div_2 = 1, clock_div_4 = 2, clock_div_8 = 3, clock_div_16 = 4, clock_div_32 = 5, clock_div_64 = 6, clock_div_128 = 7, clock_div_256 = 8, clock_div_1_rc = 15, // ATmega128RFA1 only } clock_div_t; __inline__ clock_prescale_set(x) { uint8_t tmp = _BV(CLKPCE); __asm__ __volatile__ ( " in __tmp_reg__,__SREG__ \n" " cli \n" " sts %1, %0 \n" " sts %1, %2 \n" " out __SREG__, __tmp_reg__ \n" // no outputs :"d" (tmp), "M" (_SFR_MEM_ADDR(CLKPR)), "d" (x) :"r0"); } #define clock_prescale_get() (clock_div_t)(CLKPR & (uint8_t)((1<<CLKPS0)|(1<<CLKPS1)|(1<<CLKPS2)|(1<<CLKPS3)))Clock prescaler setting enumerations.
clock_div_t
.