Initial working bring up of nrf52840 mdk dongle
This commit is contained in:
parent
4363aa7af7
commit
25a87c33b9
|
@ -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
|
set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
|
||||||
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/../tools/uf2/utils/uf2conv.py
|
COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/../tools/uf2/utils/uf2conv.py
|
||||||
-c
|
-c
|
||||||
-b 0x26000
|
-b 0x1000
|
||||||
-f 0xADA52840
|
-f 0xADA52840
|
||||||
-o ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.uf2
|
-o ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.uf2
|
||||||
${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.bin
|
${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.bin
|
||||||
|
|
|
@ -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>
|
#include <zephyr.h>
|
||||||
|
@ -9,26 +9,30 @@
|
||||||
#include <devicetree.h>
|
#include <devicetree.h>
|
||||||
#include <drivers/gpio.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)
|
#if DT_NODE_HAS_STATUS(LED_NODE, okay)
|
||||||
#define POWER_LED DT_GPIO_LABEL(POWER_LED_NODE, gpios)
|
#define LED DT_GPIO_LABEL(LED_NODE, gpios)
|
||||||
#define PIN DT_GPIO_PIN(POWER_LED_NODE, gpios)
|
#define PIN DT_GPIO_PIN(LED_NODE, gpios)
|
||||||
#define FLAGS DT_GPIO_FLAGS(POWER_LED_NODE, gpios)
|
#define FLAGS DT_GPIO_FLAGS(LED_NODE, gpios)
|
||||||
#else
|
#else
|
||||||
#error "Unsupported board: power led devicetree alias is not defined"
|
/* A build error here means your board isn't set up to blink an LED. */
|
||||||
#define POWER_LED ""
|
#error "Unsupported board: led devicetree alias is not defined"
|
||||||
|
#define LED0 ""
|
||||||
#define PIN 0
|
#define PIN 0
|
||||||
#define FLAGS 0
|
#define FLAGS 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int pwr_led_init(const struct device *dev) {
|
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) {
|
if (dev == NULL) {
|
||||||
return -EIO;
|
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) {
|
if (ret < 0) {
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,66 +11,66 @@
|
||||||
compatible = "makerdiary,nrf52840_mdk_dongle";
|
compatible = "makerdiary,nrf52840_mdk_dongle";
|
||||||
|
|
||||||
chosen {
|
chosen {
|
||||||
|
zephyr,code-partition = &code_partition;
|
||||||
zephyr,sram = &sram0;
|
zephyr,sram = &sram0;
|
||||||
zephyr,flash = &flash0;
|
zephyr,flash = &flash0;
|
||||||
zephyr,code-partition = &slot0_partition;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
leds {
|
leds {
|
||||||
compatible = "gpio-leds";
|
compatible = "gpio-leds";
|
||||||
led0_green: led_0 {
|
led_0: led_green {
|
||||||
gpios = <&gpio0 22 GPIO_ACTIVE_LOW>;
|
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>;
|
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>;
|
gpios = <&gpio0 24 GPIO_ACTIVE_LOW>;
|
||||||
label = "Blue LED 2";
|
label = "Blue LED";
|
||||||
|
status = "okay";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
pwmleds {
|
pwmleds {
|
||||||
compatible = "pwm-leds";
|
compatible = "pwm-leds";
|
||||||
pwm_led0_green: pwm_led_0 {
|
pwm_led_0: pwm_led_green {
|
||||||
pwms = <&pwm0 22>;
|
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>;
|
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>;
|
pwms = <&pwm0 24>;
|
||||||
label = "Blue PWM LED 2";
|
label = "Blue PWM LED";
|
||||||
|
status = "okay";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
buttons {
|
buttons {
|
||||||
compatible = "gpio-keys";
|
compatible = "gpio-keys";
|
||||||
button0: button_0 {
|
button0: button0 {
|
||||||
gpios = <&gpio0 18 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>;
|
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 */
|
/* These aliases are provided for compatibility with samples */
|
||||||
aliases {
|
aliases {
|
||||||
sw0 = &button0;
|
ledgreen = &led_0;
|
||||||
led0 = &led0_green;
|
ledred = &led_1;
|
||||||
led1 = &led1_red;
|
ledblue = &led_2;
|
||||||
led2 = &led2_blue;
|
pwmledgreen = &pwm_led_0;
|
||||||
led0-green = &led0_green;
|
pwmledred = &pwm_led_1;
|
||||||
led1-red = &led1_red;
|
pwmledblue = &pwm_led_2;
|
||||||
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;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -78,6 +78,10 @@
|
||||||
status = "okay";
|
status = "okay";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
&gpiote {
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
|
|
||||||
&gpio0 {
|
&gpio0 {
|
||||||
status = "okay";
|
status = "okay";
|
||||||
};
|
};
|
||||||
|
@ -89,42 +93,39 @@
|
||||||
&flash0 {
|
&flash0 {
|
||||||
/*
|
/*
|
||||||
* For more information, see:
|
* 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 {
|
partitions {
|
||||||
compatible = "fixed-partitions";
|
compatible = "fixed-partitions";
|
||||||
#address-cells = <1>;
|
#address-cells = <1>;
|
||||||
#size-cells = <1>;
|
#size-cells = <1>;
|
||||||
|
|
||||||
boot_partition: partition@0 {
|
sd_partition: partition@0 {
|
||||||
label = "mcuboot";
|
label = "mbr";
|
||||||
reg = <0x000000000 0x0000C000>;
|
reg = <0x00000000 0x00001000>;
|
||||||
};
|
};
|
||||||
slot0_partition: partition@c000 {
|
code_partition: partition@1000 {
|
||||||
label = "image-0";
|
label = "code_partition";
|
||||||
reg = <0x0000C000 0x00067000>;
|
reg = <0x00001000 0x000d3000>;
|
||||||
};
|
|
||||||
slot1_partition: partition@73000 {
|
|
||||||
label = "image-1";
|
|
||||||
reg = <0x00073000 0x00067000>;
|
|
||||||
};
|
|
||||||
scratch_partition: partition@da000 {
|
|
||||||
label = "image-scratch";
|
|
||||||
reg = <0x000da000 0x0001e000>;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The flash starting at 0x000f8000 and ending at
|
* The flash starting at 0x000d4000 and ending at
|
||||||
* 0x000fffff is reserved for use by the application.
|
* 0x000f3fff is reserved for use by the application.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Storage partition will be used by FCB/LittleFS/NVS
|
* Storage partition will be used by FCB/LittleFS/NVS
|
||||||
* if enabled.
|
* if enabled.
|
||||||
*/
|
*/
|
||||||
storage_partition: partition@f8000 {
|
storage_partition: partition@d4000 {
|
||||||
label = "storage";
|
label = "storage";
|
||||||
reg = <0x000f8000 0x00008000>;
|
reg = <0x000d4000 0x00020000>;
|
||||||
|
};
|
||||||
|
|
||||||
|
boot_partition: partition@f4000 {
|
||||||
|
label = "adafruit_boot";
|
||||||
|
reg = <0x000f4000 0x0000c000>;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
|
@ -7,7 +7,9 @@ toolchain:
|
||||||
- gnuarmemb
|
- gnuarmemb
|
||||||
- xtools
|
- xtools
|
||||||
supported:
|
supported:
|
||||||
|
- adc
|
||||||
- usb_device
|
- usb_device
|
||||||
- ble
|
- ble
|
||||||
- ieee802154
|
- ieee802154
|
||||||
- pwm
|
- pwm
|
||||||
|
- watchdog
|
||||||
|
|
|
@ -15,3 +15,12 @@ CONFIG_GPIO=y
|
||||||
|
|
||||||
# additional board options
|
# additional board options
|
||||||
CONFIG_GPIO_AS_PINRESET=n
|
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
|
Loading…
Reference in a new issue