Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stm32f4: Add support for UART4 to 10 #27

Merged
merged 6 commits into from
May 15, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 20 additions & 24 deletions arch/arm/soc/st_stm32/stm32f4/soc_pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,52 +12,48 @@
#include <pinmux/stm32/pinmux_stm32.h>
#include <drivers/clock_control/stm32_clock_control.h>

static const stm32_pin_func_t pin_pa9_funcs[] = {
[STM32F4_PINMUX_FUNC_PA9_USART1_TX - 1] =
STM32F4X_PIN_CONFIG_AF_PUSH_UP,
#define PAD(AF, func) \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to separate this on more than one line?

[AF - 1] = func

static const stm32_pin_func_t pin_pa0_funcs[] = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an interesting proposal (that would eventually deserve to be extended to whole stm32 family to keep consistency across STM32 series). Thought, please keep it easily readable and consistent across IPs. For instance:
PINMUX_UART(PA2, UART2, TX)
PINMUX_PWM(PA0, PWM2, CH1)
Aim is to understand what macro does at first reading w/o refering to macro definition.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it would be good to extend to other STM32 as I also said in the cover letter. This can be done as a follow-up if you agree, especially considering that I do not have other STM32 on my desk right now.

Sure, I will look into the consistency issue, thanks.

PAD(STM32F4_PINMUX_FUNC_PA0_PWM2_CH1, STM32F4X_PIN_CONFIG_AF_PUSH_UP),
};

