diff --git a/usart/usart.cpp b/usart/usart.cpp index e201c74..b451df5 100644 --- a/usart/usart.cpp +++ b/usart/usart.cpp @@ -332,11 +332,19 @@ bool USART0::receiveLine( char *szBuffer, size_t sizeBufferLength, const char *s } ////////////////////////////////////////////////////////////////////////// -void USART0::flushReceive( uint16_t ui16TimeoutMS ) +void USART0::flushReceive() { uint8_t ui8Received; - while( receiveByte( ui8Received, ui16TimeoutMS ) ); + while( m_vsizeRXBufferHead != m_vsizeRXBufferTail ) + { + receiveByte( ui8Received ); + } + + if( !( SREG & ( 1 << SREG_I ) ) && ( *m_vui8pUCSRA & ( 1 << RXC_D ) ) ) + { + ui8Received = *m_vui8pUDR; + } } ////////////////////////////////////////////////////////////////////////// diff --git a/usart/usart.h b/usart/usart.h index a4d2850..1e0b1bb 100644 --- a/usart/usart.h +++ b/usart/usart.h @@ -1,7 +1,7 @@ /* * Copyright (c) by BlackMark 2015-2016 -* Date 22/05/2016 -* Version 2.8 +* Date 24/05/2016 +* Version 2.9 */ #ifndef USART_H @@ -140,7 +140,7 @@ public: bool receiveByte( uint8_t &ui8Data ); bool receiveByte( uint8_t &ui8Data, uint16_t ui16TimeoutMS ); bool receiveLine( char *szBuffer, size_t sizeBufferLength, const char *szLineTerminator = "\r\n" ); - void flushReceive( uint16_t ui16TimeoutMS ); + void flushReceive(); void transmitByte( uint8_t ui8Data ); void transmitString( const char *szString );