diff options
author | Nicolas Boichat <drinkcat@chromium.org> | 2018-08-27 16:05:09 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-08-29 11:15:45 -0700 |
commit | 7eb9ff3cfcf4b96356050da66bd957225bef6044 (patch) | |
tree | 62b5f35d135e99fa14e582d3487fabb6fa41aab2 /chip/stm32/usart-stm32f0.c | |
parent | 63fd7e18588023b2940167b686611e609354b78a (diff) | |
download | chrome-ec-7eb9ff3cfcf4b96356050da66bd957225bef6044.tar.gz |
servo_micro: Allow setting the baud rate for usart
We set the baud rate in increments of 100 baud, to avoid
overflowing the 16-bit wValue integer (921600 is the highest we
are likely to use).
Also, increment the buffer size for USART3 to 1024 bytes. That
helps a bit to avoid losing characters, but we still can't keep
up if the host is printing at maximum speed.
BRANCH=servo
BUG=chromium:876651
TEST=baud usart2/3/4 115200 in servo_micro console
TEST=dut-control cpu_uart_baudrate:921600
seq 1 1000 shows numbers 1 to 226 before buffer overflows
Change-Id: Ifca266189f93def493f207dd29d2cceca4d8d68f
Signed-off-by: Nicolas Boichat <drinkcat@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1189782
Reviewed-by: Nick Sanders <nsanders@chromium.org>
Diffstat (limited to 'chip/stm32/usart-stm32f0.c')
-rw-r--r-- | chip/stm32/usart-stm32f0.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/chip/stm32/usart-stm32f0.c b/chip/stm32/usart-stm32f0.c index 8ae2085498..54d68977ef 100644 --- a/chip/stm32/usart-stm32f0.c +++ b/chip/stm32/usart-stm32f0.c @@ -36,11 +36,16 @@ static void usart_variant_enable(struct usart_config const *config) */ configs[config->hw->index] = config; - usart_set_baud_f0_l(config, clock_get_freq()); + usart_set_baud(config, config->baud); task_enable_irq(config->hw->irq); } +void usart_set_baud(struct usart_config const *config, int baud) +{ + usart_set_baud_f0_l(config, baud, clock_get_freq()); +} + static void usart_variant_disable(struct usart_config const *config) { int index = config->hw->index; @@ -69,7 +74,8 @@ static void freq_change(void) for (i = 0; i < ARRAY_SIZE(configs); ++i) if (configs[i]) - usart_set_baud_f0_l(configs[i], clock_get_freq()); + usart_set_baud_f0_l(configs[i], configs[i]->baud, + clock_get_freq()); } DECLARE_HOOK(HOOK_FREQ_CHANGE, freq_change, HOOK_PRIO_DEFAULT); |