summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--n/avr/rs232/avrconfig.h2
-rw-r--r--n/avr/rs232/rs232.c27
2 files changed, 21 insertions, 8 deletions
diff --git a/n/avr/rs232/avrconfig.h b/n/avr/rs232/avrconfig.h
index 00a0d2b..da0a805 100644
--- a/n/avr/rs232/avrconfig.h
+++ b/n/avr/rs232/avrconfig.h
@@ -49,5 +49,7 @@
#define AC_RS232_SEND_BUFFER_SIZE 32
/** Recv buffer size, should be power of 2 for RING mode. */
#define AC_RS232_RECV_BUFFER_SIZE 32
+/** Select serial port (0 or 1). */
+#define AC_RS232_PORT 0
#endif /* avrconfig_h */
diff --git a/n/avr/rs232/rs232.c b/n/avr/rs232/rs232.c
index bf1c83b..5510e45 100644
--- a/n/avr/rs232/rs232.c
+++ b/n/avr/rs232/rs232.c
@@ -37,14 +37,25 @@
/* UART number. */
#if !defined (UBRRH)
# if defined (UBRR0H)
-# define UBRRH UBRR0H
-# define UBRRL UBRR0L
-# define UCSRA UCSR0A
-# define UCSRB UCSR0B
-# define UCSRC UCSR0C
-# define UDR UDR0
-# define SIG_UART_RECV SIG_UART0_RECV
-# define SIG_UART_DATA SIG_UART0_DATA
+# if AC_RS232_PORT == 1
+# define UBRRH UBRR1H
+# define UBRRL UBRR1L
+# define UCSRA UCSR1A
+# define UCSRB UCSR1B
+# define UCSRC UCSR1C
+# define UDR UDR1
+# define SIG_UART_RECV SIG_UART1_RECV
+# define SIG_UART_DATA SIG_UART1_DATA
+# else
+# define UBRRH UBRR0H
+# define UBRRL UBRR0L
+# define UCSRA UCSR0A
+# define UCSRB UCSR0B
+# define UCSRC UCSR0C
+# define UDR UDR0
+# define SIG_UART_RECV SIG_UART0_RECV
+# define SIG_UART_DATA SIG_UART0_DATA
+# endif
# define PE UPE
# else
# error "rs232: canot find UBRR."