From: Olivier Matz Date: Tue, 6 Aug 2013 19:56:19 +0000 (+0200) Subject: uart: fix compilation on atmega328p X-Git-Url: http://git.droids-corp.org/?p=aversive.git;a=commitdiff_plain;h=172a3ee956f1be2cacf7db0e1a5051daadd70d3c uart: fix compilation on atmega328p --- diff --git a/modules/comm/uart/uart.c b/modules/comm/uart/uart.c index 25aa9e8..231d599 100644 --- a/modules/comm/uart/uart.c +++ b/modules/comm/uart/uart.c @@ -85,8 +85,14 @@ const struct regs uart_regs[UART_HW_NUM] = { */ #ifdef UART0_COMPILE #ifndef SIG_UART0_DATA +#if defined(USART_UDRE_vect) +#define SIG_UART0_DATA USART_UDRE_vect +#elif defined(USART0_UDRE_vect) +#define SIG_UART0_DATA USART0_UDRE_vect +#elif defined(SIG_USART0_DATA) #define SIG_UART0_DATA SIG_USART0_DATA #endif +#endif SIGNAL(SIG_UART0_DATA) { uart_send_next_char(0); @@ -94,8 +100,12 @@ SIGNAL(SIG_UART0_DATA) #endif #ifdef UART1_COMPILE #ifndef SIG_UART1_DATA +#if defined(USART1_UDRE_vect) +#define SIG_UART1_DATA USART1_UDRE_vect +#elif defined(SIG_USART1_DATA) #define SIG_UART1_DATA SIG_USART1_DATA #endif +#endif SIGNAL(SIG_UART1_DATA) { uart_send_next_char(1); @@ -103,8 +113,12 @@ SIGNAL(SIG_UART1_DATA) #endif #ifdef UART2_COMPILE #ifndef SIG_UART2_DATA +#if defined(USART2_UDRE_vect) +#define SIG_UART2_DATA USART2_UDRE_vect +#elif defined(SIG_USART2_DATA) #define SIG_UART2_DATA SIG_USART2_DATA #endif +#endif SIGNAL(SIG_UART2_DATA) { uart_send_next_char(2); @@ -112,8 +126,12 @@ SIGNAL(SIG_UART2_DATA) #endif #ifdef UART3_COMPILE #ifndef SIG_UART3_DATA +#if defined(USART3_UDRE_vect) +#define SIG_UART3_DATA USART3_UDRE_vect +#elif defined(SIG_USART3_DATA) #define SIG_UART3_DATA SIG_USART3_DATA #endif +#endif SIGNAL(SIG_UART3_DATA) { uart_send_next_char(3); @@ -128,8 +146,14 @@ static void uart_recv_next_char(uint8_t num); */ #ifdef UART0_COMPILE #ifndef SIG_UART0_RECV +#if defined(USART_RX_vect) +#define SIG_UART0_RECV USART_RX_vect +#elif defined(USART0_RX_vect) +#define SIG_UART0_RECV USART0_RX_vect +#elif defined(SIG_USART0_RECV) #define SIG_UART0_RECV SIG_USART0_RECV #endif +#endif SIGNAL(SIG_UART0_RECV) { uart_recv_next_char(0); @@ -137,8 +161,12 @@ SIGNAL(SIG_UART0_RECV) #endif #ifdef UART1_COMPILE #ifndef SIG_UART1_RECV +#if defined(USART1_RX_vect) +#define SIG_UART1_RECV USART1_RX_vect +#elif defined(SIG_USART1_RECV) #define SIG_UART1_RECV SIG_USART1_RECV #endif +#endif SIGNAL(SIG_UART1_RECV) { uart_recv_next_char(1); @@ -146,8 +174,12 @@ SIGNAL(SIG_UART1_RECV) #endif #ifdef UART2_COMPILE #ifndef SIG_UART2_RECV +#if defined(USART2_RX_vect) +#define SIG_UART2_RECV USART2_RX_vect +#elif defined(SIG_USART2_RECV) #define SIG_UART2_RECV SIG_USART2_RECV #endif +#endif SIGNAL(SIG_UART2_RECV) { uart_recv_next_char(2); @@ -155,8 +187,12 @@ SIGNAL(SIG_UART2_RECV) #endif #ifdef UART3_COMPILE #ifndef SIG_UART3_RECV +#if defined(USART3_RX_vect) +#define SIG_UART3_RECV USART3_RX_vect +#elif defined(SIG_USART3_RECV) #define SIG_UART3_RECV SIG_USART3_RECV #endif +#endif SIGNAL(SIG_UART3_RECV) { uart_recv_next_char(3); diff --git a/modules/comm/uart/uart_defs.h b/modules/comm/uart/uart_defs.h index 7d872a1..e8d6171 100644 --- a/modules/comm/uart/uart_defs.h +++ b/modules/comm/uart/uart_defs.h @@ -61,7 +61,7 @@ #endif #endif -#ifndef UDR0 +#if !defined(UDR0) && defined(UDR) #define UDR0 UDR #endif #ifndef UCSR0A @@ -79,54 +79,105 @@ #ifndef UBRR0H #define UBRR0H UBRRH #endif -#ifndef U2X +#if !defined(U2X) && defined(U2X0) #define U2X U2X0 #endif -#ifndef UCSZ0 +#if !defined(UCSZ0) && defined(UCSZ00) #define UCSZ0 UCSZ00 #endif -#ifndef UCSZ1 +#if !defined(UCSZ1) && defined(UCSZ01) #define UCSZ1 UCSZ01 #endif -#ifndef UCSZ2 +#if !defined(UCSZ2) && defined(UCSZ02) #define UCSZ2 UCSZ02 #endif -#ifndef UPM0 +#if !defined(UPM0) && defined(UPM00) #define UPM0 UPM00 #endif -#ifndef UPM1 +#if !defined(UPM1) && defined(UPM01) #define UPM1 UPM01 #endif -#ifndef USBS +#if !defined(USBS) && defined(USBS0) #define USBS USBS0 #endif -#ifndef TXEN +#if !defined(TXEN) && defined(TXEN0) #define TXEN TXEN0 #endif -#ifndef TXCIE +#if !defined(TXCIE) && defined(TXCIE0) #define TXCIE TXCIE0 #endif -#ifndef RXEN +#if !defined(RXEN) && defined(RXEN0) #define RXEN RXEN0 #endif -#ifndef RXCIE +#if !defined(RXCIE) && defined(RXCIE0) #define RXCIE RXCIE0 #endif -#ifndef TXC +#if !defined(TXC) && defined(TXC0) #define TXC TXC0 #endif -#ifndef RXC +#if !defined(RXC) && defined(RXC0) #define RXC RXC0 #endif -#ifndef RXB8 +#if !defined(RXB8) && defined(RXB80) #define RXB8 RXB80 #endif -#ifndef UDRIE +#if !defined(UDRIE) && defined(UDRIE0) #define UDRIE UDRIE0 #endif -#ifndef UDRE +#if !defined(UDRE) && defined(UDRE0) #define UDRE UDRE0 #endif +#if !defined(U2X) && defined(U2X1) +#define U2X U2X1 +#endif +#if !defined(UCSZ1) && defined(UCSZ10) +#define UCSZ0 UCSZ10 +#endif +#if !defined(UCSZ1) && defined(UCSZ11) +#define UCSZ1 UCSZ11 +#endif +#if !defined(UCSZ2) && defined(UCSZ12) +#define UCSZ2 UCSZ12 +#endif +#if !defined(UPM1) && defined(UPM10) +#define UPM0 UPM10 +#endif +#if !defined(UPM1) && defined(UPM11) +#define UPM1 UPM11 +#endif +#if !defined(USBS) && defined(USBS1) +#define USBS USBS1 +#endif +#if !defined(TXEN) && defined(TXEN1) +#define TXEN TXEN1 +#endif +#if !defined(TXCIE) && defined(TXCIE1) +#define TXCIE TXCIE1 +#endif +#if !defined(RXEN) && defined(RXEN1) +#define RXEN RXEN1 +#endif +#if !defined(RXCIE) && defined(RXCIE1) +#define RXCIE RXCIE1 +#endif +#if !defined(TXC) && defined(TXC1) +#define TXC TXC1 +#endif +#if !defined(RXC) && defined(RXC1) +#define RXC RXC1 +#endif +#if !defined(RXB8) && defined(RXB81) +#define RXB8 RXB81 +#endif +#if !defined(UDRIE) && defined(UDRIE1) +#define UDRIE UDRIE1 +#endif +#if !defined(UDRIE) && defined(UDRIE1) +#define UDRIE UDRIE1 +#endif +#if !defined(UDRE) && defined(UDRE1) +#define UDRE UDRE1 +#endif /* makes functions more generic, we associate USR and UCR with UCSRA * and UCSRB, respectively */ @@ -163,10 +214,12 @@ /* if the signal USART is defined, the uC has a USART. */ -#if ( defined SIG_USART0_RECV ) || ( defined SIG_USART_RECV ) +#if ( defined SIG_USART0_RECV ) || ( defined SIG_USART_RECV ) #define UART_IS_USART 1 #elif (defined USART_UDRE_vect) || (defined USART_TXC_vect) || (defined USART_RXC_vect) #define UART_IS_USART 1 +#elif (defined USART1_UDRE_vect) || (defined USART1_TXC_vect) || (defined USART1_RXC_vect) +#define UART_IS_USART 1 #else #define UART_IS_USART 0 #endif diff --git a/modules/comm/uart/uart_dev_io.c b/modules/comm/uart/uart_dev_io.c index 8ffb89e..51d0ed1 100644 --- a/modules/comm/uart/uart_dev_io.c +++ b/modules/comm/uart/uart_dev_io.c @@ -1,6 +1,6 @@ -/* +/* * Copyright Droids Corporation, Microb Technology, Eirbot (2005) - * + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or @@ -44,7 +44,7 @@ int uart0_dev_recv_nowait(__attribute__((unused)) FILE *f) int uart0_dev_recv(__attribute__((unused)) FILE *f) { return uart_recv(0); -} +} #endif #ifdef UART1_COMPILE @@ -66,7 +66,7 @@ int uart1_dev_recv_nowait(__attribute__((unused)) FILE *f) int uart1_dev_recv(__attribute__((unused)) FILE *f) { return uart_recv(1); -} +} #endif #ifdef UART2_COMPILE @@ -88,7 +88,7 @@ int uart2_dev_recv_nowait(__attribute__((unused)) FILE *f) int uart2_dev_recv(__attribute__((unused)) FILE *f) { return uart_recv(2); -} +} #endif #ifdef UART3_COMPILE @@ -110,5 +110,5 @@ int uart3_dev_recv_nowait(__attribute__((unused)) FILE *f) int uart3_dev_recv(__attribute__((unused)) FILE *f) { return uart_recv(3); -} +} #endif