Skip to content

Add nrf52840dk #32

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 16, 2022
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
27 changes: 27 additions & 0 deletions variants/nrf52840dk_nrf52840/nrf52840dk_nrf52840.overlay
Original file line number Diff line number Diff line change
@@ -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>;
};
};
96 changes: 96 additions & 0 deletions variants/nrf52840dk_nrf52840/nrf52840dk_nrf52840_pinmap.h
Original file line number Diff line number Diff line change
@@ -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 <zephyr/drivers/gpio.h>
#include <zephyr/drivers/i2c.h>
#include <zephyr/zephyr.h>

#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
5 changes: 4 additions & 1 deletion variants/variants.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@
#endif // CONFIG_BOARD_ARDUINO_NANO_33_BLE_SENSE
#ifdef CONFIG_BOARD_ARDUINO_NANO_33_IOT
#include <arduino_nano_33_iot_pinmap.h>
#endif // CONFIG_BOARD_ARDUINO_NANO_33_IOT
#endif /* CONFIG_BOARD_ARDUINO_NANO_33_IOT */
#ifdef CONFIG_BOARD_NRF52840DK_NRF52840
#include "nrf52840dk_nrf52840_pinmap.h"
#endif /* CONFIG_BOARD_NRF52840DK_NRF52840 */