Xmega Application Note


avr_compiler.h

Go to the documentation of this file.
00001 /*This file has been prepared for Doxygen automatic documentation generation.*/
00016 
00017 
00018 /* Copyright (c) 2007, Atmel Corporation All rights reserved.
00019  *
00020  * Redistribution and use in source and binary forms, with or without
00021  * modification, are permitted provided that the following conditions are met:
00022  *
00023  * 1. Redistributions of source code must retain the above copyright notice,
00024  * this list of conditions and the following disclaimer.
00025  *
00026  * 2. Redistributions in binary form must reproduce the above copyright notice,
00027  * this list of conditions and the following disclaimer in the documentation
00028  * and/or other materials provided with the distribution.
00029  *
00030  * 3. The name of ATMEL may not be used to endorse or promote products derived
00031  * from this software without specific prior written permission.
00032  *
00033  * THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED
00034  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00035  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND
00036  * SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT,
00037  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00038  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00039  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
00040  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00041  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
00042  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 /* __HAS_ELPM__ */
00078 #define _MEMATTR  __farflash
00079 #endif /* __HAS_ELPM__ */
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 
@DOC_TITLE@
Generated on Tue Jan 19 18:41:58 2010 for AVR1320: True 400kHz operation for TWI slave by doxygen 1.5.8