예제 #1
0
char UARTgetc(uint8_t UART)
{
    // Wait for data if the buffer is empty
    while (!rxQSize(UART)) flushReadFIFO(UART);

    return (char)rxDequeue(UART);
}
char UARTgetc(uint8_t UART)
{
    if (!rxQSize(UART))
    {
        // Disable interrupt to avoid possible race condition
        ROM_UARTIntDisable(UARTBASE[UART], UART_INT_RX);

        // Wait for data if the buffer is empty
        while (!rxQSize(UART)) flushReadFIFO(UART);

        // Return to the previous state
        ROM_UARTIntEnable(UARTBASE[UART], UART_INT_RX);
    }

    return (char)rxDequeue(UART);
}