Xmega Application Note


config.h

Go to the documentation of this file.
00001 /* This file has been prepared for Doxygen automatic documentation generation.*/
00048 #ifndef _CONFIG_H_
00049 #define _CONFIG_H_
00050 
00051 #include "avr_compiler.h"
00052 
00054 #define FOSC 8000
00055 
00056 /****************************** MACROS ****************************************/
00057 
00059 #define Clear_prescaler()  (CLKPR = (1<<CLKPCE),CLKPR = 0)
00060 
00062 #define Set_prescaler(x)   (CLKPR = (1<<CKLPCE),CLKPR = x)
00063 
00065 #define Start_PLL()        (PLLCSR = (( (0<<PLLP2) | (1<<PLLP1) | (1<<PLLP0) ) | (1<<PLLE)  ))
00066 
00068 #define Wait_pll_ready()   while (!(PLLCSR & (1<<PLOCK)))
00069 
00070 /* LED Control macros */
00071 #define Led_on()   (PORTB &= ~(1<<PB6))
00072 #define Led_off()  (PORTB |= (1<<PB6))
00073 #define Led_tgl()  (PINB  |= (1<<PB6))
00074 #define Led_init() ((DDRB |= (1<<PB6)),Led_on())
00075 
00076 /* Sleep control definitions */
00077 #define IDLE_MODE                        ((0<<SM2)|(0<<SM1)|(0<<SM0))
00078 #define ADC_NOISE_REDUCTION_MODE         ((0<<SM2)|(0<<SM1)|(1<<SM0))
00079 #define POWER_DOWN_MODE                  ((0<<SM2)|(1<<SM1)|(0<<SM0))
00080 #define POWER_SAVE_MODE                  ((0<<SM2)|(1<<SM1)|(1<<SM0))
00081 #define STANDBY_MODE                     ((1<<SM2)|(1<<SM1)|(0<<SM0))
00082 #define EXTENDED_STANDBY_MODE            ((1<<SM2)|(1<<SM1)|(1<<SM0))
00083 
00084 /* Macro to enter a sleep mode, uncomment the define to enable sleep. */
00085 #define Enter_sleep(mode)                (SMCR = mode | (1<<SE)),(__sleep()),(SMCR=0)
00086 
00087 /* Define to tell if strings should be contained in Flash or RAM. Use RAM for
00088  * GCC compatability.
00089  */
00090 #define code  //__flash
00091 
00092 
00093 /* Byte operation macros */
00094 #define MSB(u16)        (((uint8_t* )&u16)[1])
00095 #define LSB(u16)        (((uint8_t* )&u16)[0])
00096 #define MSW(u32)        (((uint16_t*)&u32)[1])
00097 #define LSW(u32)        (((uint16_t*)&u32)[0])
00098 #define MSB0(u32)       (((uint8_t* )&u32)[3])
00099 #define MSB1(u32)       (((uint8_t* )&u32)[2])
00100 #define MSB2(u32)       (((uint8_t* )&u32)[1])
00101 #define MSB3(u32)       (((uint8_t* )&u32)[0])
00102 #define LSB0(u32)       MSB3(u32)
00103 #define LSB1(u32)       MSB2(u32)
00104 #define LSB2(u32)       MSB1(u32)
00105 #define LSB3(u32)       MSB0(u32)
00106 
00108 #define NB_MS_BEFORE_FLUSH                      50
00109 
00110 #endif /* _CONFIG_H_ */
00111 
@DOC_TITLE@
Generated on Mon Jan 18 09:26:08 2010 for AVR1907 Xplain USB Gateway by doxygen 1.5.5