Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions boards/seeedstudio-xiao-nrf52840/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright (c) 2024 TU Dresden
#
# This file is subject to the terms and conditions of the GNU Lesser
# General Public License v2.1. See the file LICENSE in the top level
# directory for more details.

config BOARD
default "seeedstudio-xiao-nrf52840" if BOARD_XIAO_NRF52840

config BOARD_XIAO_NRF52840
bool
default y
select BOARD_COMMON_NRF52
select CPU_MODEL_NRF52840XXAA

source "$(RIOTBOARD)/common/nrf52/Kconfig"
3 changes: 3 additions & 0 deletions boards/seeedstudio-xiao-nrf52840/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MODULE = board

include $(RIOTBASE)/Makefile.base
17 changes: 17 additions & 0 deletions boards/seeedstudio-xiao-nrf52840/Makefile.dep
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ifneq (,$(filter saul_default,$(USEMODULE)))
USEMODULE += saul_gpio
endif

ifneq (,$(filter mtd,$(USEMODULE)))
USEMODULE += mtd_spi_nor
endif

# default to using littlefs2 on the external flash
ifneq (,$(filter vfs_default,$(USEMODULE)))
USEPKG += littlefs2
USEMODULE += mtd
endif

# include common nrf52 dependencies
include $(RIOTBOARD)/common/nrf52/bootloader_nrfutil.dep.mk
include $(RIOTBOARD)/common/nrf52/Makefile.dep
18 changes: 18 additions & 0 deletions boards/seeedstudio-xiao-nrf52840/Makefile.features
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CPU_MODEL = nrf52840xxaa

# Put defined MCU peripherals here (in alphabetical order)
FEATURES_PROVIDED += periph_i2c
FEATURES_PROVIDED += periph_spi
FEATURES_PROVIDED += periph_uart
FEATURES_PROVIDED += periph_usbdev

# Various other features (if any)
FEATURES_PROVIDED += arduino_analog
FEATURES_PROVIDED += arduino_i2c
FEATURES_PROVIDED += arduino_pins
FEATURES_PROVIDED += arduino_spi
FEATURES_PROVIDED += arduino_uart
FEATURES_PROVIDED += highlevel_stdio
FEATURES_PROVIDED += xiao_shield

include $(RIOTBOARD)/common/nrf52/Makefile.features
1 change: 1 addition & 0 deletions boards/seeedstudio-xiao-nrf52840/Makefile.include
27 changes: 27 additions & 0 deletions boards/seeedstudio-xiao-nrf52840/doc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
@defgroup boards_seeedstudio-xiao-nrf52840 Seeed Studio XIAO nRF52840
@ingroup boards
@brief Support for the Seeed Studio XIAO nRF52840

### General information

The [XIAO nRF52840][seeedstudio-xiao-nrf52840] (formally known as XIAO BLE)
is a development board from Seeed Studio's XIAO board family.

It provides native USB support, Bluetooth
Low Energy and IEEE 802.15.4 support via the nRF52840 MCU.

<img src="https://files.seeedstudio.com/wiki/XIAO-BLE/pinout2.png"
alt="top-down view on seeedstudio-xiao-nrf52840" width="50%"/>

[seeedstudio-xiao-nrf52840]: https://wiki.seeedstudio.com/XIAO_BLE/

### Flashing, Bootloader, and Terminal

