Xmega Application Note


avr_compiler.h
Go to the documentation of this file.
00001 /* This file has been prepared for Doxygen automatic documentation generation.*/
00048 #ifndef COMPILER_AVR_H
00049 #define COMPILER_AVR_H
00050 
00051 #ifndef F_CPU
00052 
00053 #define F_CPU 2000000UL
00054 #endif
00055 
00056 #include <stdint.h>
00057 #include <stdbool.h>
00058 #include <stdlib.h>
00059 
00061 #define AVR_ENTER_CRITICAL_REGION( ) uint8_t volatile saved_sreg = SREG; \
00062                                      cli();
00063 
00067 #define AVR_LEAVE_CRITICAL_REGION( ) SREG = saved_sreg;
00068 
00069 #if defined( __ICCAVR__ )
00070 
00071 #include <inavr.h>
00072 #include <ioavr.h>
00073 #include <intrinsics.h>
00074 #include <pgmspace.h>
00075 
00076 #ifndef __HAS_ELPM__
00077 #define _MEMATTR  __flash
00078 #else /* __HAS_ELPM__ */
00079 #define _MEMATTR  __farflash
00080 #endif /* __HAS_ELPM__ */
00081 
00092 #define delay_us( us )   ( __delay_cycles( ( F_CPU / 1000000UL ) * ( us ) ) )
00093 
00107 #define PRAGMA(x) _Pragma( #x )
00108 #define ISR(vec) PRAGMA( vector=vec ) __interrupt void handler_##vec(void)
00109 #define sei( ) (__enable_interrupt( ))
00110 #define cli( ) (__disable_interrupt( ))
00111 
00113 #define nop( ) (__no_operation())
00114 
00116 #define watchdog_reset( ) (__watchdog_reset( ))
00117 
00118 
00119 #define INLINE PRAGMA( inline=forced ) static
00120 
00121 #define FLASH_DECLARE(x) _MEMATTR x
00122 #define FLASH_STRING(x) ((_MEMATTR const char *)(x))
00123 #define FLASH_STRING_T  char const _MEMATTR *
00124 #define FLASH_BYTE_ARRAY_T uint8_t const _MEMATTR *
00125 #define PGM_READ_BYTE(x) *(x)
00126 #define PGM_READ_WORD(x) *(x)
00127 
00128 #define SHORTENUM 
00129 
00130 #elif defined( __GNUC__ )
00131 
00132 #include <avr/io.h>
00133 #include <avr/interrupt.h>
00134 #include <avr/pgmspace.h>
00135 #include <util/delay.h>
00136 
00138 #define delay_us( us )   (_delay_us( us ))
00139 
00140 #define INLINE static inline
00141 
00143 #define nop()   do { __asm__ __volatile__ ("nop"); } while (0)
00144 
00145 #define MAIN_TASK_PROLOGUE int
00146 
00147 
00148 #define MAIN_TASK_EPILOGUE() return -1;
00149 
00150 #define SHORTENUM __attribute__ ((packed))
00151 
00152 #else
00153 #error Compiler not supported.
00154 #endif
00155 
00156 #endif
00157