From b9bbc71dca6c1e7fcf7c5eddb28987c8ad121a2c Mon Sep 17 00:00:00 2001 From: Alarus Date: Sun, 12 Aug 2012 20:18:50 +0600 Subject: Update hardware/arduino/cores/arduino/HardwareSerial.h Adding advanced begin (); with the ability to specify the length of bits, parity, stop bits. --- cores/arduino/HardwareSerial.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'cores/arduino/HardwareSerial.h') diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index bf4924c..a04bb66 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -16,7 +16,7 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - Modified 28 September 2010 by Mark Sproul + Modified 12 August 2012 by Alarus */ #ifndef HardwareSerial_h @@ -37,6 +37,7 @@ class HardwareSerial : public Stream volatile uint8_t *_ubrrl; volatile uint8_t *_ucsra; volatile uint8_t *_ucsrb; + volatile uint8_t *_ucsrc; volatile uint8_t *_udr; uint8_t _rxen; uint8_t _txen; @@ -47,9 +48,10 @@ class HardwareSerial : public Stream HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer, volatile uint8_t *ubrrh, volatile uint8_t *ubrrl, volatile uint8_t *ucsra, volatile uint8_t *ucsrb, - volatile uint8_t *udr, + volatile uint8_t *ucsrc, volatile uint8_t *udr, uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x); void begin(unsigned long); + void begin(unsigned long, byte, char, byte); void end(); virtual int available(void); virtual int peek(void); -- cgit v1.2.3-18-g5258 From 03a4b50b8e95a234e9f9cf322b744890369dac90 Mon Sep 17 00:00:00 2001 From: Alarus Date: Sun, 12 Aug 2012 20:23:00 +0600 Subject: Update hardware/arduino/cores/arduino/HardwareSerial.h Adding advanced begin (); with the ability to specify the length of bits, parity, stop bits. --- cores/arduino/HardwareSerial.h | 1 + 1 file changed, 1 insertion(+) (limited to 'cores/arduino/HardwareSerial.h') diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index a04bb66..699015a 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -16,6 +16,7 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Modified 28 September 2010 by Mark Sproul Modified 12 August 2012 by Alarus */ -- cgit v1.2.3-18-g5258 From 1cda182f33ae6b1f87065b1a097f3d192ef5b6f6 Mon Sep 17 00:00:00 2001 From: Alarus Date: Tue, 14 Aug 2012 19:52:00 +0600 Subject: Update hardware/arduino/cores/arduino/HardwareSerial.h New Serial.begin(baud, config); --- cores/arduino/HardwareSerial.h | 54 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 2 deletions(-) (limited to 'cores/arduino/HardwareSerial.h') diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index 699015a..07445a0 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -17,7 +17,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Modified 28 September 2010 by Mark Sproul - Modified 12 August 2012 by Alarus + Modified 14 August 2012 by Alarus */ #ifndef HardwareSerial_h @@ -52,7 +52,7 @@ class HardwareSerial : public Stream volatile uint8_t *ucsrc, volatile uint8_t *udr, uint8_t rxen, uint8_t txen, uint8_t rxcie, uint8_t udrie, uint8_t u2x); void begin(unsigned long); - void begin(unsigned long, byte, char, byte); + void begin(unsigned long, byte); void end(); virtual int available(void); virtual int peek(void); @@ -63,6 +63,56 @@ class HardwareSerial : public Stream operator bool(); }; +// Define config for Serial.begin(baud, config); +#define _5n1_ 0x80 +#define _5N1_ 0x80 +#define _6n1_ 0x82 +#define _6N1_ 0x82 +#define _7n1_ 0x84 +#define _7N1_ 0x84 +#define _8n1_ 0x86 +#define _8N1_ 0x86 +#define _5n2_ 0x88 +#define _5N2_ 0x88 +#define _6n2_ 0x8A +#define _6N2_ 0x8A +#define _7n2_ 0x8C +#define _7N2_ 0x8C +#define _8n2_ 0x8E +#define _8N2_ 0x8E +#define _5e1_ 0xA0 +#define _5E1_ 0xA0 +#define _6e1_ 0xA2 +#define _6E1_ 0xA2 +#define _7e1_ 0xA4 +#define _7E1_ 0xA4 +#define _8e1_ 0xA6 +#define _8E1_ 0xA6 +#define _5e2_ 0xA8 +#define _5E2_ 0xA8 +#define _6e2_ 0xAA +#define _6E2_ 0xAA +#define _7e2_ 0xAC +#define _7E2_ 0xAC +#define _8e2_ 0xAE +#define _8E2_ 0xAE +#define _5o1_ 0xB0 +#define _5O1_ 0xB0 +#define _6o1_ 0xB2 +#define _6O1_ 0xB2 +#define _7o1_ 0xB4 +#define _7O1_ 0xB4 +#define _8o1_ 0xB6 +#define _8O1_ 0xB6 +#define _5o2_ 0xB8 +#define _5O2_ 0xB8 +#define _6o2_ 0xBA +#define _6O2_ 0xBA +#define _7o2_ 0xBC +#define _7O2_ 0xBC +#define _8o2_ 0xBE +#define _8O2_ 0xBE + #if defined(UBRRH) || defined(UBRR0H) extern HardwareSerial Serial; #elif defined(USBCON) -- cgit v1.2.3-18-g5258 From 00ab72619ea4364ed446d929e77143ed467514c1 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Tue, 28 Aug 2012 08:02:54 -0400 Subject: Serial.flush() waits for last character to be transmitted (michele.mazzucchi) http://code.google.com/p/arduino/issues/detail?id=871 --- cores/arduino/HardwareSerial.h | 1 + 1 file changed, 1 insertion(+) (limited to 'cores/arduino/HardwareSerial.h') diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index bf4924c..5bceb75 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -43,6 +43,7 @@ class HardwareSerial : public Stream uint8_t _rxcie; uint8_t _udrie; uint8_t _u2x; + bool transmitting; public: HardwareSerial(ring_buffer *rx_buffer, ring_buffer *tx_buffer, volatile uint8_t *ubrrh, volatile uint8_t *ubrrl, -- cgit v1.2.3-18-g5258 From c29b408a9d420f1850b6c6692f37d11b22e7bedb Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Wed, 29 Aug 2012 16:32:05 -0400 Subject: Adding overloads so Serial.write(0) works. http://code.google.com/p/arduino/issues/detail?id=1006 --- cores/arduino/HardwareSerial.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'cores/arduino/HardwareSerial.h') diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index 5bceb75..9a42773 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -57,6 +57,10 @@ class HardwareSerial : public Stream virtual int read(void); virtual void flush(void); virtual size_t write(uint8_t); + inline size_t write(unsigned long n) { return write((uint8_t)n); } + inline size_t write(long n) { return write((uint8_t)n); } + inline size_t write(unsigned int n) { return write((uint8_t)n); } + inline size_t write(int n) { return write((uint8_t)n); } using Print::write; // pull in write(str) and write(buf, size) from Print operator bool(); }; -- cgit v1.2.3-18-g5258 From 912092b03fddf38789ec680da4e619bedccaf559 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Wed, 29 Aug 2012 20:52:30 -0400 Subject: Fixing ATmega8 breakage from flush() change. (WestFW) http://code.google.com/p/arduino/issues/detail?id=1019 --- cores/arduino/HardwareSerial.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'cores/arduino/HardwareSerial.h') diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index 9a42773..eadaaa7 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -81,6 +81,15 @@ class HardwareSerial : public Stream extern HardwareSerial Serial3; #endif +/* + * on ATmega8, the uart and its bits are not numbered, so there is no "TXC0" + * definition. It is slightly cleaner to define this here instead of having + * conditional code in the cpp module. + */ +#if !defined(TXC0) +#define TXC0 TXC +#endif + extern void serialEventRun(void) __attribute__((weak)); #endif -- cgit v1.2.3-18-g5258 From 70b6f11d632d9549cd2ec20b9a7fbd1136c79d72 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Thu, 30 Aug 2012 07:44:25 -0400 Subject: Fixing Serial.flush() breakage on Leonardo (WestFW). http://code.google.com/p/arduino/issues/detail?id=1020 --- cores/arduino/HardwareSerial.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'cores/arduino/HardwareSerial.h') diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index eadaaa7..d4ccbec 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -87,7 +87,14 @@ class HardwareSerial : public Stream * conditional code in the cpp module. */ #if !defined(TXC0) +#if defined(TXC) #define TXC0 TXC +#elif defined(TXC1) +// Some devices have uart1 but no uart0 +#define TXC0 TXC1 +#else +#error TXC0 not definable in HardwareSerial.h +#endif #endif extern void serialEventRun(void) __attribute__((weak)); -- cgit v1.2.3-18-g5258 From 1650169f5d06231bc67bd5cffc484775b34f38c6 Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Thu, 30 Aug 2012 08:21:12 -0400 Subject: Renaming serial config constants to, e.g., SERIAL_8N1. --- cores/arduino/HardwareSerial.h | 72 ++++++++++++++---------------------------- 1 file changed, 24 insertions(+), 48 deletions(-) (limited to 'cores/arduino/HardwareSerial.h') diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index 8f00d15..dcbaebc 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -69,54 +69,30 @@ class HardwareSerial : public Stream }; // Define config for Serial.begin(baud, config); -#define _5n1_ 0x80 -#define _5N1_ 0x80 -#define _6n1_ 0x82 -#define _6N1_ 0x82 -#define _7n1_ 0x84 -#define _7N1_ 0x84 -#define _8n1_ 0x86 -#define _8N1_ 0x86 -#define _5n2_ 0x88 -#define _5N2_ 0x88 -#define _6n2_ 0x8A -#define _6N2_ 0x8A -#define _7n2_ 0x8C -#define _7N2_ 0x8C -#define _8n2_ 0x8E -#define _8N2_ 0x8E -#define _5e1_ 0xA0 -#define _5E1_ 0xA0 -#define _6e1_ 0xA2 -#define _6E1_ 0xA2 -#define _7e1_ 0xA4 -#define _7E1_ 0xA4 -#define _8e1_ 0xA6 -#define _8E1_ 0xA6 -#define _5e2_ 0xA8 -#define _5E2_ 0xA8 -#define _6e2_ 0xAA -#define _6E2_ 0xAA -#define _7e2_ 0xAC -#define _7E2_ 0xAC -#define _8e2_ 0xAE -#define _8E2_ 0xAE -#define _5o1_ 0xB0 -#define _5O1_ 0xB0 -#define _6o1_ 0xB2 -#define _6O1_ 0xB2 -#define _7o1_ 0xB4 -#define _7O1_ 0xB4 -#define _8o1_ 0xB6 -#define _8O1_ 0xB6 -#define _5o2_ 0xB8 -#define _5O2_ 0xB8 -#define _6o2_ 0xBA -#define _6O2_ 0xBA -#define _7o2_ 0xBC -#define _7O2_ 0xBC -#define _8o2_ 0xBE -#define _8O2_ 0xBE +#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 #if defined(UBRRH) || defined(UBRR0H) extern HardwareSerial Serial; -- cgit v1.2.3-18-g5258 From 5ca747e312e70aa87b6056c15f6dae41c2f0f20c Mon Sep 17 00:00:00 2001 From: "David A. Mellis" Date: Thu, 30 Aug 2012 08:47:35 -0400 Subject: Changing setting of the UMSELn bits (for UART mode) and serial config values. Before, the UMSELn1 bit was being to set to 1, putting the UART into a reserved mode. Now, we only set the high (0x80) bit to 1 for the ATmega8, which is needed to access UCSRnC (whose i/o address is shared with UBRRH). Also, no longer bitwise-or the new config with the existing register value, because we're actually configuring all the settings in the register. (We're not using UCPOL, but it's supposed to be 0 in asynchronous mode.) --- cores/arduino/HardwareSerial.h | 48 +++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'cores/arduino/HardwareSerial.h') 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; -- cgit v1.2.3-18-g5258