inline void xSerialFlush( xComPortHandlePtr pxPort ) { /* Flush received characters from the serial port buffer.*/ uint8_t byte; switch (pxPort->usart) { case USART0: while ( UCSR0A & (1<<RXC0) ) byte = UDR0; break; case USART1: #if defined(__AVR_ATmega324P__) || defined(__AVR_ATmega644P__)|| defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega324PA__) || defined(__AVR_ATmega644PA__) ||defined(__AVR_ATmega640__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega2561__) while ( UCSR1A & (1<<RXC1) ) byte = UDR1; break; #endif case USART2: case USART3: default: break; } ringBuffer_Flush( &(pxPort->xRxedChars) ); }
/********************************************************************************//*! * \brief Flushes all characters in the receive ring buffer (i.e. empties the buffer). * * All characters in the receive ring buffer are discarded. If characters are waiting in the * USART for reading (a 2 byte FIFO is used for buffering received characters, they are also discarded. * * @param usartId - USART identifier. */ void usart_xflushRx(USART_ID usartId) { // Flush received characters from the USART transmit buffer. register uint8_t byte __attribute__ ((unused)); // Flush the bytes in the USART while (*usartReg[usartId].ucsrAPtr & RXC_BIT) byte = *usartReg[usartId].udrPtr; // Flush the characters in the ring buffer. ringBuffer_Flush( &(usartComBuf[usartId].xRxedChars) ); }