Skip to content

Commit 89fa784

Browse files
committed
Add pin details to porting guide
1 parent 499bfdb commit 89fa784

File tree

1 file changed

+116
-4
lines changed

1 file changed

+116
-4
lines changed

docs/porting/standard_pin_names/pin_names_porting.md

Lines changed: 116 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,69 @@ The generic guidelines currently define rules for the naming of LED pins, button
1616
* A pin cannot be assigned to itself
1717
* A pin cannot be defined as `NC` (not connected)
1818

19-
Please refer to the design document for the full specification.
19+
### Definition of LEDs
20+
21+
Only add LEDs that are available on the board. This is an example on how to define LEDs in PinNames.h:
22+
23+
// Px_xx relates to the processor pin connected to the LED
24+
#define LED1 Px_xx // LED1
25+
#define LED2 Px_xx // LED2
26+
#define LED3 Px_xx // LED3
27+
#define LED4 Px_xx // LED4
28+
.
29+
.
30+
#define LEDN Px_xx // LEDN
31+
32+
### Definition of buttons
33+
34+
Only add buttons that are available on the board. This is an example on how to define buttons in PinNames.h:
35+
36+
// Px_xx relates to the processor pin connected to the button
37+
#define BUTTON1 Px_xx // BUTTON1
38+
#define BUTTON2 Px_xx // BUTTON2
39+
#define BUTTON3 Px_xx // BUTTON3
40+
#define BUTTON4 Px_xx // BUTTON4
41+
.
42+
.
43+
#define BUTTONN Px_xx // BUTTONN
44+
### Definition of UART pins
45+
46+
This is an example on how to define UART names in PinNames.h:
47+
48+
typedef enum {
49+
...
50+
// Px_xx relates to the processor pin connected to the UART
51+
USBTX = Px_xx,
52+
USBRX = Px_xx,
53+
...
54+
} PinName;
55+
56+
### Non-valid definitions
57+
58+
If either LEDs or buttons are not available, they should not be defined.
59+
This allows for unavailable LEDs or BUTTONs to be caught in Mbed OS allowing the corresponding errors to be generated.
60+
61+
#define LED1 PB_0 // LED1 is valid
62+
#define LED2 LED1 // Not valid as it's duplicate and LED2 does not exist on the board
63+
#define LED3 PB_0 // Not valid as it's duplicate and LED3 does not exist on the board
64+
#define LED4 NC // Not valid definition as LED4 does not exist
65+
66+
#define BUTTON1 PB_1 // BUTTON1 is valid
67+
#define BUTTON2 BUTTON1 // Not valid as it's duplicate and BUTTON2 does not exist on the board
68+
#define BUTTON3 PB_1 // Not valid as it's duplicate and BUTTON3 does not exist on the board
69+
#define BUTTON4 NC // Not valid as BUTTON4 does not exist
2070

2171
## Arduino Uno Pin Names
2272
The Arduino Uno guidelines currently define rules for the naming of the Arduino Uno connector pins, the functionality that each pin must support and the definition of Arduino Uno pin aliases. In summary, rules that apply to all Arduino pins are:
2373
* All ARDUINO_UNO_XXX pins are defined
2474
* A pin cannot be assigned to itself
2575
* A pin cannot be defined as `NC` (not connected)
2676

27-
Also, every board that has the Arduino Uno connector must include `ARDUINO_UNO` in `targets.json` in the `supported_form_factors` list.
77+
In Arduino Uno compliant development boards, the `ARDUINO_UNO` name should be defined as a supported form factor in targets.json file:
2878

29-
There are additional rules for different types of pins. Below is a summary of those rules.
79+
"supported_form_factors": [
80+
"ARDUINO_UNO"
81+
],
3082

3183
### Digital and Analog pins
3284
* Pins must be defined in a `PinName` enum
@@ -35,18 +87,78 @@ There are additional rules for different types of pins. Below is a summary of th
3587
* Analog pins must provide ADC functionality
3688
* A physical MCU pin can be assigned to no more than one Arduino Uno pin
3789

