avrcompat.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /* sd2iec - SD/MMC to Commodore serial bus interface/controller
  2. Copyright (C) 2007-2009 Ingo Korb <ingo@akana.de>
  3. Inspiration and low-level SD/MMC access based on code from MMC2IEC
  4. by Lars Pontoppidan et al., see sdcard.c|h and config.h.
  5. FAT filesystem access based on code from ChaN and Jim Brain, see ff.c|h.
  6. This program is free software; you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation; version 2 of the License only.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. avrcompat.h: Compatibility defines for multiple target chips
  17. */
  18. #ifndef AVRCOMPAT_H
  19. #define AVRCOMPAT_H
  20. /* USART */
  21. #if defined __AVR_ATmega644__ || defined __AVR_ATmega644P__ || defined __AVR_ATmega1281__ || defined __AVR_ATmega2561__
  22. # ifdef USE_UART1
  23. # define RXC RXC1
  24. # define RXEN RXEN1
  25. # define TXC TXC1
  26. # define TXEN TXEN1
  27. # define UBRRH UBRR1H
  28. # define UBRRL UBRR1L
  29. # define UCSRA UCSR1A
  30. # define UCSRB UCSR1B
  31. # define UCSRC UCSR1C
  32. # define UCSZ0 UCSZ10
  33. # define UCSZ1 UCSZ11
  34. # define UDR UDR1
  35. # define UDRIE UDRIE1
  36. # define RXCIE RXCIE1
  37. # define USART_UDRE_vect USART1_UDRE_vect
  38. # define USART_RX_vect USART1_RX_vect
  39. # else
  40. /* Default is USART0 */
  41. # define RXC RXC0
  42. # define RXEN RXEN0
  43. # define TXC TXC0
  44. # define TXEN TXEN0
  45. # define UBRRH UBRR0H
  46. # define UBRRL UBRR0L
  47. # define UCSRA UCSR0A
  48. # define UCSRB UCSR0B
  49. # define UCSRC UCSR0C
  50. # define UCSZ0 UCSZ00
  51. # define UCSZ1 UCSZ01
  52. # define UDR UDR0
  53. # define UDRIE UDRIE0
  54. # define RXCIE RXCIE0
  55. # define USART_UDRE_vect USART0_UDRE_vect
  56. # define USART_RX_vect USART0_RX_vect
  57. # endif
  58. #elif defined __AVR_ATmega48__ || defined __AVR_ATmega88__ || defined __AVR_ATmega168__
  59. /* These chips include the USART number in their register names, */
  60. /* but not in the ISR name. */
  61. # define RXC RXC0
  62. # define RXEN RXEN0
  63. # define TXC TXC0
  64. # define TXEN TXEN0
  65. # define UBRRH UBRR0H
  66. # define UBRRL UBRR0L
  67. # define UCSRA UCSR0A
  68. # define UCSRB UCSR0B
  69. # define UCSRC UCSR0C
  70. # define UCSZ0 UCSZ00
  71. # define UCSZ1 UCSZ01
  72. # define UDR UDR0
  73. # define UDRIE UDRIE0
  74. #elif defined __AVR_ATmega32__
  75. # define TIMER2_COMPA_vect TIMER2_COMP_vect
  76. # define TCCR0B TCCR0
  77. # define TCCR2A TCCR2
  78. # define TCCR2B TCCR2
  79. # define TIFR0 TIFR
  80. # define TIMSK2 TIMSK
  81. # define OCIE2A OCIE2
  82. # define OCR2A OCR2
  83. #elif defined __AVR_ATmega128__
  84. # define UBRRH UBRR0H
  85. # define UBRRL UBRR0L
  86. # define UCSRA UCSR0A
  87. # define UCSRB UCSR0B
  88. # define UCSRC UCSR0C
  89. # define UDR UDR0
  90. # define USART_UDRE_vect USART0_UDRE_vect
  91. # define TIMER2_COMPA_vect TIMER2_COMP_vect
  92. # define TCCR0B TCCR0
  93. # define TCCR2A TCCR2
  94. # define TCCR2B TCCR2
  95. # define TIFR0 TIFR
  96. # define TIMSK1 TIMSK
  97. # define TIMSK2 TIMSK
  98. # define OCIE2A OCIE2
  99. # define OCR2A OCR2
  100. #else
  101. # error Unknown chip! (USART)
  102. #endif
  103. /* SPI and I2C */
  104. #if defined __AVR_ATmega32__ || defined __AVR_ATmega644__ || defined __AVR_ATmega644P__
  105. # define SPI_PORT PORTB
  106. # define SPI_DDR DDRB
  107. # define SPI_SS _BV(PB4)
  108. # define SPI_MOSI _BV(PB5)
  109. # define SPI_MISO _BV(PB6)
  110. # define SPI_SCK _BV(PB7)
  111. # define HWI2C_PORT PORTC
  112. # define HWI2C_SDA _BV(PC1)
  113. # define HWI2C_SCL _BV(PC0)
  114. #elif defined __AVR_ATmega128__ || defined __AVR_ATmega1281__ || defined __AVR_ATmega2561__
  115. # define SPI_PORT PORTB
  116. # define SPI_DDR DDRB
  117. # define SPI_SS _BV(PB0)
  118. # define SPI_SCK _BV(PB1)
  119. # define SPI_MOSI _BV(PB2)
  120. # define SPI_MISO _BV(PB3)
  121. # define HWI2C_PORT PORTD
  122. # define HWI2C_SDA _BV(PD1)
  123. # define HWI2C_SCL _BV(PD0)
  124. #elif defined __AVR_ATmega48__ || defined __AVR_ATmega88__ || defined __AVR_ATmega168__
  125. # define SPI_PORT PORTB
  126. # define SPI_DDR DDRB
  127. # define SPI_SS _BV(PB2)
  128. # define SPI_SCK _BV(PB5)
  129. # define SPI_MOSI _BV(PB3)
  130. # define SPI_MISO _BV(PB4)
  131. # define HWI2C_PORT PORTC
  132. # define HWI2C_SDA _BV(PC4)
  133. # define HWI2C_SCL _BV(PC5)
  134. #else
  135. # error Unknown chip! (SPI/TWI)
  136. #endif
  137. #define SPI_MASK (SPI_SS|SPI_MOSI|SPI_MISO|SPI_SCK)
  138. #endif /* AVRCOMPAT_H */