Update the interrupt signal to new style.
[bertos.git] / bertos / cpu / avr / drv / ser_avr.c
index d6de8243dbb27056be9a71158b2d97090bd97da2..2d25fbeb27dd1176736f9a8a47d2eb23aac3f72a 100644 (file)
  * invalidate any other reasons why the executable file might be covered by
  * the GNU General Public License.
  *
- * Copyright 2003, 2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2003, 2004, 2010 Develer S.r.l. (http://www.develer.com/)
  * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
  *
  * -->
  *
  * \brief AVR UART and SPI I/O driver (Implementation)
  *
- * \version $Id$
- *
  * \author Bernie Innocenti <bernie@codewiz.org>
  * \author Stefano Fedrigo <aleph@develer.com>
+ * \author Luca Ottaviano <lottaviano@develer.com>
  */
 
 #include "hw/hw_ser.h"  /* Required for bus macros overrides */
        #define BIT_RXEN1  RXEN1
        #define BIT_TXEN1  TXEN1
        #define BIT_UDRIE1 UDRIE1
+#elif CPU_AVR_ATMEGA168 || CPU_AVR_ATMEGA328P
+       #define BIT_RXCIE0 RXCIE0
+       #define BIT_RXEN0  RXEN0
+       #define BIT_TXEN0  TXEN0
+       #define BIT_UDRIE0 UDRIE0
+
+       #define BIT_RXCIE1 RXCIE0
+       #define BIT_RXEN1  RXEN0
+       #define BIT_TXEN1  TXEN0
+       #define BIT_UDRIE1 UDRIE0
 #else
        #define BIT_RXCIE0 RXCIE
        #define BIT_RXEN0  RXEN
        #define SPI_SCK_BIT   PB1
        #define SPI_MOSI_BIT  PB2
        #define SPI_MISO_BIT  PB3
-#elif CPU_AVR_ATMEGA8
+// TODO: these bits are the same as ATMEGA8 but the defines in avr-gcc are different.
+// They should be the same!
+#elif CPU_AVR_ATMEGA328P
+       #define SPI_PORT      PORTB
+       #define SPI_DDR       DDRB
+       #define SPI_SS_BIT    PORTB2
+       #define SPI_SCK_BIT   PORTB5
+       #define SPI_MOSI_BIT  PORTB3
+       #define SPI_MISO_BIT  PORTB4
+#elif CPU_AVR_ATMEGA8 || CPU_AVR_ATMEGA168
        #define SPI_PORT      PORTB
        #define SPI_DDR       DDRB
        #define SPI_SS_BIT    PB2
 /* USART register definitions */
 #if CPU_AVR_ATMEGA64 || CPU_AVR_ATMEGA128 || CPU_AVR_ATMEGA1281
        #define AVR_HAS_UART1 1
+#elif CPU_AVR_ATMEGA168 || CPU_AVR_ATMEGA328P
+       #define AVR_HAS_UART1 0
+       #define USART0_UDRE_vect USART_UDRE_vect
+       #define USART0_RX_vect USART_RX_vect
+       #define USART0_TX_vect USART_TX_vect
 #elif CPU_AVR_ATMEGA8
        #define AVR_HAS_UART1 0
        #define UCSR0A UCSRA
        #define UDR0   UDR
        #define UBRR0L UBRRL
        #define UBRR0H UBRRH
-       #define SIG_UART0_DATA SIG_UART_DATA
-       #define SIG_UART0_RECV SIG_UART_RECV
-       #define SIG_UART0_TRANS SIG_UART_TRANS
+       #define USART0_UDRE_vect USART_UDRE_vect
+       #define USART0_RX_vect USART_RX_vect
+       #define USART0_TX_vect USART_TX_vect
 #elif CPU_AVR_ATMEGA103
        #define AVR_HAS_UART1 0
        #define UCSR0B UCR
        #define UDR0   UDR
        #define UCSR0A USR
        #define UBRR0L UBRR
-       #define SIG_UART0_DATA SIG_UART_DATA
-       #define SIG_UART0_RECV SIG_UART_RECV
-       #define SIG_UART0_TRANS SIG_UART_TRANS
+       #define USART0_UDRE_vect USART_UDRE_vect
+       #define USART0_RX_vect USART_RX_vect
+       #define USART0_TX_vect USART_TX_vect
 #else
        #error Unknown architecture
 #endif
@@ -706,7 +729,7 @@ DECLARE_ISR(USART0_UDRE_vect)
  * otherwise we'd stop the serial port with some data
  * still pending in the buffer.
  */
-DECLARE_ISR(SIG_UART0_TRANS)
+DECLARE_ISR(USART0_TX_vect)
 {
        SER_STROBE_ON;
 
@@ -893,7 +916,7 @@ DECLARE_ISR(USART1_RX_vect)
 /**
  * SPI interrupt handler
  */
-DECLARE_ISR(SIG_SPI)
+DECLARE_ISR(SPI_STC_vect)
 {
        SER_STROBE_ON;