AVR Libc Home Page AVRs AVR Libc Development Pages
Main Page User Manual Library Reference FAQ Alphabetical Index Example Projects

power.h
Go to the documentation of this file.
00001 /* Copyright (c) 2006, 2007, 2008  Eric B. Weddington
00002    All rights reserved.
00003 
00004    Redistribution and use in source and binary forms, with or without
00005    modification, are permitted provided that the following conditions are met:
00006 
00007    * Redistributions of source code must retain the above copyright
00008      notice, this list of conditions and the following disclaimer.
00009    * Redistributions in binary form must reproduce the above copyright
00010      notice, this list of conditions and the following disclaimer in
00011      the documentation and/or other materials provided with the
00012      distribution.
00013    * Neither the name of the copyright holders nor the names of
00014      contributors may be used to endorse or promote products derived
00015      from this software without specific prior written permission.
00016 
00017   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00018   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00019   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00020   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
00021   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00022   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00023   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00024   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00025   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00026   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00027   POSSIBILITY OF SUCH DAMAGE. */
00028 
00029 /* $Id: power.h 2254 2011-09-26 15:06:50Z arcanum $ */
00030 
00031 #ifndef _AVR_POWER_H_
00032 #define _AVR_POWER_H_   1
00033 
00034 #include <avr/io.h>
00035 #include <stdint.h>
00036 
00037 
00038 /** \file */
00039 /** \defgroup avr_power <avr/power.h>: Power Reduction Management
00040 
00041 \code #include <avr/power.h>\endcode
00042 
00043 Many AVRs contain a Power Reduction Register (PRR) or Registers (PRRx) that 
00044 allow you to reduce power consumption by disabling or enabling various on-board 
00045 peripherals as needed.
00046 
00047 There are many macros in this header file that provide an easy interface
00048 to enable or disable on-board peripherals to reduce power. See the table below.
00049 
00050 \note Not all AVR devices have a Power Reduction Register (for example
00051 the ATmega128). On those devices without a Power Reduction Register, these 
00052 macros are not available.
00053 
00054 \note Not all AVR devices contain the same peripherals (for example, the LCD
00055 interface), or they will be named differently (for example, USART and 
00056 USART0). Please consult your device's datasheet, or the header file, to 
00057 find out which macros are applicable to your device.
00058 
00059 */
00060 
00061 
00062 /** \addtogroup avr_power
00063 
00064 \anchor avr_powermacros
00065 <small>
00066 <center>
00067 <table border="3">
00068   <tr>
00069     <td width="10%"><strong>Power Macro</strong></td>
00070     <td width="15%"><strong>Description</strong></td>
00071     <td width="75%"><strong>Applicable for device</strong></td>
00072   </tr>
00073 
00074   <tr>
00075     <td>power_adc_enable()</td>
00076     <td>Enable the Analog to Digital Converter module.</td>
00077     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM216, AT90PWM316, AT90PWM81, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega3250, ATmega3250A, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega48, ATmega88, ATmega168, ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861</td>
00078   </tr>
00079 
00080   <tr>
00081     <td>power_adc_disable()</td>
00082     <td>Disable the Analog to Digital Converter module.</td>
00083     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM216, AT90PWM316, AT90PWM81, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega3250, ATmega3250A, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega48, ATmega88, ATmega168, ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861</td>
00084   </tr>
00085 
00086   <tr>
00087     <td>power_lcd_enable()</td>
00088     <td>Enable the LCD module.</td>
00089     <td>ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega649, ATmega6490</td>
00090   </tr>
00091 
00092   <tr>
00093     <td>power_lcd_disable().</td>
00094     <td>Disable the LCD module.</td>
00095     <td>ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega649, ATmega6490</td>
00096   </tr>
00097 
00098   <tr>
00099     <td>power_pscr_enable()</td>
00100     <td>Enable the Reduced Power Stage Controller module.</td>
00101     <td>AT90PWM81</td>
00102   </tr>
00103 
00104   <tr>
00105     <td>power_pscr_disable()</td>
00106     <td>Disable the Reduced Power Stage Controller module.</td>
00107     <td>AT90PWM81</td>
00108   </tr>
00109 
00110   <tr>
00111     <td>power_psc0_enable()</td>
00112     <td>Enable the Power Stage Controller 0 module.</td>
00113     <td>AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B</td>
00114   </tr>
00115 
00116   <tr>
00117     <td>power_psc0_disable()</td>
00118     <td>Disable the Power Stage Controller 0 module.</td>
00119     <td>AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B</td>
00120   </tr>
00121 
00122   <tr>
00123     <td>power_psc1_enable()</td>
00124     <td>Enable the Power Stage Controller 1 module.</td>
00125     <td>AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B</td>
00126   </tr>
00127 
00128   <tr>
00129     <td>power_psc1_disable()</td>
00130     <td>Disable the Power Stage Controller 1 module.</td>
00131     <td>AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B</td>
00132   </tr>
00133 
00134   <tr>
00135     <td>power_psc2_enable()</td>
00136     <td>Enable the Power Stage Controller 2 module.</td>
00137     <td>AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM81</td>
00138   </tr>
00139 
00140   <tr>
00141     <td>power_psc2_disable()</td>
00142     <td>Disable the Power Stage Controller 2 module.</td>
00143     <td>AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM81</td>
00144   </tr>
00145 
00146   <tr>
00147     <td>power_spi_enable()</td>
00148     <td>Enable the Serial Peripheral Interface module.</td>
00149     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM216, AT90PWM316, AT90PWM81, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega3250, ATmega3250A, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega48, ATmega88, ATmega168</td>
00150   </tr>
00151 
00152   <tr>
00153     <td>power_spi_disable()</td>
00154     <td>Disable the Serial Peripheral Interface module.</td>
00155     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM216, AT90PWM316, AT90PWM81, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega3250, ATmega3250A, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega48, ATmega88, ATmega168</td>
00156   </tr>
00157 
00158   <tr>
00159     <td>power_timer0_enable()</td>
00160     <td>Enable the Timer 0 module.</td>
00161     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM216, AT90PWM316, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega3250, ATmega3250A, ATmega645, ATmega6450, ATmega164P, ATmega324P, ATmega644, ATmega406, ATmega48, ATmega88, ATmega168, ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861</td>
00162   </tr>
00163 
00164   <tr>
00165     <td>power_timer0_disable()</td>
00166     <td>Disable the Timer 0 module.</td>
00167     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM216, AT90PWM316, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega3250, ATmega3250A, ATmega645, ATmega6450, ATmega164P, ATmega324P, ATmega644, ATmega406, ATmega48, ATmega88, ATmega168, ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861</td>
00168   </tr>
00169 
00170   <tr>
00171     <td>power_timer1_enable()</td>
00172     <td>Enable the Timer 1 module.</td>
00173     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM216, AT90PWM316, AT90PWM81, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega3250, ATmega3250A, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega406, ATmega48, ATmega88, ATmega168, ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861</td>
00174   </tr>
00175 
00176   <tr>
00177     <td>power_timer1_disable()</td>
00178     <td>Disable the Timer 1 module.</td>
00179     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM216, AT90PWM316, AT90PWM81, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega3250, ATmega3250A, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega406, ATmega48, ATmega88, ATmega168, ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861</td>
00180   </tr>
00181 
00182   <tr>
00183     <td>power_timer2_enable()</td>
00184     <td>Enable the Timer 2 module.</td>
00185     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, ATmega164P, ATmega324P, ATmega644, ATmega48, ATmega88, ATmega168</td>
00186   </tr>
00187 
00188   <tr>
00189     <td>power_timer2_disable()</td>
00190     <td>Disable the Timer 2 module.</td>
00191     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, ATmega164P, ATmega324P, ATmega644, ATmega48, ATmega88, ATmega168</td>
00192   </tr>
00193 
00194   <tr>
00195     <td>power_timer3_enable()</td>
00196     <td>Enable the Timer 3 module.</td>
00197     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287</td>
00198   </tr>
00199 
00200   <tr>
00201     <td>power_timer3_disable()</td>
00202     <td>Disable the Timer 3 module.</td>
00203     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287</td>
00204   </tr>
00205 
00206   <tr>
00207     <td>power_timer4_enable()</td>
00208     <td>Enable the Timer 4 module.</td>
00209     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561</td>
00210   </tr>
00211 
00212   <tr>
00213     <td>power_timer4_disable()</td>
00214     <td>Disable the Timer 4 module.</td>
00215     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561</td>
00216   </tr>
00217 
00218   <tr>
00219     <td>power_timer5_enable()</td>
00220     <td>Enable the Timer 5 module.</td>
00221     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561</td>
00222   </tr>
00223 
00224   <tr>
00225     <td>power_timer5_disable()</td>
00226     <td>Disable the Timer 5 module.</td>
00227     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561</td>
00228   </tr>
00229 
00230   <tr>
00231     <td>power_twi_enable()</td>
00232     <td>Enable the Two Wire Interface module.</td>
00233     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, ATmega164P, ATmega324P, ATmega644, ATmega406, ATmega48, ATmega88, ATmega168</td>
00234   </tr>
00235 
00236   <tr>
00237     <td>power_twi_disable()</td>
00238     <td>Disable the Two Wire Interface module.</td>
00239     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, ATmega164P, ATmega324P, ATmega644, ATmega406, ATmega48, ATmega88, ATmega168</td>
00240   </tr>
00241 
00242   <tr>
00243     <td>power_usart_enable()</td>
00244     <td>Enable the USART module.</td>
00245     <td>AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B</td>
00246   </tr>
00247 
00248   <tr>
00249     <td>power_usart_disable()</td>
00250     <td>Disable the USART module.</td>
00251     <td>AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B</td>
00252   </tr>
00253 
00254   <tr>
00255     <td>power_usart0_enable()</td>
00256     <td>Enable the USART 0 module.</td>
00257     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega3250, ATmega3250A, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega48, ATmega88, ATmega168</td>
00258   </tr>
00259 
00260   <tr>
00261     <td>power_usart0_disable()</td>
00262     <td>Disable the USART 0 module.</td>
00263     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega3250, ATmega3250A, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega48, ATmega88, ATmega168</td>
00264   </tr>
00265 
00266   <tr>
00267     <td>power_usart1_enable()</td>
00268     <td>Enable the USART 1 module.</td>
00269     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, ATmega164P, ATmega324P, ATmega644</td>
00270   </tr>
00271 
00272   <tr>
00273     <td>power_usart1_disable()</td>
00274     <td>Disable the USART 1 module.</td>
00275     <td>ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, ATmega164P, ATmega324P, ATmega644</td>
00276   </tr>
00277 
00278   <tr>
00279     <td>power_usart2_enable()</td>
00280     <td>Enable the USART 2 module.</td>
00281     <td>ATmega640, ATmega1280, ATmega1281, ATmega2560, ATmega2561</td>
00282   </tr>
00283 
00284   <tr>
00285     <td>power_usart2_disable()</td>
00286     <td>Disable the USART 2 module.</td>
00287     <td>ATmega640, ATmega1280, ATmega1281, ATmega2560, ATmega2561</td>
00288   </tr>
00289 
00290   <tr>
00291     <td>power_usart3_enable()</td>
00292     <td>Enable the USART 3 module.</td>
00293     <td>ATmega640, ATmega1280, ATmega1281, ATmega2560, ATmega2561</td>
00294   </tr>
00295 
00296   <tr>
00297     <td>power_usart3_disable()</td>
00298     <td>Disable the USART 3 module.</td>
00299     <td>ATmega640, ATmega1280, ATmega1281, ATmega2560, ATmega2561</td>
00300   </tr>
00301 
00302   <tr>
00303     <td>power_usb_enable()</td>
00304     <td>Enable the USB module.</td>
00305     <td>AT90USB646, AT90USB647, AT90USB1286, AT90USB1287</td>
00306   </tr>
00307 
00308   <tr>
00309     <td>power_usb_disable()</td>
00310     <td>Disable the USB module.</td>
00311     <td>AT90USB646, AT90USB647, AT90USB1286, AT90USB1287</td>
00312   </tr>
00313 
00314   <tr>
00315     <td>power_usi_enable()</td>
00316     <td>Enable the Universal Serial Interface module.</td>
00317     <td>ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861</td>
00318   </tr>
00319 
00320   <tr>
00321     <td>power_usi_disable()</td>
00322     <td>Disable the Universal Serial Interface module.</td>
00323     <td>ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861</td>
00324   </tr>
00325 
00326   <tr>
00327     <td>power_vadc_enable()</td>
00328     <td>Enable the Voltage ADC module.</td>
00329     <td>ATmega406</td>
00330   </tr>
00331 
00332   <tr>
00333     <td>power_vadc_disable()</td>
00334     <td>Disable the Voltage ADC module.</td>
00335     <td>ATmega406</td>
00336   </tr>
00337 
00338   <tr>
00339     <td>power_all_enable()</td>
00340     <td>Enable all modules.</td>
00341     <td>ATxmega6A4, ATxmega32A4, ATxmega64A1, ATxmega64A1U, ATxmega64A3, ATxmegaA1, ATxmegaA1U, ATxmega128A3, ATxmega192A3, ATxmega256A3, ATxmegaA3B, ATxmega16D4, ATxmega32D4, ATxmega64D3, ATxmega128D3, ATxmega192D3, ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM216, AT90PWM316, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega3250, ATmega325A, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega406, ATmega48, ATmega88, ATmega168, ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861</td>
00342   </tr>
00343 
00344   <tr>
00345     <td>power_all_disable()</td>
00346     <td>Disable all modules.</td>
00347     <td>ATxmega6A4, ATxmega32A4, ATxmega64A1, ATxmega64A1U, ATxmega64A3, ATxmegaA1, ATxmegaA1U, ATxmega128A3, ATxmega192A3, ATxmega256A3, ATxmegaA3B, ATxmega16D4, ATxmega32D4, ATxmega64D3, ATxmega128D3,ATxmega192D3, ATmega640, ATmega1280, ATmega1281, ATmega128RFA1, ATmega2560, ATmega2561, AT90USB646, AT90USB647, AT90USB1286, AT90USB1287, AT90PWM1, AT90PWM2, AT90PWM2B, AT90PWM3, AT90PWM3B, AT90PWM216, AT90PWM316, ATmega165, ATmega165P, ATmega325, ATmega325A, ATmega3250, ATmega325A, ATmega645, ATmega6450, ATmega169, ATmega169P, ATmega329, ATmega329A, ATmega3290, ATmega3290A, ATmega649, ATmega6490, ATmega164P, ATmega324P, ATmega644, ATmega406, ATmega48, ATmega88, ATmega168, ATtiny24, ATtiny44, ATtiny84, ATtiny84A, ATtiny25, ATtiny45, ATtiny85, ATtiny261, ATtiny461, ATtiny861</td>
00348   </tr>
00349 </table>
00350 </center>
00351 </small>
00352 
00353 @} */
00354 
00355 // Xmega A series has AES, EBI and DMA bits
00356 // Include any other device on need basis
00357 #if defined(__AVR_ATxmega16A4__) \
00358 || defined(__AVR_ATxmega32A4__) \
00359 || defined(__AVR_ATxmega64A1__) \
00360 || defined(__AVR_ATxmega64A1U__) \
00361 || defined(__AVR_ATxmega64A3__) \
00362 || defined(__AVR_ATxmega128A1__) \
00363 || defined(__AVR_ATxmega128A1U__) \
00364 || defined(__AVR_ATxmega128A3__) \
00365 || defined(__AVR_ATxmega192A3__) \
00366 || defined(__AVR_ATxmega256A3__) \
00367 || defined(__AVR_ATxmega256A3B__)
00368 
00369 #define power_aes_enable()  (PR_PRGEN &= (uint8_t)~(PR_AES_bm))
00370 #define power_aes_disable() (PR_PRGEN |= (uint8_t)PR_AES_bm)
00371 
00372 #define power_ebi_enable()  (PR_PRGEN &= (uint8_t)~(PR_EBI_bm))
00373 #define power_ebi_disable() (PR_PRGEN |= (uint8_t)PR_EBI_bm)
00374 
00375 #define power_dma_enable()    (PR_PRGEN &= (uint8_t)~(PR_DMA_bm))
00376 #define power_dma_disable()   (PR_PRGEN |= (uint8_t)PR_DMA_bm)
00377 
00378 #define power_daca_enable()     (PR_PRPA &= (uint8_t)~(PR_DAC_bm))
00379 #define power_daca_disable()    (PR_PRPA |= (uint8_t)PR_DAC_bm)
00380 #define power_dacb_enable()     (PR_PRPB &= (uint8_t)~(PR_DAC_bm))
00381 #define power_dacb_disable()    (PR_PRPB |= (uint8_t)PR_DAC_bm)
00382 
00383 #define power_usartc1_enable()  (PR_PRPC &= (uint8_t)~(PR_USART1_bm))
00384 #define power_usartc1_disable() (PR_PRPC |= (uint8_t)PR_USART1_bm)
00385 #define power_usartd1_enable()  (PR_PRPD &= (uint8_t)~(PR_USART1_bm))
00386 #define power_usartd1_disable() (PR_PRPD |= (uint8_t)PR_USART1_bm)
00387 #define power_usarte1_enable()  (PR_PRPE &= (uint8_t)~(PR_USART1_bm))
00388 #define power_usarte1_disable() (PR_PRPE |= (uint8_t)PR_USART1_bm)
00389 #define power_usartf1_enable()  (PR_PRPF &= (uint8_t)~(PR_USART1_bm))
00390 #define power_usartf1_disable() (PR_PRPF |= (uint8_t)PR_USART1_bm)
00391 
00392 #define power_all_enable() \
00393 do { \
00394     PR_PRGEN &= (uint8_t)~(PR_AES_bm|PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
00395     PR_PRPA &= (uint8_t)~(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00396     PR_PRPB &= (uint8_t)~(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00397     PR_PRPC &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00398     PR_PRPD &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00399     PR_PRPE &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00400     PR_PRPF &= (uint8_t)~(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00401 } while(0)
00402 
00403 
00404 #define power_all_disable() \
00405 do { \
00406     PR_PRGEN|= (uint8_t)(PR_AES_bm|PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
00407     PR_PRPA |= (uint8_t)(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00408     PR_PRPB |= (uint8_t)(PR_DAC_bm|PR_ADC_bm|PR_AC_bm); \
00409     PR_PRPC |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00410     PR_PRPD |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00411     PR_PRPE |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00412     PR_PRPF |= (uint8_t)(PR_TWI_bm|PR_USART1_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00413 } while(0)
00414 #endif
00415 
00416 #if defined(__AVR_ATxmega16A4__) \
00417 || defined(__AVR_ATxmega16D4__) \
00418 || defined(__AVR_ATxmega32A4__) \
00419 || defined(__AVR_ATxmega32D4__) \
00420 || defined(__AVR_ATxmega64A1__) \
00421 || defined(__AVR_ATxmega64A1U__) \
00422 || defined(__AVR_ATxmega64A3__) \
00423 || defined(__AVR_ATxmega64D3__) \
00424 || defined(__AVR_ATxmega128A1__) \
00425 || defined(__AVR_ATxmega128A1U__) \
00426 || defined(__AVR_ATxmega128A3__) \
00427 || defined(__AVR_ATxmega128D3__) \
00428 || defined(__AVR_ATxmega192A3__) \
00429 || defined(__AVR_ATxmega192D3__) \
00430 || defined(__AVR_ATxmega256A3__) \
00431 || defined(__AVR_ATxmega256A3B__)
00432 
00433 
00434 #define power_rtc_enable()  (PR_PRGEN &= (uint8_t)~(PR_RTC_bm))
00435 #define power_rtc_disable() (PR_PRGEN |= (uint8_t)PR_RTC_bm)
00436 
00437 #define power_evsys_enable()    (PR_PRGEN &= (uint8_t)~(PR_EVSYS_bm))
00438 #define power_evsys_disable()   (PR_PRGEN |= (uint8_t)PR_EVSYS_bm)
00439 
00440 #define power_adca_enable()     (PR_PRPA &= (uint8_t)~(PR_ADC_bm))
00441 #define power_adca_disable()    (PR_PRPA |= (uint8_t)PR_ADC_bm)
00442 #define power_adcb_enable()     (PR_PRPB &= (uint8_t)~(PR_ADC_bm))
00443 #define power_adcb_disable()    (PR_PRPB |= (uint8_t)PR_ADC_bm)
00444 
00445 #define power_aca_enable()      (PR_PRPA &= (uint8_t)~(PR_AC_bm))
00446 #define power_aca_disable()     (PR_PRPA |= (uint8_t)PR_AC_bm)
00447 #define power_acb_enable()      (PR_PRPB &= (uint8_t)~(PR_AC_bm))
00448 #define power_acb_disable()     (PR_PRPB |= (uint8_t)PR_AC_bm)
00449 
00450 #define power_twic_enable()     (PR_PRPC &= (uint8_t)~(PR_TWI_bm))
00451 #define power_twic_disable()    (PR_PRPC |= (uint8_t)PR_TWI_bm)
00452 #define power_twid_enable()     (PR_PRPD &= (uint8_t)~(PR_TWI_bm))
00453 #define power_twid_disable()    (PR_PRPD |= (uint8_t)PR_TWI_bm)
00454 #define power_twie_enable()     (PR_PRPE &= (uint8_t)~(PR_TWI_bm))
00455 #define power_twie_disable()    (PR_PRPE |= (uint8_t)PR_TWI_bm)
00456 #define power_twif_enable()     (PR_PRPF &= (uint8_t)~(PR_TWI_bm))
00457 #define power_twif_disable()    (PR_PRPF |= (uint8_t)PR_TWI_bm)
00458 
00459 #define power_usartc0_enable()  (PR_PRPC &= (uint8_t)~(PR_USART0_bm))
00460 #define power_usartc0_disable() (PR_PRPC |= (uint8_t)PR_USART0_bm)
00461 #define power_usartd0_enable()  (PR_PRPD &= (uint8_t)~(PR_USART0_bm))
00462 #define power_usartd0_disable() (PR_PRPD |= (uint8_t)PR_USART0_bm)
00463 #define power_usarte0_enable()  (PR_PRPE &= (uint8_t)~(PR_USART0_bm))
00464 #define power_usarte0_disable() (PR_PRPE |= (uint8_t)PR_USART0_bm)
00465 #define power_usartf0_enable()  (PR_PRPF &= (uint8_t)~(PR_USART0_bm))
00466 #define power_usartf0_disable() (PR_PRPF |= (uint8_t)PR_USART0_bm)
00467 
00468 #define power_spic_enable()     (PR_PRPC &= (uint8_t)~(PR_SPI_bm))
00469 #define power_spic_disable()    (PR_PRPC |= (uint8_t)PR_SPI_bm)
00470 #define power_spid_enable()     (PR_PRPD &= (uint8_t)~(PR_SPI_bm))
00471 #define power_spid_disable()    (PR_PRPD |= (uint8_t)PR_SPI_bm)
00472 #define power_spie_enable()     (PR_PRPE &= (uint8_t)~(PR_SPI_bm))
00473 #define power_spie_disable()    (PR_PRPE |= (uint8_t)PR_SPI_bm)
00474 #define power_spif_enable()     (PR_PRPF &= (uint8_t)~(PR_SPI_bm))
00475 #define power_spif_disable()    (PR_PRPF |= (uint8_t)PR_SPI_bm)
00476 
00477 #define power_hiresc_enable()   (PR_PRPC &= (uint8_t)~(PR_HIRES_bm))
00478 #define power_hiresc_disable()  (PR_PRPC |= (uint8_t)PR_HIRES_bm)
00479 #define power_hiresd_enable()   (PR_PRPD &= (uint8_t)~(PR_HIRES_bm))
00480 #define power_hiresd_disable()  (PR_PRPD |= (uint8_t)PR_HIRES_bm)
00481 #define power_hirese_enable()   (PR_PRPE &= (uint8_t)~(PR_HIRES_bm))
00482 #define power_hirese_disable()  (PR_PRPE |= (uint8_t)PR_HIRES_bm)
00483 #define power_hiresf_enable()   (PR_PRPF &= (uint8_t)~(PR_HIRES_bm))
00484 #define power_hiresf_disable()  (PR_PRPF |= (uint8_t)PR_HIRES_bm)
00485 
00486 #define power_tc1c_enable()     (PR_PRPC &= (uint8_t)~(PR_TC1_bm))
00487 #define power_tc1c_disable()    (PR_PRPC |= (uint8_t)PR_TC1_bm)
00488 #define power_tc1d_enable()     (PR_PRPD &= (uint8_t)~(PR_TC1_bm))
00489 #define power_tc1d_disable()    (PR_PRPD |= (uint8_t)PR_TC1_bm)
00490 #define power_tc1e_enable()     (PR_PRPE &= (uint8_t)~(PR_TC1_bm))
00491 #define power_tc1e_disable()    (PR_PRPE |= (uint8_t)PR_TC1_bm)
00492 #define power_tc1f_enable()     (PR_PRPF &= (uint8_t)~(PR_TC1_bm))
00493 #define power_tc1f_disable()    (PR_PRPF |= (uint8_t)PR_TC1_bm)
00494 
00495 #define power_tc0c_enable()     (PR_PRPC &= (uint8_t)~(PR_TC0_bm))
00496 #define power_tc0c_disable()    (PR_PRPC |= (uint8_t)PR_TC0_bm)
00497 #define power_tc0d_enable()     (PR_PRPD &= (uint8_t)~(PR_TC0_bm))
00498 #define power_tc0d_disable()    (PR_PRPD |= (uint8_t)PR_TC0_bm)
00499 #define power_tc0e_enable()     (PR_PRPE &= (uint8_t)~(PR_TC0_bm))
00500 #define power_tc0e_disable()    (PR_PRPE |= (uint8_t)PR_TC0_bm)
00501 #define power_tc0f_enable()     (PR_PRPF &= (uint8_t)~(PR_TC0_bm))
00502 #define power_tc0f_disable()    (PR_PRPF |= (uint8_t)PR_TC0_bm)
00503 
00504 #endif
00505 
00506 #if defined(__AVR_ATxmega16D4__) \
00507 || defined(__AVR_ATxmega32D4__) \
00508 || defined(__AVR_ATxmega64D3__) \
00509 || defined(__AVR_ATxmega128D3__) \
00510 || defined(__AVR_ATxmega192D3__) 
00511 
00512 #define power_all_enable() \
00513 do { \
00514     PR_PRGEN &= (uint8_t)~(PR_RTC_bm|PR_EVSYS_bm); \
00515     PR_PRPA &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
00516     PR_PRPB &= (uint8_t)~(PR_ADC_bm|PR_AC_bm); \
00517     PR_PRPC &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00518     PR_PRPD &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00519     PR_PRPE &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00520     PR_PRPF &= (uint8_t)~(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00521 } while(0)
00522 
00523 
00524 #define power_all_disable() \
00525 do { \
00526     PR_PRGEN|= (uint8_t)(PR_EBI_bm|PR_RTC_bm|PR_EVSYS_bm|PR_DMA_bm); \
00527     PR_PRPA |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
00528     PR_PRPB |= (uint8_t)(PR_ADC_bm|PR_AC_bm); \
00529     PR_PRPC |= (uint8_t)(PR_TWI_bm|R_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00530     PR_PRPD |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00531     PR_PRPE |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00532     PR_PRPF |= (uint8_t)(PR_TWI_bm|PR_USART0_bm|PR_SPI_bm|PR_HIRES_bm|PR_TC1_bm|PR_TC0_bm); \
00533 } while(0)
00534 
00535 #elif defined(__AVR_ATmega640__) \
00536 || defined(__AVR_ATmega1280__) \
00537 || defined(__AVR_ATmega1281__) \
00538 || defined(__AVR_ATmega2560__) \
00539 || defined(__AVR_ATmega2561__) 
00540 
00541 #define power_adc_enable()      (PRR0 &= (uint8_t)~(1 << PRADC))
00542 #define power_adc_disable()     (PRR0 |= (uint8_t)(1 << PRADC))
00543 
00544 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
00545 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
00546 
00547 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
00548 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
00549 
00550 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
00551 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
00552 
00553 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
00554 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
00555 
00556 #define power_timer2_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM2))
00557 #define power_timer2_disable()  (PRR0 |= (uint8_t)(1 << PRTIM2))
00558 
00559 #define power_timer3_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM3))
00560 #define power_timer3_disable()  (PRR1 |= (uint8_t)(1 << PRTIM3))
00561 
00562 #define power_timer4_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM4))
00563 #define power_timer4_disable()  (PRR1 |= (uint8_t)(1 << PRTIM4))
00564 
00565 #define power_timer5_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM5))
00566 #define power_timer5_disable()  (PRR1 |= (uint8_t)(1 << PRTIM5))
00567 
00568 #define power_usart0_enable()   (PRR0 &= (uint8_t)~(1 << PRUSART0))
00569 #define power_usart0_disable()  (PRR0 |= (uint8_t)(1 << PRUSART0))
00570 
00571 #define power_usart1_enable()   (PRR1 &= (uint8_t)~(1 << PRUSART1))
00572 #define power_usart1_disable()  (PRR1 |= (uint8_t)(1 << PRUSART1))
00573 
00574 #define power_usart2_enable()   (PRR1 &= (uint8_t)~(1 << PRUSART2))
00575 #define power_usart2_disable()  (PRR1 |= (uint8_t)(1 << PRUSART2))
00576 
00577 #define power_usart3_enable()   (PRR1 &= (uint8_t)~(1 << PRUSART3))
00578 #define power_usart3_disable()  (PRR1 |= (uint8_t)(1 << PRUSART3))
00579 
00580 #define power_all_enable() \
00581 do{ \
00582     PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
00583     PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)|(1<<PRUSART2)|(1<<PRUSART3)); \
00584 }while(0)
00585 
00586 #define power_all_disable() \
00587 do{ \
00588     PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
00589     PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)|(1<<PRUSART2)|(1<<PRUSART3)); \
00590 }while(0)
00591 
00592 
00593 #elif defined(__AVR_ATmega128RFA1__)
00594 
00595 #define power_adc_enable()      (PRR0 &= (uint8_t)~(1 << PRADC))
00596 #define power_adc_disable()     (PRR0 |= (uint8_t)(1 << PRADC))
00597 
00598 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
00599 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
00600 
00601 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
00602 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
00603 
00604 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
00605 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
00606 
00607 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
00608 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
00609 
00610 #define power_timer2_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM2))
00611 #define power_timer2_disable()  (PRR0 |= (uint8_t)(1 << PRTIM2))
00612 
00613 #define power_timer3_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM3))
00614 #define power_timer3_disable()  (PRR1 |= (uint8_t)(1 << PRTIM3))
00615 
00616 #define power_timer4_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM4))
00617 #define power_timer4_disable()  (PRR1 |= (uint8_t)(1 << PRTIM4))
00618 
00619 #define power_timer5_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM5))
00620 #define power_timer5_disable()  (PRR1 |= (uint8_t)(1 << PRTIM5))
00621 
00622 #define power_usart0_enable()   (PRR0 &= (uint8_t)~(1 << PRUSART0))
00623 #define power_usart0_disable()  (PRR0 |= (uint8_t)(1 << PRUSART0))
00624 
00625 #define power_usart1_enable()   (PRR1 &= (uint8_t)~(1 << PRUSART1))
00626 #define power_usart1_disable()  (PRR1 |= (uint8_t)(1 << PRUSART1))
00627 
00628 #define power_all_enable() \
00629 do{ \
00630     PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
00631     PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)); \
00632 }while(0)
00633 
00634 #define power_all_disable() \
00635 do{ \
00636     PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)); \
00637     PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRTIM4)|(1<<PRTIM5)|(1<<PRTIM5)|(1<<PRUSART1)); \
00638 }while(0)
00639 
00640 
00641 #elif defined(__AVR_AT90USB646__) \
00642 || defined(__AVR_AT90USB647__) \
00643 || defined(__AVR_AT90USB1286__) \
00644 || defined(__AVR_AT90USB1287__)
00645 
00646 #define power_adc_enable()      (PRR0 &= (uint8_t)~(1 << PRADC))
00647 #define power_adc_disable()     (PRR0 |= (uint8_t)(1 << PRADC))
00648 
00649 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
00650 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
00651 
00652 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
00653 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
00654 
00655 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
00656 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
00657 
00658 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
00659 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
00660 
00661 #define power_timer2_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM2))
00662 #define power_timer2_disable()  (PRR0 |= (uint8_t)(1 << PRTIM2))
00663 
00664 #define power_timer3_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM3))
00665 #define power_timer3_disable()  (PRR1 |= (uint8_t)(1 << PRTIM3))
00666 
00667 #define power_usart1_enable()   (PRR1 &= (uint8_t)~(1 << PRUSART1))
00668 #define power_usart1_disable()  (PRR1 |= (uint8_t)(1 << PRUSART1))
00669 
00670 #define power_usb_enable()      (PRR1 &= (uint8_t)~(1 << PRUSB))
00671 #define power_usb_disable()     (PRR1 |= (uint8_t)(1 << PRUSB))
00672 
00673 #define power_all_enable() \
00674 do{ \
00675     PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00676     PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00677 }while(0)
00678 
00679 #define power_all_disable() \
00680 do{ \
00681     PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00682     PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00683 }while(0)
00684 
00685 
00686 #elif defined(__AVR_ATmega32U4__) \
00687 || defined(__AVR_ATmega16U4__)
00688 
00689 
00690 #define power_adc_enable()      (PRR0 &= (uint8_t)~(1 << PRADC))
00691 #define power_adc_disable()     (PRR0 |= (uint8_t)(1 << PRADC))
00692 
00693 #define power_usart0_enable()   (PRR0 &= (uint8_t)~(1 << PRUSART0))
00694 #define power_usart0_disable()  (PRR0 |= (uint8_t)(1 << PRUSART0))
00695 
00696 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
00697 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
00698 
00699 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
00700 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
00701 
00702 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
00703 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
00704 
00705 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
00706 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
00707 
00708 #define power_timer2_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM2))
00709 #define power_timer2_disable()  (PRR0 |= (uint8_t)(1 << PRTIM2))
00710 
00711 #define power_timer3_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM3))
00712 #define power_timer3_disable()  (PRR1 |= (uint8_t)(1 << PRTIM3))
00713 
00714 #define power_usart1_enable()   (PRR1 &= (uint8_t)~(1 << PRUSART1))
00715 #define power_usart1_disable()  (PRR1 |= (uint8_t)(1 << PRUSART1))
00716 
00717 #define power_usb_enable()      (PRR1 &= (uint8_t)~(1 << PRUSB))
00718 #define power_usb_disable()     (PRR1 |= (uint8_t)(1 << PRUSB))
00719 
00720 #define power_all_enable() \
00721 do{ \
00722     PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRUSART0)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00723     PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00724 }while(0)
00725 
00726 #define power_all_disable() \
00727 do{ \
00728     PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRUSART0)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00729     PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00730 }while(0)
00731 
00732 
00733 #elif defined(__AVR_ATmega32U6__)
00734 
00735 
00736 #define power_adc_enable()      (PRR0 &= (uint8_t)~(1 << PRADC))
00737 #define power_adc_disable()     (PRR0 |= (uint8_t)(1 << PRADC))
00738 
00739 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
00740 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
00741 
00742 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
00743 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
00744 
00745 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
00746 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
00747 
00748 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
00749 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
00750 
00751 #define power_timer2_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM2))
00752 #define power_timer2_disable()  (PRR0 |= (uint8_t)(1 << PRTIM2))
00753 
00754 #define power_timer3_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM3))
00755 #define power_timer3_disable()  (PRR1 |= (uint8_t)(1 << PRTIM3))
00756 
00757 #define power_usart1_enable()   (PRR1 &= (uint8_t)~(1 << PRUSART1))
00758 #define power_usart1_disable()  (PRR1 |= (uint8_t)(1 << PRUSART1))
00759 
00760 #define power_usb_enable()      (PRR1 &= (uint8_t)~(1 << PRUSB))
00761 #define power_usb_disable()     (PRR1 |= (uint8_t)(1 << PRUSB))
00762 
00763 #define power_all_enable() \
00764 do{ \
00765     PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00766     PRR1 &= (uint8_t)~((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00767 }while(0)
00768 
00769 #define power_all_disable() \
00770 do{ \
00771     PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)); \
00772     PRR1 |= (uint8_t)((1<<PRTIM3)|(1<<PRUSART1)|(1<<PRUSB)); \
00773 }while(0)
00774 
00775 
00776 #elif defined(__AVR_AT90PWM1__)
00777 
00778 #define power_adc_enable()      (PRR &= (uint8_t)~(1 << PRADC))
00779 #define power_adc_disable()     (PRR |= (uint8_t)(1 << PRADC))
00780 
00781 #define power_spi_enable()      (PRR &= (uint8_t)~(1 << PRSPI))
00782 #define power_spi_disable()     (PRR |= (uint8_t)(1 << PRSPI))
00783 
00784 #define power_timer0_enable()   (PRR &= (uint8_t)~(1 << PRTIM0))
00785 #define power_timer0_disable()  (PRR |= (uint8_t)(1 << PRTIM0))
00786 
00787 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
00788 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
00789 
00790 /* Power Stage Controller 0 */
00791 #define power_psc0_enable()     (PRR &= (uint8_t)~(1 << PRPSC0))
00792 #define power_psc0_disable()    (PRR |= (uint8_t)(1 << PRPSC0))
00793 
00794 /* Power Stage Controller 1 */
00795 #define power_psc1_enable()     (PRR &= (uint8_t)~(1 << PRPSC1))
00796 #define power_psc1_disable()    (PRR |= (uint8_t)(1 << PRPSC1))
00797 
00798 /* Power Stage Controller 2 */
00799 #define power_psc2_enable()     (PRR &= (uint8_t)~(1 << PRPSC2))
00800 #define power_psc2_disable()    (PRR |= (uint8_t)(1 << PRPSC2))
00801 
00802 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
00803 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
00804 
00805 
00806 #elif defined(__AVR_AT90PWM2__) \
00807 || defined(__AVR_AT90PWM2B__) \
00808 || defined(__AVR_AT90PWM3__) \
00809 || defined(__AVR_AT90PWM3B__) \
00810 || defined(__AVR_AT90PWM216__) \
00811 || defined(__AVR_AT90PWM316__)
00812 
00813 #define power_adc_enable()      (PRR &= (uint8_t)~(1 << PRADC))
00814 #define power_adc_disable()     (PRR |= (uint8_t)(1 << PRADC))
00815 
00816 #define power_spi_enable()      (PRR &= (uint8_t)~(1 << PRSPI))
00817 #define power_spi_disable()     (PRR |= (uint8_t)(1 << PRSPI))
00818 
00819 #define power_usart_enable()    (PRR &= (uint8_t)~(1 << PRUSART))
00820 #define power_usart_disable()   (PRR |= (uint8_t)(1 << PRUSART))
00821 
00822 #define power_timer0_enable()   (PRR &= (uint8_t)~(1 << PRTIM0))
00823 #define power_timer0_disable()  (PRR |= (uint8_t)(1 << PRTIM0))
00824 
00825 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
00826 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
00827 
00828 /* Power Stage Controller 0 */
00829 #define power_psc0_enable()     (PRR &= (uint8_t)~(1 << PRPSC0))
00830 #define power_psc0_disable()    (PRR |= (uint8_t)(1 << PRPSC0))
00831 
00832 /* Power Stage Controller 1 */
00833 #define power_psc1_enable()     (PRR &= (uint8_t)~(1 << PRPSC1))
00834 #define power_psc1_disable()    (PRR |= (uint8_t)(1 << PRPSC1))
00835 
00836 /* Power Stage Controller 2 */
00837 #define power_psc2_enable()     (PRR &= (uint8_t)~(1 << PRPSC2))
00838 #define power_psc2_disable()    (PRR |= (uint8_t)(1 << PRPSC2))
00839 
00840 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
00841 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC0)|(1<<PRPSC1)|(1<<PRPSC2)))
00842 
00843 
00844 #elif defined(__AVR_AT90PWM81__)
00845 
00846 #define power_adc_enable()      (PRR &= (uint8_t)~(1 << PRADC))
00847 #define power_adc_disable()     (PRR |= (uint8_t)(1 << PRADC))
00848 
00849 #define power_spi_enable()      (PRR &= (uint8_t)~(1 << PRSPI))
00850 #define power_spi_disable()     (PRR |= (uint8_t)(1 << PRSPI))
00851 
00852 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
00853 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
00854 
00855 /* Reduced Power Stage Controller */
00856 #define power_pscr_enable()     (PRR &= (uint8_t)~(1 << PRPSCR))
00857 #define power_pscr_disable()    (PRR |= (uint8_t)(1 << PRPSCR))
00858 
00859 /* Power Stage Controller 2 */
00860 #define power_psc2_enable()     (PRR &= (uint8_t)~(1 << PRPSC2))
00861 #define power_psc2_disable()    (PRR |= (uint8_t)(1 << PRPSC2))
00862 
00863 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRPSCR)|(1<<PRPSC2)))
00864 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRPSCR)|(1<<PRPSC2)))
00865 
00866 
00867 #elif defined(__AVR_ATmega165__) \
00868 || defined(__AVR_ATmega165A__) \
00869 || defined(__AVR_ATmega165P__) \
00870 || defined(__AVR_ATmega325__) \
00871 || defined(__AVR_ATmega325A__) \
00872 || defined(__AVR_ATmega3250__) \
00873 || defined(__AVR_ATmega3250A__) \
00874 || defined(__AVR_ATmega645__) \
00875 || defined(__AVR_ATmega645A__) \
00876 || defined(__AVR_ATmega645P__) \
00877 || defined(__AVR_ATmega6450__) \
00878 || defined(__AVR_ATmega6450A__) \
00879 || defined(__AVR_ATmega6450P__)
00880 
00881 #define power_adc_enable()      (PRR &= (uint8_t)~(1 << PRADC))
00882 #define power_adc_disable()     (PRR |= (uint8_t)(1 << PRADC))
00883 
00884 #define power_spi_enable()      (PRR &= (uint8_t)~(1 << PRSPI))
00885 #define power_spi_disable()     (PRR |= (uint8_t)(1 << PRSPI))
00886 
00887 #define power_usart0_enable()   (PRR &= (uint8_t)~(1 << PRUSART0))
00888 #define power_usart0_disable()  (PRR |= (uint8_t)(1 << PRUSART0))
00889 
00890 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
00891 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
00892 
00893 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)))
00894 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)))
00895 
00896 
00897 #elif defined(__AVR_ATmega169__) \
00898 || defined(__AVR_ATmega169A__) \
00899 || defined(__AVR_ATmega169P__) \
00900 || defined(__AVR_ATmega169PA__) \
00901 || defined(__AVR_ATmega329__) \
00902 || defined(__AVR_ATmega329A__) \
00903 || defined(__AVR_ATmega329P__) \
00904 || defined(__AVR_ATmega329PA__) \
00905 || defined(__AVR_ATmega3290__) \
00906 || defined(__AVR_ATmega3290A__) \
00907 || defined(__AVR_ATmega3290P__) \
00908 || defined(__AVR_ATmega649__) \
00909 || defined(__AVR_ATmega649A__) \
00910 || defined(__AVR_ATmega649P__) \
00911 || defined(__AVR_ATmega6490__) \
00912 || defined(__AVR_ATmega6490A__) \
00913 || defined(__AVR_ATmega6490P__)
00914 
00915 #define power_adc_enable()      (PRR &= (uint8_t)~(1 << PRADC))
00916 #define power_adc_disable()     (PRR |= (uint8_t)(1 << PRADC))
00917 
00918 #define power_spi_enable()      (PRR &= (uint8_t)~(1 << PRSPI))
00919 #define power_spi_disable()     (PRR |= (uint8_t)(1 << PRSPI))
00920 
00921 #define power_usart0_enable()   (PRR &= (uint8_t)~(1 << PRUSART0))
00922 #define power_usart0_disable()  (PRR |= (uint8_t)(1 << PRUSART0))
00923 
00924 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
00925 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
00926 
00927 #define power_lcd_enable()      (PRR &= (uint8_t)~(1 << PRLCD))
00928 #define power_lcd_disable()     (PRR |= (uint8_t)(1 << PRLCD))
00929 
00930 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)|(1<<PRLCD)))
00931 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM1)|(1<<PRLCD)))
00932 
00933 
00934 #elif defined(__AVR_ATmega164A__) \
00935 || defined(__AVR_ATmega164P__) \
00936 || defined(__AVR_ATmega324A__) \
00937 || defined(__AVR_ATmega324P__) \
00938 || defined(__AVR_ATmega324PA__) \
00939 || defined(__AVR_ATmega644P__) \
00940 || defined(__AVR_ATmega644A__) \
00941 || defined(__AVR_ATmega644PA__)
00942 
00943 #define power_adc_enable()      (PRR0 &= (uint8_t)~(1 << PRADC))
00944 #define power_adc_disable()     (PRR0 |= (uint8_t)(1 << PRADC))
00945 
00946 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
00947 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
00948 
00949 #define power_usart0_enable()   (PRR0 &= (uint8_t)~(1 << PRUSART0))
00950 #define power_usart0_disable()  (PRR0 |= (uint8_t)(1 << PRUSART0))
00951 
00952 #define power_usart1_enable()   (PRR0 &= (uint8_t)~(1 << PRUSART1))
00953 #define power_usart1_disable()  (PRR0 |= (uint8_t)(1 << PRUSART1))
00954 
00955 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
00956 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
00957 
00958 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
00959 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
00960 
00961 #define power_timer2_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM2))
00962 #define power_timer2_disable()  (PRR0 |= (uint8_t)(1 << PRTIM2))
00963 
00964 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
00965 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
00966 
00967 #define power_all_enable()      (PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRUSART1)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
00968 #define power_all_disable()     (PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRUSART1)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
00969 
00970 
00971 #elif defined(__AVR_ATmega644__)
00972 
00973 #define power_adc_enable()      (PRR0 &= (uint8_t)~(1 << PRADC))
00974 #define power_adc_disable()     (PRR0 |= (uint8_t)(1 << PRADC))
00975 
00976 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
00977 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
00978 
00979 #define power_usart0_enable()   (PRR0 &= (uint8_t)~(1 << PRUSART0))
00980 #define power_usart0_disable()  (PRR0 |= (uint8_t)(1 << PRUSART0))
00981 
00982 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
00983 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
00984 
00985 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
00986 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
00987 
00988 #define power_timer2_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM2))
00989 #define power_timer2_disable()  (PRR0 |= (uint8_t)(1 << PRTIM2))
00990 
00991 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
00992 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
00993 
00994 #define power_all_enable()      (PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
00995 #define power_all_disable()     (PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
00996 
00997 
00998 #elif defined(__AVR_ATmega406__)
00999 
01000 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
01001 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
01002 
01003 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
01004 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
01005 
01006 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
01007 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
01008 
01009 /* Voltage ADC */
01010 #define power_vadc_enable()     (PRR0 &= (uint8_t)~(1 << PRVADC))
01011 #define power_vadc_disable()    (PRR0 |= (uint8_t)(1 << PRVADC))
01012 
01013 #define power_all_enable()      (PRR0 &= (uint8_t)~((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)))
01014 #define power_all_disable()     (PRR0 |= (uint8_t)((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)))
01015 
01016 
01017 #elif defined(__AVR_ATmega48__) \
01018 || defined(__AVR_ATmega48A__) \
01019 || defined(__AVR_ATmega48P__) \
01020 || defined(__AVR_ATmega88__) \
01021 || defined(__AVR_ATmega88A__) \
01022 || defined(__AVR_ATmega88P__) \
01023 || defined(__AVR_ATmega88PA__) \
01024 || defined(__AVR_ATmega168__) \
01025 || defined(__AVR_ATmega168A__) \
01026 || defined(__AVR_ATmega168P__) \
01027 || defined(__AVR_ATmega328__) \
01028 || defined(__AVR_ATmega328P__) \
01029 || defined(__AVR_ATtiny48__) \
01030 || defined(__AVR_ATtiny88__)
01031 
01032 #define power_adc_enable()      (PRR &= (uint8_t)~(1 << PRADC))
01033 #define power_adc_disable()     (PRR |= (uint8_t)(1 << PRADC))
01034 
01035 #define power_spi_enable()      (PRR &= (uint8_t)~(1 << PRSPI))
01036 #define power_spi_disable()     (PRR |= (uint8_t)(1 << PRSPI))
01037 
01038 #define power_usart0_enable()   (PRR &= (uint8_t)~(1 << PRUSART0))
01039 #define power_usart0_disable()  (PRR |= (uint8_t)(1 << PRUSART0))
01040 
01041 #define power_timer0_enable()   (PRR &= (uint8_t)~(1 << PRTIM0))
01042 #define power_timer0_disable()  (PRR |= (uint8_t)(1 << PRTIM0))
01043 
01044 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
01045 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
01046 
01047 #define power_timer2_enable()   (PRR &= (uint8_t)~(1 << PRTIM2))
01048 #define power_timer2_disable()  (PRR |= (uint8_t)(1 << PRTIM2))
01049 
01050 #define power_twi_enable()      (PRR &= (uint8_t)~(1 << PRTWI))
01051 #define power_twi_disable()     (PRR |= (uint8_t)(1 << PRTWI))
01052 
01053 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
01054 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRUSART0)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRTWI)))
01055 
01056 
01057 #elif defined(__AVR_ATtiny24__) \
01058 || defined(__AVR_ATtiny24A__) \
01059 || defined(__AVR_ATtiny44__) \
01060 || defined(__AVR_ATtiny44A__) \
01061 || defined(__AVR_ATtiny84__) \
01062 || defined(__AVR_ATtiny84A__) \
01063 || defined(__AVR_ATtiny25__) \
01064 || defined(__AVR_ATtiny45__) \
01065 || defined(__AVR_ATtiny85__) \
01066 || defined(__AVR_ATtiny261__) \
01067 || defined(__AVR_ATtiny261A__) \
01068 || defined(__AVR_ATtiny461__) \
01069 || defined(__AVR_ATtiny461A__) \
01070 || defined(__AVR_ATtiny861__) \
01071 || defined(__AVR_ATtiny861A__) \
01072 || defined(__AVR_ATtiny43U__)
01073 
01074 #define power_adc_enable()      (PRR &= (uint8_t)~(1 << PRADC))
01075 #define power_adc_disable()     (PRR |= (uint8_t)(1 << PRADC))
01076 
01077 #define power_timer0_enable()   (PRR &= (uint8_t)~(1 << PRTIM0))
01078 #define power_timer0_disable()  (PRR |= (uint8_t)(1 << PRTIM0))
01079 
01080 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
01081 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
01082 
01083 /* Universal Serial Interface */
01084 #define power_usi_enable()      (PRR &= (uint8_t)~(1 << PRUSI))
01085 #define power_usi_disable()     (PRR |= (uint8_t)(1 << PRUSI))
01086 
01087 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRUSI)))
01088 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRUSI)))
01089 
01090 
01091 #elif defined(__AVR_ATmega1284P__)
01092 
01093 
01094 #define power_adc_enable()      (PRR0 &= (uint8_t)~(1 << PRADC))
01095 #define power_adc_disable()     (PRR0 |= (uint8_t)(1 << PRADC))
01096 
01097 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
01098 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
01099 
01100 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
01101 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
01102 
01103 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
01104 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
01105 
01106 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
01107 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
01108 
01109 #define power_timer2_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM2))
01110 #define power_timer2_disable()  (PRR0 |= (uint8_t)(1 << PRTIM2))
01111 
01112 #define power_timer3_enable()   (PRR1 &= (uint8_t)~(1 << PRTIM3))
01113 #define power_timer3_disable()  (PRR1 |= (uint8_t)(1 << PRTIM3))
01114 
01115 #define power_usart0_enable()   (PRR0 &= (uint8_t)~(1 << PRUSART0))
01116 #define power_usart0_disable()  (PRR0 |= (uint8_t)(1 << PRUSART0))
01117 
01118 #define power_usart1_enable()   (PRR0 &= (uint8_t)~(1 << PRUSART1))
01119 #define power_usart1_disable()  (PRR0 |= (uint8_t)(1 << PRUSART1))
01120 
01121 #define power_all_enable() \
01122 do{ \
01123     PRR0 &= (uint8_t)~((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)|(1<<PRUSART1)); \
01124     PRR1 &= (uint8_t)~(1<<PRTIM3); \
01125 }while(0)
01126 
01127 #define power_all_disable() \
01128 do{ \
01129     PRR0 |= (uint8_t)((1<<PRADC)|(1<<PRSPI)|(1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRTIM2)|(1<<PRUSART0)|(1<<PRUSART1)); \
01130     PRR1 |= (uint8_t)(1<<PRTIM3); \
01131 }while(0)
01132 
01133 
01134 #elif defined(__AVR_ATmega32HVB__) \
01135 || defined(__AVR_ATmega32HVBREVB__) \
01136 || defined(__AVR_ATmega16HVB__) \
01137 || defined(__AVR_ATmega16HVBREVB__)
01138 
01139 
01140 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
01141 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
01142 
01143 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
01144 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
01145 
01146 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
01147 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
01148 
01149 /* Voltage ADC */
01150 #define power_vadc_enable()     (PRR0 &= (uint8_t)~(1 << PRVADC))
01151 #define power_vadc_disable()    (PRR0 |= (uint8_t)(1 << PRVADC))
01152 
01153 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
01154 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
01155 
01156 #define power_vrm_enable()      (PRR0 &= (uint8_t)~(1 << PRVRM))
01157 #define power_vrm_disable()     (PRR0 |= (uint8_t)(1 << PRVRM))
01158 
01159 #define power_all_enable()      (PRR0 &= (uint8_t)~((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)|(1<<PRSPI)|(1<<PRVRM)))
01160 #define power_all_disable()     (PRR0 |= (uint8_t)((1<<PRTWI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRVADC)|(1<<PRSPI)|(1<<PRVRM)))
01161 
01162 
01163 #elif defined(__AVR_ATmega16M1__) \
01164 || defined(__AVR_ATmega32C1__) \
01165 || defined(__AVR_ATmega32M1__) \
01166 || defined(__AVR_ATmega64C1__) \
01167 || defined(__AVR_ATmega64M1__)
01168 
01169 #define power_adc_enable()      (PRR &= (uint8_t)~(1 << PRADC))
01170 #define power_adc_disable()     (PRR |= (uint8_t)(1 << PRADC))
01171 
01172 #define power_lin_enable()      (PRR &= (uint8_t)~(1 << PRLIN))
01173 #define power_lin_disable()     (PRR |= (uint8_t)(1 << PRLIN))
01174 
01175 #define power_spi_enable()      (PRR &= (uint8_t)~(1 << PRSPI))
01176 #define power_spi_disable()     (PRR |= (uint8_t)(1 << PRSPI))
01177 
01178 #define power_timer0_enable()   (PRR &= (uint8_t)~(1 << PRTIM0))
01179 #define power_timer0_disable()  (PRR |= (uint8_t)(1 << PRTIM0))
01180 
01181 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
01182 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
01183 
01184 #define power_psc_enable()      (PRR &= (uint8_t)~(1 << PRPSC))
01185 #define power_psc_disable()     (PRR |= (uint8_t)(1 << PRPSC))
01186 
01187 #define power_can_enable()      (PRR &= (uint8_t)~(1 << PRCAN))
01188 #define power_can_disable()     (PRR |= (uint8_t)(1 << PRCAN))
01189 
01190 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRLIN)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC)|(1<<PRCAN)))
01191 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRLIN)|(1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRPSC)|(1<<PRCAN)))
01192 
01193 
01194 #elif defined(__AVR_ATtiny167__) \
01195 || defined(__AVR_ATtiny87__)
01196 
01197 
01198 #define power_adc_enable()      (PRR &= (uint8_t)~(1 << PRADC))
01199 #define power_adc_disable()     (PRR |= (uint8_t)(1 << PRADC))
01200 
01201 #define power_usi_enable()      (PRR &= (uint8_t)~(1 << PRUSI))
01202 #define power_usi_disable()     (PRR |= (uint8_t)(1 << PRUSI))
01203 
01204 #define power_timer0_enable()   (PRR &= (uint8_t)~(1 << PRTIM0))
01205 #define power_timer0_disable()  (PRR |= (uint8_t)(1 << PRTIM0))
01206 
01207 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
01208 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
01209 
01210 #define power_spi_enable()      (PRR &= (uint8_t)~(1 << PRSPI))
01211 #define power_spi_disable()     (PRR |= (uint8_t)(1 << PRSPI))
01212 
01213 #define power_lin_enable()      (PRR &= (uint8_t)~(1 << PRLIN))
01214 #define power_lin_disable()     (PRR |= (uint8_t)(1 << PRLIN))
01215 
01216 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRUSI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRLIN)))
01217 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRUSI)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRLIN)))
01218 
01219 
01220 #elif defined(__AVR_AT90USB82__) \
01221 || defined(__AVR_AT90USB162__) \
01222 || defined(__AVR_ATmega8U2__) \
01223 || defined(__AVR_ATmega16U2__) \
01224 || defined(__AVR_ATmega32U2__)
01225 
01226 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
01227 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
01228 
01229 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
01230 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
01231 
01232 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
01233 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
01234 
01235 #define power_usb_enable()      (PRR1 &= (uint8_t)~(1 << PRUSB))
01236 #define power_usb_disable()     (PRR1 |= (uint8_t)(1 << PRUSB))
01237 
01238 #define power_usart1_enable()   (PRR1 &= (uint8_t)~(1 << PRUSART1))
01239 #define power_usart1_disable()  (PRR1 |= (uint8_t)(1 << PRUSART1))
01240 
01241 #define power_all_enable() \
01242 do{ \
01243     PRR0 &= (uint8_t)~((1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)); \
01244     PRR1 &= (uint8_t)~((1<<PRUSB)|(1<<PRUSART1)); \
01245 }while(0)
01246 
01247 #define power_all_disable() \
01248 do{ \
01249     PRR0 |= (uint8_t)((1<<PRSPI)|(1<<PRTIM0)|(1<<PRTIM1)); \
01250     PRR1 |= (uint8_t)((1<<PRUSB)|(1<<PRUSART1)); \
01251 }while(0)
01252 
01253 
01254 #elif defined(__AVR_AT90SCR100__)
01255 
01256 #define power_usart0_enable()   (PRR0 &= (uint8_t)~(1 << PRUSART0))
01257 #define power_usart0_disable()  (PRR0 |= (uint8_t)(1 << PRUSART0))
01258 
01259 #define power_spi_enable()      (PRR0 &= (uint8_t)~(1 << PRSPI))
01260 #define power_spi_disable()     (PRR0 |= (uint8_t)(1 << PRSPI))
01261 
01262 #define power_timer1_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM1))
01263 #define power_timer1_disable()  (PRR0 |= (uint8_t)(1 << PRTIM1))
01264 
01265 #define power_timer0_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM0))
01266 #define power_timer0_disable()  (PRR0 |= (uint8_t)(1 << PRTIM0))
01267 
01268 #define power_timer2_enable()   (PRR0 &= (uint8_t)~(1 << PRTIM2))
01269 #define power_timer2_disable()  (PRR0 |= (uint8_t)(1 << PRTIM2))
01270 
01271 #define power_twi_enable()      (PRR0 &= (uint8_t)~(1 << PRTWI))
01272 #define power_twi_disable()     (PRR0 |= (uint8_t)(1 << PRTWI))
01273 
01274 #define power_usbh_enable()     (PRR1 &= (uint8_t)~(1 << PRUSBH))
01275 #define power_usbh_disable()    (PRR1 |= (uint8_t)(1 << PRUSBH))
01276 
01277 #define power_usb_enable()      (PRR1 &= (uint8_t)~(1 << PRUSB))
01278 #define power_usb_disable()     (PRR1 |= (uint8_t)(1 << PRUSB))
01279 
01280 #define power_hsspi_enable()    (PRR1 &= (uint8_t)~(1 << PRHSSPI))
01281 #define power_hsspi_disable()   (PRR1 |= (uint8_t)(1 << PRHSSPI))
01282 
01283 #define power_sci_enable()      (PRR1 &= (uint8_t)~(1 << PRSCI))
01284 #define power_sci_disable()     (PRR1 |= (uint8_t)(1 << PRSCI))
01285 
01286 #define power_aes_enable()      (PRR1 &= (uint8_t)~(1 << PRAES))
01287 #define power_aes_disable()     (PRR1 |= (uint8_t)(1 << PRAES))
01288 
01289 #define power_kb_enable()       (PRR1 &= (uint8_t)~(1 << PRKB))
01290 #define power_kb_disable()      (PRR1 |= (uint8_t)(1 << PRKB))
01291 
01292 #define power_all_enable() \
01293 do{ \
01294     PRR0 &= (uint8_t)~((1<<PRUSART0)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRTIM0)|(1<<PRTIM2)|(1<<PRTWI)); \
01295     PRR1 &= (uint8_t)~((1<<PRUSBH)|(1<<PRUSB)|(1<<PRHSSPI)|(1<<PRSCI)|(1<<PRAES)|(1<<PRKB)); \
01296 }while(0)
01297 
01298 #define power_all_disable() \
01299 do{ \
01300     PRR0 |= (uint8_t)((1<<PRUSART0)|(1<<PRSPI)|(1<<PRTIM1)|(1<<PRTIM0)|(1<<PRTIM2)|(1<<PRTWI)); \
01301     PRR1 |= (uint8_t)((1<<PRUSBH)|(1<<PRUSB)|(1<<PRHSSPI)|(1<<PRSCI)|(1<<PRAES)|(1<<PRKB)); \
01302 }while(0)
01303 
01304 
01305 #elif defined(__AVR_ATtiny4__) \
01306 || defined(__AVR_ATtiny5__) \
01307 || defined(__AVR_ATtiny9__) \
01308 || defined(__AVR_ATtiny10__) \
01309 || defined(__AVR_ATtiny13A__) \
01310 
01311 #define power_adc_enable()   (PRR &= (uint8_t)~(1 << PRADC))
01312 #define power_adc_disable()  (PRR |= (uint8_t)(1 << PRADC))
01313 
01314 #define power_timer0_enable()   (PRR &= (uint8_t)~(1 << PRTIM0))
01315 #define power_timer0_disable()  (PRR |= (uint8_t)(1 << PRTIM0))
01316 
01317 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRTIM0)))
01318 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRTIM0)))
01319 
01320 
01321 #elif defined(__AVR_ATtiny20__) \
01322 || defined(__AVR_ATtiny40__)
01323 
01324 #define power_adc_enable()   (PRR &= (uint8_t)~(1 << PRADC))
01325 #define power_adc_disable()  (PRR |= (uint8_t)(1 << PRADC))
01326 
01327 #define power_timer0_enable()   (PRR &= (uint8_t)~(1 << PRTIM0))
01328 #define power_timer0_disable()  (PRR |= (uint8_t)(1 << PRTIM0))
01329 
01330 #define power_timer1_enable()   (PRR &= (uint8_t)~(1 << PRTIM1))
01331 #define power_timer1_disable()  (PRR |= (uint8_t)(1 << PRTIM1))
01332 
01333 #define power_spi_enable()   (PRR &= (uint8_t)~(1 << PRSPI))
01334 #define power_spi_disable()  (PRR |= (uint8_t)(1 << PRSPI))
01335 
01336 #define power_twi_enable()   (PRR &= (uint8_t)~(1 << PRTWI))
01337 #define power_twi_disable()  (PRR |= (uint8_t)(1 << PRTWI))
01338 
01339 #define power_all_enable()      (PRR &= (uint8_t)~((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRTWI)))
01340 #define power_all_disable()     (PRR |= (uint8_t)((1<<PRADC)|(1<<PRTIM0)|(1<<PRTIM1)|(1<<PRSPI)|(1<<PRTWI)))
01341 
01342 #endif
01343 
01344 
01345 #if defined(__AVR_AT90CAN32__) \
01346 || defined(__AVR_AT90CAN64__) \
01347 || defined(__AVR_AT90CAN128__) \
01348 || defined(__AVR_AT90PWM1__) \
01349 || defined(__AVR_AT90PWM2__) \
01350 || defined(__AVR_AT90PWM2B__) \
01351 || defined(__AVR_AT90PWM3__) \
01352 || defined(__AVR_AT90PWM3B__) \
01353 || defined(__AVR_AT90PWM216__) \
01354 || defined(__AVR_AT90PWM316__) \
01355 || defined(__AVR_AT90SCR100__) \
01356 || defined(__AVR_AT90USB646__) \
01357 || defined(__AVR_AT90USB647__) \
01358 || defined(__AVR_AT90USB82__) \
01359 || defined(__AVR_AT90USB1286__) \
01360 || defined(__AVR_AT90USB1287__) \
01361 || defined(__AVR_AT90USB162__) \
01362 || defined(__AVR_ATmega1280__) \
01363 || defined(__AVR_ATmega1281__) \
01364 || defined(__AVR_ATmega128RFA1__) \
01365 || defined(__AVR_ATmega1284P__) \
01366 || defined(__AVR_ATmega162__) \
01367 || defined(__AVR_ATmega164A__) \
01368 || defined(__AVR_ATmega164P__) \
01369 || defined(__AVR_ATmega165__) \
01370 || defined(__AVR_ATmega165A__) \
01371 || defined(__AVR_ATmega165P__) \
01372 || defined(__AVR_ATmega168__) \
01373 || defined(__AVR_ATmega168P__) \
01374 || defined(__AVR_ATmega169__) \
01375 || defined(__AVR_ATmega169A__) \
01376 || defined(__AVR_ATmega169P__) \
01377 || defined(__AVR_ATmega169PA__) \
01378 || defined(__AVR_ATmega16U4__) \
01379 || defined(__AVR_ATmega2560__) \
01380 || defined(__AVR_ATmega2561__) \
01381 || defined(__AVR_ATmega324A__) \
01382 || defined(__AVR_ATmega324P__) \
01383 || defined(__AVR_ATmega325__) \
01384 || defined(__AVR_ATmega325A__) \
01385 || defined(__AVR_ATmega3250__) \
01386 || defined(__AVR_ATmega3250A__) \
01387 || defined(__AVR_ATmega328__) \
01388 || defined(__AVR_ATmega328P__) \
01389 || defined(__AVR_ATmega329__) \
01390 || defined(__AVR_ATmega329A__) \
01391 || defined(__AVR_ATmega329P__) \
01392 || defined(__AVR_ATmega329PA__) \
01393 || defined(__AVR_ATmega3290__) \
01394 || defined(__AVR_ATmega3290A__) \
01395 || defined(__AVR_ATmega32C1__) \
01396 || defined(__AVR_ATmega32HVB__) \
01397 || defined(__AVR_ATmega32HVBREVB__) \
01398 || defined(__AVR_ATmega16HVB__) \
01399 || defined(__AVR_ATmega16HVBREVB__) \
01400 || defined(__AVR_ATmega32M1__) \
01401 || defined(__AVR_ATmega32U2__) \
01402 || defined(__AVR_ATmega32U4__) \
01403 || defined(__AVR_ATmega32U6__) \
01404 || defined(__AVR_ATmega48__) \
01405 || defined(__AVR_ATmega48P__) \
01406 || defined(__AVR_ATmega640__) \
01407 || defined(__AVR_ATmega649P__) \
01408 || defined(__AVR_ATmega644__) \
01409 || defined(__AVR_ATmega644A__) \
01410 || defined(__AVR_ATmega644P__) \
01411 || defined(__AVR_ATmega644PA__) \
01412 || defined(__AVR_ATmega645__) \
01413 || defined(__AVR_ATmega645A__) \
01414 || defined(__AVR_ATmega645P__) \
01415 || defined(__AVR_ATmega6450__) \
01416 || defined(__AVR_ATmega6450A__) \
01417 || defined(__AVR_ATmega6450P__) \
01418 || defined(__AVR_ATmega649__) \
01419 || defined(__AVR_ATmega649A__) \
01420 || defined(__AVR_ATmega6490__) \
01421 || defined(__AVR_ATmega6490A__) \
01422 || defined(__AVR_ATmega6490P__) \
01423 || defined(__AVR_ATmega88__) \
01424 || defined(__AVR_ATmega88P__) \
01425 || defined(__AVR_ATmega8U2__) \
01426 || defined(__AVR_ATmega16U2__) \
01427 || defined(__AVR_ATmega32U2__) \
01428 || defined(__AVR_ATtiny48__) \
01429 || defined(__AVR_ATtiny167__) \
01430 || defined(__DOXYGEN__)
01431 
01432 
01433 /** \addtogroup avr_power
01434 
01435 Some of the newer AVRs contain a System Clock Prescale Register (CLKPR) that
01436 allows you to decrease the system clock frequency and the power consumption
01437 when the need for processing power is low. Below are two macros and an
01438 enumerated type that can be used to interface to the Clock Prescale Register.
01439 
01440 \note Not all AVR devices have a Clock Prescale Register. On those devices
01441 without a Clock Prescale Register, these macros are not available.
01442 */
01443 
01444 
01445 /** \addtogroup avr_power
01446 \code 
01447 typedef enum
01448 {
01449     clock_div_1 = 0,
01450     clock_div_2 = 1,
01451     clock_div_4 = 2,
01452     clock_div_8 = 3,
01453     clock_div_16 = 4,
01454     clock_div_32 = 5,
01455     clock_div_64 = 6,
01456     clock_div_128 = 7,
01457     clock_div_256 = 8,
01458     clock_div_1_rc = 15, // ATmega128RFA1 only
01459 } clock_div_t;
01460 \endcode
01461 Clock prescaler setting enumerations.
01462 
01463 */
01464 typedef enum
01465 {
01466     clock_div_1 = 0,
01467     clock_div_2 = 1,
01468     clock_div_4 = 2,
01469     clock_div_8 = 3,
01470     clock_div_16 = 4,
01471     clock_div_32 = 5,
01472     clock_div_64 = 6,
01473     clock_div_128 = 7,
01474     clock_div_256 = 8
01475 #if defined(__AVR_ATmega128RFA1__)
01476     , clock_div_1_rc = 15
01477 #endif
01478 } clock_div_t;
01479 
01480 
01481 static __inline__ void clock_prescale_set(clock_div_t) __attribute__((__always_inline__));
01482 
01483 /** \addtogroup avr_power
01484 \code clock_prescale_set(x) \endcode
01485 
01486 Set the clock prescaler register select bits, selecting a system clock
01487 division setting. This function is inlined, even if compiler
01488 optimizations are disabled.
01489 
01490 The type of x is clock_div_t.
01491 */
01492 void clock_prescale_set(clock_div_t __x)
01493 {
01494     uint8_t __tmp = _BV(CLKPCE);
01495     __asm__ __volatile__ (
01496         "in __tmp_reg__,__SREG__" "\n\t"
01497         "cli" "\n\t"
01498         "sts %1, %0" "\n\t"
01499         "sts %1, %2" "\n\t"
01500         "out __SREG__, __tmp_reg__"
01501         : /* no outputs */
01502         : "d" (__tmp),
01503           "M" (_SFR_MEM_ADDR(CLKPR)),
01504           "d" (__x)
01505         : "r0");
01506 }
01507 
01508 /** \addtogroup avr_power
01509 \code clock_prescale_get() \endcode
01510 Gets and returns the clock prescaler register setting. The return type is clock_div_t.
01511 
01512 */
01513 #define clock_prescale_get()  (clock_div_t)(CLKPR & (uint8_t)((1<<CLKPS0)|(1<<CLKPS1)|(1<<CLKPS2)|(1<<CLKPS3)))
01514 
01515 
01516 #elif defined(__AVR_ATtiny24__) \
01517 || defined(__AVR_ATtiny24A__) \
01518 || defined(__AVR_ATtiny44__) \
01519 || defined(__AVR_ATtiny44A__) \
01520 || defined(__AVR_ATtiny84__) \
01521 || defined(__AVR_ATtiny84A__) \
01522 || defined(__AVR_ATtiny25__) \
01523 || defined(__AVR_ATtiny45__) \
01524 || defined(__AVR_ATtiny85__) \
01525 || defined(__AVR_ATtiny261A__) \
01526 || defined(__AVR_ATtiny261__) \
01527 || defined(__AVR_ATtiny461__) \
01528 || defined(__AVR_ATtiny461A__) \
01529 || defined(__AVR_ATtiny861__) \
01530 || defined(__AVR_ATtiny861A__) \
01531 || defined(__AVR_ATtiny2313__) \
01532 || defined(__AVR_ATtiny2313A__) \
01533 || defined(__AVR_ATtiny4313__) \
01534 || defined(__AVR_ATtiny13__) \
01535 || defined(__AVR_ATtiny13A__) \
01536 || defined(__AVR_ATtiny43U__) \
01537 
01538 typedef enum
01539 {
01540     clock_div_1 = 0,
01541     clock_div_2 = 1,
01542     clock_div_4 = 2,
01543     clock_div_8 = 3,
01544     clock_div_16 = 4,
01545     clock_div_32 = 5,
01546     clock_div_64 = 6,
01547     clock_div_128 = 7,
01548     clock_div_256 = 8
01549 } clock_div_t;
01550 
01551 static __inline__ void clock_prescale_set(clock_div_t) __attribute__((__always_inline__));
01552 
01553 void clock_prescale_set(clock_div_t __x)
01554 {
01555     uint8_t __tmp = _BV(CLKPCE);
01556     __asm__ __volatile__ (
01557         "in __tmp_reg__,__SREG__" "\n\t"
01558         "cli" "\n\t"
01559         "out %1, %0" "\n\t"
01560         "out %1, %2" "\n\t"
01561         "out __SREG__, __tmp_reg__"
01562         : /* no outputs */
01563         : "d" (__tmp),
01564           "I" (_SFR_IO_ADDR(CLKPR)),
01565           "d" (__x)
01566         : "r0");
01567 }
01568 
01569 
01570 #define clock_prescale_get()  (clock_div_t)(CLKPR & (uint8_t)((1<<CLKPS0)|(1<<CLKPS1)|(1<<CLKPS2)|(1<<CLKPS3)))
01571 
01572 
01573 #endif
01574 
01575 
01576 
01577 
01578 #endif /* _AVR_POWER_H_ */

Automatically generated by Doxygen 1.7.6.1 on Tue Jan 3 2012.