summaryrefslogtreecommitdiff
path: root/chip/stm32/usart.c
diff options
context:
space:
mode:
authorAnton Staaf <robotboy@chromium.org>2015-02-18 10:25:45 -0800
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2015-02-24 03:08:07 +0000
commitd2964ba0cf936dc46da3b8f102a420483d0e69d2 (patch)
tree014f73cb92cb11f4de7242423b345474e041dc5b /chip/stm32/usart.c
parenta8628526a3a4790a1890ecffc6df1d42644697c8 (diff)
downloadchrome-ec-d2964ba0cf936dc46da3b8f102a420483d0e69d2.tar.gz
USART: Add STM32F3 support and fix STM32F baud rate bug
Previously the STM32F3 support was non-functional due to it being a cut and paste of the STM32F0, and the clocks are not set up the same way on the two platforms. Also, the STM32F initialization code was incorrectly calling the F0/L buad rate setup code. This change has the variant specific USART code pass the input frequency to the baud rate divisor clock to the baud rate setup code, instead of that code calling clock_get_freq() to determine the input clock frequency. This is required because the STM32F3 is not configured such that the clock_get_freq value and the input to the USART baud rate divisor match. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Verify USART works on discovery as well as Ryu Change-Id: I71248d83b53969d0e7020747a9bb9570803f30ac Reviewed-on: https://chromium-review.googlesource.com/250920 Reviewed-by: Vic Yang <victoryang@chromium.org> Trybot-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org> Commit-Queue: Anton Staaf <robotboy@chromium.org>
Diffstat (limited to 'chip/stm32/usart.c')
-rw-r--r--chip/stm32/usart.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/chip/stm32/usart.c b/chip/stm32/usart.c
index 29cb0b705f..d97eb45565 100644
--- a/chip/stm32/usart.c
+++ b/chip/stm32/usart.c
@@ -6,7 +6,6 @@
/* USART driver for Chrome EC */
#include "atomic.h"
-#include "clock.h"
#include "common.h"
#include "gpio.h"
#include "registers.h"
@@ -117,9 +116,9 @@ void usart_shutdown(struct usart_config const *config)
config->hw->ops->disable(config);
}
-void usart_set_baud_f0_l(struct usart_config const *config)
+void usart_set_baud_f0_l(struct usart_config const *config, int frequency_hz)
{
- int div = DIV_ROUND_NEAREST(clock_get_freq(), config->baud);
+ int div = DIV_ROUND_NEAREST(frequency_hz, config->baud);
intptr_t base = config->hw->base;
if (div / 16 > 0) {
@@ -139,9 +138,9 @@ void usart_set_baud_f0_l(struct usart_config const *config)
}
}
-void usart_set_baud_f(struct usart_config const *config)
+void usart_set_baud_f(struct usart_config const *config, int frequency_hz)
{
- int div = DIV_ROUND_NEAREST(clock_get_freq(), config->baud);
+ int div = DIV_ROUND_NEAREST(frequency_hz, config->baud);
/* STM32F only supports x16 oversampling */
STM32_USART_BRR(config->hw->base) = div;