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