Skip to content

Commit 88e29e6

Browse files
committed
boards/seeedstudio-xiao-nrf52840-sense: add initial support
1 parent 3399b64 commit 88e29e6

File tree

12 files changed

+598
-0
lines changed

12 files changed

+598
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Copyright (c) 2024 TU Dresden
2+
#
3+
# This file is subject to the terms and conditions of the GNU Lesser
4+
# General Public License v2.1. See the file LICENSE in the top level
5+
# directory for more details.
6+
7+
config BOARD
8+
default "seeedstudio-xiao-nrf52840-sense" if BOARD_XIAO_NRF52840_SENSE
9+
10+
config BOARD_XIAO_NRF52840_SENSE
11+
bool
12+
default y
13+
select BOARD_COMMON_NRF52
14+
select CPU_MODEL_NRF52840XXAA
15+
16+
source "$(RIOTBOARD)/common/nrf52/Kconfig"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
MODULE = board
2+
3+
include $(RIOTBASE)/Makefile.base
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
ifneq (,$(filter saul_default,$(USEMODULE)))
2+
USEMODULE += saul_gpio
3+
endif
4+
5+
ifneq (,$(filter mtd,$(USEMODULE)))
6+
USEMODULE += mtd_spi_nor
7+
endif
8+
9+
# default to using littlefs2 on the external flash
10+
ifneq (,$(filter vfs_default,$(USEMODULE)))
11+
USEPKG += littlefs2
12+
USEMODULE += mtd
13+
endif
14+
15+
# Use the NRFX package for the board initialization
16+
USEPKG += nrfx
17+
18+
USEMODULE += boards_common_adafruit-nrf52-bootloader
19+
20+
# include common nrf52 dependencies
21+
include $(RIOTBOARD)/common/nrf52/Makefile.dep
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
CPU_MODEL = nrf52840xxaa
2+
3+
# Put defined MCU peripherals here (in alphabetical order)
4+
FEATURES_PROVIDED += periph_i2c
5+
FEATURES_PROVIDED += periph_spi
6+
FEATURES_PROVIDED += periph_uart
7+
FEATURES_PROVIDED += periph_usbdev
8+
9+
# 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
15+
FEATURES_PROVIDED += highlevel_stdio
16+
FEATURES_PROVIDED += xiao_shield
17+
18+
include $(RIOTBOARD)/common/nrf52/Makefile.features
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
UF2_SOFTDEV ?= SD730
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright (C) 2025 Technische Universität Hamburg
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-sense
11+
* @{
12+
*
13+
* @file board.c
14+
* @brief Board specific implementations for the Seeedstudio Xiao
15+
* nRF52840 Sense board
16+
*
17+
*
18+
* @author Christopher Büchse <[email protected]>
19+
*
20+
* @}
21+
*/
22+
23+
#include <stdio.h>
24+
25+
#include "board.h"
26+
#include "periph/gpio.h"
27+
28+
#include "hal/nrf_gpio.h"
29+
30+
void board_init(void)
31+
{
32+
/* The IMU is supplied through a GPIO Pin (P1.08), so it has to be set
33+
* to high power mode. */
34+
NRF_P1->PIN_CNF[8] = ((uint32_t)NRF_GPIO_PIN_DIR_OUTPUT << GPIO_PIN_CNF_DIR_Pos)
35+
| ((uint32_t)NRF_GPIO_PIN_INPUT_DISCONNECT << GPIO_PIN_CNF_INPUT_Pos)
36+
| ((uint32_t)NRF_GPIO_PIN_NOPULL << GPIO_PIN_CNF_PULL_Pos)
37+
| ((uint32_t)NRF_GPIO_PIN_H0H1 << GPIO_PIN_CNF_DRIVE_Pos)
38+
| ((uint32_t)NRF_GPIO_PIN_NOSENSE << GPIO_PIN_CNF_SENSE_Pos);
39+
40+
gpio_set(LSM6DS3_PWR_PIN);
41+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
@defgroup boards_seeedstudio-xiao-nrf52840-sense Seeed Studio XIAO nRF52840 Sense
2+
@ingroup boards
3+
@brief Support for the Seeed Studio XIAO nRF52840 Sense
4+
5+
### General information
6+
7+
The [XIAO nRF52840 Sense][seeedstudio-xiao-nrf52840-sense]
8+
is a development board from Seeed Studio's XIAO board family.
9+
10+
It provides native USB support, Bluetooth
11+
Low Energy and IEEE 802.15.4 support via the nRF52840 MCU.
12+
Compared to the [XIAO nRF52840](@ref boards_seeedstudio-xiao-nrf52840) it
13+
features an ST LSM6DS3TR-C IMU and a PDM Microphone (not supported yet).
14+
15+
<img src="https://files.seeedstudio.com/wiki/XIAO-BLE/pinout2.png"
16+
alt="top-down view on seeedstudio-xiao-nrf52840" width="50%"/>
17+
18+
[seeedstudio-xiao-nrf52840-sense]: https://wiki.seeedstudio.com/XIAO_BLE/
19+
20+
### Using the LSM6DS3TR-C IMU
21+
22+
You can test the built-in IMU with the test provided in `tests/drivers/lsm6dsxx`:
23+
24+
```shell
25+
make BOARD=seeedstudio-xiao-nrf52840-sense -C tests/drivers/lsm6dsxx flash term
26+
```
27+
28+
### Flashing, Bootloader, and Terminal
29+
30+
Refer to the [Feather nRF52840 Express
31+
documentation](https://doc.riot-os.org/group__boards__feather-nrf52840.html) for further details.
32+
Both use the same flasher, bootloader, and terminal settings.
33+
34+
Example with `hello-world` application:
35+
```shell
36+
make BOARD=seeedstudio-xiao-nrf52840-sense -C examples/basic/hello-world flash term
37+
```
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-sense
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+
/** @} */
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
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-sense
11+
* @{
12+
*
13+
* @file
14+
* @brief Board specific configuration for the Seeed Studio XIAO
15+
* nRF52840 Sense
16+
*
17+
* @author Mikolai Gütschow <[email protected]>
18+
*/
19+
20+
#ifndef BOARD_H
21+
#define BOARD_H
22+
23+
#include "cpu.h"
24+
#include "board_common.h"
25+
#include "periph/gpio.h"
26+
27+
#ifdef __cplusplus
28+
extern "C" {
29+
#endif
30+
31+
/**
32+
* @name LED pin configuration
33+
* @{
34+
*/
35+
#define LED0_PIN GPIO_PIN(0, 26)
36+
#define LED1_PIN GPIO_PIN(0, 30)
37+
#define LED2_PIN GPIO_PIN(0, 6)
38+
39+
#define LED_PORT (NRF_P0)
40+
#define LED0_MASK (1 << 26)
41+
#define LED1_MASK (1 << 30)
42+
#define LED2_MASK (1 << 6)
43+
#define LED_MASK (LED0_MASK | LED1_MASK | LED2_MASK)
44+
45+
#define LED0_ON (LED_PORT->OUTCLR = LED0_MASK)
46+
#define LED0_OFF (LED_PORT->OUTSET = LED0_MASK)
47+
#define LED0_TOGGLE (LED_PORT->OUT ^= LED0_MASK)
48+
49+
#define LED1_ON (LED_PORT->OUTCLR = LED1_MASK)
50+
#define LED1_OFF (LED_PORT->OUTSET = LED1_MASK)
51+
#define LED1_TOGGLE (LED_PORT->OUT ^= LED1_MASK)
52+
53+
#define LED2_ON (LED_PORT->OUTCLR = LED2_MASK)
54+
#define LED2_OFF (LED_PORT->OUTSET = LED2_MASK)
55+
#define LED2_TOGGLE (LED_PORT->OUT ^= LED2_MASK)
56+
/** @} */
57+
58+
/**
59+
* @name SPI NOR flash hardware configuration
60+
*
61+
* A 2MB P25Q16H flash is present on the board.
62+
*
63+
* @see https://files.seeedstudio.com/wiki/github_weiruanexample/Flash_P25Q16H-UXH-IR_Datasheet.pdf
64+
*
65+
* @{
66+
*/
67+
#define XIAO_NRF52840_NOR_PAGE_SIZE (256)
68+
#define XIAO_NRF52840_NOR_PAGES_PER_SECTOR (16)
69+
#define XIAO_NRF52840_NOR_SECTOR_COUNT (512)
70+
#define XIAO_NRF52840_NOR_FLAGS \
71+
(SPI_NOR_F_SECT_4K | SPI_NOR_F_SECT_32K | SPI_NOR_F_SECT_64K)
72+
#define XIAO_NRF52840_NOR_SPI_DEV SPI_DEV(1)
73+
#define XIAO_NRF52840_NOR_SPI_CLK SPI_CLK_10MHZ
74+
#define XIAO_NRF52840_NOR_SPI_CS GPIO_PIN(0, 25)
75+
#define XIAO_NRF52840_NOR_SPI_WP GPIO_PIN(0, 22)
76+
#define XIAO_NRF52840_NOR_SPI_HOLD GPIO_PIN(0, 23)
77+
#define XIAO_NRF52840_NOR_SPI_MODE SPI_MODE_0
78+
/** @} */
79+
80+
/** Default MTD device */
81+
#define MTD_0 mtd_dev_get(0)
82+
83+
/**
84+
* @name LSM6DS3TR-C IMU sensor configuration
85+
* @{
86+
*/
87+
#define LSM6DSXX_PARAM_I2C I2C_DEV(1) /**< I2C device of the IMU */
88+
#define LSM6DSXX_PARAM_ADDR (0x6A) /**< I2C address of the IMU */
89+
90+
#define LSM6DS3_PWR_PIN GPIO_PIN(1, 8) /**< The IMU is directly supplied by P1.08 */
91+
/** @} */
92+
93+
/**
94+
* @name ztimer configuration values
95+
* @{
96+
*/
97+
#define CONFIG_ZTIMER_USEC_ADJUST_SET 7
98+
#define CONFIG_ZTIMER_USEC_ADJUST_SLEEP 22
99+
/** @} */
100+
101+
#ifdef __cplusplus
102+
}
103+
#endif
104+
105+
#endif /* BOARD_H */
106+
/** @} */

0 commit comments

Comments
 (0)