Skip to content

Commit

Permalink
use frequency multiplier in SetBaudrate/GetBaudrate
Browse files Browse the repository at this point in the history
  • Loading branch information
antongus committed Sep 24, 2017
1 parent d12c04f commit 4030c5d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions stm32_uart_driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -614,9 +614,9 @@ class UartDriver
INLINE static void Disable() { USARTx->CR1 &= ~USART_CR1_UE; }

INLINE static void SetBaudrate(Baudrate value, uint32_t busFreq = BUS_FREQ)
{ USARTx->BRR = (busFreq + value/2) / value;}
{ USARTx->BRR = (static_cast<unsigned long long>(busFreq) * BUS_FREQ_MUL + value/2) / value;}
INLINE static Baudrate GetBaudrate(uint32_t busFreq = BUS_FREQ)
{ return busFreq / USARTx->BRR; }
{ return static_cast<unsigned long long>(busFreq) * BUS_FREQ_MUL / USARTx->BRR; }

#if (defined STM32TPL_STM32L0XX) || (defined STM32TPL_STM32F0XX)
INLINE static uint32_t Status() { return USARTx->ISR; }
Expand Down

0 comments on commit 4030c5d

Please sign in to comment.