avr.h

Go to the documentation of this file.
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: avr.h,v $
00038  * Revision 1.14  2006/02/08 15:20:22  haraldkipp
00039  * ATmega2561 Support
00040  *
00041  * Revision 1.13  2005/10/24 10:42:48  haraldkipp
00042  * Definitions distributed to avr/icc.h and avr/gcc.h.
00043  *
00044  * Revision 1.12  2005/10/04 05:21:52  hwmaier
00045  * Added TIFR definition for AT09CAN128
00046  *
00047  * Revision 1.11  2005/08/02 17:46:48  haraldkipp
00048  * Major API documentation update.
00049  *
00050  * Revision 1.10  2005/02/22 17:03:02  freckle
00051  * changed avr-libc-1.2 test to use eeprom_rb, as other test was wrong on
00052  * 1.0.5
00053  *
00054  * Revision 1.9  2005/02/22 16:22:21  freckle
00055  * Added cpp test to guess avr-libc-version required  to specify twi.h path
00056  *
00057  * Revision 1.8  2005/02/10 07:06:48  hwmaier
00058  * Changes to incorporate support for AT90CAN128 CPU
00059  *
00060  * Revision 1.7  2005/01/10 12:40:15  olereinhardt
00061  * Included check if atof is just defined (needed by new avr-libc versions on debian unstable)
00062  *
00063  * Revision 1.6  2004/07/09 19:51:34  freckle
00064  * Added new function NutThreadSetSleepMode to tell nut/os to set the MCU
00065  * into sleep mode when idle (avr-gcc && avr128 only)
00066  *
00067  * Revision 1.5  2004/05/23 14:30:32  drsung
00068  * Added some macros, because they are no longer available since version 1.1.0 of avr-libc.
00069  *
00070  * Revision 1.4  2004/03/18 15:53:42  haraldkipp
00071  * ICCAVR failed to compile
00072  *
00073  * Revision 1.3  2004/03/18 09:57:01  haraldkipp
00074  * Architecture required in UserConf.mk
00075  *
00076  * Revision 1.2  2004/03/17 14:54:00  haraldkipp
00077  * Compiling for AVR works again
00078  *
00079  * Revision 1.1  2004/03/16 16:48:28  haraldkipp
00080  * Added Jan Dubiec's H8/300 port.
00081  *
00082  * Revision 1.1  2004/02/01 18:49:47  haraldkipp
00083  * Added CPU family support
00084  *
00085  */
00086 
00087 #if defined(__IMAGECRAFT__)
00088 #include <arch/avr/icc.h>
00089 #elif defined(__GNUC__)
00090 #include <arch/avr/gcc.h>
00091 #else
00092 #error "Unable to determine AVR compiler."
00093 #endif
00094 
00101 #undef __AVR__
00102 #define __AVR__
00103 
00104 
00105 /*
00106  * Since version 1.1.0 of avr-libc, some former deprecated macros are deleted.
00107  * But we need them futher on, so they are defined here.
00108  */
00109 #ifndef cbi
00110 #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
00111 #endif
00112 #ifndef sbi
00113 #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
00114 #endif
00115 #ifndef inb
00116 #define inb(sfr) _SFR_BYTE(sfr)
00117 #endif
00118 #ifndef outb
00119 #define outb(sfr, val) (_SFR_BYTE(sfr) = (val))
00120 #endif
00121 #ifndef outp
00122 #define outp(val, sfr) outb(sfr, val)
00123 #endif
00124 #ifndef inp
00125 #define inp(sfr) inb(sfr)
00126 #endif
00127 #ifndef BV
00128 #define BV(bit) _BV(bit)
00129 #endif
00130 #ifndef inw
00131 #define inw(sfr) _SFR_WORD(sfr)
00132 #endif
00133 #ifndef outw
00134 #define outw(sfr, val) (_SFR_WORD(sfr) = (val))
00135 #endif
00136 #ifndef PRG_RDB
00137 #define PRG_RDB(addr)       pgm_read_byte(addr)
00138 #endif
00139 
00140 #define __bss_end   __heap_start
00141 extern void *__heap_start;
00142 
00143 #ifdef __AVR_ENHANCED__
00144 
00145 /* Nut/OS is still using the original ATmega103 register names for
00146    backward compatibility. */
00147 #ifndef UDR
00148 #define UDR     UDR0
00149 #endif
00150 #ifndef UBRR
00151 #define UBRR    UBRR0L
00152 #endif
00153 #ifndef USR
00154 #define USR     UCSR0A
00155 #endif
00156 #ifndef UCR
00157 #define UCR     UCSR0B
00158 #endif
00159 #ifndef EICR
00160 #define EICR    EICRB
00161 #endif
00162 #ifndef RXC
00163 #define RXC     RXC0
00164 #endif
00165 #ifndef UDRE
00166 #define UDRE    UDRE0
00167 #endif
00168 #ifndef FE
00169 #define FE      FE0
00170 #endif
00171 #ifndef DOR
00172 #define DOR     DOR0
00173 #endif
00174 #ifndef RXCIE
00175 #define RXCIE   RXCIE0
00176 #endif
00177 #ifndef TXCIE
00178 #define TXCIE   TXCIE0
00179 #endif
00180 #ifndef UDRIE
00181 #define UDRIE   UDRIE0
00182 #endif
00183 #ifndef RXEN
00184 #define RXEN    RXEN0
00185 #endif
00186 #ifndef TXEN
00187 #define TXEN    TXEN0
00188 #endif
00189 
00190 /* Some ATC90CAN128 SFR names are different to ATMEGA128. Define some
00191    compatibilty macros. */
00192 #if defined(__AVR_AT90CAN128__) || defined(__AVR_ATmega2561__)
00193 #ifndef ADCW
00194 #define ADCW    ADC
00195 #endif
00196 #ifndef ADCSR
00197 #define ADCSR   ADCSRA
00198 #endif
00199 #ifndef ADFR
00200 #define ADFR    ADATE
00201 #endif
00202 #ifndef OCIE0
00203 #define OCIE0   OCIE0A
00204 #endif
00205 #ifndef TCCR0
00206 #define TCCR0   TCCR0A
00207 #endif
00208 #ifndef TCCR2
00209 #define TCCR2   TCCR2A
00210 #endif
00211 #ifndef OCR0
00212 #define OCR0    OCR0A
00213 #endif
00214 #ifndef TIMSK
00215 #define TIMSK   TIMSK0
00216 #endif
00217 #ifndef TIFR
00218 #define TIFR   TIFR0
00219 #endif
00220 #endif /* __AVR_AT90CAN128__ */
00221 
00222 
00223 #endif /* __AVR_ENHANCED__ */
00224 
00225 
00226 #endif /* _ARCH_AVR_H_ */

© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/