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

    return (char)rxDequeue(UART);
}
示例#2
0
// This throws away all data in the buffer
void UARTflushReceiveBuffer(uint8_t UART)
{
    rxBufferHead[UART] = rxBufferTail[UART] = 0;
    flushReadFIFO(UART);
    rxBufferHead[UART] = rxBufferTail[UART] = 0;
    overflow &= ~(bit8[UART]);
}
示例#3
0
char UARTpeekBlocking(uint8_t UART)
{
    // If there is data in the buffer return that
    if (rxQSize(UART)) return rxBuff[UART][rxBufferTail[UART]];

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

    // Return what was read without popping it from the queue
    return rxBuff[UART][rxBufferTail[UART]];
}
示例#4
0
int UARTpeek(uint8_t UART)
{
    // If there is data in the buffer return that
    if (rxQSize(UART)) return rxBuff[UART][rxBufferTail[UART]];

    // Try flushing the hardware FIFO and see if we can get data from there
    flushReadFIFO(UART);
    if (rxQSize(UART)) return rxBuff[UART][rxBufferTail[UART]];

    // No data was found
    return -255;
}
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);
}
char UARTpeekBlocking(uint8_t UART)
{
    // If there is data in the buffer return that
    if (rxQSize(UART)) return rxBuff[UART][rxBufferTail[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 what was read without popping it from the queue
    return rxBuff[UART][rxBufferTail[UART]];
}
int UARTpeek(uint8_t UART)
{
    // If there is data in the buffer return that
    if (rxQSize(UART)) return rxBuff[UART][rxBufferTail[UART]];

    // Disable interrupt to avoid possible race condition
    ROM_UARTIntDisable(UARTBASE[UART], UART_INT_RX);

    // Try flushing the hardware FIFO and see if we can get data from there
    flushReadFIFO(UART);
    if (rxQSize(UART)) return rxBuff[UART][rxBufferTail[UART]];

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

    // No data was found
    return -255;
}
示例#8
0
void rxInt7(void) {flushReadFIFO(7);}
示例#9
0
void rxInt6(void) {flushReadFIFO(6);}
示例#10
0
void rxInt5(void) {flushReadFIFO(5);}
示例#11
0
void rxInt4(void) {flushReadFIFO(4);}
示例#12
0
void rxInt3(void) {flushReadFIFO(3);}
示例#13
0
void rxInt2(void) {flushReadFIFO(2);}
示例#14
0
void rxInt1(void) {flushReadFIFO(1);}
示例#15
0
void rxInt0(void) {flushReadFIFO(0);}
示例#16
0
int16_t UARTgetBufferLevel(uint8_t UART)
{
    flushReadFIFO(UART);
    return rxQSize(UART);
}