Refer to the [Feather nRF52840 Express
documentation](https://doc.riot-os.org/group__boards__feather-nrf52840.html) for further details.
Both use the same flasher, bootloader, and terminal settings.

Example with `hello-world` application:
```shell
make BOARD=seeedstudio-xiao-nrf52840 -C examples/basic/hello-world flash term
```
132 changes: 132 additions & 0 deletions boards/seeedstudio-xiao-nrf52840/include/arduino_iomap.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
/*
* Copyright (C) 2024 TU Dresden
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup boards_seeedstudio-xiao-nrf52840
* @{
*
* @file
* @brief Mapping from MCU pins to Arduino pins
*
* You can use the defines in this file for simplified interaction with the
* Arduino specific pin numbers.
*
* @author Mikolai Gütschow <[email protected]>
*/

#ifndef ARDUINO_IOMAP_H
#define ARDUINO_IOMAP_H

#include "periph/gpio.h"
#include "periph/adc.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @name XIAO's UART devices
* @{
* @brief Arduino's Serial uses USB-CDC-ACM stdio by default
*/
#define ARDUINO_UART_DEV UART_UNDEF
/** @} */

/**
* @name XIAO's SPI buses
* @{
*/
#define ARDUINO_SPI_DEV SPI_DEV(0)
/** @} */

/**
* @name XIAO's I2C buses
* @{
*/
#define ARDUINO_I2C_DEV I2C_DEV(0)
/** @} */

/**
* @name XIAO's on-board LED (LED_BUILTIN)
* @{
*/
#define ARDUINO_LED (11)
/** @} */

/**
* @name Mapping of MCU pins to Arduino pins
* @{
*/
/* Left pins */
#define ARDUINO_PIN_0 GPIO_PIN(0, 2)
#define ARDUINO_PIN_1 GPIO_PIN(0, 3)
#define ARDUINO_PIN_2 GPIO_PIN(0, 28)
#define ARDUINO_PIN_3 GPIO_PIN(0, 29)
#define ARDUINO_PIN_4 GPIO_PIN(0, 4)
#define ARDUINO_PIN_5 GPIO_PIN(0, 5)
#define ARDUINO_PIN_6 GPIO_PIN(1, 11)

/* Right side */
#define ARDUINO_PIN_7 GPIO_PIN(1, 12)
#define ARDUINO_PIN_8 GPIO_PIN(1, 13)
#define ARDUINO_PIN_9 GPIO_PIN(1, 14)
#define ARDUINO_PIN_10 GPIO_PIN(1, 15)

/* Internal (LEDs) */
#define ARDUINO_PIN_11 GPIO_PIN(0, 26)
#define ARDUINO_PIN_12 GPIO_PIN(0, 6)
#define ARDUINO_PIN_13 GPIO_PIN(0, 30)

#define ARDUINO_PIN_LAST 13
/** @} */

/**
* @name Aliases for analog pins
* @{
*/
#define ARDUINO_PIN_A0 ARDUINO_PIN_0
#define ARDUINO_PIN_A1 ARDUINO_PIN_1
#define ARDUINO_PIN_A2 ARDUINO_PIN_2
#define ARDUINO_PIN_A3 ARDUINO_PIN_3
#define ARDUINO_PIN_A4 ARDUINO_PIN_4
#define ARDUINO_PIN_A5 ARDUINO_PIN_5
/** @} */

/**
* @name Mapping of Arduino analog pins to RIOT ADC lines
* @{
*/
/* The Seeed Studio XIAO nRF52840 has a fixed ADC to GPIO mapping:
*
* nRF | MCU pin | Exposed as Arduino pin
* -----|-----------|-----------------------
* AIN0 | P0.02 | A0 (D0)
* AIN1 | P0.03 | A1 (D1)
* AIN2 | P0.04 | A4 (D4)
* AIN3 | P0.05 | A5 (D5)
* AIN4 | P0.28 | A2 (D2)
* AIN5 | P0.29 | A3 (D3)
* AIN6 | P0.30 | - (D13)
* AIN7 | P0.31 | - (-)
*/
#define ARDUINO_A0 ADC_LINE(0)
#define ARDUINO_A1 ADC_LINE(1)
#define ARDUINO_A2 ADC_LINE(4)
#define ARDUINO_A3 ADC_LINE(5)
#define ARDUINO_A4 ADC_LINE(2)
#define ARDUINO_A5 ADC_LINE(3)

#define ARDUINO_ANALOG_PIN_LAST 5
/** @} */

#ifdef __cplusplus
}
#endif

#endif /* ARDUINO_IOMAP_H */
/** @} */
95 changes: 95 additions & 0 deletions boards/seeedstudio-xiao-nrf52840/include/board.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* Copyright (C) 2024 TU Dresden
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup boards_seeedstudio-xiao-nrf52840
* @{
*
* @file
* @brief Board specific configuration for the Seeed Studio XIAO nRF52840
*
* @author Mikolai Gütschow <[email protected]>
*/

#ifndef BOARD_H
#define BOARD_H

#include "cpu.h"
#include "board_common.h"
#include "periph/gpio.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @name LED pin configuration
* @{
*/
#define LED0_PIN GPIO_PIN(0, 26)
#define LED1_PIN GPIO_PIN(0, 30)
#define LED2_PIN GPIO_PIN(0, 6)

#define LED_PORT (NRF_P0)
#define LED0_MASK (1 << 26)
#define LED1_MASK (1 << 30)
#define LED2_MASK (1 << 6)
#define LED_MASK (LED0_MASK | LED1_MASK | LED2_MASK)

#define LED0_ON (LED_PORT->OUTCLR = LED0_MASK)
#define LED0_OFF (LED_PORT->OUTSET = LED0_MASK)
#define LED0_TOGGLE (LED_PORT->OUT ^= LED0_MASK)

#define LED1_ON (LED_PORT->OUTCLR = LED1_MASK)
#define LED1_OFF (LED_PORT->OUTSET = LED1_MASK)
#define LED1_TOGGLE (LED_PORT->OUT ^= LED1_MASK)

#define LED2_ON (LED_PORT->OUTCLR = LED2_MASK)
#define LED2_OFF (LED_PORT->OUTSET = LED2_MASK)
#define LED2_TOGGLE (LED_PORT->OUT ^= LED2_MASK)
/** @} */

/**
* @name SPI NOR flash hardware configuration
*
* A 2MB P25Q16H flash is present on the board.
*
* @see https://files.seeedstudio.com/wiki/github_weiruanexample/Flash_P25Q16H-UXH-IR_Datasheet.pdf
*
* @{
*/
#define XIAO_NRF52840_NOR_PAGE_SIZE (256)
#define XIAO_NRF52840_NOR_PAGES_PER_SECTOR (16)
#define XIAO_NRF52840_NOR_SECTOR_COUNT (512)
#define XIAO_NRF52840_NOR_FLAGS \
(SPI_NOR_F_SECT_4K | SPI_NOR_F_SECT_32K | SPI_NOR_F_SECT_64K)
#define XIAO_NRF52840_NOR_SPI_DEV SPI_DEV(1)
#define XIAO_NRF52840_NOR_SPI_CLK SPI_CLK_10MHZ
#define XIAO_NRF52840_NOR_SPI_CS GPIO_PIN(0, 25)
#define XIAO_NRF52840_NOR_SPI_WP GPIO_PIN(0, 22)
#define XIAO_NRF52840_NOR_SPI_HOLD GPIO_PIN(0, 23)
#define XIAO_NRF52840_NOR_SPI_MODE SPI_MODE_0
/** @} */

/** Default MTD device */
#define MTD_0 mtd_dev_get(0)

/**
* @name ztimer configuration values
* @{
*/
#define CONFIG_ZTIMER_USEC_ADJUST_SET 7
#define CONFIG_ZTIMER_USEC_ADJUST_SLEEP 22
/** @} */

#ifdef __cplusplus
}
#endif

#endif /* BOARD_H */
/** @} */
59 changes: 59 additions & 0 deletions boards/seeedstudio-xiao-nrf52840/include/gpio_params.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/*
* Copyright (C) 2024 TU Dresden
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/

/**
* @ingroup boards_seeedstudio-xiao-nrf52840
* @{
*
* @file
* @brief Configuration of SAUL mapped GPIO pins
*
* @author Mikolai Gütschow <[email protected]>
*/

#ifndef GPIO_PARAMS_H
#define GPIO_PARAMS_H

#include "board.h"
#include "saul/periph.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
* @brief LED configuration
*/
static const saul_gpio_params_t saul_gpio_params[] =
{
{
.name = "LED Red (USR/D11)",
.pin = LED0_PIN,
.mode = GPIO_OUT,
.flags = (SAUL_GPIO_INIT_CLEAR),
},
{
.name = "LED Green (USR/D13)",
.pin = LED1_PIN,
.mode = GPIO_OUT,
.flags = (SAUL_GPIO_INIT_CLEAR),
},
{
.name = "LED Blue (USR/D12)",
.pin = LED2_PIN,
.mode = GPIO_OUT,
.flags = (SAUL_GPIO_INIT_CLEAR),
},
};

#ifdef __cplusplus
}
#endif

#endif /* GPIO_PARAMS_H */
/** @} */
Loading