power_drv.h

Go to the documentation of this file.
00001 /*This file has been prepared for Doxygen automatic documentation generation.*/
00016 
00017 /* Copyright (c) 2007, Atmel Corporation All rights reserved.
00018  *
00019  * Redistribution and use in source and binary forms, with or without
00020  * modification, are permitted provided that the following conditions are met:
00021  *
00022  * 1. Redistributions of source code must retain the above copyright notice,
00023  * this list of conditions and the following disclaimer.
00024  *
00025  * 2. Redistributions in binary form must reproduce the above copyright notice,
00026  * this list of conditions and the following disclaimer in the documentation
00027  * and/or other materials provided with the distribution.
00028  *
00029  * 3. The name of ATMEL may not be used to endorse or promote products derived
00030  * from this software without specific prior written permission.
00031  *
00032  * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
00033  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00034  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
00035  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00036  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00037  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00038  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00039  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00040  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00041  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00042  */
00043 
00044 
00045 #ifndef _POWER_DRV_H_
00046 #define _POWER_DRV_H_
00047 
00048 #ifdef  __GNUC__
00049    #include <avr/power.h>
00050 #endif
00054    
00055 //_____ M A C R O S ________________________________________________________
00056 
00057 #define Setup_idle_mode()                       (SMCR=0,SMCR |= (1<<SE))
00058 #define Setup_power_down_mode()                 (SMCR=0,SMCR |= (1<<SE)+(1<<SM1))
00059 #define Setup_adc_noise_reduction_mode()        (SMCR=0,SMCR |= (1<<SE)+(1<<SM0))
00060 #define Setup_power_save_mode()                 (SMCR=0,SMCR |= (1<<SE)+(1<<SM1)+(1<<SM0))
00061 #define Setup_standby_mode()                    (SMCR=0,SMCR |= (1<<SE)+(1<<SM2)+(1<<SM1))
00062 #define Setup_ext_standby_mode()                (SMCR=0,SMCR |= (1<<SE)+(1<<SM2)+(1<<SM1)+(1<<SM0))
00063 
00073 #ifdef  __GNUC__
00074    #define Clear_prescaler()                       (clock_prescale_set(0))
00075 #else
00076    #define Clear_prescaler()                       (Set_cpu_prescaler(0))
00077 #endif
00078 
00088 #ifdef  __GNUC__
00089    #define Set_cpu_prescaler(x)                        (clock_prescale_set(x))
00090 #else
00091    extern void Set_cpu_prescaler(U8 x);
00092 #endif
00093 
00094 
00095 #define Sleep_instruction()      {asm("SLEEP");}
00096 
00097 //Backward compatibility
00098 #define Set_power_down_mode()      set_power_down_mode()
00099 #define Set_idle_mode()            set_idle_mode()
00100 
00101 //_____ D E C L A R A T I O N ______________________________________________
00102 
00103 void set_idle_mode(void);
00104 void set_power_down_mode(void);
00105 void set_adc_noise_reduction_mode(void);
00106 void set_power_save_mode(void);
00107 void set_standby_mode(void);
00108 void set_ext_standby_mode(void);
00109 
00118 #define Enter_idle_mode()                 (set_idle_mode())
00119 
00128 #define Enter_power_down_mode()           (set_power_down_mode())
00129 
00138 #define Enter_adc_noise_reduction_mode()  (set_adc_noise_reduction_mode())
00139 
00148 #define Enter_power_save_mode()           (set_power_save_mode())
00149 
00158 #define Enter_standby_mode()              (set_standby_mode())
00159 
00168 #define Enter_ext_standby_mode()          (set_ext_standby_mode())
00169 
00170 
00172 
00173 #endif  // _POWER_DRV_H_
00174 

Generated on Mon Nov 3 10:08:23 2008 for ATMEL by  doxygen 1.5.3