Skip to content

Commit e634018

Browse files
Remove unneeded register and ISR names in HardwareSerialx.cpp
Before, HardwareSerial1+.cpp were a copy of HardwareSerial1.cpp with all 0's replaced by the corresponding number. This would mean that e.g. the Serial1 object would use the UBRRL register instead of UBRR1L when it was defined, or the USART_RX_vect instead of USART1_RX_vect. In practice, this would neve actually cause problems, since: - No avr chip currently has both the non-numbered registers as well as numbered registers. - HardwareSerial.h would only define HAVE_HWSERIALx when the corresponding numbered register is defined (except for HAVE_HWSERIAL0, which is also defined when the unnumbered registers are present). Furthermore, before both the UARTx_xx_vect and USART_x_xx_vect was used. Looking at the include files, only UART1_xx_vect is actually used (by iom161.h), the others use USARTx_xx_vect. For this reason, HardwareSerial1.cpp keeps the preprocessor conditional to select either UART or USART and the other files use USART unconditionally. While we're here, also fix the compiler error message when no valid ISR name was found (it previously said "for the first UART" in all cases).
1 parent 7467fa0 commit e634018

File tree

4 files changed

+21
-75
lines changed

4 files changed

+21
-75
lines changed

avr/cores/arduino/HardwareSerial0.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
#elif defined(USART_RXC_vect)
4444
ISR(USART_RXC_vect) // ATmega8
4545
#else
46-
#error "Don't know what the Data Received vector is called for the first UART"
46+
#error "Don't know what the Data Received vector is called for Serial"
4747
#endif
4848
{
4949
Serial._rx_complete_irq();
@@ -58,7 +58,7 @@ ISR(USART0_UDRE_vect)
5858
#elif defined(USART_UDRE_vect)
5959
ISR(USART_UDRE_vect)
6060
#else
61-
#error "Don't know what the Data Register Empty vector is called for the first UART"
61+
#error "Don't know what the Data Register Empty vector is called for Serial"
6262
#endif
6363
{
6464
Serial._tx_udr_empty_irq();

avr/cores/arduino/HardwareSerial1.cpp

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,29 @@
3636

3737
#if defined(HAVE_HWSERIAL1)
3838

39-
#if defined(USART_RX_vect)
40-
ISR(USART_RX_vect)
39+
#if defined(UART1_RX_vect)
40+
ISR(UART1_RX_vect)
4141
#elif defined(USART1_RX_vect)
42-
ISR(USART1_RX_vect)
43-
#elif defined(USART_RXC_vect)
44-
ISR(USART_RXC_vect) // ATmega8
42+
ISR(USART1_RX_vect)
4543
#else
46-
#error "Don't know what the Data Received vector is called for the first UART"
44+
#error "Don't know what the Data Register Empty vector is called for Serial1"
4745
#endif
48-
{
49-
Serial1._rx_complete_irq();
50-
}
46+
{
47+
Serial1._rx_complete_irq();
48+
}
5149

5250
#if defined(UART1_UDRE_vect)
5351
ISR(UART1_UDRE_vect)
54-
#elif defined(UART_UDRE_vect)
55-
ISR(UART_UDRE_vect)
5652
#elif defined(USART1_UDRE_vect)
5753
ISR(USART1_UDRE_vect)
58-
#elif defined(USART_UDRE_vect)
59-
ISR(USART_UDRE_vect)
6054
#else
61-
#error "Don't know what the Data Register Empty vector is called for the first UART"
55+
#error "Don't know what the Data Register Empty vector is called for Serial1"
6256
#endif
6357
{
6458
Serial1._tx_udr_empty_irq();
6559
}
6660

67-
#if defined(UBRRH) && defined(UBRRL)
68-
HardwareSerial Serial1(&UBRRH, &UBRRL, &UCSRA, &UCSRB, &UCSRC, &UDR);
69-
#else
70-
HardwareSerial Serial1(&UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UCSR1C, &UDR1);
71-
#endif
61+
HardwareSerial Serial1(&UBRR1H, &UBRR1L, &UCSR1A, &UCSR1B, &UCSR1C, &UDR1);
7262

7363
// Function that can be weakly referenced by serialEventRun to prevent
7464
// pulling in this file if it's not otherwise used.

avr/cores/arduino/HardwareSerial2.cpp

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,17 @@
3636

3737
#if defined(HAVE_HWSERIAL2)
3838

39-
#if defined(USART_RX_vect)
40-
ISR(USART_RX_vect)
41-
#elif defined(USART2_RX_vect)
42-
ISR(USART2_RX_vect)
43-
#elif defined(USART_RXC_vect)
44-
ISR(USART_RXC_vect) // ATmega8
45-
#else
46-
#error "Don't know what the Data Received vector is called for the first UART"
47-
#endif
48-
{
49-
Serial2._rx_complete_irq();
50-
}
39+
ISR(USART2_RX_vect)
40+
{
41+
Serial2._rx_complete_irq();
42+
}
5143

52-
#if defined(UART2_UDRE_vect)
53-
ISR(UART2_UDRE_vect)
54-
#elif defined(UART_UDRE_vect)
55-
ISR(UART_UDRE_vect)
56-
#elif defined(USART2_UDRE_vect)
5744
ISR(USART2_UDRE_vect)
58-
#elif defined(USART_UDRE_vect)
59-
ISR(USART_UDRE_vect)
60-
#else
61-
#error "Don't know what the Data Register Empty vector is called for the first UART"
62-
#endif
6345
{
6446
Serial2._tx_udr_empty_irq();
6547
}
6648

67-
#if defined(UBRRH) && defined(UBRRL)
68-
HardwareSerial Serial2(&UBRRH, &UBRRL, &UCSRA, &UCSRB, &UCSRC, &UDR);
69-
#else
70-
HardwareSerial Serial2(&UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UCSR2C, &UDR2);
71-
#endif
49+
HardwareSerial Serial2(&UBRR2H, &UBRR2L, &UCSR2A, &UCSR2B, &UCSR2C, &UDR2);
7250

7351
// Function that can be weakly referenced by serialEventRun to prevent
7452
// pulling in this file if it's not otherwise used.

avr/cores/arduino/HardwareSerial3.cpp

Lines changed: 5 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,17 @@
3636

3737
#if defined(HAVE_HWSERIAL3)
3838

39-
#if defined(USART_RX_vect)
40-
ISR(USART_RX_vect)
41-
#elif defined(USART3_RX_vect)
42-
ISR(USART3_RX_vect)
43-
#elif defined(USART_RXC_vect)
44-
ISR(USART_RXC_vect) // ATmega8
45-
#else
46-
#error "Don't know what the Data Received vector is called for the first UART"
47-
#endif
48-
{
49-
Serial3._rx_complete_irq();
50-
}
39+
ISR(USART3_RX_vect)
40+
{
41+
Serial3._rx_complete_irq();
42+
}
5143

52-
#if defined(UART3_UDRE_vect)
53-
ISR(UART3_UDRE_vect)
54-
#elif defined(UART_UDRE_vect)
55-
ISR(UART_UDRE_vect)
56-
#elif defined(USART3_UDRE_vect)
5744
ISR(USART3_UDRE_vect)
58-
#elif defined(USART_UDRE_vect)
59-
ISR(USART_UDRE_vect)
60-
#else
61-
#error "Don't know what the Data Register Empty vector is called for the first UART"
62-
#endif
6345
{
6446
Serial3._tx_udr_empty_irq();
6547
}
6648

67-
#if defined(UBRRH) && defined(UBRRL)
68-
HardwareSerial Serial3(&UBRRH, &UBRRL, &UCSRA, &UCSRB, &UCSRC, &UDR);
69-
#else
70-
HardwareSerial Serial3(&UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UCSR3C, &UDR3);
71-
#endif
49+
HardwareSerial Serial3(&UBRR3H, &UBRR3L, &UCSR3A, &UCSR3B, &UCSR3C, &UDR3);
7250

7351
// Function that can be weakly referenced by serialEventRun to prevent
7452
// pulling in this file if it's not otherwise used.

0 commit comments

Comments
 (0)