Skip to content

Commit

Permalink
squash LPUART discard erroneous frames
Browse files Browse the repository at this point in the history
  • Loading branch information
Joakim Nohlgård committed Sep 27, 2017
1 parent c17cf2b commit 6b64133
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions cpu/kinetis_common/periph/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -326,14 +326,32 @@ static inline void irq_handler_lpuart(uart_t uart)
{
LPUART_Type *dev = uart_config[uart].dev;

if (dev->STAT & LPUART_STAT_RDRF_MASK) {
if (stat & LPUART_STAT_RDRF_MASK) {
/* RDRF flag will be cleared when LPUART_DATA is read */
uint8_t data = dev->DATA;

if (config[uart].rx_cb != NULL) {
if (stat & (LPUART_STAT_FE_MASK | LPUART_STAT_PF_MASK)) {
if (stat & LPUART_STAT_FE_MASK) {
DEBUG("LPUART framing error %08" PRIx32 "\n", stat);
}
if (stat & LPUART_STAT_PF_MASK) {
DEBUG("LPUART parity error %08" PRIx32 "\n", stat);
}
/* FE is set whenever the next character to be read from LPUART_DATA
* was received with logic 0 detected where a stop bit was expected. */
/* PF is set whenever the next character to be read from LPUART_DATA
* was received when parity is enabled (PE = 1) and the parity bit in
* the received character does not agree with the expected parity value. */
}
/* Only run callback if no error occurred */
else if (config[uart].rx_cb != NULL) {
config[uart].rx_cb(config[uart].arg, data);
}
}
if (stat & LPUART_STAT_OR_MASK) {
/* Input buffer overflow, means that the software was too slow to
* receive the data */
DEBUG("LPUART overrun %08" PRIx32 "\n", stat);
}

cortexm_isr_end();
}
Expand Down

0 comments on commit 6b64133

Please sign in to comment.