From 8af809a12a26c1c4670627b92807eabb970209c6 Mon Sep 17 00:00:00 2001 From: Piotr Esden-Tempski Date: Wed, 16 Nov 2011 18:06:20 -0800 Subject: Reverted the api of the usart_set_baudrate function to hide the clock rail selection again. --- lib/stm32/usart.c | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) (limited to 'lib/stm32/usart.c') 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 -void usart_set_baudrate(u32 usart, u32 baud, u32 clock) +#if defined(STM32F1) +# include +#elif defined(STM32F2) +# include +#elif defined(STM32F4) +# include +#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 -- cgit v1.2.3