drivers/pinctrl: stm32f1: Provide a function which centralize remap
Centralize AFIO remapping into one single function. Signed-off-by: Erwan Gouriou <erwan.gouriou@linaro.org>
This commit is contained in:
parent
62a5179b7b
commit
0143b5e3de
7 changed files with 221 additions and 225 deletions
|
@ -689,41 +689,7 @@ static int uart_stm32_init(const struct device *dev)
|
|||
return remap;
|
||||
}
|
||||
|
||||
/* A valid remapping configuration is provided */
|
||||
/* Apply remapping before proceeding with pin configuration */
|
||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_AFIO);
|
||||
|
||||
switch ((uint32_t)UART_STRUCT(dev)) {
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usart1), okay)
|
||||
case DT_REG_ADDR(DT_NODELABEL(usart1)):
|
||||
if (remap == REMAP_1) {
|
||||
LL_GPIO_AF_EnableRemap_USART1();
|
||||
} else {
|
||||
LL_GPIO_AF_DisableRemap_USART1();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usart2), okay)
|
||||
case DT_REG_ADDR(DT_NODELABEL(usart2)):
|
||||
if (remap == REMAP_1) {
|
||||
LL_GPIO_AF_EnableRemap_USART2();
|
||||
} else {
|
||||
LL_GPIO_AF_DisableRemap_USART2();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#if DT_NODE_HAS_STATUS(DT_NODELABEL(usart3), okay)
|
||||
case DT_REG_ADDR(DT_NODELABEL(usart3)):
|
||||
if (remap == REMAP_2) {
|
||||
LL_GPIO_AF_EnableRemap_USART3();
|
||||
} else if (remap == REMAP_1) {
|
||||
LL_GPIO_AF_RemapPartial_USART3();
|
||||
} else {
|
||||
LL_GPIO_AF_DisableRemap_USART3();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
stm32_dt_pinctrl_remap_set((uint32_t)UART_STRUCT(dev), remap);
|
||||
#endif /* DT_HAS_COMPAT_STATUS_OKAY(st_stm32f1_pinctrl) */
|
||||
|
||||
stm32_dt_pinctrl_configure(config->pinctrl_list,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue