|
15 | 15 | #define PAD(AF, func) \ |
16 | 16 | [AF - 1] = func |
17 | 17 |
|
| 18 | +#define PINMUX_PWM(port, chan, pin) \ |
| 19 | + PAD(STM32F4_PINMUX_FUNC_##pin##_PWM##port##_CH##chan,\ |
| 20 | + STM32F4X_PIN_CONFIG_AF_PUSH_UP), |
| 21 | + |
| 22 | +#define PINMUX_UART(port, dir, pin) \ |
| 23 | + PAD(STM32F4_PINMUX_FUNC_##pin##_##port##_##dir, \ |
| 24 | + STM32F4X_PIN_CONFIG_AF_PUSH_UP), |
| 25 | + |
| 26 | +/* Blank pinmux by default */ |
| 27 | +#define PINMUX_PWM2(pin, chan) |
| 28 | +#define PINMUX_UART1(dir, pin) |
| 29 | +#define PINMUX_UART2(dir, pin) |
| 30 | + |
| 31 | +#ifdef CONFIG_PWM_STM32_2 |
| 32 | + #undef PINMUX_PWM2 |
| 33 | + #define PINMUX_PWM2(pin, chan) PINMUX_PWM(2, chan, pin) |
| 34 | +#endif |
| 35 | + |
| 36 | +#ifdef CONFIG_UART_STM32_PORT_1 |
| 37 | + #undef PINMUX_UART1 |
| 38 | + #define PINMUX_UART1(dir, pin) PINMUX_UART(USART1, dir, pin) |
| 39 | +#endif |
| 40 | + |
| 41 | +#ifdef CONFIG_UART_STM32_PORT_2 |
| 42 | + #undef PINMUX_UART2 |
| 43 | + #define PINMUX_UART2(dir, pin) PINMUX_UART(USART2, dir, pin) |
| 44 | +#endif |
| 45 | + |
| 46 | +#define PINMUX_UART_TX(pin, port) PINMUX_UART##port(TX, pin) |
| 47 | +#define PINMUX_UART_RX(pin, port) PINMUX_UART##port(RX, pin) |
| 48 | + |
18 | 49 | static const stm32_pin_func_t pin_pa0_funcs[] = { |
19 | | - PAD(STM32F4_PINMUX_FUNC_PA0_PWM2_CH1, STM32F4X_PIN_CONFIG_AF_PUSH_UP), |
| 50 | + PINMUX_PWM2(PA0, 1) |
20 | 51 | }; |
21 | 52 |
|
22 | 53 | static const stm32_pin_func_t pin_pa2_funcs[] = { |
23 | | - PAD(STM32F4_PINMUX_FUNC_PA2_USART2_TX, STM32F4X_PIN_CONFIG_AF_PUSH_UP), |
| 54 | + PINMUX_UART_TX(PA2, 2) |
24 | 55 | }; |
25 | 56 |
|
26 | 57 | static const stm32_pin_func_t pin_pa3_funcs[] = { |
27 | | - PAD(STM32F4_PINMUX_FUNC_PA3_USART2_RX, STM32F4X_PIN_CONFIG_AF_PUSH_UP), |
| 58 | + PINMUX_UART_RX(PA3, 2) |
28 | 59 | }; |
29 | 60 |
|
30 | 61 | static const stm32_pin_func_t pin_pa9_funcs[] = { |
31 | | - PAD(STM32F4_PINMUX_FUNC_PA9_USART1_TX, STM32F4X_PIN_CONFIG_AF_PUSH_UP), |
| 62 | + PINMUX_UART_TX(PA9, 1) |
32 | 63 | }; |
33 | 64 |
|
34 | 65 | static const stm32_pin_func_t pin_pa10_funcs[] = { |
35 | | - PAD(STM32F4_PINMUX_FUNC_PA10_USART1_RX, STM32F4X_PIN_CONFIG_AF_PUSH_UP) |
| 66 | + PINMUX_UART_RX(PA10, 1) |
36 | 67 | }; |
37 | 68 |
|
38 | 69 | static const stm32_pin_func_t pin_pb6_funcs[] = { |
39 | | - PAD(STM32F4_PINMUX_FUNC_PB6_USART1_TX, STM32F4X_PIN_CONFIG_AF_PUSH_UP), |
| 70 | + PINMUX_UART_TX(PB6, 1) |
40 | 71 | }; |
41 | 72 |
|
42 | 73 | static const stm32_pin_func_t pin_pb7_funcs[] = { |
43 | | - PAD(STM32F4_PINMUX_FUNC_PB7_USART1_RX, STM32F4X_PIN_CONFIG_AF_PUSH_UP), |
| 74 | + PINMUX_UART_RX(PB7, 1) |
44 | 75 | }; |
45 | 76 |
|
46 | 77 | /** |
|
0 commit comments