Skip to content

Commit 8562ca9

Browse files
committed
boards/seeedstudio-xiao-nrf52840: Arduino pin map
1 parent 6fe853c commit 8562ca9

File tree

5 files changed

+172
-26
lines changed

5 files changed

+172
-26
lines changed

boards/seeedstudio-xiao-nrf52840/Makefile.features

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,12 @@ FEATURES_PROVIDED += periph_uart
77
FEATURES_PROVIDED += periph_usbdev
88

99
# Various other features (if any)
10+
FEATURES_PROVIDED += arduino_analog
11+
FEATURES_PROVIDED += arduino_i2c
12+
FEATURES_PROVIDED += arduino_pins
13+
FEATURES_PROVIDED += arduino_spi
14+
FEATURES_PROVIDED += arduino_uart
1015
FEATURES_PROVIDED += highlevel_stdio
16+
FEATURES_PROVIDED += xiao_shield
1117

1218
include $(RIOTBOARD)/common/nrf52/Makefile.features
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
/*
2+
* Copyright (C) 2024 TU Dresden
3+
*
4+
* This file is subject to the terms and conditions of the GNU Lesser
5+
* General Public License v2.1. See the file LICENSE in the top level
6+
* directory for more details.
7+
*/
8+
9+
/**
10+
* @ingroup boards_seeedstudio-xiao-nrf52840
11+
* @{
12+
*
13+
* @file
14+
* @brief Mapping from MCU pins to Arduino pins
15+
*
16+
* You can use the defines in this file for simplified interaction with the
17+
* Arduino specific pin numbers.
18+
*
19+
* @author Mikolai Gütschow <[email protected]>
20+
*/
21+
22+
#ifndef ARDUINO_IOMAP_H
23+
#define ARDUINO_IOMAP_H
24+
25+
#include "periph/gpio.h"
26+
#include "periph/adc.h"
27+
28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
32+
/**
33+
* @name XIAO's UART devices
34+
* @{
35+
* @brief Arduino's Serial uses USB-CDC-ACM stdio by default
36+
*/
37+
#define ARDUINO_UART_DEV UART_UNDEF
38+
/** @} */
39+
40+
/**
41+
* @name XIAO's SPI buses
42+
* @{
43+
*/
44+
#define ARDUINO_SPI_DEV SPI_DEV(0)
45+
/** @} */
46+
47+
/**
48+
* @name XIAO's I2C buses
49+
* @{
50+
*/
51+
#define ARDUINO_I2C_DEV I2C_DEV(0)
52+
/** @} */
53+
54+
/**
55+
* @name XIAO's on-board LED (LED_BUILTIN)
56+
* @{
57+
*/
58+
#define ARDUINO_LED (11)
59+
/** @} */
60+
61+
/**
62+
* @name Mapping of MCU pins to Arduino pins
63+
* @{
64+
*/
65+
/* Left pins */
66+
#define ARDUINO_PIN_0 GPIO_PIN(0, 2)
67+
#define ARDUINO_PIN_1 GPIO_PIN(0, 3)
68+
#define ARDUINO_PIN_2 GPIO_PIN(0,28)
69+
#define ARDUINO_PIN_3 GPIO_PIN(0,29)
70+
#define ARDUINO_PIN_4 GPIO_PIN(0, 4)
71+
#define ARDUINO_PIN_5 GPIO_PIN(0, 5)
72+
#define ARDUINO_PIN_6 GPIO_PIN(1,11)
73+
74+
/* Right side */
75+
#define ARDUINO_PIN_7 GPIO_PIN(1,12)
76+
#define ARDUINO_PIN_8 GPIO_PIN(1,13)
77+
#define ARDUINO_PIN_9 GPIO_PIN(1,14)
78+
#define ARDUINO_PIN_10 GPIO_PIN(1,15)
79+
80+
/* Internal (LEDs) */
81+
#define ARDUINO_PIN_11 GPIO_PIN(0,26)
82+
#define ARDUINO_PIN_12 GPIO_PIN(0, 6)
83+
#define ARDUINO_PIN_13 GPIO_PIN(0,30)
84+
85+
#define ARDUINO_PIN_LAST 13
86+
/** @} */
87+
88+
/**
89+
* @name Aliases for analog pins
90+
* @{
91+
*/
92+
#define ARDUINO_PIN_A0 ARDUINO_PIN_0
93+
#define ARDUINO_PIN_A1 ARDUINO_PIN_1
94+
#define ARDUINO_PIN_A2 ARDUINO_PIN_2
95+
#define ARDUINO_PIN_A3 ARDUINO_PIN_3
96+
#define ARDUINO_PIN_A4 ARDUINO_PIN_4
97+
#define ARDUINO_PIN_A5 ARDUINO_PIN_5
98+
/** @} */
99+
100+
/**
101+
* @name Mapping of Arduino analog pins to RIOT ADC lines
102+
* @{
103+
*/
104+
/* The Seeed Studio XIAO nRF52840 has a fixed ADC to GPIO mapping:
105+
*
106+
* nRF | MCU pin | Exposed as Arduino pin
107+
* -----|-----------|-----------------------
108+
* AIN0 | P0.02 | A0 (D0)
109+
* AIN1 | P0.03 | A1 (D1)
110+
* AIN2 | P0.04 | A4 (D4)
111+
* AIN3 | P0.05 | A5 (D5)
112+
* AIN4 | P0.28 | A2 (D2)
113+
* AIN5 | P0.29 | A3 (D3)
114+
* AIN6 | P0.30 | - (D13)
115+
* AIN7 | P0.31 | - (-)
116+
*/
117+
#define ARDUINO_A0 ADC_LINE(0)
118+
#define ARDUINO_A1 ADC_LINE(1)
119+
#define ARDUINO_A2 ADC_LINE(4)
120+
#define ARDUINO_A3 ADC_LINE(5)
121+
#define ARDUINO_A4 ADC_LINE(2)
122+
#define ARDUINO_A5 ADC_LINE(3)
123+
124+
#define ARDUINO_ANALOG_PIN_LAST 5
125+
/** @} */
126+
127+
#ifdef __cplusplus
128+
}
129+
#endif
130+
131+
#endif /* ARDUINO_IOMAP_H */
132+
/** @} */

