Changed receive flushing function to not need a timeout and to work with and without interrupts

This commit is contained in:
BlackMark 2016-05-24 21:08:06 +02:00
parent 07474c7e19
commit cf1b273549
2 changed files with 13 additions and 5 deletions

View File

@ -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;
}
}
//////////////////////////////////////////////////////////////////////////

View File

@ -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 );