Compiler Warning UARTClass.cpp and RingBuffer.h correction

This commit is contained in:
techpaul 2016-01-18 01:09:55 +00:00 committed by Sandeep Mistry
parent 4a5228f559
commit fa0d580846
2 changed files with 4 additions and 4 deletions

View File

@ -22,7 +22,7 @@
#include <stdint.h>
// 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

View File

@ -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;
}