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 EGNITE SOFTWARE GMBH 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 EGNITE 00024 * SOFTWARE GMBH 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 outp 00126 #define outp(val, sfr) outb(sfr, val) 00127 #endif 00128 #ifndef inp 00129 #define inp(sfr) inb(sfr) 00130 #endif 00131 #ifndef BV 00132 #define BV(bit) _BV(bit) 00133 #endif 00134 #ifndef inw 00135 #define inw(sfr) _SFR_WORD(sfr) 00136 #endif 00137 #ifndef outw 00138 #define outw(sfr, val) (_SFR_WORD(sfr) = (val)) 00139 #endif 00140 #ifndef PRG_RDB 00141 #define PRG_RDB(addr) pgm_read_byte(addr) 00142 #endif 00143 00144 #define __bss_end __heap_start 00145 extern void *__heap_start; 00146 00147 #ifdef __AVR_ENHANCED__ 00148 00149 /* Nut/OS is still using the original ATmega103 register names for 00150 backward compatibility. */ 00151 #ifndef UDR 00152 #define UDR UDR0 00153 #endif 00154 #ifndef UBRR 00155 #define UBRR UBRR0L 00156 #endif 00157 #ifndef USR 00158 #define USR UCSR0A 00159 #endif 00160 #ifndef UCR 00161 #define UCR UCSR0B 00162 #endif 00163 #ifndef EICR 00164 #define EICR EICRB 00165 #endif 00166 #ifndef RXC 00167 #define RXC RXC0 00168 #endif 00169 #ifndef UDRE 00170 #define UDRE UDRE0 00171 #endif 00172 #ifndef FE 00173 #define FE FE0 00174 #endif 00175 #ifndef DOR 00176 #define DOR DOR0 00177 #endif 00178 #ifndef RXCIE 00179 #define RXCIE RXCIE0 00180 #endif 00181 #ifndef TXCIE 00182 #define TXCIE TXCIE0 00183 #endif 00184 #ifndef UDRIE 00185 #define UDRIE UDRIE0 00186 #endif 00187 #ifndef RXEN 00188 #define RXEN RXEN0 00189 #endif 00190 #ifndef TXEN 00191 #define TXEN TXEN0 00192 #endif 00193 00194 /* Some ATC90CAN128 SFR names are different to ATMEGA128. Define some 00195 compatibilty macros. */ 00196 #if defined(__AVR_AT90CAN128__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) 00197 #ifndef ADCW 00198 #define ADCW ADC 00199 #endif 00200 #ifndef ADCSR 00201 #define ADCSR ADCSRA 00202 #endif 00203 #ifndef ADFR 00204 #define ADFR ADATE 00205 #endif 00206 #ifndef OCIE0 00207 #define OCIE0 OCIE0A 00208 #endif 00209 #ifndef TCCR0 00210 #define TCCR0 TCCR0A 00211 #endif 00212 #ifndef TCCR2 00213 #define TCCR2 TCCR2A 00214 #endif 00215 #ifndef OCR0 00216 #define OCR0 OCR0A 00217 #endif 00218 #ifndef TIMSK 00219 #define TIMSK TIMSK0 00220 #endif 00221 #ifndef TIFR 00222 #define TIFR TIFR0 00223 #endif 00224 #endif /* __AVR_AT90CAN128__ || __AVR_ATmega2560__ || __AVR_ATmega2561__*/ 00225 00226 00227 #endif /* __AVR_ENHANCED__ */ 00228 00229 00230 #endif /* _ARCH_AVR_H_ */