diff --git a/cores/arduino/pins_arduino_var.h b/cores/arduino/pins_arduino_var.h index 89e33312a9..256ab7a782 100644 --- a/cores/arduino/pins_arduino_var.h +++ b/cores/arduino/pins_arduino_var.h @@ -25,6 +25,10 @@ // Include board variant #include "variant.h" +// Avoid pins number misalignment +_Static_assert(NUM_DIGITAL_PINS==PEND, "NUM_DIGITAL_PINS and PEND differ!"); +_Static_assert(NUM_ANALOG_INPUTS==(AEND-A0), "NUM_DIGITAL_PINS and (AEND-A0) differ!"); + #ifdef __cplusplus extern "C" { #endif @@ -32,11 +36,6 @@ extern "C" { #define NOT_AN_INTERRUPT NC // -1 #define DEND NUM_DIGITAL_PINS -#ifdef __cplusplus -static_assert(NUM_DIGITAL_PINS==((uint32_t)PEND)); -static_assert(NUM_ANALOG_INPUTS==((uint32_t)(AEND-A0))); -#endif - // Convert a digital pin number Dxx to a PinName PX_n // Note: Analog pin is also a digital pin. #define digitalPinToPinName(p) (((uint32_t)p < NUM_DIGITAL_PINS) ? digitalPin[p] : NC) diff --git a/variants/DISCO_F100RB/variant.h b/variants/DISCO_F100RB/variant.h index 9eef6927af..82413c8d92 100644 --- a/variants/DISCO_F100RB/variant.h +++ b/variants/DISCO_F100RB/variant.h @@ -104,9 +104,9 @@ enum { PB1_2,//D62/A15 = D15 PEND }; - + // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 63 +#define NUM_DIGITAL_PINS 63 enum { A_START_AFTER = D46, @@ -116,7 +116,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 16 +#define NUM_ANALOG_INPUTS 16 // On-board LED pin number #define LED_BUILTIN PC9 diff --git a/variants/DISCO_F407VG/variant.h b/variants/DISCO_F407VG/variant.h index b96233a79a..55b6b151cb 100644 --- a/variants/DISCO_F407VG/variant.h +++ b/variants/DISCO_F407VG/variant.h @@ -132,7 +132,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 87 +#define NUM_DIGITAL_PINS 87 enum { A_START_AFTER = D78, @@ -141,7 +141,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 8 +#define NUM_ANALOG_INPUTS 8 // On-board LED pin number #define LED_BUILTIN PD12 diff --git a/variants/DISCO_F746NG/variant.h b/variants/DISCO_F746NG/variant.h index a73e28c1bd..fe9d07140f 100644 --- a/variants/DISCO_F746NG/variant.h +++ b/variants/DISCO_F746NG/variant.h @@ -64,7 +64,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 25 +#define NUM_DIGITAL_PINS 25 enum { A_START_AFTER = D15, @@ -73,7 +73,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 6 +#define NUM_ANALOG_INPUTS 6 // On-board LED pin number #define LED_BUILTIN 13 diff --git a/variants/DISCO_L072CZ_LRWAN1/variant.h b/variants/DISCO_L072CZ_LRWAN1/variant.h index 2d2b4c234d..4d3f644696 100644 --- a/variants/DISCO_L072CZ_LRWAN1/variant.h +++ b/variants/DISCO_L072CZ_LRWAN1/variant.h @@ -74,7 +74,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 33 +#define NUM_DIGITAL_PINS 33 enum { A_START_AFTER = D25, @@ -83,7 +83,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 7 +#define NUM_ANALOG_INPUTS 7 // On-board LED pin number #define LED_BUILTIN PA5 diff --git a/variants/DISCO_L475VG_IOT/variant.h b/variants/DISCO_L475VG_IOT/variant.h index f1f6201609..b8ef035e79 100644 --- a/variants/DISCO_L475VG_IOT/variant.h +++ b/variants/DISCO_L475VG_IOT/variant.h @@ -133,7 +133,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 85 +#define NUM_DIGITAL_PINS 85 enum { A_START_AFTER = D68, @@ -143,7 +143,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 16 +#define NUM_ANALOG_INPUTS 16 // On-board LED pin number #define LED_BUILTIN 13 diff --git a/variants/NUCLEO_F030R8/variant.h b/variants/NUCLEO_F030R8/variant.h index 8ec1f1a2f4..44065b8037 100644 --- a/variants/NUCLEO_F030R8/variant.h +++ b/variants/NUCLEO_F030R8/variant.h @@ -106,7 +106,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 61 +#define NUM_DIGITAL_PINS 61 enum { A_START_AFTER = D48, @@ -116,7 +116,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 12 +#define NUM_ANALOG_INPUTS 12 // On-board LED pin number #define LED_BUILTIN 13 diff --git a/variants/NUCLEO_F091RC/variant.h b/variants/NUCLEO_F091RC/variant.h index a6471817a8..9f4e537c7a 100644 --- a/variants/NUCLEO_F091RC/variant.h +++ b/variants/NUCLEO_F091RC/variant.h @@ -103,7 +103,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 58 +#define NUM_DIGITAL_PINS 58 enum { A_START_AFTER = D45, @@ -113,7 +113,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 12 +#define NUM_ANALOG_INPUTS 12 // On-board LED pin number #define LED_BUILTIN 13 diff --git a/variants/NUCLEO_F103RB/variant.h b/variants/NUCLEO_F103RB/variant.h index 2354ebd86f..7d3b8817ea 100644 --- a/variants/NUCLEO_F103RB/variant.h +++ b/variants/NUCLEO_F103RB/variant.h @@ -105,7 +105,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 60 +#define NUM_DIGITAL_PINS 60 enum { A_START_AFTER = D45, @@ -115,7 +115,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 14 +#define NUM_ANALOG_INPUTS 14 // On-board LED pin number #define LED_BUILTIN 13 diff --git a/variants/NUCLEO_F207ZG/variant.h b/variants/NUCLEO_F207ZG/variant.h index 9771902e07..04c391182d 100644 --- a/variants/NUCLEO_F207ZG/variant.h +++ b/variants/NUCLEO_F207ZG/variant.h @@ -149,7 +149,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 96 +#define NUM_DIGITAL_PINS 96 // Enum defining Arduino style alias for analog pin number --> Ax enum { @@ -160,7 +160,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 18 +#define NUM_ANALOG_INPUTS 18 // On-board LED pin number #define LED_BUILTIN PB0 diff --git a/variants/NUCLEO_F302R8/variant.h b/variants/NUCLEO_F302R8/variant.h index 0c1de49358..64dcfa3bc5 100644 --- a/variants/NUCLEO_F302R8/variant.h +++ b/variants/NUCLEO_F302R8/variant.h @@ -103,7 +103,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 58 +#define NUM_DIGITAL_PINS 58 enum { A_START_AFTER = D45, @@ -113,7 +113,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 12 +#define NUM_ANALOG_INPUTS 12 // On-board LED pin number #define LED_BUILTIN 13 diff --git a/variants/NUCLEO_F303K8/variant.h b/variants/NUCLEO_F303K8/variant.h index 3773f7dbd7..70c7829523 100644 --- a/variants/NUCLEO_F303K8/variant.h +++ b/variants/NUCLEO_F303K8/variant.h @@ -62,7 +62,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 23 +#define NUM_DIGITAL_PINS 23 enum { A_START_AFTER = D13, @@ -71,7 +71,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 7 +#define NUM_ANALOG_INPUTS 7 // On-board LED pin number #define LED_BUILTIN 13 diff --git a/variants/NUCLEO_F303RE/variant.h b/variants/NUCLEO_F303RE/variant.h index 5a1977736d..1349f4a118 100644 --- a/variants/NUCLEO_F303RE/variant.h +++ b/variants/NUCLEO_F303RE/variant.h @@ -105,7 +105,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 60 +#define NUM_DIGITAL_PINS 60 enum { A_START_AFTER = D45, @@ -115,7 +115,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 14 +#define NUM_ANALOG_INPUTS 14 // On-board LED pin number #define LED_BUILTIN 13 diff --git a/variants/NUCLEO_F401RE/variant.h b/variants/NUCLEO_F401RE/variant.h index 467277ec90..2d1e201c43 100644 --- a/variants/NUCLEO_F401RE/variant.h +++ b/variants/NUCLEO_F401RE/variant.h @@ -104,7 +104,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 59 +#define NUM_DIGITAL_PINS 59 enum { A_START_AFTER = D45, @@ -114,7 +114,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 13 +#define NUM_ANALOG_INPUTS 13 // On-board LED pin number #define LED_BUILTIN 13 diff --git a/variants/NUCLEO_F411RE/variant.h b/variants/NUCLEO_F411RE/variant.h index b465b77645..2be2eb01f2 100644 --- a/variants/NUCLEO_F411RE/variant.h +++ b/variants/NUCLEO_F411RE/variant.h @@ -104,7 +104,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 59 +#define NUM_DIGITAL_PINS 59 enum { A_START_AFTER = D45, @@ -114,7 +114,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 13 +#define NUM_ANALOG_INPUTS 13 // On-board LED pin number #define LED_BUILTIN 13 diff --git a/variants/NUCLEO_F429ZI/variant.h b/variants/NUCLEO_F429ZI/variant.h index a61713b629..0b04ad4059 100644 --- a/variants/NUCLEO_F429ZI/variant.h +++ b/variants/NUCLEO_F429ZI/variant.h @@ -136,7 +136,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 96 +#define NUM_DIGITAL_PINS 96 enum { A_START_AFTER = D77, @@ -146,7 +146,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 18 +#define NUM_ANALOG_INPUTS 18 // On-board LED pin number #define LED_BUILTIN PB0 diff --git a/variants/NUCLEO_F446RE/variant.h b/variants/NUCLEO_F446RE/variant.h index c0bd9cedfa..db06591554 100644 --- a/variants/NUCLEO_F446RE/variant.h +++ b/variants/NUCLEO_F446RE/variant.h @@ -105,7 +105,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 60 +#define NUM_DIGITAL_PINS 60 enum { A_START_AFTER = D45, @@ -115,7 +115,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 14 +#define NUM_ANALOG_INPUTS 14 // On-board LED pin number #define LED_BUILTIN 13 diff --git a/variants/NUCLEO_L031K6/variant.h b/variants/NUCLEO_L031K6/variant.h index 843d1a6804..4e5f2355ef 100644 --- a/variants/NUCLEO_L031K6/variant.h +++ b/variants/NUCLEO_L031K6/variant.h @@ -74,7 +74,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 23 +#define NUM_DIGITAL_PINS 23 enum { A_START_AFTER = D13, @@ -83,7 +83,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 7 +#define NUM_ANALOG_INPUTS 7 // On-board LED pin number #define LED_BUILTIN 13 diff --git a/variants/NUCLEO_L053R8/variant.h b/variants/NUCLEO_L053R8/variant.h index 700cf71105..35e281eb65 100644 --- a/variants/NUCLEO_L053R8/variant.h +++ b/variants/NUCLEO_L053R8/variant.h @@ -103,7 +103,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 58 +#define NUM_DIGITAL_PINS 58 enum { A_START_AFTER = D45, @@ -113,7 +113,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 12 +#define NUM_ANALOG_INPUTS 12 // On-board LED pin number #define LED_BUILTIN 13 diff --git a/variants/NUCLEO_L152RE/variant.h b/variants/NUCLEO_L152RE/variant.h index 1648aa3baa..25621d7b82 100644 --- a/variants/NUCLEO_L152RE/variant.h +++ b/variants/NUCLEO_L152RE/variant.h @@ -108,7 +108,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 63 +#define NUM_DIGITAL_PINS 63 enum { A_START_AFTER = D45, @@ -118,7 +118,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 17 +#define NUM_ANALOG_INPUTS 17 // On-board LED pin number diff --git a/variants/NUCLEO_L432KC/variant.h b/variants/NUCLEO_L432KC/variant.h index 0c83eb6885..e7bbfafe0c 100644 --- a/variants/NUCLEO_L432KC/variant.h +++ b/variants/NUCLEO_L432KC/variant.h @@ -62,7 +62,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 23 +#define NUM_DIGITAL_PINS 23 enum { A_START_AFTER = D13, @@ -71,7 +71,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 7 +#define NUM_ANALOG_INPUTS 7 // On-board LED pin number #define LED_BUILTIN 13 diff --git a/variants/NUCLEO_L476RG/variant.h b/variants/NUCLEO_L476RG/variant.h index d015722873..ad75cf3dc6 100644 --- a/variants/NUCLEO_L476RG/variant.h +++ b/variants/NUCLEO_L476RG/variant.h @@ -103,7 +103,7 @@ enum { }; // This must be a literal with the same value as PEND -#define NUM_DIGITAL_PINS 58 +#define NUM_DIGITAL_PINS 58 enum { A_START_AFTER = D45, @@ -113,7 +113,7 @@ enum { }; // This must be a literal with the same value as AEND-A0 -#define NUM_ANALOG_INPUTS 12 +#define NUM_ANALOG_INPUTS 12 // On-board LED pin number #define LED_BUILTIN 13 diff --git a/variants/board_template/variant.h b/variants/board_template/variant.h index 1d9979d327..5fb83e5fb9 100644 --- a/variants/board_template/variant.h +++ b/variants/board_template/variant.h @@ -61,7 +61,7 @@ enum { // This must be a literal with the same value as PEND // It is used with preprocessor tests (i.e. #if NUM_DIGITAL_PINS > 3) // so an enum will not work. -#define NUM_DIGITAL_PINS 0 +#define NUM_DIGITAL_PINS 0 // Enum defining Arduino style alias for analog pin number --> Ax // !!! @@ -78,7 +78,7 @@ enum { // This must be a literal with the same value as AEND-A0 // It is used with preprocessor tests (i.e. #if NUM_ANALOG_INPUTS > 3) // so an enum will not work. -#define NUM_ANALOG_INPUTS 18 +#define NUM_ANALOG_INPUTS 18 // Below ADC, DAC and PWM definitions already done in the core // Could be redefined here if needed