diff options
Diffstat (limited to 'chip/stm32/usart.c')
-rw-r--r-- | chip/stm32/usart.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/chip/stm32/usart.c b/chip/stm32/usart.c index 7f8c55aaa6..be9d0a4571 100644 --- a/chip/stm32/usart.c +++ b/chip/stm32/usart.c @@ -1,4 +1,4 @@ -/* Copyright 2014 The Chromium OS Authors. All rights reserved. +/* Copyright 2014 The ChromiumOS Authors * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ @@ -45,7 +45,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) + defined(CHIP_FAMILY_STM32L4) if (config->flags & USART_CONFIG_FLAG_RX_INV) cr2 |= BIT(16); if (config->flags & USART_CONFIG_FLAG_TX_INV) @@ -87,11 +87,16 @@ void usart_shutdown(struct usart_config const *config) } void usart_set_baud_f0_l(struct usart_config const *config, int baud, - int frequency_hz) + int frequency_hz) { - int div = DIV_ROUND_NEAREST(frequency_hz, baud); + int div = DIV_ROUND_NEAREST(frequency_hz, baud); intptr_t base = config->hw->base; +#ifdef STM32_USART9_BASE + if (config->hw->base == STM32_USART9_BASE) /* LPUART */ + div *= 256; +#endif + if (div / 16 > 0) { /* * CPU clock is high enough to support x16 oversampling. @@ -110,10 +115,15 @@ void usart_set_baud_f0_l(struct usart_config const *config, int baud, } void usart_set_baud_f(struct usart_config const *config, int baud, - int frequency_hz) + int frequency_hz) { int div = DIV_ROUND_NEAREST(frequency_hz, baud); +#ifdef STM32_USART9_BASE + if (config->hw->base == STM32_USART9_BASE) /* LPUART */ + div *= 256; +#endif + /* STM32F only supports x16 oversampling */ STM32_USART_BRR(config->hw->base) = div; } |