diff options
Diffstat (limited to 'os/hal/platforms/STM32/USARTv2')
-rw-r--r-- | os/hal/platforms/STM32/USARTv2/serial_lld.c | 10 | ||||
-rw-r--r-- | os/hal/platforms/STM32/USARTv2/serial_lld.h | 4 |
2 files changed, 9 insertions, 5 deletions
diff --git a/os/hal/platforms/STM32/USARTv2/serial_lld.c b/os/hal/platforms/STM32/USARTv2/serial_lld.c index 3c6bb272a..40195319b 100644 --- a/os/hal/platforms/STM32/USARTv2/serial_lld.c +++ b/os/hal/platforms/STM32/USARTv2/serial_lld.c @@ -93,10 +93,7 @@ static void usart_init(SerialDriver *sdp, const SerialConfig *config) { USART_TypeDef *u = sdp->usart;
/* Baud rate setting.*/
- if (sdp->usart == USART1)
- u->BRR = STM32_USART1CLK / config->sc_speed;
- else
- u->BRR = STM32_PCLK / config->sc_speed;
+ u->BRR = sdp->clock / config->sc_speed;
/* Note that some bits are enforced.*/
u->CR2 = config->sc_cr2 | USART_CR2_LBDIE;
@@ -373,26 +370,31 @@ void sd_lld_init(void) { #if STM32_SERIAL_USE_USART1
sdObjectInit(&SD1, NULL, notify1);
SD1.usart = USART1;
+ SD1.clock = STM32_USART1CLK;
#endif
#if STM32_SERIAL_USE_USART2
sdObjectInit(&SD2, NULL, notify2);
SD2.usart = USART2;
+ SD1.clock = STM32_USART2CLK;
#endif
#if STM32_SERIAL_USE_USART3
sdObjectInit(&SD3, NULL, notify3);
SD3.usart = USART3;
+ SD1.clock = STM32_USART3CLK;
#endif
#if STM32_SERIAL_USE_UART4
sdObjectInit(&SD4, NULL, notify4);
SD4.usart = UART4;
+ SD1.clock = STM32_UART4CLK;
#endif
#if STM32_SERIAL_USE_UART5
sdObjectInit(&SD5, NULL, notify5);
SD5.usart = UART5;
+ SD1.clock = STM32_UART5CLK;
#endif
#if STM32_SERIAL_USE_USART6
diff --git a/os/hal/platforms/STM32/USARTv2/serial_lld.h b/os/hal/platforms/STM32/USARTv2/serial_lld.h index d3b3a9352..639884fdb 100644 --- a/os/hal/platforms/STM32/USARTv2/serial_lld.h +++ b/os/hal/platforms/STM32/USARTv2/serial_lld.h @@ -252,7 +252,9 @@ typedef struct { uint8_t ob[SERIAL_BUFFERS_SIZE]; \
/* End of the mandatory fields.*/ \
/* Pointer to the USART registers block.*/ \
- USART_TypeDef *usart;
+ USART_TypeDef *usart; \
+ /* Clock frequency for this USART.*/ \
+ uint32_t clock;
/*===========================================================================*/
/* Driver macros. */
|