summaryrefslogtreecommitdiff
path: root/chip/stm32
diff options
context:
space:
mode:
authorNicolas Boichat <drinkcat@chromium.org>2017-11-20 17:36:55 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-12-15 05:32:29 -0800
commit575c03f31c5c92144e8ee034d2b99679db09785f (patch)
tree2c43d3316cb64e656a0271fba1e6c14eb2b6acc1 /chip/stm32
parent7610082ddc18640b1f7fd810fdf442592acb2e46 (diff)
downloadchrome-ec-575c03f31c5c92144e8ee034d2b99679db09785f.tar.gz
chip/stm32: Add support for half-duplex UART
BRANCH=none BUG=b:65697962 TEST=make BOARD=wand -j Change-Id: I2af4acb5cce6da6ce2f01d6d60cf5e806c9a4ed2 Signed-off-by: Nicolas Boichat <drinkcat@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/821891 Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Diffstat (limited to 'chip/stm32')
-rw-r--r--chip/stm32/usart.c7
-rw-r--r--chip/stm32/usart.h3
2 files changed, 7 insertions, 3 deletions
diff --git a/chip/stm32/usart.c b/chip/stm32/usart.c
index 75859fa979..893303deaf 100644
--- a/chip/stm32/usart.c
+++ b/chip/stm32/usart.c
@@ -17,7 +17,7 @@
void usart_init(struct usart_config const *config)
{
intptr_t base = config->hw->base;
- uint32_t cr2;
+ uint32_t cr2, cr3;
/*
* Enable clock to USART, this must be done first, before attempting
@@ -43,6 +43,7 @@ void usart_init(struct usart_config const *config)
*/
cr2 = 0x0000;
+ cr3 = 0x0000;
#if defined(CHIP_FAMILY_STM32F0) || defined(CHIP_FAMILY_STM32F3) || \
defined(CHIP_FAMILY_STM32L4)
if (config->flags & USART_CONFIG_FLAG_RX_INV)
@@ -50,10 +51,12 @@ void usart_init(struct usart_config const *config)
if (config->flags & USART_CONFIG_FLAG_TX_INV)
cr2 |= (1 << 17);
#endif
+ if (config->flags & USART_CONFIG_FLAG_HDSEL)
+ cr3 |= (1 << 3);
STM32_USART_CR1(base) = 0x0000;
STM32_USART_CR2(base) = cr2;
- STM32_USART_CR3(base) = 0x0000;
+ STM32_USART_CR3(base) = cr3;
/*
* Enable the RX, TX, and variant specific HW.
diff --git a/chip/stm32/usart.h b/chip/stm32/usart.h
index e158382b58..d218f64fd5 100644
--- a/chip/stm32/usart.h
+++ b/chip/stm32/usart.h
@@ -133,9 +133,10 @@ struct usart_config {
*/
int baud;
- /* Other flags. */
+ /* Other flags (rx/tx inversion, half-duplex). */
#define USART_CONFIG_FLAG_RX_INV (1 << 0)
#define USART_CONFIG_FLAG_TX_INV (1 << 1)
+#define USART_CONFIG_FLAG_HDSEL (1 << 2)
unsigned int flags;
struct consumer consumer;