char UARTgetc(uint8_t UART) { // Wait for data if the buffer is empty while (!rxQSize(UART)) flushReadFIFO(UART); return (char)rxDequeue(UART); }
// 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]); }
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]]; }
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; }
void rxInt7(void) {flushReadFIFO(7);}
void rxInt6(void) {flushReadFIFO(6);}
void rxInt5(void) {flushReadFIFO(5);}
void rxInt4(void) {flushReadFIFO(4);}
void rxInt3(void) {flushReadFIFO(3);}
void rxInt2(void) {flushReadFIFO(2);}
void rxInt1(void) {flushReadFIFO(1);}
void rxInt0(void) {flushReadFIFO(0);}
int16_t UARTgetBufferLevel(uint8_t UART) { flushReadFIFO(UART); return rxQSize(UART); }