User manual
LPCXpresso Experiment Kit - User’s Guide
Page 109
Copyright 2013 © Embedded Artists AB
/* Read LSR will clear the interrupt */
Dummy = LPC_UART->RBR; //Dummy read on RX to clear interrupt, then bail out
return;
}
if (LSRValue & LSR_RDR) /* Receive Data Ready */
{
/* If no error on RLS, normal ready, save into the data buffer. */
/* Note: read RBR will clear the interrupt */
tmpHead = (rxHead + 1) & RX_BUFFER_MASK;
rxHead = tmpHead;
if(tmpHead == rxTail)
tmpHead = LPC_UART->RBR; //dummy read to reset IRQ flag
else
rxBuf[tmpHead] = LPC_UART->RBR; //will reset IRQ flag
}
}
else if (IIRValue == IIR_RDA) /* Receive Data Available */
{
/* Receive Data Available */
tmpHead = (rxHead + 1) & RX_BUFFER_MASK;
rxHead = tmpHead;
if(tmpHead == rxTail)
tmpHead = LPC_UART->RBR; //dummy read to reset IRQ flag
else
rxBuf[tmpHead] = LPC_UART->RBR; //will reset IRQ flag
}
else if (IIRValue == IIR_CTI) /* Character timeout indicator */
{
/* Character Time-out indicator */
; //functionality not implemented
}
else if (IIRValue == IIR_THRE) /* THRE, transmit holding register empty */
{
//check if all data is transmitted
if (txHead != txTail)
{
uint32_t bytesToSend;
if (statusReg & 0xc0)
bytesToSend = 16; //FIFO enabled
else
bytesToSend = 1; //no FIFO enabled
do
{
//calculate buffer index
tmpTail = (txTail + 1) & TX_BUFFER_MASK;
txTail = tmpTail;
LPC_UART->THR = txBuf[tmpTail];
} while((txHead != txTail) && --bytesToSend);
}
//all data has been transmitted
else
{
txRunning = FALSE;
LPC_UART->IER &= ~IER_THRE; //disable TX IRQ
}
}
}
/*****************************************************************************
** Function name: UARTSendChar
**
** Descriptions: Send a byte/char of data to the UART 0 port
**
** parameters: byte to send
** Returned value: None
**
*****************************************************************************/
void UARTSendChar(uint8_t toSend)
{