1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-01-17 05:52:44 +01:00

boards/seeedstudio-xiao-nrf52840: initial board support

This commit is contained in:
Mikolai Gütschow 2024-11-01 18:16:47 +01:00
parent 3a7f3b4880
commit a636cfe394
No known key found for this signature in database
GPG Key ID: 943E2F37AA659AD5
11 changed files with 386 additions and 0 deletions

View File

@ -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"

View File

@ -0,0 +1,3 @@
MODULE = board
include $(RIOTBASE)/Makefile.base

View File

@ -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

View File

@ -0,0 +1,12 @@
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 += highlevel_stdio
include $(RIOTBOARD)/common/nrf52/Makefile.features

View File

@ -0,0 +1 @@
../feather-nrf52840/Makefile.include

View File

@ -0,0 +1,30 @@
/**
@defgroup boards_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:
```
make BOARD=seeedstudio-xiao-nrf52840 -C examples/hello-world flash term
```
*/

View File

@ -0,0 +1,91 @@
/*
* 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 <mikolai.guetschow@tu-dresden.de>
*/
#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.
* @{
*/
#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 */
/** @} */

View File

@ -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_feather-nrf52840-sense
* @{
*
* @file
* @brief Configuration of SAUL mapped GPIO pins
*
* @author Mikolai Gütschow <mikolai.guetschow@tu-dresden.de>
*/
#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 */
/** @} */

View File

@ -0,0 +1,96 @@
/*
* 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 Peripheral configuration for the Seeed Studio XIAO nRF52840
*
* @author Mikolai Gütschow <mikolai.guetschow@tu-dresden.de>
*
*/
#ifndef PERIPH_CONF_H
#define PERIPH_CONF_H
#include "periph_cpu.h"
#include "cfg_clock_32_1.h"
#include "cfg_rtt_default.h"
#include "cfg_timer_default.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @name UART configuration
* @{
*/
static const uart_conf_t uart_config[] = {
{
.dev = NRF_UARTE0,
.rx_pin = GPIO_PIN(1, 12),
.tx_pin = GPIO_PIN(1, 11),
#ifdef MODULE_PERIPH_UART_HW_FC
.rts_pin = GPIO_UNDEF,
.cts_pin = GPIO_UNDEF,
#endif
.irqn = UARTE0_UART0_IRQn,
},
};
#define UART_0_ISR (isr_uart0)
#define UART_NUMOF ARRAY_SIZE(uart_config)
/** @} */
/**
* @name SPI configuration
* @{
*/
static const spi_conf_t spi_config[] = {
{
.dev = NRF_SPIM0,
.sclk = GPIO_PIN(1, 13),
.mosi = GPIO_PIN(1, 15),
.miso = GPIO_PIN(1, 14),
},
{
.dev = NRF_SPIM1,
.sclk = GPIO_PIN(0, 21),
.mosi = GPIO_PIN(0, 20),
.miso = GPIO_PIN(0, 24),
}
};
#define SPI_NUMOF ARRAY_SIZE(spi_config)
/** @} */
/**
* @name I2C configuration
* @{
*/
static const i2c_conf_t i2c_config[] = {
{
.dev = NRF_TWIM1,
.scl = GPIO_PIN(0, 5),
.sda = GPIO_PIN(0, 4),
.speed = I2C_SPEED_NORMAL
}
};
#define I2C_NUMOF ARRAY_SIZE(i2c_config)
/** @} */
#ifdef __cplusplus
}
#endif
#endif /* PERIPH_CONF_H */
/** @} */

View File

@ -0,0 +1,60 @@
/*
* 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 MTD configuration for the XIAO nRF52840
*
* @author Mikolai Gütschow <mikolai.guetschow@tu-dresden.de>
*
* @}
*/
#ifdef MODULE_MTD
#include "board.h"
#include "mtd.h"
#include "mtd_spi_nor.h"
#include "periph_conf.h"
#include "timex.h"
static const mtd_spi_nor_params_t _xiao_nrf52840_nor_params = {
.opcode = &mtd_spi_nor_opcode_default,
.wait_chip_erase = 20LU * US_PER_SEC,
.wait_32k_erase = 20LU *US_PER_MS,
.wait_sector_erase = 20LU * US_PER_MS,
.wait_chip_wake_up = 35LU * US_PER_MS,
.clk = XIAO_NRF52840_NOR_SPI_CLK,
.flag = XIAO_NRF52840_NOR_FLAGS,
.spi = XIAO_NRF52840_NOR_SPI_DEV,
.mode = XIAO_NRF52840_NOR_SPI_MODE,
.cs = XIAO_NRF52840_NOR_SPI_CS,
.wp = XIAO_NRF52840_NOR_SPI_WP,
.hold = XIAO_NRF52840_NOR_SPI_HOLD,
};
static mtd_spi_nor_t xiao_nrf52840_nor_dev = {
.base = {
.driver = &mtd_spi_nor_driver,
.page_size = XIAO_NRF52840_NOR_PAGE_SIZE,
.pages_per_sector = XIAO_NRF52840_NOR_PAGES_PER_SECTOR,
.sector_count = XIAO_NRF52840_NOR_SECTOR_COUNT,
},
.params = &_xiao_nrf52840_nor_params,
};
MTD_XFA_ADD(xiao_nrf52840_nor_dev, 0);
#ifdef MODULE_VFS_DEFAULT
#include "vfs_default.h"
VFS_AUTO_MOUNT(littlefs2, VFS_MTD(xiao_nrf52840_nor_dev), VFS_DEFAULT_NVM(0), 0);
#endif
#endif

View File

@ -0,0 +1 @@
../feather-nrf52840/reset.c