From fa0d5808462a435c7178121585f90668223e017d Mon Sep 17 00:00:00 2001 From: techpaul Date: Mon, 18 Jan 2016 01:09:55 +0000 Subject: [PATCH] Compiler Warning UARTClass.cpp and RingBuffer.h correction --- hardware/arduino/sam/cores/arduino/RingBuffer.h | 2 +- hardware/arduino/sam/cores/arduino/UARTClass.cpp | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/hardware/arduino/sam/cores/arduino/RingBuffer.h b/hardware/arduino/sam/cores/arduino/RingBuffer.h index 1a5861b0b..6041430ea 100644 --- a/hardware/arduino/sam/cores/arduino/RingBuffer.h +++ b/hardware/arduino/sam/cores/arduino/RingBuffer.h @@ -22,7 +22,7 @@ #include // Define constants and variables for buffering incoming serial data. We're -// using a ring buffer (I think), in which head is the index of the location +// using a ring buffer, in which head is the index of the location // to which to write the next incoming character and tail is the index of the // location from which to read. #define SERIAL_BUFFER_SIZE 128 diff --git a/hardware/arduino/sam/cores/arduino/UARTClass.cpp b/hardware/arduino/sam/cores/arduino/UARTClass.cpp index ed1cb2687..36de13586 100644 --- a/hardware/arduino/sam/cores/arduino/UARTClass.cpp +++ b/hardware/arduino/sam/cores/arduino/UARTClass.cpp @@ -149,12 +149,12 @@ size_t UARTClass::write( const uint8_t uc_data ) (_tx_buffer->_iTail != _tx_buffer->_iHead)) { // If busy we buffer - unsigned int l = (_tx_buffer->_iHead + 1) % SERIAL_BUFFER_SIZE; - while (_tx_buffer->_iTail == l) + int nextWrite = (_tx_buffer->_iHead + 1) % SERIAL_BUFFER_SIZE; + while (_tx_buffer->_iTail == nextWrite) ; // Spin locks if we're about to overwrite the buffer. This continues once the data is sent _tx_buffer->_aucBuffer[_tx_buffer->_iHead] = uc_data; - _tx_buffer->_iHead = l; + _tx_buffer->_iHead = nextWrite; // Make sure TX interrupt is enabled _pUart->UART_IER = UART_IER_TXRDY; }