power_drv.h

Go to the documentation of this file.
00001 /*This file is prepared for Doxygen automatic documentation generation.*/
00016 
00017 /* Copyright (c) 2009 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  * 4. This software may only be redistributed and used in connection with an Atmel
00033  * AVR product.
00034  *
00035  * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
00036  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00037  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE EXPRESSLY AND
00038  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00039  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00040  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00041  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00042  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00043  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00044  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00045  */
00046 
00047 
00048 #ifndef _POWER_DRV_H_
00049 #define _POWER_DRV_H_
00050 
00051 #ifdef  __GNUC__
00052    #include <avr/power.h>
00053 #endif
00057    
00058 //_____ M A C R O S ________________________________________________________
00059 
00060 #define Setup_idle_mode()                       (SMCR=0,SMCR |= (1<<SE))
00061 #define Setup_power_down_mode()                 (SMCR=0,SMCR |= (1<<SE)+(1<<SM1))
00062 #define Setup_adc_noise_reduction_mode()        (SMCR=0,SMCR |= (1<<SE)+(1<<SM0))
00063 #define Setup_power_save_mode()                 (SMCR=0,SMCR |= (1<<SE)+(1<<SM1)+(1<<SM0))
00064 #define Setup_standby_mode()                    (SMCR=0,SMCR |= (1<<SE)+(1<<SM2)+(1<<SM1))
00065 #define Setup_ext_standby_mode()                (SMCR=0,SMCR |= (1<<SE)+(1<<SM2)+(1<<SM1)+(1<<SM0))
00066 
00069 #ifdef  __GNUC__
00070    #define Clear_prescaler()                       (clock_prescale_set(0))
00071 #else
00072    #define Clear_prescaler()                       (Set_cpu_prescaler(0))
00073 #endif
00074 
00079 #ifdef  __GNUC__
00080    #define Set_cpu_prescaler(x)                        (clock_prescale_set(x))
00081 #else
00082    extern void Set_cpu_prescaler(U8 x);
00083 #endif
00084 
00085 
00086 #define Sleep_instruction()      {asm("SLEEP");}
00087 
00088 //Backward compatibility
00089 #define Set_power_down_mode()      set_power_down_mode()
00090 #define Set_idle_mode()            set_idle_mode()
00091 
00092 //_____ D E C L A R A T I O N ______________________________________________
00093 
00094 void set_idle_mode(void);
00095 void set_power_down_mode(void);
00096 void set_adc_noise_reduction_mode(void);
00097 void set_power_save_mode(void);
00098 void set_standby_mode(void);
00099 void set_ext_standby_mode(void);
00100 
00103 #define Enter_idle_mode()                 (set_idle_mode())
00104 
00107 #define Enter_power_down_mode()           (set_power_down_mode())
00108 
00111 #define Enter_adc_noise_reduction_mode()  (set_adc_noise_reduction_mode())
00112 
00115 #define Enter_power_save_mode()           (set_power_save_mode())
00116 
00119 
00120 #define Enter_standby_mode()              (set_standby_mode())
00121 
00124 #define Enter_ext_standby_mode()          (set_ext_standby_mode())
00125 
00126 
00128 
00129 #endif  // _POWER_DRV_H_
00130 

Generated on Mon Sep 14 13:24:11 2009 for ATMEL by  doxygen 1.5.3