| Xmega Application Note |

# avr_compiler.h

Go to the documentation of this file.

    00001 /* This file has been prepared for Doxygen automatic documentation generation.*/
    00045 #ifndef COMPILER_AVR_H
    00046 #define COMPILER_AVR_H
    00047
    00048 #ifndef F_CPU
    00049
    00050 #define F_CPU 2000000UL
    00051 #endif
    00052
    00053 #include <stdint.h>
    00054 #include <stdbool.h>
    00055 #include <stdlib.h>
    00056
    00058 #define AVR_ENTER_CRITICAL_REGION( ) uint8_t volatile saved_sreg = SREG; \
    00059                                      cli();
    00060
    00064 #define AVR_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
    00089 #define delay_us( us )   ( __delay_cycles( ( F_CPU / 1000000UL ) * ( us ) ) )
    00090
    00104 #define PRAGMA(x) _Pragma( #x )
    00105 #define ISR(vec) PRAGMA( vector=vec ) __interrupt void handler_##vec(void)
    00106 #define sei( ) (__enable_interrupt( ))
    00107 #define cli( ) (__disable_interrupt( ))
    00108
    00110 #define nop( ) (__no_operation())
    00111
    00113 #define watchdog_reset( ) (__watchdog_reset( ))
    00114
    00115
    00116 #define INLINE PRAGMA( inline=forced ) static
    00117
    00118 #define FLASH_DECLARE(x) _MEMATTR x
    00119 #define FLASH_STRING(x) ((_MEMATTR const char *)(x))
    00120 #define FLASH_STRING_T  char const _MEMATTR *
    00121 #define FLASH_BYTE_ARRAY_T uint8_t const _MEMATTR *
    00122 #define PGM_READ_BYTE(x) *(x)
    00123 #define PGM_READ_WORD(x) *(x)
    00124
    00125 #define SHORTENUM
    00126
    00127 #elif defined( __GNUC__ )
    00128
    00129 #include <avr/io.h>
    00130 #include <avr/interrupt.h>
    00131 #include <avr/pgmspace.h>
    00132 #include <util/delay.h>
    00133
    00135 #define delay_us( us )   (_delay_us( us ))
    00136
    00137 #define INLINE static inline
    00138
    00140 #define nop()   do { __asm__ __volatile__ ("nop"); } while (0)
    00141
    00142 #define MAIN_TASK_PROLOGUE int
    00143
    00144
    00145 #define MAIN_TASK_EPILOGUE() return -1;
    00146
    00147 #define SHORTENUM __attribute__ ((packed))
    00148
    00149 #else
    00150 #error Compiler not supported.
    00151 #endif
    00152
    00153 #endif
    00154

@DOC_TITLE@