doc/doxygen/src/io-mapping-and-shields.md

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -90,25 +90,27 @@ mapping. For the official Arduino boards and compatible boards, the
9090
Please extend the table below to keep naming among boards of the same form
9191
factor consistent:
9292

93-
| Form Factor | Macro Name | Description |
94-
|:------------- |:--------------------- |:--------------------------------- |
95-
| Arduino Nano | `ARDUINO_UART_D0D1` | UART on D0 (RXD) and D1 (TXD) |
96-
| Arduino Uno | `ARDUINO_UART_D0D1` | UART on D0 (RXD) and D1 (TXD) |
97-
| Arduino Mega | `ARDUINO_UART_D0D1` | UART on D0 (RXD) and D1 (TXD) |
93+
| Form Factor | Macro Name | Description |
94+
|:---------------- |:--------------------- |:--------------------------------- |
95+
| Arduino Nano | `ARDUINO_UART_D0D1` | UART on D0 (RXD) and D1 (TXD) |
96+
| Arduino Uno | `ARDUINO_UART_D0D1` | UART on D0 (RXD) and D1 (TXD) |
97+
| Arduino Mega | `ARDUINO_UART_D0D1` | UART on D0 (RXD) and D1 (TXD) |
98+
| Seeedstudio XIAO | `ARDUINO_UART_DEV` | UART on D7 (RXD) and D6 (TXD) |
9899