static const stm32_pin_func_t pin_pa10_funcs[] = {
[STM32F4_PINMUX_FUNC_PA10_USART1_RX - 1] =
STM32F4X_PIN_CONFIG_AF_PUSH_UP,
static const stm32_pin_func_t pin_pa2_funcs[] = {
PAD(STM32F4_PINMUX_FUNC_PA2_USART2_TX, STM32F4X_PIN_CONFIG_AF_PUSH_UP),
};

static const stm32_pin_func_t pin_pb6_funcs[] = {
[STM32F4_PINMUX_FUNC_PB6_USART1_TX - 1] =
STM32F4X_PIN_CONFIG_AF_PUSH_UP,
static const stm32_pin_func_t pin_pa3_funcs[] = {
PAD(STM32F4_PINMUX_FUNC_PA3_USART2_RX, STM32F4X_PIN_CONFIG_AF_PUSH_UP),
};

static const stm32_pin_func_t pin_pb7_funcs[] = {
[STM32F4_PINMUX_FUNC_PB7_USART1_RX - 1] =
STM32F4X_PIN_CONFIG_AF_PUSH_UP,
static const stm32_pin_func_t pin_pa9_funcs[] = {
PAD(STM32F4_PINMUX_FUNC_PA9_USART1_TX, STM32F4X_PIN_CONFIG_AF_PUSH_UP),
};

static const stm32_pin_func_t pin_pa2_funcs[] = {
[STM32F4_PINMUX_FUNC_PA2_USART2_TX - 1] =
STM32F4X_PIN_CONFIG_AF_PUSH_UP,
static const stm32_pin_func_t pin_pa10_funcs[] = {
PAD(STM32F4_PINMUX_FUNC_PA10_USART1_RX, STM32F4X_PIN_CONFIG_AF_PUSH_UP)
};

static const stm32_pin_func_t pin_pa3_funcs[] = {
[STM32F4_PINMUX_FUNC_PA3_USART2_RX - 1] =
STM32F4X_PIN_CONFIG_AF_PUSH_UP,
static const stm32_pin_func_t pin_pb6_funcs[] = {
PAD(STM32F4_PINMUX_FUNC_PB6_USART1_TX, STM32F4X_PIN_CONFIG_AF_PUSH_UP),
};

static const stm32_pin_func_t pin_pa0_funcs[] = {
[STM32F4_PINMUX_FUNC_PA0_PWM2_CH1 - 1] =
STM32F4X_PIN_CONFIG_AF_PUSH_UP,
static const stm32_pin_func_t pin_pb7_funcs[] = {
PAD(STM32F4_PINMUX_FUNC_PB7_USART1_RX, STM32F4X_PIN_CONFIG_AF_PUSH_UP),
};

/**
* @brief pin configuration
*/
static const struct stm32_pinmux_conf pins[] = {
STM32_PIN_CONF(STM32_PIN_PA0, pin_pa0_funcs),
STM32_PIN_CONF(STM32_PIN_PA2, pin_pa2_funcs),
STM32_PIN_CONF(STM32_PIN_PA3, pin_pa3_funcs),
STM32_PIN_CONF(STM32_PIN_PA9, pin_pa9_funcs),
STM32_PIN_CONF(STM32_PIN_PA10, pin_pa10_funcs),
STM32_PIN_CONF(STM32_PIN_PB6, pin_pb6_funcs),
STM32_PIN_CONF(STM32_PIN_PB7, pin_pb7_funcs),
STM32_PIN_CONF(STM32_PIN_PA2, pin_pa2_funcs),
STM32_PIN_CONF(STM32_PIN_PA3, pin_pa3_funcs),
STM32_PIN_CONF(STM32_PIN_PA0, pin_pa0_funcs),
};

int stm32_get_pin_config(int pin, int func)
Expand Down
126 changes: 126 additions & 0 deletions drivers/serial/Kconfig.stm32
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,130 @@ config UART_STM32_PORT_3_NAME
This is the device name for USART3 port, and is
included in the device struct.

# --- port 4 ---

config UART_STM32_PORT_4
bool "Enable STM32 UART4 Port"
default n
depends on UART_STM32
help
Enable support for UART4 port in the driver. Say y here
if you want to use UART4 device.

config UART_STM32_PORT_4_NAME
string "Device Name for STM32 UART4 Port"
default "UART_4"
depends on UART_STM32_PORT_4
help
This is the device name for UART4 port, and is
included in the device struct.

# --- port 5 ---

config UART_STM32_PORT_5
bool "Enable STM32 UART5 Port"
default n
depends on UART_STM32
help
Enable support for UART5 port in the driver. Say y here
if you want to use UART5 device.

config UART_STM32_PORT_5_NAME
string "Device Name for STM32 UART5 Port"
default "UART_5"
depends on UART_STM32_PORT_5
help
This is the device name for UART5 port, and is
included in the device struct.

# --- port 6 ---

config UART_STM32_PORT_6
bool "Enable STM32 USART6 Port"
default n
depends on UART_STM32
help
Enable support for USART6 port in the driver. Say y here
if you want to use USART6 device.

config UART_STM32_PORT_6_NAME
string "Device Name for STM32 USART6 Port"
default "UART_6"
depends on UART_STM32_PORT_6
help
This is the device name for USART6 port, and is
included in the device struct.

# --- port 7 ---

config UART_STM32_PORT_7
bool "Enable STM32 UART7 Port"
default n
depends on UART_STM32
help
Enable support for UART7 port in the driver. Say y here
if you want to use UART7 device.

config UART_STM32_PORT_7_NAME
string "Device Name for STM32 UART7 Port"
default "UART_7"
depends on UART_STM32_PORT_7
help
This is the device name for UART7 port, and is
included in the device struct.

# --- port 8 ---

config UART_STM32_PORT_8
bool "Enable STM32 UART8 Port"
default n
depends on UART_STM32
help
Enable support for UART8 port in the driver. Say y here
if you want to use UART8 device.

config UART_STM32_PORT_8_NAME
string "Device Name for STM32 UART8 Port"
default "UART_8"
depends on UART_STM32_PORT_8
help
This is the device name for UART8 port, and is
included in the device struct.

# --- port 9 ---

config UART_STM32_PORT_9
bool "Enable STM32 UART9 Port"
default n
depends on UART_STM32
help
Enable support for UART9 port in the driver. Say y here
if you want to use UART9 device.

config UART_STM32_PORT_9_NAME
string "Device Name for STM32 UART9 Port"
default "UART_9"
depends on UART_STM32_PORT_9
help
This is the device name for UART9 port, and is
included in the device struct.

# --- port 10 ---

config UART_STM32_PORT_10
bool "Enable STM32 UART10 Port"
default n
depends on UART_STM32
help
Enable support for UART10 port in the driver. Say y here
if you want to use UART10 device.

config UART_STM32_PORT_10_NAME
string "Device Name for STM32 UART10 Port"
default "UART_10"
depends on UART_STM32_PORT_10
help
This is the device name for UART10 port, and is
included in the device struct.

endif # UART_STM32
Loading