From 49fc2ab8ad43b86f7668da8d0186abe0d48cd6d9 Mon Sep 17 00:00:00 2001 From: Cristian Maglie Date: Wed, 22 Jan 2014 10:12:56 +0100 Subject: Inlined HardwareSerial calls to RX ISR. Moreover, declaring pointers-to-registers as const and using initializer list in class constructor allows the compiler to further improve inlining performance. This change recovers about 50 bytes of program space on single-UART devices. See #1711 --- cores/arduino/HardwareSerial.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'cores/arduino/HardwareSerial.h') diff --git a/cores/arduino/HardwareSerial.h b/cores/arduino/HardwareSerial.h index da9efbc..bd3c4c4 100644 --- a/cores/arduino/HardwareSerial.h +++ b/cores/arduino/HardwareSerial.h @@ -66,12 +66,12 @@ class HardwareSerial : public Stream { protected: - volatile uint8_t *_ubrrh; - volatile uint8_t *_ubrrl; - volatile uint8_t *_ucsra; - volatile uint8_t *_ucsrb; - volatile uint8_t *_ucsrc; - volatile uint8_t *_udr; + volatile uint8_t * const _ubrrh; + volatile uint8_t * const _ubrrl; + volatile uint8_t * const _ucsra; + volatile uint8_t * const _ucsrb; + volatile uint8_t * const _ucsrc; + volatile uint8_t * const _udr; // Has any byte been written to the UART since begin() bool _written; @@ -87,7 +87,7 @@ class HardwareSerial : public Stream unsigned char _tx_buffer[SERIAL_BUFFER_SIZE]; public: - HardwareSerial( + inline HardwareSerial( volatile uint8_t *ubrrh, volatile uint8_t *ubrrl, volatile uint8_t *ucsra, volatile uint8_t *ucsrb, volatile uint8_t *ucsrc, volatile uint8_t *udr); @@ -107,7 +107,7 @@ class HardwareSerial : public Stream operator bool() { return true; } // Interrupt handlers - Not intended to be called externally - void _rx_complete_irq(void); + inline void _rx_complete_irq(void); void _tx_udr_empty_irq(void); }; -- cgit v1.2.3-18-g5258