XMEGA Application Note


avr_compiler.h

Go to the documentation of this file.
00001 // This file has been prepared for Doxygen automatic documentation generation.
00051 #ifndef COMPILER_AVR_H
00052 #define COMPILER_AVR_H
00053 
00054 #include <stdint.h>
00055 #include <stdbool.h>
00056 #include <stdlib.h>
00057 
00059 #define ENTER_CRITICAL_REGION() uint8_t volatile saved_sreg = SREG; \
00060                                      cli();
00061 
00064 #define LEAVE_CRITICAL_REGION() SREG = saved_sreg;
00065 
00066 #if defined(__ICCAVR__)
00067 
00068 #include <inavr.h>
00069 #include <ioavr.h>
00070 #include <intrinsics.h>
00071 #include <pgmspace.h>
00072 
00073 #ifndef __HAS_ELPM__
00074 #define _MEMATTR  __flash
00075 #else /* __HAS_ELPM__ */
00076 #define _MEMATTR  __farflash
00077 #endif /* __HAS_ELPM__ */
00078 
00079 #define cpu_sleep() __sleep()
00080 
00081 #define delay_us( us )   __delay_cycles((F_CPU / 1000000UL) * (us))
00082 
00095 #define PRAGMA(x) _Pragma(#x)
00096 #define ISR(vec) PRAGMA(vector=vec) __interrupt void handler_##vec(void)
00097 #define sei() (__enable_interrupt( ))
00098 #define cli() (__disable_interrupt( ))
00099 
00100 #define nop() (__no_operation())
00101 
00102 #define INLINE PRAGMA(inline=forced) static
00103 
00104 #define PROGMEM_LOCATION(var, loc) const _MEMATTR var @ loc
00105 #define PROGMEM_DECLARE(x) _MEMATTR x
00106 #define PROGMEM_STRING(x) ((_MEMATTR const char *)(x))
00107 #define PROGMEM_STRING_T  char const _MEMATTR *
00108 #define PROGMEM_T const _MEMATTR
00109 #define PROGMEM_PTR_T const _MEMATTR *
00110 #define PROGMEM_BYTE_ARRAY_T uint8_t const _MEMATTR *
00111 #define PROGMEM_WORD_ARRAY_T uint16_t const _MEMATTR *
00112 #define PROGMEM_READ_BYTE(x) *(x)
00113 #define PROGMEM_READ_WORD(x) *(x)
00114 
00115 #define EEPROM_DECLARE(var) __eeprom var
00116 #define EEGET(var, adr) __EEGET(var, adr)
00117 #define EEPUT(adr, val) __EEPUT(adr, val)
00118 
00119 #define watchdog_reset() __watchdog_reset()
00120 
00121 #define SHORTENUM 
00122 
00123 #elif defined(__GNUC__)
00124 
00125 #include <avr/sleep.h>
00126 #include <avr/io.h>
00127 #include <avr/interrupt.h>
00128 #include <avr/pgmspace.h>
00129 //#include <avr/eeprom.h>
00130 #include <avr/wdt.h>
00131 #include <util/delay.h>
00132 
00133 #define cpu_sleep() sleep_cpu()
00134 
00135 #define delay_us(us)   (_delay_us( us ))
00136 
00137 #define INLINE static inline
00138 
00139 #define nop()   do {__asm__ __volatile__ ("nop");} while (0)
00140 
00141 #define PROGMEM_LOCATION(var, loc) var __attribute__((section (#loc)))
00142 #define PROGMEM_DECLARE(x) x __attribute__((__progmem__))
00143 #define PROGMEM_STRING(x) PSTR(x)
00144 #define PROGMEM_STRING_T  PGM_P
00145 #define PROGMEM_T
00146 #define PROGMEM_PTR_T *
00147 #define PROGMEM_BYTE_ARRAY_T uint8_t*
00148 #define PROGMEM_WORD_ARRAY_T uint16_t*
00149 #define PROGMEM_READ_BYTE(x) pgm_read_byte(x)
00150 #define PROGMEM_READ_WORD(x) pgm_read_word(x)
00151 
00152 #define EEPROM_DECLARE(var) var EEMEM
00153 #define EEGET(var, addr) (var) = eeprom_read_byte ((uint8_t *)(addr))
00154 #define EEPUT(addr, var) eeprom_write_byte ((uint8_t *)(addr), var)
00155 
00156 #define watchdog_reset() wdt_reset()
00157 
00158 #define SHORTENUM __attribute__ ((packed))
00159 #else
00160 #error Compiler not supported.
00161 #endif
00162 #endif
00163 
00164 /* EOF */
@DOC_TITLE@
Generated on Mon Nov 9 13:44:26 2009 for XMEGA power consumption evaluation code by doxygen 1.5.9