aboutsummaryrefslogtreecommitdiff
path: root/lib/stm32/usart.c
diff options
context:
space:
mode:
authorFergus Noble2012-01-31 15:11:17 -0800
committerUwe Hermann2012-02-06 23:08:07 +0100
commit7c67322f753e9f33a98ea2393c8345db479abf69 (patch)
tree600705781e68db0ea5c9aa0d370f6ebd4d9e1392 /lib/stm32/usart.c
parentd071a9ffde5160a0f6cdaa2fe8f991ba9b5f9226 (diff)
Change stm32 usart baud rate generation to round rather than floor for more accurate divisor selection.
Diffstat (limited to 'lib/stm32/usart.c')
-rw-r--r--lib/stm32/usart.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/stm32/usart.c b/lib/stm32/usart.c
index 3de0eb4..a2c9f16 100644
--- a/lib/stm32/usart.c
+++ b/lib/stm32/usart.c
@@ -52,8 +52,10 @@ void usart_set_baudrate(u32 usart, u32 baud)
* marketting bable to sound awesome. It is nothing else but a
* simple divider to generate the correct baudrate. >_< If I
* am wrong feel free to correct me on that. :) (esden)
+ *
+ * Changed to round rather than floor (Fergus)
*/
- USART_BRR(usart) = clock / baud;
+ USART_BRR(usart) = (2*clock + baud) / (2*baud);
}
void usart_set_databits(u32 usart, u32 bits)