You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/design-documents/hal/0004-pin-names-general-guidelines.md
+23-23Lines changed: 23 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,28 +42,28 @@ To achieve meaningful portability of application code across various Mbed Enable
42
42
Only add LEDs that are available on the board. This is an example on how to define LEDs in PinNames.h:
43
43
44
44
// Px_xx relates to the processor pin connected to the LED
45
-
#define LED1 = Px_xx // LED1
46
-
#define LED2 = Px_xx // LED2
47
-
#define LED3 = Px_xx // LED3
48
-
#define LED4 = Px_xx // LED4
45
+
#define LED1 Px_xx // LED1
46
+
#define LED2 Px_xx // LED2
47
+
#define LED3 Px_xx // LED3
48
+
#define LED4 Px_xx // LED4
49
49
.
50
50
.
51
-
#define LEDN = Px_xx // LEDN
51
+
#define LEDN Px_xx // LEDN
52
52
53
53
Note this document is proposing changing LEDs from `enums` to `define`, which causes a minor change in the compile preprocessor. From application point of view, there are no implications.
54
54
55
55
**Using LEDs at application**
56
56
57
57
The detection of available LEDs at application level can be done as follow:
58
58
59
-
#ifdef(LED1)
59
+
#ifdefLED1
60
60
DigitalOut myLED(LED1);
61
61
myLED = 1;
62
62
#endif
63
63
64
64
Alternatively, if the usage of an LED is required, then the application can detect its availability and generate an error accordingly:
65
65
66
-
#ifndef(LED1)
66
+
#ifndefLED1
67
67
#error This application requires the availability of an LED
68
68
#endif
69
69
@@ -81,28 +81,28 @@ However, these names do not apply to all boards and hence should not be used in
81
81
Only add buttons that are available on the board. This is an example on how to define buttons in PinNames.h:
82
82
83
83
// Px_xx relates to the processor pin connected to the button
84
-
#define BUTTON1 = Px_xx // BUTTON1
85
-
#define BUTTON2 = Px_xx // BUTTON2
86
-
#define BUTTON3 = Px_xx // BUTTON3
87
-
#define BUTTON4 = Px_xx // BUTTON4
84
+
#define BUTTON1 Px_xx // BUTTON1
85
+
#define BUTTON2 Px_xx // BUTTON2
86
+
#define BUTTON3 Px_xx // BUTTON3
87
+
#define BUTTON4 Px_xx // BUTTON4
88
88
.
89
89
.
90
-
#define BUTTONN = Px_xx // BUTTONN
90
+
#define BUTTONN Px_xx // BUTTONN
91
91
92
92
Note this document is proposing changing buttons from `enums` to `define`, which causes a minor change in the compile preprocessor. From application point of view, there are no implications.
93
93
94
94
**Using Buttons at application**
95
95
96
96
The detection of available buttons at application level can be done as follow:
97
97
98
-
#ifdef(BUTTON1)
98
+
#ifdefBUTTON1
99
99
DigitalIn myBUTTON(BUTTON1);
100
100
int input = myBUTTON.read();
101
101
#endif
102
102
103
103
Alternatively, if the usage of a button is required, then the application can detect its availability and generate an error accordingly:
104
104
105
-
#ifndef(BUTTON1)
105
+
#ifndefBUTTON1
106
106
#error This application requires the availability of a button
107
107
#endif
108
108
@@ -135,15 +135,15 @@ Note this document is proposing unifying the pin names used for UART communicati
135
135
If either LEDs or buttons are not available, they should not be defined.
136
136
This allows for unavailable LEDs or BUTTONs to be caught in Mbed OS allowing the corresponding errors to be generated.
137
137
138
-
LED1 = PB_0, // LED1 is valid
139
-
LED2 = LED1, // Not valid as it's duplicate and LED2 does not exist on the board
140
-
LED3 = PB_0, // Not valid as it's duplicate and LED3 does not exist on the board
141
-
LED4 = NC // Not valid definition as LED4 does not exist
142
-
143
-
BUTTON1 = PB_1, // BUTTON1 is valid
144
-
BUTTON2 = BUTTON1, // Not valid as it's duplicate and BUTTON2 does not exist on the board
145
-
BUTTON3 = PB_1, // Not valid as it's duplicate and BUTTON3 does not exist on the board
146
-
BUTTON4 = NC, // Not valid as BUTTON4 does not exist
138
+
#define LED1 PB_0 // LED1 is valid
139
+
#define LED2 LED1 // Not valid as it's duplicate and LED2 does not exist on the board
140
+
#define LED3 PB_0 // Not valid as it's duplicate and LED3 does not exist on the board
141
+
#define LED4 NC // Not valid definition as LED4 does not exist
142
+
143
+
#define BUTTON1 PB_1 // BUTTON1 is valid
144
+
#define BUTTON2 BUTTON1 // Not valid as it's duplicate and BUTTON2 does not exist on the board
145
+
#define BUTTON3 PB_1 // Not valid as it's duplicate and BUTTON3 does not exist on the board
146
+
#define BUTTON4 NC // Not valid as BUTTON4 does not exist
0 commit comments