Skip to content

Commit 6fe853c

Browse files
committed
boards/seeedstudio-xiao-nrf52840: initial board support
1 parent cdcabf2 commit 6fe853c

File tree

12 files changed

+388
-0
lines changed

12 files changed

+388
-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" if BOARD_XIAO_NRF52840
9+
10+
config BOARD_XIAO_NRF52840
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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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+
# include common nrf52 dependencies
16+
include $(RIOTBOARD)/common/nrf52/bootloader_nrfutil.dep.mk
17+
include $(RIOTBOARD)/common/nrf52/Makefile.dep
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
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 += highlevel_stdio
11+
12+
include $(RIOTBOARD)/common/nrf52/Makefile.features
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../feather-nrf52840/Makefile.include
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
@defgroup boards_seeedstudio-xiao-nrf52840 Seeed Studio XIAO nRF52840
2+
@ingroup boards
3+
@brief Support for the Seeed Studio XIAO nRF52840
4+
5+
### General information
6+
7+
The [XIAO nRF52840][seeedstudio-xiao-nrf52840] (formally known as XIAO BLE)
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+
13+
<img src="https://files.seeedstudio.com/wiki/XIAO-BLE/pinout2.png"
14+
alt="top-down view on seeedstudio-xiao-nrf52840" width="50%"/>
15+
16+
[seeedstudio-xiao-nrf52840]: https://wiki.seeedstudio.com/XIAO_BLE/
17+
18+
### Flashing, Bootloader, and Terminal
19+
20+
Refer to the [Feather nRF52840 Express
21+
documentation](https://doc.riot-os.org/group__boards__feather-nrf52840.html) for further details.
22+
Both use the same flasher, bootloader, and terminal settings.
23+
24+
Example with `hello-world` application:
25+
```shell
26+
make BOARD=seeedstudio-xiao-nrf52840 -C examples/basic/hello-world flash term
27+
```
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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 Board specific configuration for the Seeed Studio XIAO nRF52840
15+
*
16+
* @author Mikolai Gütschow <[email protected]>
17+
*/
18+
19+
#ifndef BOARD_H
20+
#define BOARD_H
21+
22+
#include "cpu.h"
23+
#include "board_common.h"
24+
#include "periph/gpio.h"
25+
26+
#ifdef __cplusplus
27+
extern "C" {
28+
#endif
29+
30+
/**
31+
* @name LED pin configuration
32+
* @{
33+
*/
34+
#define LED0_PIN GPIO_PIN(0, 26)
35+
#define LED1_PIN GPIO_PIN(0, 30)
36+
#define LED2_PIN GPIO_PIN(0, 6)
37+
38+
#define LED_PORT (NRF_P0)
39+
#define LED0_MASK (1 << 26)
40+
#define LED1_MASK (1 << 30)
41+
#define LED2_MASK (1 << 6)
42+
#define LED_MASK (LED0_MASK | LED1_MASK | LED2_MASK)
43+
44+
#define LED0_ON (LED_PORT->OUTCLR = LED0_MASK)
45+
#define LED0_OFF (LED_PORT->OUTSET = LED0_MASK)
46+
#define LED0_TOGGLE (LED_PORT->OUT ^= LED0_MASK)
47+
48+
#define LED1_ON (LED_PORT->OUTCLR = LED1_MASK)
49+
#define LED1_OFF (LED_PORT->OUTSET = LED1_MASK)
50+
#define LED1_TOGGLE (LED_PORT->OUT ^= LED1_MASK)
51+
52+
#define LED2_ON (LED_PORT->OUTCLR = LED2_MASK)
53+
#define LED2_OFF (LED_PORT->OUTSET = LED2_MASK)
54+
#define LED2_TOGGLE (LED_PORT->OUT ^= LED2_MASK)
55+
/** @} */
56+
57+
/**
58+
* @name SPI NOR flash hardware configuration
59+
*
60+
* A 2MB P25Q16H flash is present on the board.
61+
*
62+
* @see https://files.seeedstudio.com/wiki/github_weiruanexample/Flash_P25Q16H-UXH-IR_Datasheet.pdf
63+
*
64+
* @{
65+
*/
66+
#define XIAO_NRF52840_NOR_PAGE_SIZE (256)
67+
#define XIAO_NRF52840_NOR_PAGES_PER_SECTOR (16)
68+
#define XIAO_NRF52840_NOR_SECTOR_COUNT (512)
69+
#define XIAO_NRF52840_NOR_FLAGS (SPI_NOR_F_SECT_4K | SPI_NOR_F_SECT_32K | SPI_NOR_F_SECT_64K)
70+
#define XIAO_NRF52840_NOR_SPI_DEV SPI_DEV(1)
71+
#define XIAO_NRF52840_NOR_SPI_CLK SPI_CLK_10MHZ
72+
#define XIAO_NRF52840_NOR_SPI_CS GPIO_PIN(0, 25)
73+
#define XIAO_NRF52840_NOR_SPI_WP GPIO_PIN(0, 22)
74+
#define XIAO_NRF52840_NOR_SPI_HOLD GPIO_PIN(0, 23)
75+
#define XIAO_NRF52840_NOR_SPI_MODE SPI_MODE_0
76+
/** @} */
77+
78+
/** Default MTD device */
79+
#define MTD_0 mtd_dev_get(0)
80+
81+
/**
82+
* @name ztimer configuration values
83+
* @{
84+
*/
85+
#define CONFIG_ZTIMER_USEC_ADJUST_SET 7
86+
#define CONFIG_ZTIMER_USEC_ADJUST_SLEEP 22
87+
/** @} */
88+
89+
#ifdef __cplusplus
90+
}
91+
#endif
92+
93+
#endif /* BOARD_H */
94+
/** @} */
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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 Configuration of SAUL mapped GPIO pins
15+
*
16+
* @author Mikolai Gütschow <[email protected]>
17+
*/
18+
19+
#ifndef GPIO_PARAMS_H
20+
#define GPIO_PARAMS_H
21+
22+
#include "board.h"
23+
#include "saul/periph.h"
24+
25+
#ifdef __cplusplus
26+
extern "C" {
27+
#endif
28+
29+
/**
30+
* @brief LED configuration
31+
*/
32+
static const saul_gpio_params_t saul_gpio_params[] =
33+
{
34+
{
35+
.name = "LED Red (USR/D11)",
36+
.pin = LED0_PIN,
37+
.mode = GPIO_OUT,
38+
.flags = (SAUL_GPIO_INIT_CLEAR),
39+
},
40+
{
41+
.name = "LED Green (USR/D13)",
42+
.pin = LED1_PIN,
43+
.mode = GPIO_OUT,
44+
.flags = (SAUL_GPIO_INIT_CLEAR),
45+
},
46+
{
47+
.name = "LED Blue (USR/D12)",
48+
.pin = LED2_PIN,
49+
.mode = GPIO_OUT,
50+
.flags = (SAUL_GPIO_INIT_CLEAR),
51+
},
52+
};
53+
54+
#ifdef __cplusplus
55+
}
56+
#endif
57+
58+
#endif /* GPIO_PARAMS_H */
59+
/** @} */
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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 Peripheral configuration for the Seeed Studio XIAO nRF52840
15+
*
16+
* @author Mikolai Gütschow <[email protected]>
17+
*
18+
*/
19+
20+
#ifndef PERIPH_CONF_H
21+
#define PERIPH_CONF_H
22+
23+
#include "periph_cpu.h"
24+
#include "cfg_clock_32_1.h"
25+
#include "cfg_rtt_default.h"
26+
#include "cfg_timer_default.h"
27+
28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
32+
/**
33+
* @name UART configuration
34+
* @{
35+
*/
36+
static const uart_conf_t uart_config[] = {
37+
{
38+
.dev = NRF_UARTE0,
39+
.rx_pin = GPIO_PIN(1, 12),
40+
.tx_pin = GPIO_PIN(1, 11),
41+
#ifdef MODULE_PERIPH_UART_HW_FC
42+
.rts_pin = GPIO_UNDEF,
43+
.cts_pin = GPIO_UNDEF,
44+
#endif
45+
.irqn = UARTE0_UART0_IRQn,
46+
},
47+
};
48+
49+
#define UART_0_ISR (isr_uart0)
50+
51+
#define UART_NUMOF ARRAY_SIZE(uart_config)
52+
/** @} */
53+
54+
/**
55+
* @name SPI configuration
56+
* @{
57+
*/
58+
static const spi_conf_t spi_config[] = {
59+
{
60+
.dev = NRF_SPIM0,
61+
.sclk = GPIO_PIN(1, 13),
62+
.mosi = GPIO_PIN(1, 15),
63+
.miso = GPIO_PIN(1, 14),
64+
},
65+
{
66+
.dev = NRF_SPIM1,
67+
.sclk = GPIO_PIN(0, 21),
68+
.mosi = GPIO_PIN(0, 20),
69+
.miso = GPIO_PIN(0, 24),
70+
}
71+
};
72+
73+
#define SPI_NUMOF ARRAY_SIZE(spi_config)
74+
/** @} */
75+
76+
/**
77+
* @name I2C configuration
78+
* @{
79+
*/
80+
static const i2c_conf_t i2c_config[] = {
81+
{
82+
.dev = NRF_TWIM1,
83+
.scl = GPIO_PIN(0, 5),
84+
.sda = GPIO_PIN(0, 4),
85+
.speed = I2C_SPEED_NORMAL
86+
}
87+
};
88+
#define I2C_NUMOF ARRAY_SIZE(i2c_config)
89+
/** @} */
90+
91+
#ifdef __cplusplus
92+
}
93+
#endif
94+
95+
#endif /* PERIPH_CONF_H */
96+
/** @} */
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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 MTD configuration for the XIAO nRF52840
15+
*
16+
* @author Mikolai Gütschow <[email protected]>
17+
*
18+
* @}
19+
*/
20+
21+
#ifdef MODULE_MTD
22+
23+
#include "board.h"
24+
#include "mtd.h"
25+
#include "mtd_spi_nor.h"
26+
#include "periph_conf.h"
27+
#include "timex.h"
28+
29+
static const mtd_spi_nor_params_t _xiao_nrf52840_nor_params = {
30+
.opcode = &mtd_spi_nor_opcode_default,
31+
/* datasheet reports 20ms, but experiments showed ~135ms*/
32+
.wait_chip_erase = 200LU * US_PER_MS,
33+
.wait_32k_erase = 20LU * US_PER_MS,
34+
.wait_sector_erase = 20LU * US_PER_MS,
35+
.wait_chip_wake_up = 35LU * US_PER_MS,
36+
.clk = XIAO_NRF52840_NOR_SPI_CLK,
37+
.flag = XIAO_NRF52840_NOR_FLAGS,
38+
.spi = XIAO_NRF52840_NOR_SPI_DEV,
39+
.mode = XIAO_NRF52840_NOR_SPI_MODE,
40+
.cs = XIAO_NRF52840_NOR_SPI_CS,
41+
.wp = XIAO_NRF52840_NOR_SPI_WP,
42+
.hold = XIAO_NRF52840_NOR_SPI_HOLD,
43+
};
44+
45+
static mtd_spi_nor_t xiao_nrf52840_nor_dev = {
46+
.base = {
47+
.driver = &mtd_spi_nor_driver,
48+
.page_size = XIAO_NRF52840_NOR_PAGE_SIZE,
49+
.pages_per_sector = XIAO_NRF52840_NOR_PAGES_PER_SECTOR,
50+
.sector_count = XIAO_NRF52840_NOR_SECTOR_COUNT,
51+
},
52+
.params = &_xiao_nrf52840_nor_params,
53+
};
54+
55+
MTD_XFA_ADD(xiao_nrf52840_nor_dev, 0);
56+
57+
#ifdef MODULE_VFS_DEFAULT
58+
#include "vfs_default.h"
59+
VFS_AUTO_MOUNT(littlefs2, VFS_MTD(xiao_nrf52840_nor_dev), VFS_DEFAULT_NVM(0), 0);
60+
#endif
61+
#endif

0 commit comments

Comments
 (0)