Skip to content

Commit 9fabadc

Browse files
author
Donatien Garnier
authored
Merge pull request #1417 from ARMmbed/std-pin-names-porting
Standard Pin Names Porting and Developer Guide
2 parents 03d2191 + c1e721e commit 9fabadc

File tree

6 files changed

+486
-1
lines changed

6 files changed

+486
-1
lines changed

docs.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,16 @@
265265
}
266266
]
267267
},
268+
{
269+
"title": "Standard Pin Names Developer Guide",
270+
"sources": [{
271+
"path": "docs/porting/standard_pin_names/pin_names_dev_guide.md"
272+
},
273+
{
274+
"path": "docs/porting/standard_pin_names/pin_names_dev_guide_arduino.md"
275+
}
276+
]
277+
},
268278
{
269279
"title": "Serial (UART) APIs",
270280
"sources": [{
@@ -1305,6 +1315,9 @@
13051315
{
13061316
"path": "docs/porting/target/gpio.md"
13071317
},
1318+
{
1319+
"path": "docs/porting/standard_pin_names/pin_names_porting.md"
1320+
},
13081321
{
13091322
"path": "docs/porting/target/rtc.md"
13101323
},

docs/images/Arduino_Uno_Mbed.png

93.3 KB
Loading
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
## Introduction
2+
3+
### Overview and assumptions
4+
5+
Platform code should be portable across different Mbed supported boards with the same hardware capabilities or interfaces.
6+
7+
This document provides general developer guidelines on pin names that apply to all boards but it's not specific to any type of connector.
8+
9+
**_NOTE:_** there might be separate documents for pin names that apply to specific connectors.
10+
11+
## Standard Pin Names
12+
13+
### LEDs
14+
15+
Available onboard LEDs are defined as `LEDx` e.g. `LED1`, `LED2`, ...
16+
17+
The detection of available LEDs at application level can be done as follows:
18+
19+
#ifdef LED1
20+
DigitalOut myLED(LED1);
21+
myLED = 1;
22+
#endif
23+
24+
Alternatively, if the usage of an LED is required, then the application can detect its availability and generate an error accordingly:
25+
26+
#ifndef LED1
27+
#error This application requires the availability of an LED
28+
#endif
29+
30+
It's possible to define new names of LEDs related to its properties, like color or functionality. They can be defined as aliases in the application as shown below:
31+
32+
#define RED_LED LED1
33+
#define STATUS_LED LED2
34+
35+
However, these names do not apply to all boards and hence should not be used in official example applications.
36+
37+
### Buttons
38+
39+
Buttons that are available on a board will be defined as `BUTTONx` e.g. `BUTTON1`, `BUTTON2`, ...
40+
41+
The detection of available buttons at application level can be done as follow:
42+
43+
#ifdef BUTTON1
44+
DigitalIn myBUTTON(BUTTON1);
45+
int input = myBUTTON.read();
46+
#endif
47+
48+
Alternatively, if the usage of a button is required, then the application can detect its availability and generate an error accordingly:
49+
50+
#ifndef BUTTON1
51+
#error This application requires the availability of a button
52+
#endif
53+
54+
It's possible to define new names of buttons related to its properties. It's recommended to add a comment with a description. They can be defined as aliases at application level as shown below:
55+
56+
#define PUSH_BUTTON BUTTON1 // Momentary push Button
57+
58+
However, these names do not apply to all boards and hence should not be used in official example applications.
59+
60+
### UART
61+
62+
Every Mbed board includes a serial interface to the host PC, which allows the console to print useful information about the application.
63+
64+
The pins for the main serial interface are defined as `CONSOLE_TX` and `CONSOLE_RX`.
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
## Arduino Uno
2+
3+
The Arduino Uno connector is a standardised connector in Mbed, which has a set amount of exposed functionality. To achieve meaningful portability of application code across various Mbed boards that are Arduino Uno compliant, the pin names used for the connector pins are common across these boards.
4+
5+
The following diagram shows the Arduino Uno standard for Mbed boards:
6+
![Static pinmap model](../../images/Arduino_Uno_Mbed.png)
7+
8+
**Digital and Analog pins**
9+
10+
The Arduino Uno connector for Mbed boards supports both digital and analog pins. Please note that the Arduino Uno only supports analog inputs and does not support analog output functionality. Digital pin functionality such as GPIO output or input on the Arduino Uno header can be accessed from any of the pins labelled as ARDUINO_UNO_D0 to ARDUINO_UNO_D15 and ARDUINO_UNO_A0 to ARDUINO_UNO_A5. The analog input functionality on the Arduino Uno connector can only be accessed on pins ARDUINO_UNO_A0 to ARDUINO_UNO_A5. The full digital and analog pin alias list for the Arduino Uno connector can be seen below.
11+
12+
ARDUINO_UNO_D0
13+
ARDUINO_UNO_D1
14+
ARDUINO_UNO_D2
15+
ARDUINO_UNO_D3
16+
ARDUINO_UNO_D4
17+
ARDUINO_UNO_D5
18+
ARDUINO_UNO_D6
19+
ARDUINO_UNO_D7
20+
ARDUINO_UNO_D8
21+
ARDUINO_UNO_D9
22+
ARDUINO_UNO_D10
23+
ARDUINO_UNO_D11
24+
ARDUINO_UNO_D12
25+
ARDUINO_UNO_D13
26+
ARDUINO_UNO_D14
27+
ARDUINO_UNO_D15
28+
29+
ARDUINO_UNO_A0
30+
ARDUINO_UNO_A1
31+
ARDUINO_UNO_A2
32+
ARDUINO_UNO_A3
33+
ARDUINO_UNO_A4
34+
ARDUINO_UNO_A5
35+
36+
**SPI pins**
37+
38+
The Arduino Uno connector for Mbed boards supports SPI functionality on specific pins and can be accessed using the pin alias's below
39+
40+
ARDUINO_UNO_SPI_CS or ARDUINO_UNO_D10
41+
ARDUINO_UNO_SPI_MOSI or ARDUINO_UNO_D11
42+
ARDUINO_UNO_SPI_MISO or ARDUINO_UNO_D12
43+
ARDUINO_UNO_SPI_SCK or ARDUINO_UNO_D13
44+
45+
if you need more SPI chip selects(CS) for your application, these can be controlled using additional digital out pins with the alias explained previously on this page
46+
47+
**I2C pins**
48+
49+
The Arduino Uno connector for Mbed boards supports I2C functionality on specific pins and can be accessed using the pin alias's below.
50+
51+
ARDUINO_UNO_I2C_SDA or ARDUINO_UNO_D14
52+
ARDUINO_UNO_I2C_SCL or ARDUINO_UNO_D15
53+
54+
**UART pins**
55+
56+
The Arduino Uno connector for Mbed boards supports UART functionality on specific pins and can be accessed using the pin alias's below
57+
58+
ARDUINO_UNO_UART_TX or ARDUINO_UNO_D1
59+
ARDUINO_UNO_UART_RX or ARDUINO_UNO_D0
60+
61+
For more details about UART, please check the Mbed API.
62+
63+
**PWM/Timer pins**
64+
65+
In the Arduino Uno standard, there are only 6 PWM and timers available on pins ARDUINO_UNO_D3, ARDUINO_UNO_D5, ARDUINO_UNO_D6, ARDUINO_UNO_D9, ARDUINO_UNO_D10 and ARDUINO_UNO_D11. However, Mbed boards may support the usage of PWM and timers functions on other pins as well.

0 commit comments

Comments
 (0)