Skip to content

Commit 9248b43

Browse files
committed
Refactoring the UART0 / USART0 receive interrupt handler.
1 parent 245730e commit 9248b43

File tree

1 file changed

+11
-40
lines changed

1 file changed

+11
-40
lines changed

hardware/arduino/cores/arduino/HardwareSerial.cpp

Lines changed: 11 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -81,61 +81,32 @@ inline void store_char(unsigned char c, ring_buffer *buffer)
8181
}
8282
}
8383

84+
#if !defined(USART_RX_vect) && !defined(SIG_USART0_RECV) && \
85+
!defined(SIG_UART0_RECV) && !defined(USART0_RX_vect) && \
86+
!defined(SIG_UART_RECV)
87+
#error Don't know what the Data Received vector is called for the first UART
88+
#else
8489
#if defined(USART_RX_vect)
8590
SIGNAL(USART_RX_vect)
86-
{
87-
#if defined(UDR0)
88-
unsigned char c = UDR0;
89-
#elif defined(UDR)
90-
unsigned char c = UDR; // atmega8535
91-
#else
92-
#error UDR not defined
93-
#endif
94-
store_char(c, &rx_buffer);
95-
}
96-
#elif defined(SIG_USART0_RECV) && defined(UDR0)
91+
#elif defined(SIG_USART0_RECV)
9792
SIGNAL(SIG_USART0_RECV)
98-
{
99-
unsigned char c = UDR0;
100-
store_char(c, &rx_buffer);
101-
}
102-
#elif defined(SIG_UART0_RECV) && defined(UDR0)
93+
#elif defined(SIG_UART0_RECV)
10394
SIGNAL(SIG_UART0_RECV)
104-
{
105-
unsigned char c = UDR0;
106-
store_char(c, &rx_buffer);
107-
}
108-
//#elif defined(SIG_USART_RECV)
10995
#elif defined(USART0_RX_vect)
110-
// fixed by Mark Sproul this is on the 644/644p
111-
//SIGNAL(SIG_USART_RECV)
11296
SIGNAL(USART0_RX_vect)
97+
#elif defined(SIG_UART_RECV)
98+
SIGNAL(SIG_UART_RECV)
99+
#endif
113100
{
114101
#if defined(UDR0)
115102
unsigned char c = UDR0;
116103
#elif defined(UDR)
117-
unsigned char c = UDR; // atmega8, atmega32
104+
unsigned char c = UDR;
118105
#else
119106
#error UDR not defined
120107
#endif
121108
store_char(c, &rx_buffer);
122109
}
123-
#elif defined(SIG_UART_RECV)
124-
// this is for atmega8
125-
SIGNAL(SIG_UART_RECV)
126-
{
127-
#if defined(UDR0)
128-
unsigned char c = UDR0; // atmega645
129-
#elif defined(UDR)
130-
unsigned char c = UDR; // atmega8
131-
#endif
132-
store_char(c, &rx_buffer);
133-
}
134-
#elif defined(USBCON)
135-
#warning No interrupt handler for usart 0
136-
#warning Serial(0) is on USB interface
137-
#else
138-
#error No interrupt handler for usart 0
139110
#endif
140111

141112
//#if defined(SIG_USART1_RECV)

0 commit comments

Comments
 (0)