diff options
author | Anton Staaf <robotboy@chromium.org> | 2015-07-28 10:30:44 -0700 |
---|---|---|
committer | ChromeOS Commit Bot <chromeos-commit-bot@chromium.org> | 2015-08-10 17:54:17 +0000 |
commit | 014d180b1da90a5e23f2ebd4df3d00457bc5fb28 (patch) | |
tree | e6ac67ab0e24d86d82e2e93fc811261bddd66568 /chip/stm32/usart_rx_interrupt.c | |
parent | 77f68f204f2e27f7ed7e80bcdd1e36280bbcff83 (diff) | |
download | chrome-ec-014d180b1da90a5e23f2ebd4df3d00457bc5fb28.tar.gz |
USART: Split RX driver between L and F families
The USART peripheral in the L and F families is different enough to need
different receive drivers. In particular, the L family USART perihperal
has no way of disabling the overflow error bit. So for that family we
check and clear the bit, and keep a count of overflows.
Signed-off-by: Anton Staaf <robotboy@chromium.org>
BRANCH=None
BUG=None
TEST=make buildall -j
Change-Id: Iea26c242d5177afd552a3bd4d6ab1a9c7a65f90e
Reviewed-on: https://chromium-review.googlesource.com/288978
Trybot-Ready: Anton Staaf <robotboy@chromium.org>
Tested-by: Anton Staaf <robotboy@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Queue: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'chip/stm32/usart_rx_interrupt.c')
-rw-r--r-- | chip/stm32/usart_rx_interrupt.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/chip/stm32/usart_rx_interrupt.c b/chip/stm32/usart_rx_interrupt.c index ea1b4a4c6a..d4fb48f5a0 100644 --- a/chip/stm32/usart_rx_interrupt.c +++ b/chip/stm32/usart_rx_interrupt.c @@ -3,7 +3,7 @@ * found in the LICENSE file. */ -/* Interrupt based USART RX driver for STM32 */ +/* Interrupt based USART RX driver for STM32F0 and STM32F3 */ #include "usart.h" @@ -18,20 +18,20 @@ static void usart_rx_init(struct usart_config const *config) STM32_USART_CR1(base) |= STM32_USART_CR1_RXNEIE; STM32_USART_CR1(base) |= STM32_USART_CR1_RE; + STM32_USART_CR3(base) |= STM32_USART_CR3_OVRDIS; } static void usart_rx_interrupt_handler(struct usart_config const *config) { - intptr_t base = config->hw->base; - uint8_t byte; - - if (!(STM32_USART_SR(base) & STM32_USART_SR_RXNE)) - return; + intptr_t base = config->hw->base; + int32_t status = STM32_USART_SR(base); - byte = STM32_USART_RDR(base); + if (status & STM32_USART_SR_RXNE) { + uint8_t byte = STM32_USART_RDR(base); - if (!queue_add_unit(config->producer.queue, &byte)) - atomic_add(&config->state->rx_dropped, 1); + if (!queue_add_unit(config->producer.queue, &byte)) + atomic_add(&config->state->rx_dropped, 1); + } } struct usart_rx const usart_rx_interrupt = { |