From 950573ddf7ef238aa7cc623fbed1886c26a102ea Mon Sep 17 00:00:00 2001 From: Mike Szczys Date: Sun, 11 Sep 2022 21:47:32 -0500 Subject: [PATCH] variants: add nrf52840dk Add varints folder and pinmapping for nRF52840dk Signed-off-by: Mike Szczys --- .../nrf52840dk_nrf52840.overlay | 27 ++++++ .../nrf52840dk_nrf52840_pinmap.h | 96 +++++++++++++++++++ variants/variants.h | 5 +- 3 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 variants/nrf52840dk_nrf52840/nrf52840dk_nrf52840.overlay create mode 100644 variants/nrf52840dk_nrf52840/nrf52840dk_nrf52840_pinmap.h diff --git a/variants/nrf52840dk_nrf52840/nrf52840dk_nrf52840.overlay b/variants/nrf52840dk_nrf52840/nrf52840dk_nrf52840.overlay new file mode 100644 index 00000000..6d2ee2ba --- /dev/null +++ b/variants/nrf52840dk_nrf52840/nrf52840dk_nrf52840.overlay @@ -0,0 +1,27 @@ +/ { + zephyr,user { + d0_gpios = <&arduino_header 6 0>; /* Digital */ + d1_gpios = <&arduino_header 7 0>; + d2_gpios = <&arduino_header 8 0>; + d3_gpios = <&arduino_header 9 0>; + d4_gpios = <&arduino_header 10 0>; + d5_gpios = <&arduino_header 11 0>; + d6_gpios = <&arduino_header 12 0>; + d7_gpios = <&arduino_header 13 0>; + d8_gpios = <&arduino_header 14 0>; + d9_gpios = <&arduino_header 15 0>; + d10_gpios = <&arduino_header 16 0>; + d11_gpios = <&arduino_header 17 0>; + d12_gpios = <&arduino_header 18 0>; + d13_gpios = <&arduino_header 19 0>; + d14_gpios = <&arduino_header 20 0>; + d15_gpios = <&arduino_header 21 0>; + d16_gpios = <&arduino_header 0 0>; /* Analog */ + d17_gpios = <&arduino_header 1 0>; + d18_gpios = <&arduino_header 2 0>; + d19_gpios = <&arduino_header 3 0>; + d20_gpios = <&arduino_header 4 0>; + d21_gpios = <&arduino_header 5 0>; + d22_gpios = <&gpio0 13 GPIO_ACTIVE_LOW>; + }; +}; diff --git a/variants/nrf52840dk_nrf52840/nrf52840dk_nrf52840_pinmap.h b/variants/nrf52840dk_nrf52840/nrf52840dk_nrf52840_pinmap.h new file mode 100644 index 00000000..f5a4d78d --- /dev/null +++ b/variants/nrf52840dk_nrf52840/nrf52840dk_nrf52840_pinmap.h @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2022 Mike Szczys + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef __NRF52840DK_NRF52840_PINMAP_H__ +#define __NRF52840DK_NRF52840_PINMAP_H__ + +#include +#include +#include + +#define LED_BUILTIN 22 + +static struct gpio_dt_spec d0 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d0_gpios); +static struct gpio_dt_spec d1 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d1_gpios); +static struct gpio_dt_spec d2 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d2_gpios); +static struct gpio_dt_spec d3 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d3_gpios); +static struct gpio_dt_spec d4 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d4_gpios); +static struct gpio_dt_spec d5 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d5_gpios); +static struct gpio_dt_spec d6 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d6_gpios); +static struct gpio_dt_spec d7 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d7_gpios); +static struct gpio_dt_spec d8 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d8_gpios); +static struct gpio_dt_spec d9 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d9_gpios); +static struct gpio_dt_spec d10 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d10_gpios); +static struct gpio_dt_spec d11 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d11_gpios); +static struct gpio_dt_spec d12 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d12_gpios); +static struct gpio_dt_spec d13 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d13_gpios); +static struct gpio_dt_spec d14 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d13_gpios); +static struct gpio_dt_spec d15 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d15_gpios); +static struct gpio_dt_spec d16 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d16_gpios); +static struct gpio_dt_spec d17 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d17_gpios); +static struct gpio_dt_spec d18 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d18_gpios); +static struct gpio_dt_spec d19 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d19_gpios); +static struct gpio_dt_spec d20 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d20_gpios); +static struct gpio_dt_spec d21 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d21_gpios); +static struct gpio_dt_spec d22 = + GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), d22_gpios); /* LED0 */ + +static struct gpio_dt_spec *arduino_pins[23] = { + &d0, &d1, &d2, &d3, &d4, &d5, &d6, &d7, &d8, &d9, &d10, + &d11, &d12, &d13, &d14, &d15, &d16, &d17, &d18, &d19, &d20, &d21, + &d22}; + +enum digitalPins { + D0, + D1, + D2, + D3, + D4, + D5, + D6, + D7, + D8, + D9, + D10, + D11, + D12, + D13, + D14, + D15, + D16, + D17, + D18, + D19, + D20, + D21, + D22 /* LED0 */ +}; + +const static struct device *i2c_dev = DEVICE_DT_GET(DT_NODELABEL(arduino_i2c)); + +#endif diff --git a/variants/variants.h b/variants/variants.h index 6ba71c5d..aa7dd771 100644 --- a/variants/variants.h +++ b/variants/variants.h @@ -6,4 +6,7 @@ #endif // CONFIG_BOARD_ARDUINO_NANO_33_BLE_SENSE #ifdef CONFIG_BOARD_ARDUINO_NANO_33_IOT #include -#endif // CONFIG_BOARD_ARDUINO_NANO_33_IOT \ No newline at end of file +#endif /* CONFIG_BOARD_ARDUINO_NANO_33_IOT */ +#ifdef CONFIG_BOARD_NRF52840DK_NRF52840 +#include "nrf52840dk_nrf52840_pinmap.h" +#endif /* CONFIG_BOARD_NRF52840DK_NRF52840 */