From 6e235622edb1b882401c77c171b0e738a093fd5b Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Fri, 1 Dec 2017 15:41:18 +0100 Subject: Fix MCUs without MPCM0 register --- cores/arduino/HardwareSerial.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'cores/arduino') diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index ecd7918..e99d503 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -100,7 +100,11 @@ void HardwareSerial::_tx_udr_empty_irq(void) // actually got written. Other r/w bits are preserved, and zeroes // written to the rest. +#ifdef MPCM0 *_ucsra = ((*_ucsra) & ((1 << U2X0) | (1 << MPCM0))) | (1 << TXC0); +#else + *_ucsra = ((*_ucsra) & ((1 << U2X0) | (1 << TXC0))); +#endif if (_tx_buffer_head == _tx_buffer_tail) { // Buffer empty, so disable interrupts @@ -236,7 +240,11 @@ size_t HardwareSerial::write(uint8_t c) // be cleared when no bytes are left, causing flush() to hang ATOMIC_BLOCK(ATOMIC_RESTORESTATE) { *_udr = c; +#ifdef MPCM0 *_ucsra = ((*_ucsra) & ((1 << U2X0) | (1 << MPCM0))) | (1 << TXC0); +#else + *_ucsra = ((*_ucsra) & ((1 << U2X0) | (1 << TXC0))); +#endif } return 1; } -- cgit v1.2.3-18-g5258