Skip to content

Commit

Permalink
Remap pin management
Browse files Browse the repository at this point in the history
Fix stm32duino#1180

Signed-off-by: Frederic Pillon <[email protected]>
  • Loading branch information
fpistm committed Mar 9, 2021
1 parent 1c06c97 commit 5b67453
Showing 1 changed file with 34 additions and 17 deletions.
51 changes: 34 additions & 17 deletions libraries/SrcWrapper/src/stm32/pinmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) == PREMAP) {
LL_SYSCFG_EnablePinRemap();
}
break;
#else
case PA_9:
if ((pin & PREMAP) == 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) == 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

Expand Down

0 comments on commit 5b67453

Please sign in to comment.