File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -200,6 +200,12 @@ bool SERCOM::isFrameErrorUART()
200200 return sercom->USART .STATUS .bit .FERR ;
201201}
202202
203+ void SERCOM::clearFrameErrorUART ()
204+ {
205+ // clear FERR bit writing 1 status bit
206+ sercom->USART .STATUS .bit .FERR = 1 ;
207+ }
208+
203209bool SERCOM::isParityErrorUART ()
204210{
205211 // PERR : Parity Error
Original file line number Diff line number Diff line change @@ -163,6 +163,7 @@ class SERCOM
163163 bool availableDataUART ( void ) ;
164164 bool isBufferOverflowErrorUART ( void ) ;
165165 bool isFrameErrorUART ( void ) ;
166+ void clearFrameErrorUART ( void ) ;
166167 bool isParityErrorUART ( void ) ;
167168 bool isDataRegisterEmptyUART ( void ) ;
168169 uint8_t readDataUART ( void ) ;
Original file line number Diff line number Diff line change @@ -122,6 +122,13 @@ void Uart::errorHandler()
122122#else
123123void Uart::IrqHandler ()
124124{
125+ if (sercom->isFrameErrorUART ()) {
126+ // frame error, next byte is invalid so read and discard it
127+ sercom->readDataUART ();
128+
129+ sercom->clearFrameErrorUART ();
130+ }
131+
125132 if (sercom->availableDataUART ()) {
126133 rxBuffer.store_char (sercom->readDataUART ());
127134
@@ -146,7 +153,6 @@ void Uart::IrqHandler()
146153 if (sercom->isUARTError ()) {
147154 sercom->acknowledgeUARTError ();
148155 // TODO: if (sercom->isBufferOverflowErrorUART()) ....
149- // TODO: if (sercom->isFrameErrorUART()) ....
150156 // TODO: if (sercom->isParityErrorUART()) ....
151157 sercom->clearStatusUART ();
152158 }
You can’t perform that action at this time.
0 commit comments