avr.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. #ifndef _ARCH_AVR_H_
  2. #define _ARCH_AVR_H_
  3. /*
  4. * Copyright (C) 2001-2005 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY EGNITE SOFTWARE GMBH AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EGNITE
  23. * SOFTWARE GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. */
  34. /*
  35. * $Log: avr.h,v $
  36. * Revision 1.14 2006/02/08 15:20:22 haraldkipp
  37. * ATmega2561 Support
  38. *
  39. * Revision 1.13 2005/10/24 10:42:48 haraldkipp
  40. * Definitions distributed to avr/icc.h and avr/gcc.h.
  41. *
  42. * Revision 1.12 2005/10/04 05:21:52 hwmaier
  43. * Added TIFR definition for AT09CAN128
  44. *
  45. * Revision 1.11 2005/08/02 17:46:48 haraldkipp
  46. * Major API documentation update.
  47. *
  48. * Revision 1.10 2005/02/22 17:03:02 freckle
  49. * changed avr-libc-1.2 test to use eeprom_rb, as other test was wrong on
  50. * 1.0.5
  51. *
  52. * Revision 1.9 2005/02/22 16:22:21 freckle
  53. * Added cpp test to guess avr-libc-version required to specify twi.h path
  54. *
  55. * Revision 1.8 2005/02/10 07:06:48 hwmaier
  56. * Changes to incorporate support for AT90CAN128 CPU
  57. *
  58. * Revision 1.7 2005/01/10 12:40:15 olereinhardt
  59. * Included check if atof is just defined (needed by new avr-libc versions on debian unstable)
  60. *
  61. * Revision 1.6 2004/07/09 19:51:34 freckle
  62. * Added new function NutThreadSetSleepMode to tell nut/os to set the MCU
  63. * into sleep mode when idle (avr-gcc && avr128 only)
  64. *
  65. * Revision 1.5 2004/05/23 14:30:32 drsung
  66. * Added some macros, because they are no longer available since version 1.1.0 of avr-libc.
  67. *
  68. * Revision 1.4 2004/03/18 15:53:42 haraldkipp
  69. * ICCAVR failed to compile
  70. *
  71. * Revision 1.3 2004/03/18 09:57:01 haraldkipp
  72. * Architecture required in UserConf.mk
  73. *
  74. * Revision 1.2 2004/03/17 14:54:00 haraldkipp
  75. * Compiling for AVR works again
  76. *
  77. * Revision 1.1 2004/03/16 16:48:28 haraldkipp
  78. * Added Jan Dubiec's H8/300 port.
  79. *
  80. * Revision 1.1 2004/02/01 18:49:47 haraldkipp
  81. * Added CPU family support
  82. *
  83. */
  84. #if defined(__IMAGECRAFT__)
  85. #include <arch/avr/icc.h>
  86. #elif defined(__GNUC__)
  87. #include <arch/avr/gcc.h>
  88. #else
  89. #error "Unable to determine AVR compiler."
  90. #endif
  91. /*!
  92. * \brief Specify AVR target.
  93. *
  94. * Only GCC provides this as a predefined macro. Nut/OS explicitly
  95. * re-defines this, so that it will be available for all compilers.
  96. */
  97. #undef __AVR__
  98. #define __AVR__
  99. /*
  100. * Since version 1.1.0 of avr-libc, some former deprecated macros are deleted.
  101. * But we need them futher on, so they are defined here.
  102. */
  103. #ifndef cbi
  104. #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit))
  105. #endif
  106. #ifndef sbi
  107. #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit))
  108. #endif
  109. #ifndef inb
  110. #define inb(sfr) _SFR_BYTE(sfr)
  111. #endif
  112. #ifndef outb
  113. #define outb(sfr, val) (_SFR_BYTE(sfr) = (val))
  114. #endif
  115. #ifndef outp
  116. #define outp(val, sfr) outb(sfr, val)
  117. #endif
  118. #ifndef inp
  119. #define inp(sfr) inb(sfr)
  120. #endif
  121. #ifndef BV
  122. #define BV(bit) _BV(bit)
  123. #endif
  124. #ifndef inw
  125. #define inw(sfr) _SFR_WORD(sfr)
  126. #endif
  127. #ifndef outw
  128. #define outw(sfr, val) (_SFR_WORD(sfr) = (val))
  129. #endif
  130. #ifndef PRG_RDB
  131. #define PRG_RDB(addr) pgm_read_byte(addr)
  132. #endif
  133. #define __bss_end __heap_start
  134. extern void *__heap_start;
  135. #ifdef __AVR_ENHANCED__
  136. /* Nut/OS is still using the original ATmega103 register names for
  137. backward compatibility. */
  138. #ifndef UDR
  139. #define UDR UDR0
  140. #endif
  141. #ifndef UBRR
  142. #define UBRR UBRR0L
  143. #endif
  144. #ifndef USR
  145. #define USR UCSR0A
  146. #endif
  147. #ifndef UCR
  148. #define UCR UCSR0B
  149. #endif
  150. #ifndef EICR
  151. #define EICR EICRB
  152. #endif
  153. #ifndef RXC
  154. #define RXC RXC0
  155. #endif
  156. #ifndef UDRE
  157. #define UDRE UDRE0
  158. #endif
  159. #ifndef FE
  160. #define FE FE0
  161. #endif
  162. #ifndef DOR
  163. #define DOR DOR0
  164. #endif
  165. #ifndef RXCIE
  166. #define RXCIE RXCIE0
  167. #endif
  168. #ifndef TXCIE
  169. #define TXCIE TXCIE0
  170. #endif
  171. #ifndef UDRIE
  172. #define UDRIE UDRIE0
  173. #endif
  174. #ifndef RXEN
  175. #define RXEN RXEN0
  176. #endif
  177. #ifndef TXEN
  178. #define TXEN TXEN0
  179. #endif
  180. /* Some ATC90CAN128 SFR names are different to ATMEGA128. Define some
  181. compatibilty macros. */
  182. #if defined(__AVR_AT90CAN128__) || defined(__AVR_ATmega2561__)
  183. #ifndef ADCW
  184. #define ADCW ADC
  185. #endif
  186. #ifndef ADCSR
  187. #define ADCSR ADCSRA
  188. #endif
  189. #ifndef ADFR
  190. #define ADFR ADATE
  191. #endif
  192. #ifndef OCIE0
  193. #define OCIE0 OCIE0A
  194. #endif
  195. #ifndef TCCR0
  196. #define TCCR0 TCCR0A
  197. #endif
  198. #ifndef TCCR2
  199. #define TCCR2 TCCR2A
  200. #endif
  201. #ifndef OCR0
  202. #define OCR0 OCR0A
  203. #endif
  204. #ifndef TIMSK
  205. #define TIMSK TIMSK0
  206. #endif
  207. #ifndef TIFR
  208. #define TIFR TIFR0
  209. #endif
  210. #endif /* __AVR_AT90CAN128__ */
  211. #endif /* __AVR_ENHANCED__ */
  212. #endif /* _ARCH_AVR_H_ */