diff --git a/arch/arm/soc/st_stm32/stm32f4/Kconfig.defconfig.series b/arch/arm/soc/st_stm32/stm32f4/Kconfig.defconfig.series index 7b7ad2bc359..a9b243f3e66 100644 --- a/arch/arm/soc/st_stm32/stm32f4/Kconfig.defconfig.series +++ b/arch/arm/soc/st_stm32/stm32f4/Kconfig.defconfig.series @@ -40,15 +40,6 @@ config UART_CONSOLE config UART_STM32 def_bool y -config UART_STM32_PORT_0 - def_bool y - -config UART_STM32_PORT_0_NAME - default UART_0 - -config UART_STM32_PORT_0_BAUD_RATE - default 115200 - config UART_STM32_PORT_1 def_bool y @@ -58,6 +49,15 @@ config UART_STM32_PORT_1_NAME config UART_STM32_PORT_1_BAUD_RATE default 115200 +config UART_STM32_PORT_2 + def_bool y + +config UART_STM32_PORT_2_NAME + default UART_2 + +config UART_STM32_PORT_2_BAUD_RATE + default 115200 + endif #SERIAL if CLOCK_CONTROL diff --git a/boards/arm/96b_carbon/96b_carbon_defconfig b/boards/arm/96b_carbon/96b_carbon_defconfig index 72f345bbc1f..fa36d7a16d2 100644 --- a/boards/arm/96b_carbon/96b_carbon_defconfig +++ b/boards/arm/96b_carbon/96b_carbon_defconfig @@ -7,10 +7,10 @@ CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=84000000 CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000 # enable USART1 - passthrough to FT230XQ -CONFIG_UART_STM32_PORT_0=y -CONFIG_UART_STM32_PORT_0_BAUD_RATE=115200 +CONFIG_UART_STM32_PORT_1=y +CONFIG_UART_STM32_PORT_1_BAUD_RATE=115200 # enable console on this port by default -CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_0" +CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_1" # enable pinmux CONFIG_PINMUX=y diff --git a/boards/arm/nucleo_f103rb/nucleo_f103rb_defconfig b/boards/arm/nucleo_f103rb/nucleo_f103rb_defconfig index d29215532bd..a3fbbd906cc 100644 --- a/boards/arm/nucleo_f103rb/nucleo_f103rb_defconfig +++ b/boards/arm/nucleo_f103rb/nucleo_f103rb_defconfig @@ -11,12 +11,12 @@ CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=72000000 CONFIG_SERIAL=y CONFIG_UART_STM32=y # enable USART2 - passthrough to STLINK v2 connector -CONFIG_UART_STM32_PORT_1=y -CONFIG_UART_STM32_PORT_1_BAUD_RATE=115200 +CONFIG_UART_STM32_PORT_2=y +CONFIG_UART_STM32_PORT_2_BAUD_RATE=115200 # enable console on this port by default CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y -CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_1" +CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_2" # enable pinmux CONFIG_PINMUX=y diff --git a/boards/arm/nucleo_f401re/nucleo_f401re_defconfig b/boards/arm/nucleo_f401re/nucleo_f401re_defconfig index 879c630418f..9d04f788621 100644 --- a/boards/arm/nucleo_f401re/nucleo_f401re_defconfig +++ b/boards/arm/nucleo_f401re/nucleo_f401re_defconfig @@ -7,10 +7,10 @@ CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=84000000 CONFIG_SYS_CLOCK_TICKS_PER_SEC=1000 # enable USART2 - passthrough to STLINK v2 connector -CONFIG_UART_STM32_PORT_1=y -CONFIG_UART_STM32_PORT_1_BAUD_RATE=115200 +CONFIG_UART_STM32_PORT_2=y +CONFIG_UART_STM32_PORT_2_BAUD_RATE=115200 # enable console on this port by default -CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_1" +CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_2" # enable pinmux CONFIG_PINMUX=y diff --git a/boards/arm/olimexino_stm32/olimexino_stm32_defconfig b/boards/arm/olimexino_stm32/olimexino_stm32_defconfig index 1ea4db3c3db..42969c21966 100644 --- a/boards/arm/olimexino_stm32/olimexino_stm32_defconfig +++ b/boards/arm/olimexino_stm32/olimexino_stm32_defconfig @@ -11,12 +11,12 @@ CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=72000000 CONFIG_SERIAL=y CONFIG_UART_STM32=y # enable USART1 -CONFIG_UART_STM32_PORT_0=y -CONFIG_UART_STM32_PORT_0_BAUD_RATE=115200 +CONFIG_UART_STM32_PORT_1=y +CONFIG_UART_STM32_PORT_1_BAUD_RATE=115200 # enable console on this port by default CONFIG_CONSOLE=y CONFIG_UART_CONSOLE=y -CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_0" +CONFIG_UART_CONSOLE_ON_DEV_NAME="UART_1" # enable pinmux diff --git a/boards/arm/stm32_mini_a15/stm32_mini_a15_defconfig b/boards/arm/stm32_mini_a15/stm32_mini_a15_defconfig index d8fd1fed033..d6ab3ba4ecd 100644 --- a/boards/arm/stm32_mini_a15/stm32_mini_a15_defconfig +++ b/boards/arm/stm32_mini_a15/stm32_mini_a15_defconfig @@ -10,8 +10,8 @@ CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=72000000 # enable uart driver CONFIG_SERIAL=y CONFIG_UART_STM32=y -CONFIG_UART_STM32_PORT_0=y -CONFIG_UART_STM32_PORT_0_BAUD_RATE=115200 +CONFIG_UART_STM32_PORT_1=y +CONFIG_UART_STM32_PORT_1_BAUD_RATE=115200 # enable pinmux CONFIG_PINMUX=y diff --git a/drivers/pinmux/stm32/pinmux_board_carbon.c b/drivers/pinmux/stm32/pinmux_board_carbon.c index 9da3fa130cb..2a8ae5ce238 100644 --- a/drivers/pinmux/stm32/pinmux_board_carbon.c +++ b/drivers/pinmux/stm32/pinmux_board_carbon.c @@ -25,14 +25,14 @@ /* pin assignments for 96boards Carbon board */ static const struct pin_config pinconf[] = { -#ifdef CONFIG_UART_STM32_PORT_0 +#ifdef CONFIG_UART_STM32_PORT_1 {STM32_PIN_PA9, STM32F4_PINMUX_FUNC_PA9_USART1_TX}, {STM32_PIN_PA10, STM32F4_PINMUX_FUNC_PA10_USART1_RX}, -#endif /* CONFIG_UART_STM32_PORT_0 */ -#ifdef CONFIG_UART_STM32_PORT_1 +#endif /* CONFIG_UART_STM32_PORT_1 */ +#ifdef CONFIG_UART_STM32_PORT_2 {STM32_PIN_PA2, STM32F4_PINMUX_FUNC_PA2_USART2_TX}, {STM32_PIN_PA3, STM32F4_PINMUX_FUNC_PA3_USART2_RX}, -#endif /* CONFIG_UART_STM32_PORT_1 */ +#endif /* CONFIG_UART_STM32_PORT_2 */ }; static int pinmux_stm32_init(struct device *port) diff --git a/drivers/pinmux/stm32/pinmux_board_nucleo_f103rb.c b/drivers/pinmux/stm32/pinmux_board_nucleo_f103rb.c index de38084549a..9fc2bd638de 100644 --- a/drivers/pinmux/stm32/pinmux_board_nucleo_f103rb.c +++ b/drivers/pinmux/stm32/pinmux_board_nucleo_f103rb.c @@ -25,18 +25,18 @@ /* pin assignments for NUCLEO-F103RB board */ static const struct pin_config pinconf[] = { -#ifdef CONFIG_UART_STM32_PORT_0 +#ifdef CONFIG_UART_STM32_PORT_1 {STM32_PIN_PA9, STM32F1_PINMUX_FUNC_PA9_USART1_TX}, {STM32_PIN_PA10, STM32F1_PINMUX_FUNC_PA10_USART1_RX}, -#endif /* CONFIG_UART_STM32_PORT_0 */ -#ifdef CONFIG_UART_STM32_PORT_1 - {STM32_PIN_PA2, STM32F1_PINMUX_FUNC_PA2_USART2_TX}, - {STM32_PIN_PA3, STM32F1_PINMUX_FUNC_PA3_USART2_RX}, #endif /* CONFIG_UART_STM32_PORT_1 */ #ifdef CONFIG_UART_STM32_PORT_2 + {STM32_PIN_PA2, STM32F1_PINMUX_FUNC_PA2_USART2_TX}, + {STM32_PIN_PA3, STM32F1_PINMUX_FUNC_PA3_USART2_RX}, +#endif /* CONFIG_UART_STM32_PORT_2 */ +#ifdef CONFIG_UART_STM32_PORT_3 {STM32_PIN_PB10, STM32F1_PINMUX_FUNC_PB10_USART3_TX}, {STM32_PIN_PB11, STM32F1_PINMUX_FUNC_PB11_USART3_RX}, -#endif /* CONFIG_UART_STM32_PORT_2 */ +#endif /* CONFIG_UART_STM32_PORT_3 */ }; static int pinmux_stm32_init(struct device *port) diff --git a/drivers/pinmux/stm32/pinmux_board_nucleo_f401re.c b/drivers/pinmux/stm32/pinmux_board_nucleo_f401re.c index b87ae5d0082..3c6ddf3de1e 100644 --- a/drivers/pinmux/stm32/pinmux_board_nucleo_f401re.c +++ b/drivers/pinmux/stm32/pinmux_board_nucleo_f401re.c @@ -25,14 +25,14 @@ /* pin assignments for NUCLEO-F401RE board */ static const struct pin_config pinconf[] = { -#ifdef CONFIG_UART_STM32_PORT_0 +#ifdef CONFIG_UART_STM32_PORT_1 {STM32_PIN_PB6, STM32F4_PINMUX_FUNC_PB6_USART1_TX}, {STM32_PIN_PB7, STM32F4_PINMUX_FUNC_PB7_USART1_RX}, -#endif /* CONFIG_UART_STM32_PORT_0 */ -#ifdef CONFIG_UART_STM32_PORT_1 +#endif /* CONFIG_UART_STM32_PORT_1 */ +#ifdef CONFIG_UART_STM32_PORT_2 {STM32_PIN_PA2, STM32F4_PINMUX_FUNC_PA2_USART2_TX}, {STM32_PIN_PA3, STM32F4_PINMUX_FUNC_PA3_USART2_RX}, -#endif /* CONFIG_UART_STM32_PORT_1 */ +#endif /* CONFIG_UART_STM32_PORT_2 */ }; static int pinmux_stm32_init(struct device *port) diff --git a/drivers/pinmux/stm32/pinmux_board_olimexino_stm32.c b/drivers/pinmux/stm32/pinmux_board_olimexino_stm32.c index 447ab43a50a..1b1503c1990 100644 --- a/drivers/pinmux/stm32/pinmux_board_olimexino_stm32.c +++ b/drivers/pinmux/stm32/pinmux_board_olimexino_stm32.c @@ -25,18 +25,18 @@ /* pin assignments for NUCLEO-F103RB board */ static const struct pin_config pinconf[] = { -#ifdef CONFIG_UART_STM32_PORT_0 +#ifdef CONFIG_UART_STM32_PORT_1 {STM32_PIN_PA9, STM32F1_PINMUX_FUNC_PA9_USART1_TX}, {STM32_PIN_PA10, STM32F1_PINMUX_FUNC_PA10_USART1_RX}, -#endif /* CONFIG_UART_STM32_PORT_0 */ -#ifdef CONFIG_UART_STM32_PORT_1 +#endif /* CONFIG_UART_STM32_PORT_2 */ +#ifdef CONFIG_UART_STM32_PORT_2 {STM32_PIN_PA2, STM32F1_PINMUX_FUNC_PA2_USART2_TX}, {STM32_PIN_PA3, STM32F1_PINMUX_FUNC_PA3_USART2_RX}, -#endif /* CONFIG_UART_STM32_PORT_1 */ -#ifdef CONFIG_UART_STM32_PORT_2 +#endif /* CONFIG_UART_STM32_PORT_2 */ +#ifdef CONFIG_UART_STM32_PORT_3 {STM32_PIN_PB10, STM32F1_PINMUX_FUNC_PB10_USART3_TX}, {STM32_PIN_PB11, STM32F1_PINMUX_FUNC_PB11_USART3_RX}, -#endif /* CONFIG_UART_STM32_PORT_2 */ +#endif /* CONFIG_UART_STM32_PORT_3 */ }; static int pinmux_stm32_init(struct device *port) diff --git a/drivers/pinmux/stm32/pinmux_board_stm32_mini_a15.c b/drivers/pinmux/stm32/pinmux_board_stm32_mini_a15.c index e0595cab79a..8ea4c17a517 100644 --- a/drivers/pinmux/stm32/pinmux_board_stm32_mini_a15.c +++ b/drivers/pinmux/stm32/pinmux_board_stm32_mini_a15.c @@ -25,18 +25,18 @@ /* pin assignments for STM32 MINI A15 board */ static const struct pin_config pinconf[] = { -#ifdef CONFIG_UART_STM32_PORT_0 +#ifdef CONFIG_UART_STM32_PORT_1 {STM32_PIN_PA9, STM32F1_PINMUX_FUNC_PA9_USART1_TX}, {STM32_PIN_PA10, STM32F1_PINMUX_FUNC_PA10_USART1_RX}, -#endif /* CONFIG_UART_STM32_PORT_0 */ -#ifdef CONFIG_UART_STM32_PORT_1 - {STM32_PIN_PA2, STM32F1_PINMUX_FUNC_PA2_USART2_TX}, - {STM32_PIN_PA3, STM32F1_PINMUX_FUNC_PA3_USART2_RX}, #endif /* CONFIG_UART_STM32_PORT_1 */ #ifdef CONFIG_UART_STM32_PORT_2 + {STM32_PIN_PA2, STM32F1_PINMUX_FUNC_PA2_USART2_TX}, + {STM32_PIN_PA3, STM32F1_PINMUX_FUNC_PA3_USART2_RX}, +#endif /* CONFIG_UART_STM32_PORT_2 */ +#ifdef CONFIG_UART_STM32_PORT_3 {STM32_PIN_PB10, STM32F1_PINMUX_FUNC_PB10_USART3_TX}, {STM32_PIN_PB11, STM32F1_PINMUX_FUNC_PB11_USART3_RX}, -#endif /* CONFIG_UART_STM32_PORT_2 */ +#endif /* CONFIG_UART_STM32_PORT_3 */ }; static int pinmux_stm32_init(struct device *port) diff --git a/drivers/serial/Kconfig.stm32 b/drivers/serial/Kconfig.stm32 index ba0c58202ad..a36f08dc1e2 100644 --- a/drivers/serial/Kconfig.stm32 +++ b/drivers/serial/Kconfig.stm32 @@ -25,9 +25,9 @@ menuconfig UART_STM32 processors. Say y if you wish to use serial port on STM32F10x MCU. -# --- port 0 --- +# --- port 1 --- -config UART_STM32_PORT_0 +config UART_STM32_PORT_1 bool "Enable STM32 USART1 Port" default n depends on UART_STM32 @@ -35,44 +35,12 @@ config UART_STM32_PORT_0 Enable support for USART1 port in the driver. Say y here if you want to use USART1 device. -config UART_STM32_PORT_0_NAME - string "Device Name for STM32 USART1 Port" - default "UART_0" - depends on UART_STM32_PORT_0 - help - This is the device name for USART1 port, and is - included in the device struct. - -config UART_STM32_PORT_0_BAUD_RATE - int "STM32 USART1 Baud Rate" - default 9600 - depends on UART_STM32_PORT_0 - help - The baud rate for USART1 port to be set to at boot. - -config UART_STM32_PORT_0_IRQ_PRI - int "STM32 USART1 Interrupt Priority" - default 0 - depends on UART_STM32_PORT_0 && UART_INTERRUPT_DRIVEN - help - The interrupt priority for USART1 port. - -# --- port 1 --- - -config UART_STM32_PORT_1 - bool "Enable STM32 USART2 Port" - default n - depends on UART_STM32 - help - Enable support for USART2 port in the driver. Say y here - if you want to use USART2 device. - config UART_STM32_PORT_1_NAME string "Device Name for STM32 USART1 Port" default "UART_1" depends on UART_STM32_PORT_1 help - This is the device name for USART2 port, and is + This is the device name for USART1 port, and is included in the device struct. config UART_STM32_PORT_1_BAUD_RATE @@ -80,18 +48,50 @@ config UART_STM32_PORT_1_BAUD_RATE default 9600 depends on UART_STM32_PORT_1 help - The baud rate for USART2 port to be set to at boot. + The baud rate for USART1 port to be set to at boot. config UART_STM32_PORT_1_IRQ_PRI - int "STM32 USART2 Interrupt Priority" + int "STM32 USART1 Interrupt Priority" default 0 depends on UART_STM32_PORT_1 && UART_INTERRUPT_DRIVEN help - The interrupt priority for USART2 port. + The interrupt priority for USART1 port. # --- port 2 --- config UART_STM32_PORT_2 + bool "Enable STM32 USART2 Port" + default n + depends on UART_STM32 + help + Enable support for USART2 port in the driver. Say y here + if you want to use USART2 device. + +config UART_STM32_PORT_2_NAME + string "Device Name for STM32 USART2 Port" + default "UART_2" + depends on UART_STM32_PORT_2 + help + This is the device name for USART2 port, and is + included in the device struct. + +config UART_STM32_PORT_2_BAUD_RATE + int "STM32 USART2 Baud Rate" + default 9600 + depends on UART_STM32_PORT_2 + help + The baud rate for USART2 port to be set to at boot. + +config UART_STM32_PORT_2_IRQ_PRI + int "STM32 USART2 Interrupt Priority" + default 0 + depends on UART_STM32_PORT_2 && UART_INTERRUPT_DRIVEN + help + The interrupt priority for USART2 port. + +# --- port 3 --- + +config UART_STM32_PORT_3 bool "Enable STM32 USART3 Port" default n depends on UART_STM32 @@ -99,24 +99,24 @@ config UART_STM32_PORT_2 Enable support for USART3 port in the driver. Say y here if you want to use USART3 device. -config UART_STM32_PORT_2_NAME - string "Device Name for STM32 USART1 Port" - default "UART_2" - depends on UART_STM32_PORT_2 +config UART_STM32_PORT_3_NAME + string "Device Name for STM32 USART3 Port" + default "UART_3" + depends on UART_STM32_PORT_3 help This is the device name for USART3 port, and is included in the device struct. -config UART_STM32_PORT_2_BAUD_RATE - int "STM32 USART1 Baud Rate" +config UART_STM32_PORT_3_BAUD_RATE + int "STM32 USART3 Baud Rate" default 9600 - depends on UART_STM32_PORT_2 + depends on UART_STM32_PORT_3 help The baud rate for USART3 port to be set to at boot. -config UART_STM32_PORT_2_IRQ_PRI +config UART_STM32_PORT_3_IRQ_PRI int "STM32 USART3 Interrupt Priority" default 0 - depends on UART_STM32_PORT_2 && UART_INTERRUPT_DRIVEN + depends on UART_STM32_PORT_3 && UART_INTERRUPT_DRIVEN help The interrupt priority for USART3 port. diff --git a/drivers/serial/uart_stm32.c b/drivers/serial/uart_stm32.c index abceff6cef5..c85b9043791 100644 --- a/drivers/serial/uart_stm32.c +++ b/drivers/serial/uart_stm32.c @@ -319,57 +319,6 @@ static int uart_stm32_init(struct device *dev) return 0; } -#ifdef CONFIG_UART_STM32_PORT_0 - -#ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void uart_stm32_irq_config_func_0(struct device *dev); -#endif /* CONFIG_UART_INTERRUPT_DRIVEN */ - -static const struct uart_stm32_config uart_stm32_dev_cfg_0 = { - .uconf = { - .base = (uint8_t *)USART1_BASE, -#ifdef CONFIG_UART_INTERRUPT_DRIVEN - .irq_config_func = uart_stm32_irq_config_func_0, -#endif /* CONFIG_UART_INTERRUPT_DRIVEN */ - }, -#ifdef CONFIG_SOC_SERIES_STM32F1X - .clock_subsys = UINT_TO_POINTER(STM32F10X_CLOCK_SUBSYS_USART1), -#elif CONFIG_SOC_SERIES_STM32F4X - .pclken = { .bus = STM32F4X_CLOCK_BUS_APB2, - .enr = STM32F4X_CLOCK_ENABLE_USART1 }, -#endif /* CONFIG_SOC_SERIES_STM32FX */ -}; - -static struct uart_stm32_data uart_stm32_dev_data_0 = { - .huart = { - .Init = { - .BaudRate = CONFIG_UART_STM32_PORT_0_BAUD_RATE} } -}; - -DEVICE_AND_API_INIT(uart_stm32_0, CONFIG_UART_STM32_PORT_0_NAME, - &uart_stm32_init, - &uart_stm32_dev_data_0, &uart_stm32_dev_cfg_0, - PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, - &uart_stm32_driver_api); - -#ifdef CONFIG_UART_INTERRUPT_DRIVEN -static void uart_stm32_irq_config_func_0(struct device *dev) -{ -#ifdef CONFIG_SOC_SERIES_STM32F1X -#define PORT_0_IRQ STM32F1_IRQ_USART1 -#elif CONFIG_SOC_SERIES_STM32F4X -#define PORT_0_IRQ STM32F4_IRQ_USART1 -#endif - IRQ_CONNECT(PORT_0_IRQ, - CONFIG_UART_STM32_PORT_0_IRQ_PRI, - uart_stm32_isr, DEVICE_GET(uart_stm32_0), - 0); - irq_enable(PORT_0_IRQ); -} -#endif /* CONFIG_UART_INTERRUPT_DRIVEN */ - -#endif /* CONFIG_UART_STM32_PORT_0 */ - #ifdef CONFIG_UART_STM32_PORT_1 @@ -379,16 +328,16 @@ static void uart_stm32_irq_config_func_1(struct device *dev); static const struct uart_stm32_config uart_stm32_dev_cfg_1 = { .uconf = { - .base = (uint8_t *)USART2_BASE, + .base = (uint8_t *)USART1_BASE, #ifdef CONFIG_UART_INTERRUPT_DRIVEN .irq_config_func = uart_stm32_irq_config_func_1, #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ }, #ifdef CONFIG_SOC_SERIES_STM32F1X - .clock_subsys = UINT_TO_POINTER(STM32F10X_CLOCK_SUBSYS_USART2), + .clock_subsys = UINT_TO_POINTER(STM32F10X_CLOCK_SUBSYS_USART1), #elif CONFIG_SOC_SERIES_STM32F4X - .pclken = { .bus = STM32F4X_CLOCK_BUS_APB1, - .enr = STM32F4X_CLOCK_ENABLE_USART2 }, + .pclken = { .bus = STM32F4X_CLOCK_BUS_APB2, + .enr = STM32F4X_CLOCK_ENABLE_USART1 }, #endif /* CONFIG_SOC_SERIES_STM32FX */ }; @@ -408,9 +357,9 @@ DEVICE_AND_API_INIT(uart_stm32_1, CONFIG_UART_STM32_PORT_1_NAME, static void uart_stm32_irq_config_func_1(struct device *dev) { #ifdef CONFIG_SOC_SERIES_STM32F1X -#define PORT_1_IRQ STM32F1_IRQ_USART2 +#define PORT_1_IRQ STM32F1_IRQ_USART1 #elif CONFIG_SOC_SERIES_STM32F4X -#define PORT_1_IRQ STM32F4_IRQ_USART2 +#define PORT_1_IRQ STM32F4_IRQ_USART1 #endif IRQ_CONNECT(PORT_1_IRQ, CONFIG_UART_STM32_PORT_1_IRQ_PRI, @@ -431,16 +380,17 @@ static void uart_stm32_irq_config_func_2(struct device *dev); static const struct uart_stm32_config uart_stm32_dev_cfg_2 = { .uconf = { - .base = (uint8_t *)USART3_BASE, + .base = (uint8_t *)USART2_BASE, #ifdef CONFIG_UART_INTERRUPT_DRIVEN .irq_config_func = uart_stm32_irq_config_func_2, #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ }, #ifdef CONFIG_SOC_SERIES_STM32F1X - .clock_subsys = UINT_TO_POINTER(STM32F10X_CLOCK_SUBSYS_USART3), + .clock_subsys = UINT_TO_POINTER(STM32F10X_CLOCK_SUBSYS_USART2), #elif CONFIG_SOC_SERIES_STM32F4X - .clock_subsys = UINT_TO_POINTER(STM32F40X_CLOCK_SUBSYS_USART3), -#endif /* CONFIG_SOC_SERIES_STM32F4X */ + .pclken = { .bus = STM32F4X_CLOCK_BUS_APB1, + .enr = STM32F4X_CLOCK_ENABLE_USART2 }, +#endif /* CONFIG_SOC_SERIES_STM32FX */ }; static struct uart_stm32_data uart_stm32_dev_data_2 = { @@ -459,9 +409,9 @@ DEVICE_AND_API_INIT(uart_stm32_2, CONFIG_UART_STM32_PORT_2_NAME, static void uart_stm32_irq_config_func_2(struct device *dev) { #ifdef CONFIG_SOC_SERIES_STM32F1X -#define PORT_2_IRQ STM32F1_IRQ_USART3 +#define PORT_2_IRQ STM32F1_IRQ_USART2 #elif CONFIG_SOC_SERIES_STM32F4X -#define PORT_2_IRQ STM32F4_IRQ_USART3 +#define PORT_2_IRQ STM32F4_IRQ_USART2 #endif IRQ_CONNECT(PORT_2_IRQ, CONFIG_UART_STM32_PORT_2_IRQ_PRI, @@ -472,3 +422,54 @@ static void uart_stm32_irq_config_func_2(struct device *dev) #endif /* CONFIG_UART_INTERRUPT_DRIVEN */ #endif /* CONFIG_UART_STM32_PORT_2 */ + + +#ifdef CONFIG_UART_STM32_PORT_3 + +#ifdef CONFIG_UART_INTERRUPT_DRIVEN +static void uart_stm32_irq_config_func_3(struct device *dev); +#endif /* CONFIG_UART_INTERRUPT_DRIVEN */ + +static const struct uart_stm32_config uart_stm32_dev_cfg_3 = { + .uconf = { + .base = (uint8_t *)USART3_BASE, +#ifdef CONFIG_UART_INTERRUPT_DRIVEN + .irq_config_func = uart_stm32_irq_config_func_3, +#endif /* CONFIG_UART_INTERRUPT_DRIVEN */ + }, +#ifdef CONFIG_SOC_SERIES_STM32F1X + .clock_subsys = UINT_TO_POINTER(STM32F10X_CLOCK_SUBSYS_USART3), +#elif CONFIG_SOC_SERIES_STM32F4X + .clock_subsys = UINT_TO_POINTER(STM32F40X_CLOCK_SUBSYS_USART3), +#endif /* CONFIG_SOC_SERIES_STM32F4X */ +}; + +static struct uart_stm32_data uart_stm32_dev_data_3 = { + .huart = { + .Init = { + .BaudRate = CONFIG_UART_STM32_PORT_3_BAUD_RATE} } +}; + +DEVICE_AND_API_INIT(uart_stm32_3, CONFIG_UART_STM32_PORT_3_NAME, + &uart_stm32_init, + &uart_stm32_dev_data_3, &uart_stm32_dev_cfg_3, + PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, + &uart_stm32_driver_api); + +#ifdef CONFIG_UART_INTERRUPT_DRIVEN +static void uart_stm32_irq_config_func_3(struct device *dev) +{ +#ifdef CONFIG_SOC_SERIES_STM32F1X +#define PORT_3_IRQ STM32F1_IRQ_USART3 +#elif CONFIG_SOC_SERIES_STM32F4X +#define PORT_3_IRQ STM32F4_IRQ_USART3 +#endif + IRQ_CONNECT(PORT_3_IRQ, + CONFIG_UART_STM32_PORT_3_IRQ_PRI, + uart_stm32_isr, DEVICE_GET(uart_stm32_3), + 0); + irq_enable(PORT_3_IRQ); +} +#endif /* CONFIG_UART_INTERRUPT_DRIVEN */ + +#endif /* CONFIG_UART_STM32_PORT_3 */