00001
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 #ifndef COMPILER_AVR_H
00047 #define COMPILER_AVR_H
00048
00049 #ifndef F_CPU
00050
00051 #define F_CPU 32000000UL
00052
00053 #endif
00054
00055 #include <stdint.h>
00056 #include <stdbool.h>
00057 #include <stdlib.h>
00058
00060 #define AVR_ENTER_CRITICAL_REGION( ) uint8_t volatile saved_sreg = SREG; \
00061 cli();
00062
00066 #define AVR_LEAVE_CRITICAL_REGION( ) SREG = saved_sreg;
00067
00068 #if defined( __ICCAVR__ )
00069
00070 #include <inavr.h>
00071 #include <ioavr.h>
00072 #include <intrinsics.h>
00073 #include <pgmspace.h>
00074
00075 #ifndef __HAS_ELPM__
00076 #define _MEMATTR __flash
00077 #else
00078 #define _MEMATTR __farflash
00079 #endif
00080
00091 #define delay_us( us ) ( __delay_cycles( ( F_CPU / 1000000UL ) * ( us ) ) )
00092
00106 #define PRAGMA(x) _Pragma( #x )
00107 #define ISR(vec) PRAGMA( vector=vec ) __interrupt void handler_##vec(void)
00108 #define sei( ) (__enable_interrupt( ))
00109 #define cli( ) (__disable_interrupt( ))
00110
00112 #define nop( ) (__no_operation())
00113
00115 #define watchdog_reset( ) (__watchdog_reset( ))
00116
00117
00118 #define INLINE PRAGMA( inline=forced ) static
00119
00120 #define FLASH_DECLARE(x) _MEMATTR x
00121 #define FLASH_STRING(x) ((_MEMATTR const char *)(x))
00122 #define FLASH_STRING_T char const _MEMATTR *
00123 #define FLASH_BYTE_ARRAY_T uint8_t const _MEMATTR *
00124 #define PGM_READ_BYTE(x) *(x)
00125 #define PGM_READ_WORD(x) *(x)
00126
00127 #define SHORTENUM
00128
00129 #elif defined( __GNUC__ )
00130
00131 #include <avr/io.h>
00132 #include <avr/interrupt.h>
00133 #include <avr/pgmspace.h>
00134 #include <util/delay.h>
00135
00137 #define delay_us( us ) (_delay_us( us ))
00138
00139 #define INLINE static inline
00140
00142 #define nop() do { __asm__ __volatile__ ("nop"); } while (0)
00143
00144 #define MAIN_TASK_PROLOGUE int
00145
00146
00147 #define MAIN_TASK_EPILOGUE() return -1;
00148
00149 #define SHORTENUM __attribute__ ((packed))
00150
00151 #else
00152 #error Compiler not supported.
00153 #endif
00154
00155 #endif
00156