99100
I²C Buses {#iomaps-mapping-i2c}
100101
---------
101102

102103
The feature `arduino_i2c` is provided by boards that do provide an I²C bus
103104
mapping.
104105

105-
| Form Factor | Macro Name | Description |
106-
|:------------- |:--------------------- |:--------------------------------- |
107-
| Arduino Nano | `ARDUINO_I2C_NANO` | D18 (SDA) / D19 (SCL) |
108-
| Arduino Uno | `ARDUINO_I2C_UNO` | D18 (SDA) / D19 (SCL) |
109-
| Arduino Mega | `ARDUINO_I2C_UNO` | D20 (SDA) / D21 (SCL) |
110-
| Arduino Zero | `ARDUINO_I2C_UNO` | D20 (SDA) / D21 (SCL) |
111-
| Arduino Due | `ARDUINO_I2C_UNO` | D70 (SDA) / D71 (SCL) |
106+
| Form Factor | Macro Name | Description |
107+
|:---------------- |:--------------------- |:--------------------------------- |
108+
| Arduino Nano | `ARDUINO_I2C_NANO` | D18 (SDA) / D19 (SCL) |
109+
| Arduino Uno | `ARDUINO_I2C_UNO` | D18 (SDA) / D19 (SCL) |
110+
| Arduino Mega | `ARDUINO_I2C_UNO` | D20 (SDA) / D21 (SCL) |
111+
| Arduino Zero | `ARDUINO_I2C_UNO` | D20 (SDA) / D21 (SCL) |
112+
| Arduino Due | `ARDUINO_I2C_UNO` | D70 (SDA) / D71 (SCL) |
113+
| Seeedstudio XIAO | `ARDUINO_I2C_DEV` | D4 (SDA) / D5 (SCL) |
112114

113115
The `ARDUINO_I2C_UNO` refers to the I²C bus next to the AREF pin (the topmost
114116
pins on header on the top right) of an Arduino Uno compatible board, e.g.
@@ -123,14 +125,15 @@ SPI Buses {#iomaps-mapping-spi}
123125
The feature `arduino_spi` is provided by boards that do provide an SPI bus
124126
mapping.
125127

126-
| Form Factor | Macro Name | Description |
127-
|:------------- |:------------------------- |:------------------------------------- |
128-
| Arduino Nano | `ARDUINO_SPI_ISP` | The SPI on the ISP header |
129-
| Arduino Nano | `ARDUINO_SPI_D11D12D13` | D11 (MOSI) / D12 (MISO) / D13 (SCK) |
130-
| Arduino Uno | `ARDUINO_SPI_ISP` | The SPI on the ISP header |
131-
| Arduino Uno | `ARDUINO_SPI_D11D12D13` | D11 (MOSI) / D12 (MISO) / D13 (SCK) |
132-
| Arduino Mega | `ARDUINO_SPI_ISP` | The SPI on the ISP header |
133-
| Arduino Mega | `ARDUINO_SPI_D11D12D13` | D11 (MOSI) / D12 (MISO) / D13 (SCK) |
128+
| Form Factor | Macro Name | Description |
129+
|:---------------- |:------------------------- |:------------------------------------- |
130+
| Arduino Nano | `ARDUINO_SPI_ISP` | The SPI on the ISP header |
131+
| Arduino Nano | `ARDUINO_SPI_D11D12D13` | D11 (MOSI) / D12 (MISO) / D13 (SCK) |
132+
| Arduino Uno | `ARDUINO_SPI_ISP` | The SPI on the ISP header |
133+
| Arduino Uno | `ARDUINO_SPI_D11D12D13` | D11 (MOSI) / D12 (MISO) / D13 (SCK) |
134+
| Arduino Mega | `ARDUINO_SPI_ISP` | The SPI on the ISP header |
135+
| Arduino Mega | `ARDUINO_SPI_D11D12D13` | D11 (MOSI) / D12 (MISO) / D13 (SCK) |
136+
| Seeedstudio XIAO | `ARDUINO_SPI_DEV` | D10 (MOSI) / D9 (MISO) / D8 (SCK) |
134137

135138
@note The original AVR based Arduinos only have a single hard SPI bus which
136139
is only provided via the ISP header. Many modern Arduino compatible
@@ -144,12 +147,12 @@ Modules implementing drivers for extension boards, a.k.a. shields, can express
144147
their mechanical and electrical requirements by depending on `arduino_shield_...`
145148
features. The following list of features currently exists:
146149

147-
| Feature Name | Compatibility Claim |
148-
|
149-
| `arduino_shield_nano` | Board has side headers compatible with the Arduino Nano |
150-
| `arduino_shield_uno` | Board has side headers compatible with the Arduino UNO |
151-
| `arduino_shield_mega` | Board has side headers compatible with the Arduino MEGA |
152-
| `arduino_shield_isp` | Board has an ISP header |
150+
| Feature Name | Compatibility Claim |
151+
|:--------------------- |:------------------------------------------------------------- |
152+
| `arduino_shield_nano` | Board has side headers compatible with the Arduino Nano |
153+
| `arduino_shield_uno` | Board has side headers compatible with the Arduino UNO |
154+
| `arduino_shield_mega` | Board has side headers compatible with the Arduino MEGA |
155+
| `xiao_shield` | Board has headers compatible with the Seeedstudio XIAO boards |
153156

154157
@note A board providing `arduino_shield_mega` **MUST** also provide
155158
`arduino_shield_uno`, as Arduino MEGA boards are backward compatible to

features.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,10 @@ groups:
409409
Indicates that the board is mechanically and electrically compatible
410410
with shields developed for the Arduino Nano. (Note: Except the
411411
ISP header, that requires `arduino_shield_isp` in addition.)
412+
- name: xiao_shield
413+
help: >
414+
Indicates that the board is mechanically and electrically compatible
415+
with shields developed for the Seeed Studio XIAO board family.
412416
413417
- title: RAM Related Features
414418
help: These features indicate presence of special RAM regions or features

makefiles/features_existing.inc.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,4 +267,5 @@ FEATURES_EXISTING := \
267267
tinyusb_device \
268268
vdd_lc_filter_reg0 \
269269
vdd_lc_filter_reg1 \
270+
xiao_shield \
270271
#

0 commit comments

Comments
 (0)