00001 #ifndef _ARCH_AVR_H_ 00002 #define _ARCH_AVR_H_ 00003 00004 /* 00005 * Copyright (C) 2001-2005 by egnite Software GmbH. All rights reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * 1. Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 2. Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in the 00015 * documentation and/or other materials provided with the distribution. 00016 * 3. Neither the name of the copyright holders nor the names of 00017 * contributors may be used to endorse or promote products derived 00018 * from this software without specific prior written permission. 00019 * 00020 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00021 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00022 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 00023 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00024 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00025 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00026 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00027 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 00028 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00029 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 00030 * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00031 * SUCH DAMAGE. 00032 * 00033 * For additional information see http://www.ethernut.de/ 00034 */ 00035 00036 /* 00037 * $Log$ 00038 * Revision 1.15 2008/08/11 11:51:20 thiagocorrea 00039 * Preliminary Atmega2560 compile options, but not yet supported. 00040 * It builds, but doesn't seam to run properly at this time. 00041 * 00042 * Revision 1.14 2006/02/08 15:20:22 haraldkipp 00043 * ATmega2561 Support 00044 * 00045 * Revision 1.13 2005/10/24 10:42:48 haraldkipp 00046 * Definitions distributed to avr/icc.h and avr/gcc.h. 00047 * 00048 * Revision 1.12 2005/10/04 05:21:52 hwmaier 00049 * Added TIFR definition for AT09CAN128 00050 * 00051 * Revision 1.11 2005/08/02 17:46:48 haraldkipp 00052 * Major API documentation update. 00053 * 00054 * Revision 1.10 2005/02/22 17:03:02 freckle 00055 * changed avr-libc-1.2 test to use eeprom_rb, as other test was wrong on 00056 * 1.0.5 00057 * 00058 * Revision 1.9 2005/02/22 16:22:21 freckle 00059 * Added cpp test to guess avr-libc-version required to specify twi.h path 00060 * 00061 * Revision 1.8 2005/02/10 07:06:48 hwmaier 00062 * Changes to incorporate support for AT90CAN128 CPU 00063 * 00064 * Revision 1.7 2005/01/10 12:40:15 olereinhardt 00065 * Included check if atof is just defined (needed by new avr-libc versions on debian unstable) 00066 * 00067 * Revision 1.6 2004/07/09 19:51:34 freckle 00068 * Added new function NutThreadSetSleepMode to tell nut/os to set the MCU 00069 * into sleep mode when idle (avr-gcc && avr128 only) 00070 * 00071 * Revision 1.5 2004/05/23 14:30:32 drsung 00072 * Added some macros, because they are no longer available since version 1.1.0 of avr-libc. 00073 * 00074 * Revision 1.4 2004/03/18 15:53:42 haraldkipp 00075 * ICCAVR failed to compile 00076 * 00077 * Revision 1.3 2004/03/18 09:57:01 haraldkipp 00078 * Architecture required in UserConf.mk 00079 * 00080 * Revision 1.2 2004/03/17 14:54:00 haraldkipp 00081 * Compiling for AVR works again 00082 * 00083 * Revision 1.1 2004/03/16 16:48:28 haraldkipp 00084 * Added Jan Dubiec's H8/300 port. 00085 * 00086 * Revision 1.1 2004/02/01 18:49:47 haraldkipp 00087 * Added CPU family support 00088 * 00089 */ 00090 00091 #if defined(__IMAGECRAFT__) 00092 #include <arch/avr/icc.h> 00093 #elif defined(__GNUC__) 00094 #include <arch/avr/gcc.h> 00095 #else 00096 #error "Unable to determine AVR compiler." 00097 #endif 00098 00105 #undef __AVR__ 00106 #define __AVR__ 00107 00108 00109 /* 00110 * Since version 1.1.0 of avr-libc, some former deprecated macros are deleted. 00111 * But we need them futher on, so they are defined here. 00112 */ 00113 #ifndef cbi 00114 #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) 00115 #endif 00116 #ifndef sbi 00117 #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) 00118 #endif 00119 #ifndef inb 00120 #define inb(sfr) _SFR_BYTE(sfr) 00121 #endif 00122 #ifndef outb 00123 #define outb(sfr, val) (_SFR_BYTE(sfr) = (val)) 00124 #endif 00125 #ifndef BV 00126 #define BV(bit) _BV(bit) 00127 #endif 00128 #ifndef inw 00129 #define inw(sfr) _SFR_WORD(sfr) 00130 #endif 00131 #ifndef outw 00132 #define outw(sfr, val) (_SFR_WORD(sfr) = (val)) 00133 #endif 00134 #ifndef PRG_RDB 00135 #define PRG_RDB(addr) pgm_read_byte(addr) 00136 #endif 00137 00138 #define __bss_end __heap_start 00139 extern void *__heap_start; 00140 00141 #ifdef __AVR_ENHANCED__ 00142 00143 /* Nut/OS is still using the original ATmega103 register names for 00144 backward compatibility. */ 00145 #ifndef UDR 00146 #define UDR UDR0 00147 #endif 00148 #ifndef UBRR 00149 #define UBRR UBRR0L 00150 #endif 00151 #ifndef USR 00152 #define USR UCSR0A 00153 #endif 00154 #ifndef UCR 00155 #define UCR UCSR0B 00156 #endif 00157 #ifndef EICR 00158 #define EICR EICRB 00159 #endif 00160 #ifndef RXC 00161 #define RXC RXC0 00162 #endif 00163 #ifndef UDRE 00164 #define UDRE UDRE0 00165 #endif 00166 #ifndef FE 00167 #define FE FE0 00168 #endif 00169 #ifndef DOR 00170 #define DOR DOR0 00171 #endif 00172 #ifndef RXCIE 00173 #define RXCIE RXCIE0 00174 #endif 00175 #ifndef TXCIE 00176 #define TXCIE TXCIE0 00177 #endif 00178 #ifndef UDRIE 00179 #define UDRIE UDRIE0 00180 #endif 00181 #ifndef RXEN 00182 #define RXEN RXEN0 00183 #endif 00184 #ifndef TXEN 00185 #define TXEN TXEN0 00186 #endif 00187 00188 /* Some ATC90CAN128 SFR names are different to ATMEGA128. Define some 00189 compatibilty macros. */ 00190 #if defined(__AVR_AT90CAN128__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) 00191 #ifndef ADCW 00192 #define ADCW ADC 00193 #endif 00194 #ifndef ADCSR 00195 #define ADCSR ADCSRA 00196 #endif 00197 #ifndef ADFR 00198 #define ADFR ADATE 00199 #endif 00200 #ifndef OCIE0 00201 #define OCIE0 OCIE0A 00202 #endif 00203 #ifndef TCCR0 00204 #define TCCR0 TCCR0A 00205 #endif 00206 #ifndef TCCR2 00207 #define TCCR2 TCCR2A 00208 #endif 00209 #ifndef OCR0 00210 #define OCR0 OCR0A 00211 #endif 00212 #ifndef TIMSK 00213 #define TIMSK TIMSK0 00214 #endif 00215 #ifndef TIFR 00216 #define TIFR TIFR0 00217 #endif 00218 #endif /* __AVR_AT90CAN128__ || __AVR_ATmega2560__ || __AVR_ATmega2561__*/ 00219 00220 00221 #endif /* __AVR_ENHANCED__ */ 00222 00223 00224 #endif /* _ARCH_AVR_H_ */