Skip to content

Assigning literal values to NUM_DIGITAL_PINS and NUM_ANALOG_INPUTS #206

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions cores/arduino/pins_arduino_var.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@
// 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_ANALOG_INPUTS and (AEND-A0) differ!");

#ifdef __cplusplus
extern "C" {
#endif

#define NOT_AN_INTERRUPT NC // -1
#define DEND PEND
#define NUM_DIGITAL_PINS ((uint32_t)DEND)
#define NUM_ANALOG_INPUTS ((uint32_t)(AEND-A0))
#define DEND NUM_DIGITAL_PINS

// Convert a digital pin number Dxx to a PinName PX_n
// Note: Analog pin is also a digital pin.
Expand Down
6 changes: 6 additions & 0 deletions variants/DISCO_F100RB/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,19 @@ enum {
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 63

enum {
A_START_AFTER = D46,
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
A10, A11, A12, A13, A14, A15,
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 16

// On-board LED pin number
#define LED_BUILTIN PC9
#define LED_GREEN LED_BUILTIN
Expand Down
6 changes: 6 additions & 0 deletions variants/DISCO_F407VG/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,18 @@ enum {
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 87

enum {
A_START_AFTER = D78,
A0, A1, A2, A3, A4, A5, A6, A7,
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 8

// On-board LED pin number
#define LED_BUILTIN PD12
#define LED_GREEN LED_BUILTIN
Expand Down
6 changes: 6 additions & 0 deletions variants/DISCO_F746NG/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,18 @@ enum {
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 25

enum {
A_START_AFTER = D15,
A0, A1, A2, A3, A4, A5,
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 6

// On-board LED pin number
#define LED_BUILTIN 13
#define LED_GREEN LED_BUILTIN
Expand Down
6 changes: 6 additions & 0 deletions variants/DISCO_L072CZ_LRWAN1/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,18 @@ enum {
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 33

enum {
A_START_AFTER = D25,
A0, A1, A2, A3, A4, A5, A6,
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 7

// On-board LED pin number
#define LED_BUILTIN PA5
#define LED_LD2 LED_BUILTIN
Expand Down
6 changes: 6 additions & 0 deletions variants/DISCO_L475VG_IOT/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,19 @@ enum {
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 85

enum {
A_START_AFTER = D68,
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
A10, A11, A12, A13, A14, A15,
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 16

// On-board LED pin number
#define LED_BUILTIN 13
#define LED1 LED_BUILTIN
Expand Down
6 changes: 6 additions & 0 deletions variants/NUCLEO_F030R8/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,19 @@ enum {
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 61

enum {
A_START_AFTER = D48,
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
A10, A11,
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 12

// On-board LED pin number
#define LED_BUILTIN 13
#define LED_GREEN LED_BUILTIN
Expand Down
6 changes: 6 additions & 0 deletions variants/NUCLEO_F091RC/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,19 @@ enum {
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 58

enum {
A_START_AFTER = D45,
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
A10, A11,
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 12

// On-board LED pin number
#define LED_BUILTIN 13
#define LED_GREEN LED_BUILTIN
Expand Down
6 changes: 6 additions & 0 deletions variants/NUCLEO_F103RB/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,19 @@ enum {
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 60

enum {
A_START_AFTER = D45,
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
A10, A11, A12, A13,
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 14

// On-board LED pin number
#define LED_BUILTIN 13
#define LED_GREEN LED_BUILTIN
Expand Down
7 changes: 7 additions & 0 deletions variants/NUCLEO_F207ZG/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ enum {
PF9_2,//D95/A17 = D63
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 96

// Enum defining Arduino style alias for analog pin number --> Ax
enum {
A_START_AFTER = D77, // pin number preceding A0
Expand All @@ -155,6 +159,9 @@ enum {
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 18

// On-board LED pin number
#define LED_BUILTIN PB0
#define LED_GREEN LED_BUILTIN
Expand Down
6 changes: 6 additions & 0 deletions variants/NUCLEO_F302R8/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,19 @@ enum {
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 58

enum {
A_START_AFTER = D45,
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
A10, A11,
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 12

// On-board LED pin number
#define LED_BUILTIN 13
#define LED_GREEN LED_BUILTIN
Expand Down
6 changes: 6 additions & 0 deletions variants/NUCLEO_F303K8/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,18 @@ enum {
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 23

enum {
A_START_AFTER = D13,
A0, A1, A2, A3, A4, A5, A6,
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 7

// On-board LED pin number
#define LED_BUILTIN 13
#define LED_GREEN LED_BUILTIN
Expand Down
6 changes: 6 additions & 0 deletions variants/NUCLEO_F303RE/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,19 @@ enum {
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 60

enum {
A_START_AFTER = D45,
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
A10, A11, A12, A13,
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 14

// On-board LED pin number
#define LED_BUILTIN 13
#define LED_GREEN LED_BUILTIN
Expand Down
6 changes: 6 additions & 0 deletions variants/NUCLEO_F401RE/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,19 @@ enum {
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 59

enum {
A_START_AFTER = D45,
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
A10, A11, A12,
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 13

// On-board LED pin number
#define LED_BUILTIN 13
#define LED_GREEN LED_BUILTIN
Expand Down
6 changes: 6 additions & 0 deletions variants/NUCLEO_F411RE/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,19 @@ enum {
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 59

enum {
A_START_AFTER = D45,
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
A10, A11, A12,
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 13

// On-board LED pin number
#define LED_BUILTIN 13
#define LED_GREEN LED_BUILTIN
Expand Down
6 changes: 6 additions & 0 deletions variants/NUCLEO_F429ZI/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,19 @@ enum {
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 96

enum {
A_START_AFTER = D77,
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
A10, A11, A12, A13, A14, A15, A16, A17,
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 18

// On-board LED pin number
#define LED_BUILTIN PB0
#define LED_GREEN LED_BUILTIN
Expand Down
6 changes: 6 additions & 0 deletions variants/NUCLEO_F446RE/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,19 @@ enum {
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 60

enum {
A_START_AFTER = D45,
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
A10, A11, A12, A13,
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 14

// On-board LED pin number
#define LED_BUILTIN 13
#define LED_LD2 LED_BUILTIN
Expand Down
6 changes: 6 additions & 0 deletions variants/NUCLEO_L031K6/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,18 @@ enum {
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 23

enum {
A_START_AFTER = D13,
A0, A1, A2, A3, A4, A5, A6,
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 7

// On-board LED pin number
#define LED_BUILTIN 13
#define LED_GREEN LED_BUILTIN
Expand Down
6 changes: 6 additions & 0 deletions variants/NUCLEO_L053R8/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,19 @@ enum {
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 58

enum {
A_START_AFTER = D45,
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
A10, A11,
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 12

// On-board LED pin number
#define LED_BUILTIN 13
#define LED_GREEN LED_BUILTIN
Expand Down
7 changes: 7 additions & 0 deletions variants/NUCLEO_L152RE/variant.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,20 @@ enum {
PEND
};

// This must be a literal with the same value as PEND
#define NUM_DIGITAL_PINS 63

enum {
A_START_AFTER = D45,
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
A10, A11, A12, A13, A14, A15, A16,
AEND
};

// This must be a literal with the same value as AEND-A0
#define NUM_ANALOG_INPUTS 17


// On-board LED pin number
#define LED_BUILTIN 13
#define LED_GREEN LED_BUILTIN
Expand Down
Loading