From f084f6e3354f4d73ab33f39f0bbe5ec6833bcc0e Mon Sep 17 00:00:00 2001 From: Dylan Laduranty Date: Tue, 4 Jul 2023 17:16:50 +0200 Subject: [PATCH] boards/nrf5340dk-app: add initial support Signed-off-by: Dylan Laduranty --- boards/nrf5340dk-app/Makefile | 3 + boards/nrf5340dk-app/Makefile.features | 7 ++ boards/nrf5340dk-app/Makefile.include | 2 + boards/nrf5340dk-app/doc.txt | 38 +++++++++ boards/nrf5340dk-app/include/board.h | 98 ++++++++++++++++++++++ boards/nrf5340dk-app/include/periph_conf.h | 83 ++++++++++++++++++ 6 files changed, 231 insertions(+) create mode 100644 boards/nrf5340dk-app/Makefile create mode 100644 boards/nrf5340dk-app/Makefile.features create mode 100644 boards/nrf5340dk-app/Makefile.include create mode 100644 boards/nrf5340dk-app/doc.txt create mode 100644 boards/nrf5340dk-app/include/board.h create mode 100644 boards/nrf5340dk-app/include/periph_conf.h diff --git a/boards/nrf5340dk-app/Makefile b/boards/nrf5340dk-app/Makefile new file mode 100644 index 0000000000..f8fcbb53a0 --- /dev/null +++ b/boards/nrf5340dk-app/Makefile @@ -0,0 +1,3 @@ +MODULE = board + +include $(RIOTBASE)/Makefile.base diff --git a/boards/nrf5340dk-app/Makefile.features b/boards/nrf5340dk-app/Makefile.features new file mode 100644 index 0000000000..ea35d40380 --- /dev/null +++ b/boards/nrf5340dk-app/Makefile.features @@ -0,0 +1,7 @@ +CPU_MODEL = nrf5340_app +CPU = nrf53 + +# Put defined MCU peripherals here (in alphabetical order) +FEATURES_PROVIDED += periph_timer +FEATURES_PROVIDED += periph_uart +FEATURES_PROVIDED += periph_uart_hw_fc diff --git a/boards/nrf5340dk-app/Makefile.include b/boards/nrf5340dk-app/Makefile.include new file mode 100644 index 0000000000..b841e8d809 --- /dev/null +++ b/boards/nrf5340dk-app/Makefile.include @@ -0,0 +1,2 @@ +# include this module into the build +INCLUDES += -I$(RIOTBOARD)/nrf5340dk-app/include diff --git a/boards/nrf5340dk-app/doc.txt b/boards/nrf5340dk-app/doc.txt new file mode 100644 index 0000000000..22a23c71b7 --- /dev/null +++ b/boards/nrf5340dk-app/doc.txt @@ -0,0 +1,38 @@ +/** +@defgroup boards_nrf5340dk-app nRF5340DK +@ingroup boards +@brief Support for the nRF5340DK-app board + +### General information + +The nRF5340DK is a devboard based on nRF5340 MCU which offers a dual core +Cortex-M33 with one application core and one network core. +The network core is able to handle Bluetooth 5.3, BLE, mesh, NFC, Thread and +Zigbee connectivity. +Currently only the application core can be used with RIOT-OS. + +The board features four LEDs, four user buttons/switches and a reset button. + +### Links + +- [nRF5340DK web page](https://infocenter.nordicsemi.com/topic/ug_nrf5340_dk/UG/dk/intro.html) +- [documentation and hardware description](https://infocenter.nordicsemi.com/index.jsp?topic=%2Fstruct_nrf53%2Fstruct%2Fnrf5340.html) + +### Flash the board + +The board is flashed using JLink or nrfjprog software. Programs needs to +be installed. + +The process is automated in the usual `make flash` target. + +### Accessing STDIO via UART + +The STDIO is directly accessible via the USB port. On a Linux host, it's +generally mapped to `/dev/ttyACM0`. + +Use the `term` target to connect to the board serial port
+``` + make BOARD=nrf5340dk-app -C examples/hello-world term +``` + + */ diff --git a/boards/nrf5340dk-app/include/board.h b/boards/nrf5340dk-app/include/board.h new file mode 100644 index 0000000000..445946e248 --- /dev/null +++ b/boards/nrf5340dk-app/include/board.h @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2023 Mesotic SAS + * + * 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_nrf5340dk-app + * @{ + * + * @file + * @brief Board configuration for the nRF5340DK-app board + * + * @author Dylan Laduranty + */ + +#ifndef BOARD_H +#define BOARD_H + +#include "cpu.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief System core clock speed, for all NRF53 Application core. + */ +#define CLOCK_CORECLOCK MHZ(128) + +/** + * @name HF Clock configuration + * + * + * @{ + */ + + /* CLOCK_HFCLKSRC_SRC_HFXO to use external 32MHz crystal + * CLOCK_HFCLKSRC_SRC_HFINT to use internal crystal */ +#define CLOCK_HFCLK (CLOCK_HFCLKSRC_SRC_HFXO) /**< HFCLK Source selection */ +#define CLOCK_LFCLK (3) /**< LFCLK Source selection */ +/** @} */ + +/** + * @name LED pin configuration + * @{ + */ +#define LED0_PIN GPIO_PIN(0, 28) /**< LED0 pin definition */ +#define LED1_PIN GPIO_PIN(0, 29) /**< LED1 pin definition */ +#define LED2_PIN GPIO_PIN(0, 30) /**< LED2 pin definition */ +#define LED3_PIN GPIO_PIN(0, 31) /**< LED3 pin definition */ + +#define LED0_MASK (1 << 28) /**< LED0 PORT bitmask */ +#define LED1_MASK (1 << 29) /**< LED1 PORT bitmask */ +#define LED2_MASK (1 << 30) /**< LED2 PORT bitmask */ +#define LED3_MASK (1 << 31) /**< LED3 PORT bitmask */ + +#define LED_PORT (NRF_P0_S) /**< Default LED PORT */ + +#define LED0_ON (LED_PORT->OUTCLR = LED0_MASK) /**< LED0 ON macro */ +#define LED0_OFF (LED_PORT->OUTSET = LED0_MASK) /**< LED0 OFF macro */ +#define LED0_TOGGLE (LED_PORT->OUT ^= LED0_MASK) /**< LED0 toggle macro */ + +#define LED1_ON (LED_PORT->OUTCLR = LED1_MASK) /**< LED1 ON macro */ +#define LED1_OFF (LED_PORT->OUTSET = LED1_MASK) /**< LED1 OFF macro */ +#define LED1_TOGGLE (LED_PORT->OUT ^= LED1_MASK) /**< LED1 toggle macro */ + +#define LED2_ON (LED_PORT->OUTCLR = LED2_MASK) /**< LED2 ON macro */ +#define LED2_OFF (LED_PORT->OUTSET = LED2_MASK) /**< LED2 OFF macro */ +#define LED2_TOGGLE (LED_PORT->OUT ^= LED2_MASK) /**< LED2 toggle macro */ + +#define LED3_ON (LED_PORT->OUTCLR = LED3_MASK) /**< LED3 ON macro */ +#define LED3_OFF (LED_PORT->OUTSET = LED3_MASK) /**< LED3 OFF macro */ +#define LED3_TOGGLE (LED_PORT->OUT ^= LED3_MASK) /**< LED3 toggle macro */ +/** @} */ + +/** + * @name Button pin configuration + * @{ + */ +#define BTN0_PIN GPIO_PIN(0, 23) /**< BTN0 pin definition */ +#define BTN0_MODE GPIO_IN_PU /**< BTN0 default mode */ +#define BTN1_PIN GPIO_PIN(0, 24) /**< BTN1 pin definition */ +#define BTN1_MODE GPIO_IN_PU /**< BTN1 default mode */ +#define BTN2_PIN GPIO_PIN(0, 8) /**< BTN2 pin definition */ +#define BTN2_MODE GPIO_IN_PU /**< BTN2 default mode */ +#define BTN3_PIN GPIO_PIN(0, 9) /**< BTN3 pin definition */ +#define BTN3_MODE GPIO_IN_PU /**< BTN3 default mode */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* BOARD_H */ +/** @} */ diff --git a/boards/nrf5340dk-app/include/periph_conf.h b/boards/nrf5340dk-app/include/periph_conf.h new file mode 100644 index 0000000000..64d5820abc --- /dev/null +++ b/boards/nrf5340dk-app/include/periph_conf.h @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2023 Mesotic SAS + * + * 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_nrf5340dk-app + * @{ + * + * @file + * @brief Peripheral configuration for the nRF5340DK-app + * + * @author Dylan Laduranty + * + */ + +#ifndef PERIPH_CONF_H +#define PERIPH_CONF_H + +#include "periph_cpu.h" + +#include "board.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @name Timer configuration + * @{ + */ +static const timer_conf_t timer_config[] = { + { + .dev = NRF_TIMER0_S, + .channels = 5, + .bitmode = TIMER_BITMODE_BITMODE_32Bit, + .irqn = TIMER0_IRQn + }, + { + .dev = NRF_TIMER1_S, + .channels = 5, + .bitmode = TIMER_BITMODE_BITMODE_32Bit, + .irqn = TIMER1_IRQn + }, +}; + +#define TIMER_0_ISR isr_timer0 /**< Timer0 IRQ*/ +#define TIMER_1_ISR isr_timer1 /**< Timer1 IRQ */ + +#define TIMER_NUMOF ARRAY_SIZE(timer_config) /**< Timer configuration NUMOF */ +/** @} */ + +/** + * @name UART configuration + * @{ + */ +static const uart_conf_t uart_config[] = { + { + .dev = NRF_UARTE0_S, + .rx_pin = GPIO_PIN(1, 0), + .tx_pin = GPIO_PIN(1, 1), +#ifdef MODULE_PERIPH_UART_HW_FC + .rts_pin = GPIO_UNDEF, + .cts_pin = GPIO_UNDEF, +#endif + .irqn = SERIAL0_IRQn, + }, +}; + +#define UART_0_ISR (isr_serial0) /**< SERIAL0_IRQn */ + +#define UART_NUMOF ARRAY_SIZE(uart_config) /**< UART configuration NUMOF */ +/** @} */ + +#ifdef __cplusplus +} +#endif + +#endif /* PERIPH_CONF_H */ +/** @} */