gcc.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. #ifndef _ARCH_AVR_GCC_H_
  2. #define _ARCH_AVR_GCC_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: gcc.h,v $
  36. * Revision 1.3 2007/04/12 09:20:34 haraldkipp
  37. * Added new register bit names for the ATmega2561.
  38. *
  39. * Revision 1.2 2006/01/11 08:32:21 hwmaier
  40. * Support for avr-libc >= 1.4.x
  41. *
  42. * Revision 1.1 2005/10/24 10:46:05 haraldkipp
  43. * First check in.
  44. * Contents taken from avr.h in the parent directory.
  45. *
  46. */
  47. /* ================================================================ */
  48. /* To be sorted out. */
  49. /* ================================================================ */
  50. #define CONST const
  51. #define INLINE inline
  52. #include <avr/io.h>
  53. #include <avr/interrupt.h>
  54. #if __AVR_LIBC_VERSION__ < 10400UL
  55. #include <avr/signal.h>
  56. #endif
  57. #include <avr/eeprom.h>
  58. #include <avr/pgmspace.h>
  59. #include <avr/sleep.h>
  60. #include <stdlib.h>
  61. /*
  62. * test for a macro added in avr-libc 1.2.0, if yes use different path for twi.h
  63. * note: has to be after #include <eeprom.h>
  64. */
  65. #ifdef eeprom_rb
  66. #include <avr/twi.h>
  67. #else
  68. #include <compat/twi.h>
  69. #endif
  70. #if defined(__AVR_ATmega2561__)
  71. #if !defined(TXC)
  72. #define TXC TXC0
  73. #endif
  74. #if !defined(TXB8)
  75. #define TXB8 TXB80
  76. #endif
  77. #if !defined(UMSEL)
  78. #define UMSEL UMSEL00
  79. #endif
  80. #if !defined(U2X)
  81. #define U2X U2X0
  82. #endif
  83. #if !defined(UCSZ0)
  84. #define UCSZ0 UCSZ00
  85. #endif
  86. #if !defined(UCSZ1)
  87. #define UCSZ1 UCSZ01
  88. #endif
  89. #if !defined(UCSZ2)
  90. #define UCSZ2 UCSZ02
  91. #endif
  92. #if !defined(UPM0)
  93. #define UPM0 UPM00
  94. #endif
  95. #if !defined(UPM1)
  96. #define UPM1 UPM01
  97. #endif
  98. #if !defined(USBS)
  99. #define USBS USBS0
  100. #endif
  101. #if !defined(UPE)
  102. #define UPE UPE0
  103. #endif
  104. #if !defined(MPCM)
  105. #define MPCM MPCM0
  106. #endif
  107. #if !defined(UCPOL)
  108. #define UCPOL UCPOL0
  109. #endif
  110. #endif
  111. #ifndef __SFR_OFFSET
  112. #define __SFR_OFFSET 0
  113. #endif
  114. #define COMPRESS_DISABLE
  115. #define COMPRESS_REENABLE
  116. #ifndef _NOP
  117. #define _NOP() __asm__ __volatile__ ("nop")
  118. #endif
  119. #ifndef atof
  120. #define atof(s) strtod(s, 0)
  121. #endif
  122. #define EEPROMReadBytes(addr, ptr, size) eeprom_read_block((char *)(addr), ptr, size)
  123. /*!
  124. * \brief Read multibyte types from the EEPROM.
  125. */
  126. #define EEPROM_READ(addr, dst) eeprom_read_block((char *)(addr), &dst, sizeof(dst))
  127. #define EEPROMread(addr) eeprom_read_byte((char *)(addr))
  128. /*!
  129. * \brief Write multibyte types to the EEPROM.
  130. */
  131. #define EEPROM_WRITE(addr, src) \
  132. { \
  133. unsigned short __i; \
  134. for(__i = 0; __i < sizeof(src); __i++) \
  135. eeprom_write_byte(((char *)(addr)) + __i, *(((char *)(&(src))) + __i)); \
  136. }
  137. #define EEPROMWriteBytes(addr, ptr, size) \
  138. { \
  139. unsigned short __i; \
  140. for(__i = 0; __i < size; __i++) \
  141. eeprom_write_byte(((char *)(addr)) + __i, *(((char *)(ptr)) + __i)); \
  142. }
  143. #define main NutAppMain
  144. #endif /* _ARCH_AVR_GCC_H_ */