Variant.h pin definitions unclear?
Posted: Sat Oct 24, 2020 11:04 pm
I'm running into trouble with invalid digital pin definition values from variant.h on a Nucleo-F401RE. I am using PA4 as a digital output pin. PA4 is returned as a uint value of 55, when I am expecting some value below NUM_DIGITAL_PINS of 52. Looking at variant.h it is now defined as A2. It is a mystery to me and my search as to where A2 is being defined. For the life of me I can not locate where A2 is being defined. Could anyone help in understanding where A2 definition is coming from?
Also, this level of multiple #define redirection is new and somewhat confusing to to me, I'm left wondering if this is a good and more importantly maintainable implementation for variant files?
Thanks,
George
Nucleo-F401RE variant.h https://github.com/stm32duino/Arduino_C ... iant.h#L83
Also, this level of multiple #define redirection is new and somewhat confusing to to me, I'm left wondering if this is a good and more importantly maintainable implementation for variant files?
Thanks,
George
Nucleo-F401RE variant.h https://github.com/stm32duino/Arduino_C ... iant.h#L83
Code: Select all
/*----------------------------------------------------------------------------
* Pins
*----------------------------------------------------------------------------*/
#define PA3 0
#define PA2 1
#define PA10 2
#define PB3 3
#define PB5 4
#define PB4 5
#define PB10 6
#define PA8 7
#define PA9 8
#define PC7 9
#define PB6 10
#define PA7 A6
#define PA6 A7
#define PA5 A8 // LD2
#define PB9 14
#define PB8 15
// ST Morpho
// CN7 Left Side
#define PC10 16
#define PC12 17
// 18 is NC - BOOT0
#define PA13 19 // SWD
#define PA14 20 // SWD
#define PA15 21
#define PB7 22
#define PC13 23 // USER_BTN
#define PC14 24 // NC by default SB49 opened
#define PC15 25 // NC by default SB48 opened
#define PH0 26 // NC by default SB55 opened
#define PH1 27
#define PC2 A9
#define PC3 A10
// CN7 Right Side
#define PC11 30
#define PD2 31
// CN10 Left Side
#define PC9 32
// CN10 Right side
#define PC8 33
#define PC6 34
#define PC5 A11
#define PA12 36
#define PA11 37
#define PB12 38
// 39 is NC
#define PB2 40
#define PB1 A12
#define PB15 42
#define PB14 43
#define PB13 44
#define PC4 A13
#define PA0 A0
#define PA1 A1
#define PA4 A2
#define PB0 A3
#define PC1 A4
#define PC0 A5