Skip to content

Commit

Permalink
drivers: uart: stm32: improve STM32L0 support
Browse files Browse the repository at this point in the history
STM32L0 UARTs are named as STM32F0 ones, but their
clocking is like all other families.

Signed-off-by: Ilya Tagunov <tagunil@gmail.com>
  • Loading branch information
tagunil authored and Anas Nashif committed Mar 21, 2018
1 parent 84cffc7 commit 08418a2
Showing 1 changed file with 27 additions and 6 deletions.
33 changes: 27 additions & 6 deletions drivers/serial/uart_stm32.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,11 +360,13 @@ DEVICE_AND_API_INIT(uart_stm32_##n, CONFIG_UART_STM32_PORT_##n##_NAME, \
\
STM32_UART_IRQ_HANDLER(n)

/* STM32F0 Series differs from other STM32FX series in regard to the clock
* busses used for USARTS and the naming of the corresponding peripheral Enable
* bitmasks.
/*
* STM32F0 and STM32L0 series differ from other STM32 series by some
* peripheral names (UART vs USART). Besides, STM32F0 doesn't have APB2 bus,
* so APB1 GRP2 should be accessed instead.
*/
#ifdef CONFIG_SOC_SERIES_STM32F0X
#if defined(CONFIG_SOC_SERIES_STM32F0X)

#ifdef CONFIG_UART_STM32_PORT_1
UART_DEVICE_INIT_STM32(1, STM32_CLOCK_BUS_APB1_2, LL_APB1_GRP2_PERIPH_USART1)
#endif /* CONFIG_UART_STM32_PORT_1 */
Expand Down Expand Up @@ -397,7 +399,25 @@ UART_DEVICE_INIT_STM32(7, STM32_CLOCK_BUS_APB1_2, LL_APB1_GRP2_PERIPH_USART7)
UART_DEVICE_INIT_STM32(8, STM32_CLOCK_BUS_APB1_2, LL_APB1_GRP2_PERIPH_USART8)
#endif /* CONFIG_UART_STM32_PORT_8 */

#else /* CONFIG_SOC_SERIES_STM32F0X */
#elif defined(CONFIG_SOC_SERIES_STM32L0X)

#ifdef CONFIG_UART_STM32_PORT_1
UART_DEVICE_INIT_STM32(1, STM32_CLOCK_BUS_APB2, LL_APB2_GRP1_PERIPH_USART1)
#endif /* CONFIG_UART_STM32_PORT_1 */

#ifdef CONFIG_UART_STM32_PORT_2
UART_DEVICE_INIT_STM32(2, STM32_CLOCK_BUS_APB1, LL_APB1_GRP1_PERIPH_USART2)
#endif /* CONFIG_UART_STM32_PORT_2 */

#ifdef CONFIG_UART_STM32_PORT_4
UART_DEVICE_INIT_STM32(4, STM32_CLOCK_BUS_APB1, LL_APB1_GRP1_PERIPH_USART4)
#endif /* CONFIG_UART_STM32_PORT_4 */

#ifdef CONFIG_UART_STM32_PORT_5
UART_DEVICE_INIT_STM32(5, STM32_CLOCK_BUS_APB1, LL_APB1_GRP1_PERIPH_USART5)
#endif /* CONFIG_UART_STM32_PORT_5 */

#else

#ifdef CONFIG_UART_STM32_PORT_1
UART_DEVICE_INIT_STM32(1, STM32_CLOCK_BUS_APB2, LL_APB2_GRP1_PERIPH_USART1)
Expand Down Expand Up @@ -438,4 +458,5 @@ UART_DEVICE_INIT_STM32(9, STM32_CLOCK_BUS_APB2, LL_APB2_GRP1_PERIPH_UART9)
#ifdef CONFIG_UART_STM32_PORT_10
UART_DEVICE_INIT_STM32(10, STM32_CLOCK_BUS_APB2, LL_APB2_GRP1_PERIPH_UART10)
#endif /* CONFIG_UART_STM32_PORT_10 */
#endif /* CONFIG_SOC_SERIES_STM32F0X */

#endif

0 comments on commit 08418a2

Please sign in to comment.