Skip to content

Commit

Permalink
firmware/sniffer: Log parity errors, just like overruns and framing e…
Browse files Browse the repository at this point in the history
…rrors

Reading of code + datasheet showed that we did enable parity checking
but never actually checked if the USART has the PARE bit in CSR set.

Let's change that.  Plus also avoid possible race conditions due to
multiple status resets via US_CR_RSTSTA.  Let's only reset that once
per interrupt handler.

TODO: actually do something useful at that point.  We currently don't
report those to the host, nor do we attempt to recover in any way.  The
data sheet also doesn't tell us what it actually does in such
situations; it appears the character is *not* returned from the USART,
so we're missing one byte in the stream at that point.

Change-Id: I5f012d86c61a2377d355396e7b95d078952bee7c
Related: OS#5464
  • Loading branch information
laf0rge committed Nov 19, 2022
1 parent cfab7c0 commit 0190e45
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions firmware/libcommon/source/sniffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -800,14 +800,14 @@ void Sniffer_usart_isr(void)
/* Read channel status register */
uint32_t csr = sniff_usart.base->US_CSR;
/* Verify if there was an error */
if (csr & US_CSR_OVRE) {
TRACE_WARNING("USART overrun error\n\r");
if (csr & US_CSR_OVRE)
TRACE_ERROR("USART overrun error\n\r");
if (csr & US_CSR_FRAME)
TRACE_ERROR("USART framing error\n\r");
if (csr & US_CSR_PARE)
TRACE_ERROR("USART parity error\n\r");
if (csr & (US_CSR_OVRE|US_CSR_FRAME|US_CSR_PARE))
sniff_usart.base->US_CR |= US_CR_RSTSTA;
}
if (csr & US_CSR_FRAME) {
TRACE_WARNING("USART framing error\n\r");
sniff_usart.base->US_CR |= US_CR_RSTSTA;
}

/* Verify if character has been received */
if (csr & US_CSR_RXRDY) {
Expand Down

0 comments on commit 0190e45

Please sign in to comment.