From 7d38730b5e2d419636bc597175c100e8f8785b22 Mon Sep 17 00:00:00 2001 From: Frederic Pillon Date: Tue, 8 Dec 2020 13:49:25 +0100 Subject: [PATCH] Remap pin management Fix #1180 Signed-off-by: Frederic Pillon --- libraries/SrcWrapper/src/stm32/pinmap.c | 51 ++++++++++++++++--------- 1 file changed, 34 insertions(+), 17 deletions(-) diff --git a/libraries/SrcWrapper/src/stm32/pinmap.c b/libraries/SrcWrapper/src/stm32/pinmap.c index 31c81f2850..ae411ef87e 100644 --- a/libraries/SrcWrapper/src/stm32/pinmap.c +++ b/libraries/SrcWrapper/src/stm32/pinmap.c @@ -73,25 +73,42 @@ void pin_function(PinName pin, int function) } /* Handle pin remap if any */ -#if defined(LL_SYSCFG_PIN_RMP_PA11) && defined(LL_SYSCFG_PIN_RMP_PA12) - if ((pin >= PA_9) && (pin <= PA_12)) { - __HAL_RCC_SYSCFG_CLK_ENABLE(); - switch ((int)pin) { - case PA_9: +#if defined(LL_SYSCFG_PIN_RMP_PA11) && defined(LL_SYSCFG_PIN_RMP_PA12) || defined(SYSCFG_CFGR1_PA11_PA12_RMP) + __HAL_RCC_SYSCFG_CLK_ENABLE(); + switch (pin & PNAME_MASK) { +#if defined(SYSCFG_CFGR1_PA11_PA12_RMP) + /* Disable PIN pair PA11/12 mapped instead of PA9/10 */ + case PA_9: + case PA_10: + LL_SYSCFG_DisablePinRemap(); + break; + /* Enable PIN pair PA11/12 mapped instead of PA9/10 */ + case PA_11: + case PA_12: + if (pin & PREMAP) { + LL_SYSCFG_EnablePinRemap(); + } + break; +#else + case PA_9: + if (pin & PREMAP) { LL_SYSCFG_EnablePinRemap(LL_SYSCFG_PIN_RMP_PA11); - break; - case PA_11: - LL_SYSCFG_DisablePinRemap(LL_SYSCFG_PIN_RMP_PA11); - break; - case PA_10: + } + break; + case PA_10: + if (pin & PREMAP) { LL_SYSCFG_EnablePinRemap(LL_SYSCFG_PIN_RMP_PA12); - break; - case PA_12: - LL_SYSCFG_DisablePinRemap(LL_SYSCFG_PIN_RMP_PA12); - break; - default: - break; - } + } + break; + case PA_11: + LL_SYSCFG_DisablePinRemap(LL_SYSCFG_PIN_RMP_PA11); + break; + case PA_12: + LL_SYSCFG_DisablePinRemap(LL_SYSCFG_PIN_RMP_PA12); + break; +#endif + default: + break; } #endif