aboutsummaryrefslogtreecommitdiff
path: root/lib/stm32/usart.c
diff options
context:
space:
mode:
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