From 699e9c09ce7a23b1ec0292ac763477e4be743acc Mon Sep 17 00:00:00 2001 From: jantje Date: Sun, 23 Mar 2014 23:12:00 +0100 Subject: This commit contains 2 changes: Added support for different size of TX and RX buffer sizes. Added support for buffer sizes bigger than 256 bytes. Added support for different size of TX and RX buffer sizes. The default values remain the same. If you want to have different values define SERIAL_TX_BUFFER_SIZE and SERIAL_RX_BUFFER_SIZE on the command line Added support for buffer sizes bigger than 256 bytes. The type of the indexes is decided upon the size of the buffers. So there is no increase in program/data size when the buffers are smaller than 257 --- cores/arduino/HardwareSerial.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'cores/arduino/HardwareSerial.cpp') diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index a270ace..a634b28 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -83,7 +83,7 @@ void HardwareSerial::_tx_udr_empty_irq(void) // If interrupts are enabled, there must be more data in the output // buffer. Send the next byte unsigned char c = _tx_buffer[_tx_buffer_tail]; - _tx_buffer_tail = (_tx_buffer_tail + 1) % SERIAL_BUFFER_SIZE; + _tx_buffer_tail = (_tx_buffer_tail + 1) % SERIAL_TX_BUFFER_SIZE; *_udr = c; @@ -152,7 +152,7 @@ void HardwareSerial::end() int HardwareSerial::available(void) { - return (unsigned int)(SERIAL_BUFFER_SIZE + _rx_buffer_head - _rx_buffer_tail) % SERIAL_BUFFER_SIZE; + return (unsigned int)(SERIAL_RX_BUFFER_SIZE + _rx_buffer_head - _rx_buffer_tail) % SERIAL_RX_BUFFER_SIZE; } int HardwareSerial::peek(void) @@ -171,7 +171,7 @@ int HardwareSerial::read(void) return -1; } else { unsigned char c = _rx_buffer[_rx_buffer_tail]; - _rx_buffer_tail = (uint8_t)(_rx_buffer_tail + 1) % SERIAL_BUFFER_SIZE; + _rx_buffer_tail = (BUFPOINTER)(_rx_buffer_tail + 1) % SERIAL_RX_BUFFER_SIZE; return c; } } @@ -207,7 +207,7 @@ size_t HardwareSerial::write(uint8_t c) sbi(*_ucsra, TXC0); return 1; } - uint8_t i = (_tx_buffer_head + 1) % SERIAL_BUFFER_SIZE; + BUFPOINTER i = (_tx_buffer_head + 1) % SERIAL_TX_BUFFER_SIZE; // If the output buffer is full, there's nothing for it other than to // wait for the interrupt handler to empty it a bit -- cgit v1.2.3-18-g5258 From f87e11534aaf48475856a210b2b473988d70a43d Mon Sep 17 00:00:00 2001 From: jantje Date: Mon, 24 Mar 2014 21:40:12 +0100 Subject: Added support for different size of TX and RX buffer sizes. Added support for buffer sizes bigger than 256 bytes. Added possibility to overrule the default size. Added support for different size of TX and RX buffer sizes. The default values remain the same. You can however specify a different value for TX and RX buffer Added possibility to overrule the default size. If you want to have different values define SERIAL_TX_BUFFER_SIZE and SERIAL_RX_BUFFER_SIZE on the command line Added support for buffer sizes bigger than 256 bytes. Because of the possibility to change the size of the buffer sizes longer than 256 must be supported. The type of the indexes is decided upon the size of the buffers. So there is no increase in program/data size when the buffers are smaller than 257 --- cores/arduino/HardwareSerial.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'cores/arduino/HardwareSerial.cpp') diff --git a/cores/arduino/HardwareSerial.cpp b/cores/arduino/HardwareSerial.cpp index a634b28..b9dce07 100644 --- a/cores/arduino/HardwareSerial.cpp +++ b/cores/arduino/HardwareSerial.cpp @@ -171,7 +171,7 @@ int HardwareSerial::read(void) return -1; } else { unsigned char c = _rx_buffer[_rx_buffer_tail]; - _rx_buffer_tail = (BUFPOINTER)(_rx_buffer_tail + 1) % SERIAL_RX_BUFFER_SIZE; + _rx_buffer_tail = (rx_buffer_index_t)(_rx_buffer_tail + 1) % SERIAL_RX_BUFFER_SIZE; return c; } } @@ -207,7 +207,7 @@ size_t HardwareSerial::write(uint8_t c) sbi(*_ucsra, TXC0); return 1; } - BUFPOINTER i = (_tx_buffer_head + 1) % SERIAL_TX_BUFFER_SIZE; + tx_buffer_index_t i = (_tx_buffer_head + 1) % SERIAL_TX_BUFFER_SIZE; // If the output buffer is full, there's nothing for it other than to // wait for the interrupt handler to empty it a bit -- cgit v1.2.3-18-g5258