90+
The Arduino Uno (Rev3) form factor for Mbed boards must support and define both D0-D15 pins for digital GPIO and A0-A5 pins for analog input as part of the default standard. These pins should be defined in PinNames.h file within a PinName enum. The prefix `ARDUINO_UNO_` distinguishes these pins from pins defined for other custom or common connectors that may have similar pin names.
91+
92+
The analog input signals in the Arduino Uno connector must be supported on at least the Ax pins.
93+
94+
#ifdef TARGET_FF_ARDUINO_UNO
95+
// Arduino Uno (Rev3) pins
96+
// Px_xx relates to the processor pin connected to the Arduino Uno (Rev3) connector pin
97+
ARDUINO_UNO_D0 = Px_xx,
98+
ARDUINO_UNO_D1 = Px_xx,
99+
ARDUINO_UNO_D2 = Px_xx,
100+
ARDUINO_UNO_D3 = Px_xx,
101+
ARDUINO_UNO_D4 = Px_xx,
102+
ARDUINO_UNO_D5 = Px_xx,
103+
ARDUINO_UNO_D6 = Px_xx,
104+
ARDUINO_UNO_D7 = Px_xx,
105+
ARDUINO_UNO_D8 = Px_xx,
106+
ARDUINO_UNO_D9 = Px_xx,
107+
ARDUINO_UNO_D10 = Px_xx,
108+
ARDUINO_UNO_D11 = Px_xx,
109+
ARDUINO_UNO_D12 = Px_xx,
110+
ARDUINO_UNO_D13 = Px_xx,
111+
ARDUINO_UNO_D14 = Px_xx,
112+
ARDUINO_UNO_D15 = Px_xx,
113+
114+
ARDUINO_UNO_A0 = Px_xx,
115+
ARDUINO_UNO_A1 = Px_xx,
116+
ARDUINO_UNO_A2 = Px_xx,
117+
ARDUINO_UNO_A3 = Px_xx,
118+
ARDUINO_UNO_A4 = Px_xx,
119+
ARDUINO_UNO_A5 = Px_xx,
120+
#endif // TARGET_FF_ARDUINO_UNO
121+
122+
If the development board has the Arduino Uno connector in hardware, but does not comply with the Arduino Uno standard, whether it be with alternate functionality pins or non connected pins, the board should not be defined as Arduino Uno compliant and `ARDUINO_UNO` should not be added as a supported form factor in targets.json. Note this may result in a warning being generated at compile time to inform the user.
123+
38124
### I2C, SPI and UART pins
39125
* Pins D14, D15 must provide I2C functionality (SDA, SCL)
40126
* Pins D10, D11, D12, D13 must provide SPI functionality (CS, MOSI, MISO, SCK)
41127
* Pins D0, D1 must provide UART functionality (RX, TX)
42128

129+
All I2C, SPI and UART pin name alias definitions for the Arduino Uno (Rev3) connector pins is defined in the Mbed OS HAL (hal/include/hal/ArduinoUnoAliases.h) and are common to all Arduino Uno compliant targets:
130+
131+
#ifdef TARGET_FF_ARDUINO_UNO
132+
// Arduino Uno I2C signals aliases
133+
#define ARDUINO_UNO_I2C_SDA ARDUINO_UNO_D14
134+
#define ARDUINO_UNO_I2C_SCL ARDUINO_UNO_D15
135+
136+
// Arduino Uno SPI signals aliases
137+
#define ARDUINO_UNO_SPI_CS ARDUINO_UNO_D10
138+
#define ARDUINO_UNO_SPI_MOSI ARDUINO_UNO_D11
139+
#define ARDUINO_UNO_SPI_MISO ARDUINO_UNO_D12
140+
#define ARDUINO_UNO_SPI_SCK ARDUINO_UNO_D13
141+
142+
// Arduino Uno UART signals aliases
143+
#define ARDUINO_UNO_UART_TX ARDUINO_UNO_D1
144+
#define ARDUINO_UNO_UART_RX ARDUINO_UNO_D0
145+
#endif // TARGET_FF_ARDUINO_UNO
146+
43147
### Other pins
44148
* Mbed boards may provide PWM and timer functionality on certain Dx pins
45149
* Applications cannot assume consistent availability of PWM and timer pins across Mbed boards
46150
* The reset pin must be wired correctly in hardware but is not required to be defined in `PinNames.h`
47151

48-
Please refer to the design document for the full specification.
152+
In the Arduino Uno standard there are only 6 PWM and timers available on pins D3, D5, D6, D9, D10 and D11.
153+
Mbed boards may support the usage of PWM and timers functions in some Dx pinnames. Although this is recomended as per the Arduino Uno standard, it's not a mandatory as requirement to be compliant with the Arduino Uno standard for Mbed boards.
154+
155+
Note this might be one of the main differencess accross Mbed boards and therefore the application should not assume the same behaviour for PWM and Timers for them.
156+
157+
The Reset signal in the Arduino Uno header is a bidirectional reset that will put both a connected Arduino Uno shield and the Mbed board into a reset state. There is a hardware requirement to wire this signal correctly; however there is no need to define the Reset signal in the BSP for the Mbed board.
49158

159+
The Vin signal is defined in the Arduino Uno standard and should be implemented between 7V to 12V. In some cases this signal may be implemented as a bi-directional power supply.
160+
A warning should be included in the Mbed platform's website if it isn't implemented in the correct voltage range.
161+
Note if a Partner or developer designs an Arduino Uno shield and expects 7V-12V on the Vin, it will have power issues with a controller board supplying less then 7V and will likely cause the Arduino Uno shield to not power up correctly
50162

51163
## Target markers
52164

0 commit comments

Comments
 (0)