| AVR1600 Using the XMEGA Quadrature Decoder

avr_compiler.h
Go to the documentation of this file.
1 /* This file has been prepared for Doxygen automatic documentation generation.*/
44 #ifndef COMPILER_AVR_H
45 #define COMPILER_AVR_H
46
47 #ifndef F_CPU
48
49 #define F_CPU 2000000UL
50 #endif
51
52 #include <stdint.h>
53 #include <stdbool.h>
54 #include <stdlib.h>
55
57 #define AVR_ENTER_CRITICAL_REGION( ) uint8_t volatile saved_sreg = SREG; \
58 cli();
59
63 #define AVR_LEAVE_CRITICAL_REGION( ) SREG = saved_sreg;
64
65 #if defined( __ICCAVR__ )
66
67 #include <inavr.h>
68 #include <ioavr.h>
69 #include <intrinsics.h>
70 #include <pgmspace.h>
71
72 #ifndef __HAS_ELPM__
73 #define _MEMATTR __flash
74 #else /* __HAS_ELPM__ */
75 #define _MEMATTR __farflash
76 #endif /* __HAS_ELPM__ */
77
88 #define delay_us( us ) ( __delay_cycles( ( F_CPU / 1000000UL ) * ( us ) ) )
89
103 #define PRAGMA(x) _Pragma( #x )
104 #define ISR(vec) PRAGMA( vector=vec ) __interrupt void handler_##vec(void)
105 #define sei( ) (__enable_interrupt( ))
106 #define cli( ) (__disable_interrupt( ))
107
109 #define nop( ) (__no_operation())
110
112 #define watchdog_reset( ) (__watchdog_reset( ))
113
114
115 #define INLINE PRAGMA( inline=forced ) static
116
117 #define FLASH_DECLARE(x) _MEMATTR x
118 #define FLASH_STRING(x) ((_MEMATTR const char *)(x))
119 #define FLASH_STRING_T char const _MEMATTR *
120 #define FLASH_BYTE_ARRAY_T uint8_t const _MEMATTR *
121 #define PGM_READ_BYTE(x) *(x)
122 #define PGM_READ_WORD(x) *(x)
123
124 #define SHORTENUM
125
126 #elif defined( __GNUC__ )
127
128 #include <avr/io.h>
129 #include <avr/interrupt.h>
130 #include <avr/pgmspace.h>
131 #include <util/delay.h>
132
134 #define delay_us( us ) (_delay_us( us ))
135
136 #define INLINE static inline
137
139 #define nop() do { __asm__ __volatile__ ("nop"); } while (0)
140
141 #define MAIN_TASK_PROLOGUE int
142
143
144 #define MAIN_TASK_EPILOGUE() return -1;
145
146 #define SHORTENUM __attribute__ ((packed))
147
148 #else
149 #error Compiler not supported.
150 #endif
151
152 #endif
153
@DOC_TITLE@