aboutsummaryrefslogtreecommitdiff
path: root/cores/arduino
diff options
context:
space:
mode:
authorCristian Maglie <c.maglie@bug.st>2014-01-16 13:50:59 +0100
committerCristian Maglie <c.maglie@bug.st>2014-01-16 13:50:59 +0100
commit0a0cda4f04844cc209c0523ba59e8a2f47fc502e (patch)
treeaad05a8bd711581659761760ac0b11ac8380fe78 /cores/arduino
parent4bc8aa15e3309496e2adf98b5933e4825341df07 (diff)
Slightly reduce code utilization by inlining HardwareSerail begin(baud) and operator bool()
Diffstat (limited to 'cores/arduino')
-rw-r--r--cores/arduino/HardwareSerial.cpp9
-rw-r--r--cores/arduino/HardwareSerial.h56
2 files changed, 28 insertions, 37 deletions
diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp
index f95fa5d..a5a3462 100644
--- a/cores/arduino/HardwareSerial.cpp
+++ b/cores/arduino/HardwareSerial.cpp
@@ -281,11 +281,6 @@ HardwareSerial::HardwareSerial(
// Public Methods //////////////////////////////////////////////////////////////
-void HardwareSerial::begin(unsigned long baud)
-{
- begin(baud, SERIAL_8N1);
-}
-
void HardwareSerial::begin(unsigned long baud, byte config)
{
uint16_t baud_setting;
@@ -402,10 +397,6 @@ size_t HardwareSerial::write(uint8_t c)
return 1;
}
-HardwareSerial::operator bool() {
- return true;
-}
-
// Preinstantiate Objects //////////////////////////////////////////////////////
#if defined(UBRRH) && defined(UBRRL)
diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h
index 0f62262..6dba734 100644
--- a/cores/arduino/HardwareSerial.h
+++ b/cores/arduino/HardwareSerial.h
@@ -37,6 +37,32 @@
#define SERIAL_BUFFER_SIZE 64
#endif
+// Define config for Serial.begin(baud, config);
+#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
+
class HardwareSerial : public Stream
{
protected:
@@ -70,7 +96,7 @@ class HardwareSerial : public Stream
volatile uint8_t *ucsra, volatile uint8_t *ucsrb,
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 baud) { begin(baud, SERIAL_8N1); }
void begin(unsigned long, uint8_t);
void end();
virtual int available(void);
@@ -83,35 +109,9 @@ class HardwareSerial : public Stream
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();
+ operator bool() { return true; }
};
-// Define config for Serial.begin(baud, config);
-#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;
#elif defined(USBCON)