aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino
diff options
context:
space:
mode:
authorDavid A. Mellis <d.mellis@arduino.cc>2011-06-25 11:08:42 -0400
committerDavid A. Mellis <d.mellis@arduino.cc>2011-06-25 11:08:42 -0400
commitd81d7f8415e4a9e909ea411e9b1dc3cc73cdb758 (patch)
tree9a880811591e8ca22b811f8f6b4bc1ad0a1ad55b /cores/arduino
parent89ba040f45064132c662a4385ade644dded7e436 (diff)
parentfad37544d39aa0f14828cf1f5acd3168218b7f58 (diff)
Merge remote branch 'ricklon/platforms' into new-extension
Diffstat (limited to 'cores/arduino')
-rw-r--r--cores/arduino/HardwareSerial.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp
index d6d7b60..db6b149 100644
--- a/cores/arduino/HardwareSerial.cpp
+++ b/cores/arduino/HardwareSerial.cpp
@@ -278,6 +278,8 @@ void HardwareSerial::begin(unsigned long baud)
use_u2x = false;
}
#endif
+
+try_again:
if (use_u2x) {
*_ucsra = 1 << _u2x;
@@ -286,6 +288,12 @@ void HardwareSerial::begin(unsigned long baud)
*_ucsra = 0;
baud_setting = (F_CPU / 8 / baud - 1) / 2;
}
+
+ if ((baud_setting > 4095) && use_u2x)
+ {
+ use_u2x = false;
+ goto try_again;
+ }
// assign the baud_setting, a.k.a. ubbr (USART Baud Rate Register)
*_ubrrh = baud_setting >> 8;