diff options
Diffstat (limited to 'cores/arduino/HardwareSerial.cpp')
-rw-r--r-- | cores/arduino/HardwareSerial.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index d6be218..48f5fd3 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -50,6 +50,10 @@ struct ring_buffer volatile int tail; }; +#if defined(USBCON) + ring_buffer rx_buffer = { { 0 }, 0, 0}; + ring_buffer tx_buffer = { { 0 }, 0, 0}; +#endif #if defined(UBRRH) || defined(UBRR0H) ring_buffer rx_buffer = { { 0 }, 0, 0 }; ring_buffer tx_buffer = { { 0 }, 0, 0 }; @@ -81,6 +85,9 @@ inline void store_char(unsigned char c, ring_buffer *buffer) } } +#if !defined(USART0_RX_vect) && defined(USART1_RX_vect) +// do nothing - on the 32u4 the first USART is USART1 +#else #if !defined(USART_RX_vect) && !defined(SIG_USART0_RECV) && \ !defined(SIG_UART0_RECV) && !defined(USART0_RX_vect) && \ !defined(SIG_UART_RECV) @@ -111,6 +118,7 @@ inline void store_char(unsigned char c, ring_buffer *buffer) serialEvent(); } #endif +#endif #if defined(USART1_RX_vect) void serialEvent1() __attribute__((weak)); @@ -151,7 +159,9 @@ inline void store_char(unsigned char c, ring_buffer *buffer) #error SIG_USART3_RECV #endif - +#if !defined(USART0_UDRE_vect) && defined(USART1_UDRE_vect) +// do nothing - on the 32u4 the first USART is USART1 +#else #if !defined(UART0_UDRE_vect) && !defined(UART_UDRE_vect) && !defined(USART0_UDRE_vect) && !defined(USART_UDRE_vect) #error Don't know what the Data Register Empty vector is called for the first UART #else @@ -188,6 +198,7 @@ ISR(USART_UDRE_vect) } } #endif +#endif #ifdef USART1_UDRE_vect ISR(USART1_UDRE_vect) @@ -377,7 +388,7 @@ size_t HardwareSerial::write(uint8_t c) #elif defined(UBRR0H) && defined(UBRR0L) HardwareSerial Serial(&rx_buffer, &tx_buffer, &UBRR0H, &UBRR0L, &UCSR0A, &UCSR0B, &UDR0, RXEN0, TXEN0, RXCIE0, UDRIE0, U2X0); #elif defined(USBCON) - #warning no serial port defined (port 0) + // do nothing - Serial object and buffers are initialized in CDC code #else #error no serial port defined (port 0) #endif |