aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino
diff options
context:
space:
mode:
Diffstat (limited to 'cores/arduino')
-rw-r--r--cores/arduino/HardwareSerial.cpp10
-rw-r--r--cores/arduino/HardwareSerial.h48
2 files changed, 29 insertions, 29 deletions
diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp
index e512421..2e64acb 100644
--- a/cores/arduino/HardwareSerial.cpp
+++ b/cores/arduino/HardwareSerial.cpp
@@ -393,11 +393,11 @@ try_again:
*_ubrrh = baud_setting >> 8;
*_ubrrl = baud_setting;
- //set number of data bits
- current_config = *_ubrrh;
- current_config = *_ucsrc;
- current_config |= config;
- *_ucsrc = current_config;
+ //set the data bits, parity, and stop bits
+#if defined(__AVR_ATmega8__)
+ config |= 0x80; // select UCSRC register (shared with UBRRH)
+#endif
+ *_ucsrc = config;
sbi(*_ucsrb, _rxen);
sbi(*_ucsrb, _txen);
diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h
index dcbaebc..c2d0ce9 100644
--- a/cores/arduino/HardwareSerial.h
+++ b/cores/arduino/HardwareSerial.h
@@ -69,30 +69,30 @@ class HardwareSerial : public Stream
};
// Define config for Serial.begin(baud, config);
-#define SERIAL_5N1 0x80
-#define SERIAL_6N1 0x82
-#define SERIAL_7N1 0x84
-#define SERIAL_8N1 0x86
-#define SERIAL_5N2 0x88
-#define SERIAL_6N2 0x8A
-#define SERIAL_7N2 0x8C
-#define SERIAL_8N2 0x8E
-#define SERIAL_5E1 0xA0
-#define SERIAL_6E1 0xA2
-#define SERIAL_7E1 0xA4
-#define SERIAL_8E1 0xA6
-#define SERIAL_5E2 0xA8
-#define SERIAL_6E2 0xAA
-#define SERIAL_7E2 0xAC
-#define SERIAL_8E2 0xAE
-#define SERIAL_5O1 0xB0
-#define SERIAL_6O1 0xB2
-#define SERIAL_7O1 0xB4
-#define SERIAL_8O1 0xB6
-#define SERIAL_5O2 0xB8
-#define SERIAL_6O2 0xBA
-#define SERIAL_7O2 0xBC
-#define SERIAL_8O2 0xBE
+#define SERIAL_5N1 0x00
+#define SERIAL_6N1 0x02
+#define SERIAL_7N1 0x04
+#define SERIAL_8N1 0x06
+#define SERIAL_5N2 0x08
+#define SERIAL_6N2 0x0A
+#define SERIAL_7N2 0x0C
+#define SERIAL_8N2 0x0E
+#define SERIAL_5E1 0x20
+#define SERIAL_6E1 0x22
+#define SERIAL_7E1 0x24
+#define SERIAL_8E1 0x26
+#define SERIAL_5E2 0x28
+#define SERIAL_6E2 0x2A
+#define SERIAL_7E2 0x2C
+#define SERIAL_8E2 0x2E
+#define SERIAL_5O1 0x30
+#define SERIAL_6O1 0x32
+#define SERIAL_7O1 0x34
+#define SERIAL_8O1 0x36
+#define SERIAL_5O2 0x38
+#define SERIAL_6O2 0x3A
+#define SERIAL_7O2 0x3C
+#define SERIAL_8O2 0x3E
#if defined(UBRRH) || defined(UBRR0H)
extern HardwareSerial Serial;