Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions cores/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,16 @@ if(( XMC_USIC_CH_GetTransmitBufferStatus( _XMC_UART_config->channel ) == XMC_USI
int nextWrite = _tx_buffer->_iHead + 1;
if( nextWrite >= SERIAL_BUFFER_SIZE )
nextWrite = 0;

//This should always be false but in case transmission is completed before buffer, we need to reenable IRQ
if( XMC_USIC_CH_GetTransmitBufferStatus( _XMC_UART_config->channel ) != XMC_USIC_CH_TBUF_STATUS_BUSY ) {
XMC_UART_CH_EnableEvent( _XMC_UART_config->channel, XMC_UART_CH_EVENT_TRANSMIT_BUFFER );
XMC_UART_CH_Transmit( _XMC_UART_config->channel, _tx_buffer->_aucBuffer[ _tx_buffer->_iTail ] );
_tx_buffer->_iTail++;
if(_tx_buffer->_iTail >= SERIAL_BUFFER_SIZE)
_tx_buffer->_iTail = _tx_buffer->_iTail - SERIAL_BUFFER_SIZE; // If iTail is larger than Serial Buffer Size calculate the correct index value
}

while( _tx_buffer->_iTail == nextWrite )
; // Spin locks if we're about to overwrite the buffer. This continues once the data is sent

Expand Down Expand Up @@ -232,12 +242,14 @@ if( ( status & XMC_UART_CH_STATUS_FLAG_TRANSMIT_BUFFER_INDICATION ) != 0U )
if( _tx_buffer->_iTail >= SERIAL_BUFFER_SIZE )
_tx_buffer->_iTail = 0;
}
else
else {
// Mask off transmit interrupt so we don't get it any more
XMC_UART_CH_DisableEvent( _XMC_UART_config->channel, XMC_UART_CH_EVENT_TRANSMIT_BUFFER );
XMC_UART_CH_DisableEvent( _XMC_UART_config->channel, XMC_UART_CH_EVENT_TRANSMIT_BUFFER );
}
}
}

//****************************************************************************
// END OF FILE
//****************************************************************************

Loading