From ecfa2f7573b8da4008d29cdefe213afc3cd583fb Mon Sep 17 00:00:00 2001 From: chrysn Date: Mon, 22 Jan 2024 23:44:16 +0100 Subject: [PATCH 1/3] boards/nrf52dk: Minimal Arduino pinout support --- boards/nrf52dk/Makefile.features | 4 + boards/nrf52dk/include/arduino_iomap.h | 105 +++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 boards/nrf52dk/include/arduino_iomap.h diff --git a/boards/nrf52dk/Makefile.features b/boards/nrf52dk/Makefile.features index b375a1a927..1bfb0157e6 100644 --- a/boards/nrf52dk/Makefile.features +++ b/boards/nrf52dk/Makefile.features @@ -1,3 +1,7 @@ CPU_MODEL = nrf52832xxaa +FEATURES_PROVIDED += arduino_i2c +FEATURES_PROVIDED += arduino_pins +FEATURES_PROVIDED += arduino_shield_uno + include $(RIOTBOARD)/common/nrf52xxxdk/Makefile.features diff --git a/boards/nrf52dk/include/arduino_iomap.h b/boards/nrf52dk/include/arduino_iomap.h new file mode 100644 index 0000000000..f36753eaeb --- /dev/null +++ b/boards/nrf52dk/include/arduino_iomap.h @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2024 Christian Amsüss + * + * 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_nrf52dk + * @{ + * + * @file + * @brief Mapping from MCU pins to Arduino pins + * + * @author Christian Amsüss + * + */ + +#ifndef ARDUINO_IOMAP_H +#define ARDUINO_IOMAP_H + +#include "periph/gpio.h" +#include "periph/adc.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Mapping of MCU pins to Arduino pins + * + * For refernce, see schematic file `nRF52 Development Kit - Hardware files + * 3_0_0/PCA10040-nRF52832 Development Board 3_0_0/Schematic_Layout pdf + * files/PCA10040_Schematic_And_PCB.pdf` in + * `nrf52-development-kit---hardware-files-3_0_0.zip` from + * , + * page 2 areas CD123 + * + * @{ + */ +#define ARDUINO_PIN_0 GPIO_PIN(0, 11) +#define ARDUINO_PIN_1 GPIO_PIN(0, 12) + +#define ARDUINO_PIN_2 GPIO_PIN(0, 13) +#define ARDUINO_PIN_3 GPIO_PIN(0, 14) +#define ARDUINO_PIN_4 GPIO_PIN(0, 15) +#define ARDUINO_PIN_5 GPIO_PIN(0, 16) + +/* Those interact with LEDs, SWO and IOEXP_IRQ */ +#define ARDUINO_PIN_6 GPIO_PIN(0, 17) +#define ARDUINO_PIN_7 GPIO_PIN(0, 18) +#define ARDUINO_PIN_8 GPIO_PIN(0, 19) +#define ARDUINO_PIN_9 GPIO_PIN(0, 20) + +#define ARDUINO_PIN_10 GPIO_PIN(0, 22) +#define ARDUINO_PIN_11 GPIO_PIN(0, 23) +#define ARDUINO_PIN_12 GPIO_PIN(0, 24) +#define ARDUINO_PIN_13 GPIO_PIN(0, 25) +#define ARDUINO_PIN_14 GPIO_PIN(0, 0) +#define ARDUINO_PIN_15 GPIO_PIN(0, 1) +/* Also RESET */ +#define ARDUINO_PIN_16 GPIO_PIN(0, 21) + +/* These are also UART ports */ +#define ARDUINO_PIN_17 GPIO_PIN(0, 5) +#define ARDUINO_PIN_18 GPIO_PIN(0, 6) +#define ARDUINO_PIN_19 GPIO_PIN(0, 7) +#define ARDUINO_PIN_20 GPIO_PIN(0, 8) + +#define ARDUINO_PIN_21 GPIO_PIN(0, 9) +#define ARDUINO_PIN_22 GPIO_PIN(0, 10) + +#define ARDUINO_PIN_LAST 22 +/** @} */ + +/** + * @name Aliases for analog pins + * @{ + */ +#define ARDUINO_PIN_A0 GPIO_PIN(0, 3) +#define ARDUINO_PIN_A1 GPIO_PIN(0, 4) +#define ARDUINO_PIN_A2 GPIO_PIN(0, 28) +#define ARDUINO_PIN_A3 GPIO_PIN(0, 29) +#define ARDUINO_PIN_A4 GPIO_PIN(0, 30) +#define ARDUINO_PIN_A5 GPIO_PIN(0, 31) +/** @} */ + +/** + * @name Arduino's I2C buses + * @{ + */ +/** + * @brief The only configured I2C + */ +#define ARDUINO_I2C_UNO I2C_DEV(0) +/** @} */ + + +#ifdef __cplusplus +} +#endif + +#endif /* ARDUINO_IOMAP_H */ +/** @} */ From b0a46c2eba99aea39bf966319230e37b2d265983 Mon Sep 17 00:00:00 2001 From: chrysn Date: Tue, 23 Jan 2024 00:39:03 +0100 Subject: [PATCH 2/3] boards/nrf52dk arduino: Declare SPI (side SPI) support --- boards/nrf52dk/Makefile.features | 1 + boards/nrf52dk/include/arduino_iomap.h | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/boards/nrf52dk/Makefile.features b/boards/nrf52dk/Makefile.features index 1bfb0157e6..823871f47f 100644 --- a/boards/nrf52dk/Makefile.features +++ b/boards/nrf52dk/Makefile.features @@ -1,6 +1,7 @@ CPU_MODEL = nrf52832xxaa FEATURES_PROVIDED += arduino_i2c +FEATURES_PROVIDED += arduino_spi FEATURES_PROVIDED += arduino_pins FEATURES_PROVIDED += arduino_shield_uno diff --git a/boards/nrf52dk/include/arduino_iomap.h b/boards/nrf52dk/include/arduino_iomap.h index f36753eaeb..77c9e27047 100644 --- a/boards/nrf52dk/include/arduino_iomap.h +++ b/boards/nrf52dk/include/arduino_iomap.h @@ -96,6 +96,15 @@ extern "C" { #define ARDUINO_I2C_UNO I2C_DEV(0) /** @} */ +/** + * @name Arduino's SPI buses + * @{ + */ +/** + * @brief D11..13 is 0.23..0.25, which is called SPI_DEV(0) here + */ +#define ARDUINO_SPI_D11D12D13 SPI_DEV(0) +/** @} */ #ifdef __cplusplus } From 7452a61e64a804e9c294468e647c02d005922707 Mon Sep 17 00:00:00 2001 From: chrysn Date: Tue, 23 Jan 2024 01:11:51 +0100 Subject: [PATCH 3/3] fixup! boards/nrf52dk: Minimal Arduino pinout support --- boards/nrf52dk/include/arduino_iomap.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boards/nrf52dk/include/arduino_iomap.h b/boards/nrf52dk/include/arduino_iomap.h index 77c9e27047..432117d000 100644 --- a/boards/nrf52dk/include/arduino_iomap.h +++ b/boards/nrf52dk/include/arduino_iomap.h @@ -30,7 +30,7 @@ extern "C" { /** * @brief Mapping of MCU pins to Arduino pins * - * For refernce, see schematic file `nRF52 Development Kit - Hardware files + * For reference, see schematic file `nRF52 Development Kit - Hardware files * 3_0_0/PCA10040-nRF52832 Development Board 3_0_0/Schematic_Layout pdf * files/PCA10040_Schematic_And_PCB.pdf` in * `nrf52-development-kit---hardware-files-3_0_0.zip` from