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, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT 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 
00066 #ifdef  __GNUC__
00067    #define Clear_prescaler()                       (clock_prescale_set(0))
00068 #else
00069    #define Clear_prescaler()                       (Set_cpu_prescaler(0))
00070 #endif
00071 
00076 #ifdef  __GNUC__
00077    #define Set_cpu_prescaler(x)                        (clock_prescale_set(x))
00078 #else
00079    extern void Set_cpu_prescaler(U8 x);
00080 #endif
00081 
00082 
00083 #define Sleep_instruction()      {asm("SLEEP");}
00084 
00085 //Backward compatibility
00086 #define Set_power_down_mode()      set_power_down_mode()
00087 #define Set_idle_mode()            set_idle_mode()
00088 
00089 //_____ D E C L A R A T I O N ______________________________________________
00090 
00091 void set_idle_mode(void);
00092 void set_power_down_mode(void);
00093 void set_adc_noise_reduction_mode(void);
00094 void set_power_save_mode(void);
00095 void set_standby_mode(void);
00096 void set_ext_standby_mode(void);
00097 
00100 #define Enter_idle_mode()                 (set_idle_mode())
00101 
00104 #define Enter_power_down_mode()           (set_power_down_mode())
00105 
00108 #define Enter_adc_noise_reduction_mode()  (set_adc_noise_reduction_mode())
00109 
00112 #define Enter_power_save_mode()           (set_power_save_mode())
00113 
00116 
00117 #define Enter_standby_mode()              (set_standby_mode())
00118 
00121 #define Enter_ext_standby_mode()          (set_ext_standby_mode())
00122 
00123 
00125 
00126 #endif  // _POWER_DRV_H_
00127 

Generated on Fri May 15 15:41:36 2009 for ATMEL by  doxygen 1.5.3