Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7100c7e

Browse files
committedJan 26, 2018
PR stm32duino#206 review
Use _Static_assert instead of static_assert Cosmetic change Signed-off-by: Frederic Pillon <[email protected]>
1 parent 6ae9c28 commit 7100c7e

File tree

23 files changed

+49
-50
lines changed

23 files changed

+49
-50
lines changed
 

‎cores/arduino/pins_arduino_var.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,17 @@
2525
// Include board variant
2626
#include "variant.h"
2727

28+
// Avoid pins number misalignment
29+
_Static_assert(NUM_DIGITAL_PINS==PEND, "NUM_DIGITAL_PINS and PEND differ!");
30+
_Static_assert(NUM_ANALOG_INPUTS==(AEND-A0), "NUM_DIGITAL_PINS and (AEND-A0) differ!");
31+
2832
#ifdef __cplusplus
2933
extern "C" {
3034
#endif
3135

3236
#define NOT_AN_INTERRUPT NC // -1
3337
#define DEND NUM_DIGITAL_PINS
3438

35-
#ifdef __cplusplus
36-
static_assert(NUM_DIGITAL_PINS==((uint32_t)PEND));
37-
static_assert(NUM_ANALOG_INPUTS==((uint32_t)(AEND-A0)));
38-
#endif
39-
4039
// Convert a digital pin number Dxx to a PinName PX_n
4140
// Note: Analog pin is also a digital pin.
4241
#define digitalPinToPinName(p) (((uint32_t)p < NUM_DIGITAL_PINS) ? digitalPin[p] : NC)

‎variants/DISCO_F100RB/variant.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ enum {
104104
PB1_2,//D62/A15 = D15
105105
PEND
106106
};
107-
107+
108108
// This must be a literal with the same value as PEND
109-
#define NUM_DIGITAL_PINS 63
109+
#define NUM_DIGITAL_PINS 63
110110

111111
enum {
112112
A_START_AFTER = D46,
@@ -116,7 +116,7 @@ enum {
116116
};
117117

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

121121
// On-board LED pin number
122122
#define LED_BUILTIN PC9

‎variants/DISCO_F407VG/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ enum {
132132
};
133133

134134
// This must be a literal with the same value as PEND
135-
#define NUM_DIGITAL_PINS 87
135+
#define NUM_DIGITAL_PINS 87
136136

137137
enum {
138138
A_START_AFTER = D78,
@@ -141,7 +141,7 @@ enum {
141141
};
142142

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

146146
// On-board LED pin number
147147
#define LED_BUILTIN PD12

‎variants/DISCO_F746NG/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ enum {
6464
};
6565

6666
// This must be a literal with the same value as PEND
67-
#define NUM_DIGITAL_PINS 25
67+
#define NUM_DIGITAL_PINS 25
6868

6969
enum {
7070
A_START_AFTER = D15,
@@ -73,7 +73,7 @@ enum {
7373
};
7474

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

7878
// On-board LED pin number
7979
#define LED_BUILTIN 13

‎variants/DISCO_L072CZ_LRWAN1/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ enum {
7474
};
7575

7676
// This must be a literal with the same value as PEND
77-
#define NUM_DIGITAL_PINS 33
77+
#define NUM_DIGITAL_PINS 33
7878

7979
enum {
8080
A_START_AFTER = D25,
@@ -83,7 +83,7 @@ enum {
8383
};
8484

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

8888
// On-board LED pin number
8989
#define LED_BUILTIN PA5

‎variants/DISCO_L475VG_IOT/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ enum {
133133
};
134134

135135
// This must be a literal with the same value as PEND
136-
#define NUM_DIGITAL_PINS 85
136+
#define NUM_DIGITAL_PINS 85
137137

138138
enum {
139139
A_START_AFTER = D68,
@@ -143,7 +143,7 @@ enum {
143143
};
144144

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

148148
// On-board LED pin number
149149
#define LED_BUILTIN 13

‎variants/NUCLEO_F030R8/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ enum {
106106
};
107107

108108
// This must be a literal with the same value as PEND
109-
#define NUM_DIGITAL_PINS 61
109+
#define NUM_DIGITAL_PINS 61
110110

111111
enum {
112112
A_START_AFTER = D48,
@@ -116,7 +116,7 @@ enum {
116116
};
117117

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

121121
// On-board LED pin number
122122
#define LED_BUILTIN 13

‎variants/NUCLEO_F091RC/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ enum {
103103
};
104104

105105
// This must be a literal with the same value as PEND
106-
#define NUM_DIGITAL_PINS 58
106+
#define NUM_DIGITAL_PINS 58
107107

108108
enum {
109109
A_START_AFTER = D45,
@@ -113,7 +113,7 @@ enum {
113113
};
114114

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

118118
// On-board LED pin number
119119
#define LED_BUILTIN 13

‎variants/NUCLEO_F103RB/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ enum {
105105
};
106106

107107
// This must be a literal with the same value as PEND
108-
#define NUM_DIGITAL_PINS 60
108+
#define NUM_DIGITAL_PINS 60
109109

110110
enum {
111111
A_START_AFTER = D45,
@@ -115,7 +115,7 @@ enum {
115115
};
116116

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

120120
// On-board LED pin number
121121
#define LED_BUILTIN 13

‎variants/NUCLEO_F207ZG/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ enum {
149149
};
150150

151151
// This must be a literal with the same value as PEND
152-
#define NUM_DIGITAL_PINS 96
152+
#define NUM_DIGITAL_PINS 96
153153

154154
// Enum defining Arduino style alias for analog pin number --> Ax
155155
enum {
@@ -160,7 +160,7 @@ enum {
160160
};
161161

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

165165
// On-board LED pin number
166166
#define LED_BUILTIN PB0

‎variants/NUCLEO_F302R8/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ enum {
103103
};
104104

105105
// This must be a literal with the same value as PEND
106-
#define NUM_DIGITAL_PINS 58
106+
#define NUM_DIGITAL_PINS 58
107107

108108
enum {
109109
A_START_AFTER = D45,
@@ -113,7 +113,7 @@ enum {
113113
};
114114

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

118118
// On-board LED pin number
119119
#define LED_BUILTIN 13

‎variants/NUCLEO_F303K8/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ enum {
6262
};
6363

6464
// This must be a literal with the same value as PEND
65-
#define NUM_DIGITAL_PINS 23
65+
#define NUM_DIGITAL_PINS 23
6666

6767
enum {
6868
A_START_AFTER = D13,
@@ -71,7 +71,7 @@ enum {
7171
};
7272

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

7676
// On-board LED pin number
7777
#define LED_BUILTIN 13

‎variants/NUCLEO_F303RE/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ enum {
105105
};
106106

107107
// This must be a literal with the same value as PEND
108-
#define NUM_DIGITAL_PINS 60
108+
#define NUM_DIGITAL_PINS 60
109109

110110
enum {
111111
A_START_AFTER = D45,
@@ -115,7 +115,7 @@ enum {
115115
};
116116

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

120120
// On-board LED pin number
121121
#define LED_BUILTIN 13

‎variants/NUCLEO_F401RE/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ enum {
104104
};
105105

106106
// This must be a literal with the same value as PEND
107-
#define NUM_DIGITAL_PINS 59
107+
#define NUM_DIGITAL_PINS 59
108108

109109
enum {
110110
A_START_AFTER = D45,
@@ -114,7 +114,7 @@ enum {
114114
};
115115

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

119119
// On-board LED pin number
120120
#define LED_BUILTIN 13

‎variants/NUCLEO_F411RE/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ enum {
104104
};
105105

106106
// This must be a literal with the same value as PEND
107-
#define NUM_DIGITAL_PINS 59
107+
#define NUM_DIGITAL_PINS 59
108108

109109
enum {
110110
A_START_AFTER = D45,
@@ -114,7 +114,7 @@ enum {
114114
};
115115

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

119119
// On-board LED pin number
120120
#define LED_BUILTIN 13

‎variants/NUCLEO_F429ZI/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ enum {
136136
};
137137

138138
// This must be a literal with the same value as PEND
139-
#define NUM_DIGITAL_PINS 96
139+
#define NUM_DIGITAL_PINS 96
140140

141141
enum {
142142
A_START_AFTER = D77,
@@ -146,7 +146,7 @@ enum {
146146
};
147147

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

151151
// On-board LED pin number
152152
#define LED_BUILTIN PB0

‎variants/NUCLEO_F446RE/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ enum {
105105
};
106106

107107
// This must be a literal with the same value as PEND
108-
#define NUM_DIGITAL_PINS 60
108+
#define NUM_DIGITAL_PINS 60
109109

110110
enum {
111111
A_START_AFTER = D45,
@@ -115,7 +115,7 @@ enum {
115115
};
116116

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

120120
// On-board LED pin number
121121
#define LED_BUILTIN 13

‎variants/NUCLEO_L031K6/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ enum {
7474
};
7575

7676
// This must be a literal with the same value as PEND
77-
#define NUM_DIGITAL_PINS 23
77+
#define NUM_DIGITAL_PINS 23
7878

7979
enum {
8080
A_START_AFTER = D13,
@@ -83,7 +83,7 @@ enum {
8383
};
8484

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

8888
// On-board LED pin number
8989
#define LED_BUILTIN 13

‎variants/NUCLEO_L053R8/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ enum {
103103
};
104104

105105
// This must be a literal with the same value as PEND
106-
#define NUM_DIGITAL_PINS 58
106+
#define NUM_DIGITAL_PINS 58
107107

108108
enum {
109109
A_START_AFTER = D45,
@@ -113,7 +113,7 @@ enum {
113113
};
114114

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

118118
// On-board LED pin number
119119
#define LED_BUILTIN 13

‎variants/NUCLEO_L152RE/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ enum {
108108
};
109109

110110
// This must be a literal with the same value as PEND
111-
#define NUM_DIGITAL_PINS 63
111+
#define NUM_DIGITAL_PINS 63
112112

113113
enum {
114114
A_START_AFTER = D45,
@@ -118,7 +118,7 @@ enum {
118118
};
119119

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

123123

124124
// On-board LED pin number

‎variants/NUCLEO_L432KC/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ enum {
6262
};
6363

6464
// This must be a literal with the same value as PEND
65-
#define NUM_DIGITAL_PINS 23
65+
#define NUM_DIGITAL_PINS 23
6666

6767
enum {
6868
A_START_AFTER = D13,
@@ -71,7 +71,7 @@ enum {
7171
};
7272

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

7676
// On-board LED pin number
7777
#define LED_BUILTIN 13

‎variants/NUCLEO_L476RG/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ enum {
103103
};
104104

105105
// This must be a literal with the same value as PEND
106-
#define NUM_DIGITAL_PINS 58
106+
#define NUM_DIGITAL_PINS 58
107107

108108
enum {
109109
A_START_AFTER = D45,
@@ -113,7 +113,7 @@ enum {
113113
};
114114

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

118118
// On-board LED pin number
119119
#define LED_BUILTIN 13

‎variants/board_template/variant.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ enum {
6161
// This must be a literal with the same value as PEND
6262
// It is used with preprocessor tests (i.e. #if NUM_DIGITAL_PINS > 3)
6363
// so an enum will not work.
64-
#define NUM_DIGITAL_PINS 0
64+
#define NUM_DIGITAL_PINS 0
6565

6666
// Enum defining Arduino style alias for analog pin number --> Ax
6767
// !!!
@@ -78,7 +78,7 @@ enum {
7878
// This must be a literal with the same value as AEND-A0
7979
// It is used with preprocessor tests (i.e. #if NUM_ANALOG_INPUTS > 3)
8080
// so an enum will not work.
81-
#define NUM_ANALOG_INPUTS 18
81+
#define NUM_ANALOG_INPUTS 18
8282

8383
// Below ADC, DAC and PWM definitions already done in the core
8484
// Could be redefined here if needed

0 commit comments

Comments
 (0)
Please sign in to comment.