aboutsummaryrefslogtreecommitdiff
path: root/lib/stm32/usart.c
diff options
context:
space:
mode:
authorPiotr Esden-Tempski2011-11-16 18:06:20 -0800
committerPiotr Esden-Tempski2011-11-16 18:41:48 -0800
commit8af809a12a26c1c4670627b92807eabb970209c6 (patch)
tree5849d32794cc52c40d48518a21d36b90df51b98c /lib/stm32/usart.c
parent679f39426f4806b32fbdc66164575bbfe8347555 (diff)
Reverted the api of the usart_set_baudrate function to hide the clock rail selection again.
Diffstat (limited to 'lib/stm32/usart.c')
-rw-r--r--lib/stm32/usart.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/lib/stm32/usart.c b/lib/stm32/usart.c
index b97422e..3de0eb4 100644
--- a/lib/stm32/usart.c
+++ b/lib/stm32/usart.c
@@ -19,13 +19,33 @@
#include <libopencm3/stm32/usart.h>
-void usart_set_baudrate(u32 usart, u32 baud, u32 clock)
+#if defined(STM32F1)
+# include <libopencm3/stm32/f1/rcc.h>
+#elif defined(STM32F2)
+# include <libopencm3/stm32/f2/rcc.h>
+#elif defined(STM32F4)
+# include <libopencm3/stm32/f4/rcc.h>
+#else
+# error "stm32 family not defined."
+#endif
+
+void usart_set_baudrate(u32 usart, u32 baud)
{
- //u32 clock = rcc_ppre1_frequency;
+ u32 clock = rcc_ppre1_frequency;
- //if (usart == USART1) {
- // clock = rcc_ppre2_frequency;
- //}
+//#ifdef STM32F1
+ if (usart == USART1) {
+ clock = rcc_ppre2_frequency;
+ }
+/* This has to be added for F2 when it get's support for USART6 */
+/*
+#else
+ if ((usart == USART1) ||
+ (usart == USART6)) {
+ clock = rcc_ppre2_frequency;
+ }
+#endif
+*/
/* yes it is as simple as that. The reference manual is
* talking about factional calculation but it seems to be only