diff options
author | Zach Eveland <zeveland@blacklabel-development.com> | 2011-08-18 19:40:04 -0400 |
---|---|---|
committer | Zach Eveland <zeveland@blacklabel-development.com> | 2011-08-18 19:40:04 -0400 |
commit | 7d575222afc358c004f6b94a28e9b136a2b92168 (patch) | |
tree | 91513d1ccb736215f307a8a20062ef96f7de51e1 /cores | |
parent | 84c0d2cff8bc92caa2e72b050781de122376fe72 (diff) |
HW Serial on pins 0 and 1 works. Accessed by Serial1.* methods
Diffstat (limited to 'cores')
-rw-r--r-- | cores/arduino/HardwareSerial.cpp | 28 |
1 files changed, 7 insertions, 21 deletions
diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index ee77b45..77ccd06 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -85,14 +85,8 @@ inline void store_char(unsigned char c, ring_buffer *buffer) } } -#if defined(__AVR_ATmega32U4__) - void serialEvent() __attribute__((weak)); - void serialEvent() {} - SIGNAL(USART1_RX_vect) { - unsigned char c = UDR1; - store_char(c, &rx_buffer); - serialEvent(); - } +#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) && \ @@ -124,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)); @@ -163,18 +158,9 @@ inline void store_char(unsigned char c, ring_buffer *buffer) #elif defined(SIG_USART3_RECV) #error SIG_USART3_RECV #endif -#endif -#if defined(__AVR_ATmega32U4__) -ISR(USART1_UDRE_vect) { - if (tx_buffer.head == tx_buffer.tail) { - cbi(UCSR1B, UDRIE1); - } else { - unsigned char c = tx_buffer.buffer[tx_buffer.tail]; - tx_buffer.tail = (tx_buffer.tail + 1) % SERIAL_BUFFER_SIZE; - UDR1 = c; - } -} +#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 @@ -212,6 +198,7 @@ ISR(USART_UDRE_vect) } } #endif +#endif #ifdef USART1_UDRE_vect ISR(USART1_UDRE_vect) @@ -229,7 +216,6 @@ ISR(USART1_UDRE_vect) } } #endif -#endif #ifdef USART2_UDRE_vect ISR(USART2_UDRE_vect) @@ -399,7 +385,7 @@ void 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 |