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.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/lib/stm32/usart.c b/lib/stm32/usart.c
index 7995a52..7ce0ddc 100644
--- a/lib/stm32/usart.c
+++ b/lib/stm32/usart.c
@@ -47,15 +47,16 @@ void usart_set_baudrate(u32 usart, u32 baud)
#endif
*/
- /* yes it is as simple as that. The reference manual is
- * talking about factional calculation but it seems to be only
- * 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)
+ /*
+ * Yes it is as simple as that. The reference manual is
+ * talking about fractional calculation but it seems to be only
+ * marketting babble to sound awesome. It is nothing else but a
+ * simple divider to generate the correct baudrate.
+ *
+ * Note: We round() the value rather than floor()ing it, for more
+ * accurate divisor selection.
*/
- USART_BRR(usart) = (2*clock + baud) / (2*baud);
+ USART_BRR(usart) = ((2 * clock) + baud) / (2 * baud);
}
void usart_set_databits(u32 usart, u32 bits)
@@ -151,21 +152,20 @@ u16 usart_recv_blocking(u32 usart)
void usart_enable_rx_dma(u32 usart)
{
- USART_CR3(usart) |= USART_CR3_DMAR;
+ USART_CR3(usart) |= USART_CR3_DMAR;
}
void usart_disable_rx_dma(u32 usart)
{
- USART_CR3(usart) &= ~USART_CR3_DMAR;
+ USART_CR3(usart) &= ~USART_CR3_DMAR;
}
void usart_enable_tx_dma(u32 usart)
{
- USART_CR3(usart) |= USART_CR3_DMAT;
+ USART_CR3(usart) |= USART_CR3_DMAT;
}
void usart_disable_tx_dma(u32 usart)
{
- USART_CR3(usart) &= ~USART_CR3_DMAT;
+ USART_CR3(usart) &= ~USART_CR3_DMAT;
}
-