Compare commits

..

2 commits

Author SHA1 Message Date
KemoNine 5f80150894 Add readme for mdk dongle 2020-12-31 01:49:31 +00:00
KemoNine 25a87c33b9 Initial working bring up of nrf52840 mdk dongle 2020-12-31 01:46:17 +00:00
6 changed files with 108 additions and 62 deletions

View file

@ -1,7 +1,14 @@
#
# Copyright (c) 2020 The ZMK Contributors
# SPDX-License-Identifier: MIT
#
target_sources(app PRIVATE mdk_dongle_power_led.c)
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/../tools/uf2/utils/uf2conv.py
-c
-b 0x26000
-b 0x1000
-f 0xADA52840
-o ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.uf2
${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.bin

View file

@ -0,0 +1,23 @@
# nRF52840 MDK USB Dongle
A basic USB stick that contains the nRF52840 chip from Nordic and has 12 GPIOs available.
Additional detail: https://wiki.makerdiary.com/nrf52840-mdk-usb-dongle/
## Hardware Features
* Nordic nRF52840 System-on-Chip
* ARM® Cortex®-M4F processor optimized for ultra-low power operation
* Combining Bluetooth 5, Bluetooth Mesh, Thread, IEEE 802.15.4, ANT and 2.4GHz proprietary
* On-chip NFC-A tag
* On-chip USB 2.0 (Full speed) controller
* ARM TrustZone® Cryptocell 310 security subsystem
* 1 MB FLASH and 256 kB RAM
* Up to 12 GPIOs available via headers
* User programmable Button and RGB LED
* On-board 2.4G chip antenna
* 3.3V regulator with 1A peak current output
* VBUS & VIN Power-Path Management
* Convenient USB dongle form factor
* Breadboard-friendly with dual 10-Pin headers
* Measures 1.65" x 0.7" x 0.16" (42mm x 18mm x 4mm) without headers soldered in

View file

@ -1,7 +1,7 @@
/*
* Copyright (c) 2020 The ZMK Contributors
* Copyright (c) 2016 Intel Corporation
*
* SPDX-License-Identifier: MIT
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr.h>
@ -9,26 +9,30 @@
#include <devicetree.h>
#include <drivers/gpio.h>
#define POWER_LED_NODE DT_ALIAS(led1_red)
/* The devicetree node identifier for the "led0" alias. */
#define LED_NODE DT_ALIAS(ledblue)
#if DT_NODE_HAS_STATUS(POWER_LED_NODE, okay)
#define POWER_LED DT_GPIO_LABEL(POWER_LED_NODE, gpios)
#define PIN DT_GPIO_PIN(POWER_LED_NODE, gpios)
#define FLAGS DT_GPIO_FLAGS(POWER_LED_NODE, gpios)
#if DT_NODE_HAS_STATUS(LED_NODE, okay)
#define LED DT_GPIO_LABEL(LED_NODE, gpios)
#define PIN DT_GPIO_PIN(LED_NODE, gpios)
#define FLAGS DT_GPIO_FLAGS(LED_NODE, gpios)
#else
#error "Unsupported board: power led devicetree alias is not defined"
#define POWER_LED ""
#define PIN 0
#define FLAGS 0
/* A build error here means your board isn't set up to blink an LED. */
#error "Unsupported board: led devicetree alias is not defined"
#define LED0 ""
#define PIN 0
#define FLAGS 0
#endif
static int pwr_led_init(const struct device *dev) {
dev = device_get_binding(POWER_LED);
int ret;
dev = device_get_binding(LED);
if (dev == NULL) {
return -EIO;
}
int ret = gpio_pin_configure(dev, PIN, GPIO_OUTPUT_ACTIVE | FLAGS);
ret = gpio_pin_configure(dev, PIN, GPIO_OUTPUT | FLAGS);
if (ret < 0) {
return -EIO;
}

View file

@ -11,66 +11,66 @@
compatible = "makerdiary,nrf52840_mdk_dongle";
chosen {
zephyr,code-partition = &code_partition;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,code-partition = &slot0_partition;
};
leds {
compatible = "gpio-leds";
led0_green: led_0 {
led_0: led_green {
gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
label = "Green LED 0";
label = "Green LED";
status = "okay";
};
led1_red: led_1 {
led_1: led_red {
gpios = <&gpio0 23 GPIO_ACTIVE_LOW>;
label = "Red LED 1";
label = "Red LED";
status = "okay";
};
led2_blue: led_2 {
led_2: led_blue {
gpios = <&gpio0 24 GPIO_ACTIVE_LOW>;
label = "Blue LED 2";
label = "Blue LED";
status = "okay";
};
};
pwmleds {
compatible = "pwm-leds";
pwm_led0_green: pwm_led_0 {
pwm_led_0: pwm_led_green {
pwms = <&pwm0 22>;
label = "Green PWM LED 0";
label = "Green PWM LED";
status = "okay";
};
pwm_led1_red: pwm_led_1 {
pwm_led_1: pwm_led_red {
pwms = <&pwm0 23>;
label = "Red PWM LED 1";
label = "Red PWM LED";
status = "okay";
};
pwm_led2_blue: pwm_led_2 {
pwm_led_2: pwm_led_blue {
pwms = <&pwm0 24>;
label = "Blue PWM LED 2";
label = "Blue PWM LED";
status = "okay";
};
};
buttons {
compatible = "gpio-keys";
button0: button_0 {
button0: button0 {
gpios = <&gpio0 18 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
label = "Push button switch 0";
label = "Push button 0";
status = "okay";
};
};
/* These aliases are provided for compatibility with samples */
aliases {
sw0 = &button0;
led0 = &led0_green;
led1 = &led1_red;
led2 = &led2_blue;
led0-green = &led0_green;
led1-red = &led1_red;
led1-blue = &led2_blue;
pwm-led0 = &pwm_led0_green;
pwm-led1 = &pwm_led1_red;
pwm-led2 = &pwm_led2_blue;
green-pwm-led = &pwm_led0_green;
red-pwm-led = &pwm_led1_red;
blue-pwm-led = &pwm_led2_blue;
ledgreen = &led_0;
ledred = &led_1;
ledblue = &led_2;
pwmledgreen = &pwm_led_0;
pwmledred = &pwm_led_1;
pwmledblue = &pwm_led_2;
};
};
@ -78,6 +78,10 @@
status = "okay";
};
&gpiote {
status = "okay";
};
&gpio0 {
status = "okay";
};
@ -89,42 +93,39 @@
&flash0 {
/*
* For more information, see:
* https://docs.zephyrproject.org/latest/guides/dts/legacy-macros.html#legacy-flash-partitions
* http://docs.zephyrproject.org/latest/devices/dts/flash_partitions.html
*/
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x000000000 0x0000C000>;
sd_partition: partition@0 {
label = "mbr";
reg = <0x00000000 0x00001000>;
};
slot0_partition: partition@c000 {
label = "image-0";
reg = <0x0000C000 0x00067000>;
};
slot1_partition: partition@73000 {
label = "image-1";
reg = <0x00073000 0x00067000>;
};
scratch_partition: partition@da000 {
label = "image-scratch";
reg = <0x000da000 0x0001e000>;
code_partition: partition@1000 {
label = "code_partition";
reg = <0x00001000 0x000d3000>;
};
/*
* The flash starting at 0x000f8000 and ending at
* 0x000fffff is reserved for use by the application.
* The flash starting at 0x000d4000 and ending at
* 0x000f3fff is reserved for use by the application.
*/
/*
* Storage partition will be used by FCB/LittleFS/NVS
* if enabled.
*/
storage_partition: partition@f8000 {
storage_partition: partition@d4000 {
label = "storage";
reg = <0x000f8000 0x00008000>;
reg = <0x000d4000 0x00020000>;
};
boot_partition: partition@f4000 {
label = "adafruit_boot";
reg = <0x000f4000 0x0000c000>;
};
};
};

View file

@ -7,7 +7,9 @@ toolchain:
- gnuarmemb
- xtools
supported:
- adc
- usb_device
- ble
- ieee802154
- pwm
- watchdog

View file

@ -15,3 +15,12 @@ CONFIG_GPIO=y
# additional board options
CONFIG_GPIO_AS_PINRESET=n
CONFIG_USE_DT_CODE_PARTITION=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_NVS=y
#CONFIG_SETTINGS_NVS=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y