diff options
Diffstat (limited to 'chip')
-rw-r--r-- | chip/stm32/usart.c | 7 | ||||
-rw-r--r-- | chip/stm32/usart.h | 3 |
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; |