Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a62ef26

Browse filesBrowse files
committed
UART frame error handling
1 parent 9f9d2c7 commit a62ef26
Copy full SHA for a62ef26

File tree

3 files changed

+14
-1
lines changed
Filter options

3 files changed

+14
-1
lines changed

‎cores/arduino/SERCOM.cpp

Copy file name to clipboardExpand all lines: cores/arduino/SERCOM.cpp
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,12 @@ bool SERCOM::isFrameErrorUART()
152152
return sercom->USART.STATUS.bit.FERR;
153153
}
154154

155+
void SERCOM::clearFrameErrorUART()
156+
{
157+
// clear FERR bit writing 1 status bit
158+
sercom->USART.STATUS.bit.FERR = 1;
159+
}
160+
155161
bool SERCOM::isParityErrorUART()
156162
{
157163
//PERR : Parity Error

‎cores/arduino/SERCOM.h

Copy file name to clipboardExpand all lines: cores/arduino/SERCOM.h
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ class SERCOM
158158
bool availableDataUART( void ) ;
159159
bool isBufferOverflowErrorUART( void ) ;
160160
bool isFrameErrorUART( void ) ;
161+
void clearFrameErrorUART( void ) ;
161162
bool isParityErrorUART( void ) ;
162163
bool isDataRegisterEmptyUART( void ) ;
163164
uint8_t readDataUART( void ) ;

‎cores/arduino/Uart.cpp

Copy file name to clipboardExpand all lines: cores/arduino/Uart.cpp
+7-1Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ void Uart::flush()
9090

9191
void Uart::IrqHandler()
9292
{
93+
if (sercom->isFrameErrorUART()) {
94+
// frame error, next byte is invalid so read and discard it
95+
sercom->readDataUART();
96+
97+
sercom->clearFrameErrorUART();
98+
}
99+
93100
if (sercom->availableDataUART()) {
94101
rxBuffer.store_char(sercom->readDataUART());
95102

@@ -114,7 +121,6 @@ void Uart::IrqHandler()
114121
if (sercom->isUARTError()) {
115122
sercom->acknowledgeUARTError();
116123
// TODO: if (sercom->isBufferOverflowErrorUART()) ....
117-
// TODO: if (sercom->isFrameErrorUART()) ....
118124
// TODO: if (sercom->isParityErrorUART()) ....
119125
sercom->clearStatusUART();
120126
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.