aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino/HardwareSerial.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'cores/arduino/HardwareSerial.cpp')
-rw-r--r--cores/arduino/HardwareSerial.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp
index 49a3796..b5992ad 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)
store_char(c, &rx_buffer);
}
#endif
+#endif
#if defined(USART1_RX_vect)
void serialEvent1() __attribute__((weak));
@@ -168,6 +176,9 @@ void serialEventRun(void)
}
+#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
@@ -204,6 +215,7 @@ ISR(USART_UDRE_vect)
}
}
#endif
+#endif
#ifdef USART1_UDRE_vect
ISR(USART1_UDRE_vect)
@@ -393,7 +405,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