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

Automatically generated by Doxygen 1.4.7 on 19 Aug 2011.