From 9532195e65edcec7d2f55dbb71f00bb18a04dac8 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Mon, 6 Feb 2012 23:39:06 +0100 Subject: More coding-style and cosmetic fixes. --- lib/stm32/usart.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'lib/stm32/usart.c') 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; } - -- cgit v1.2.3