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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
pinmux: stm32f4: Clean-up pinmux arrays
Clean-up the pinmux arrays as a preparatory work before adding more
pinmuxes.

This is achieved by the following two actions:
- Define the PAD macro to simplify the [x - 1] = y construct
- Reorder the declartions by bank / pin to make it easier to
  locate a pin among a high number of other pins, while minimizing the
  risk of conflict when two people add a new declaration for two
  different pins

Change-Id: I1ca0cc4f48bcd8cfd35b331e9821935f5c855876
Signed-off-by: Florian Vaussard <florian.vaussard@heig-vd.ch>
  • Loading branch information
Florian Vaussard committed May 11, 2017
commit 9dce1d8b44f5b2abd975a3b35898292167b7597a
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