Description
Because of most constants (like pins Px[0-16], AFIO_, STM_PIN_ ) defined as enum, it is not possible to use them in preprocessor conditions.
Because of that Marlin port for STM32 have unpredictable behavior
MarlinFirmware/Marlin#14777
MarlinFirmware/Marlin#14711
MarlinFirmware/Marlin#14732
In contrast the arduino port for LPC176x, where pins and other constants is defined as macro definitions https://github.com/p3p/pio-framework-arduino-lpc176x/blob/b3635e53cbd2b6481b207eda668e47dbe712f1e7/cores/arduino/pinmapping.h
Marlin developers has make workaround to resolve this problem https://github.com/MarlinFirmware/Marlin/pull/14785/files
But i believe that problem must be resolved on stm32duino side, i think implementation similar to LPC176x port will be nice.
Similar problem already was discussed earlier, for example here #140 (comment)