aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorHai-Ninh Dang <[email protected]>2021-11-09 12:57:24 +0700
committerGitHub <[email protected]>2021-11-09 00:57:24 -0500
commitf2e0642291621611f3abce69f73a22c33b1ce801 (patch)
treeb19c681188373e28fc7e03b9f8366a99c11a5d96
parent944f93170454008759200a27a11225da40935edf (diff)
downloadzmk-f2e0642291621611f3abce69f73a22c33b1ce801.tar.gz
zmk-f2e0642291621611f3abce69f73a22c33b1ce801.zip
feat(boards): Add Mikoto board
* Supports selecting from several possible charge currents Co-authored-by: Pete Johanson <[email protected]>
-rw-r--r--app/boards/arm/mikoto/CMakeLists.txt14
-rw-r--r--app/boards/arm/mikoto/Kconfig29
-rw-r--r--app/boards/arm/mikoto/Kconfig.board8
-rw-r--r--app/boards/arm/mikoto/Kconfig.defconfig40
-rw-r--r--app/boards/arm/mikoto/arduino_pro_micro_pins.dtsi59
-rw-r--r--app/boards/arm/mikoto/board.cmake5
-rw-r--r--app/boards/arm/mikoto/mikoto_520.dts115
-rw-r--r--app/boards/arm/mikoto/mikoto_520.yaml15
-rw-r--r--app/boards/arm/mikoto/mikoto_520.zmk.yml10
-rw-r--r--app/boards/arm/mikoto/mikoto_520_defconfig20
-rw-r--r--app/boards/arm/mikoto/pinmux.c48
11 files changed, 363 insertions, 0 deletions
diff --git a/app/boards/arm/mikoto/CMakeLists.txt b/app/boards/arm/mikoto/CMakeLists.txt
new file mode 100644
index 0000000000..cd4843af1f
--- /dev/null
+++ b/app/boards/arm/mikoto/CMakeLists.txt
@@ -0,0 +1,14 @@
+set_property(GLOBAL APPEND PROPERTY extra_post_build_commands
+ COMMAND ${PYTHON_EXECUTABLE} ${ZEPHYR_BASE}/../tools/uf2/utils/uf2conv.py
+ -c
+ -b 0x26000
+ -f 0xADA52840
+ -o ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.uf2
+ ${PROJECT_BINARY_DIR}/${CONFIG_KERNEL_BIN_NAME}.bin
+)
+
+if(CONFIG_PINMUX)
+zephyr_library()
+zephyr_library_sources(pinmux.c)
+zephyr_library_include_directories(${ZEPHYR_BASE}/drivers)
+endif() \ No newline at end of file
diff --git a/app/boards/arm/mikoto/Kconfig b/app/boards/arm/mikoto/Kconfig
new file mode 100644
index 0000000000..646d119c18
--- /dev/null
+++ b/app/boards/arm/mikoto/Kconfig
@@ -0,0 +1,29 @@
+config BOARD_ENABLE_DCDC
+ bool "Enable DCDC mode"
+ select SOC_DCDC_NRF52X
+ default y
+ depends on (BOARD_MIKOTO_520)
+
+choice BOARD_MIKOTO_CHARGER_CURRENT
+ prompt "Charge current to supply to attached batteries"
+ depends on (BOARD_MIKOTO_520)
+
+config BOARD_MIKOTO_CHARGER_CURRENT_40MA
+ bool "40mA charge current, for battery capacity 40mAh or higher"
+
+config BOARD_MIKOTO_CHARGER_CURRENT_100MA
+ bool "100mA charge current, for battery capacity 100mAh or higher"
+
+config BOARD_MIKOTO_CHARGER_CURRENT_150MA
+ bool "150mA charge current, for battery capacity 150mAh or higher"
+
+config BOARD_MIKOTO_CHARGER_CURRENT_250MA
+ bool "250mA charge current, for battery capacity 250mAh or higher"
+
+config BOARD_MIKOTO_CHARGER_CURRENT_350MA
+ bool "350mA charge current, for battery capacity 350mAh or higher"
+
+config BOARD_MIKOTO_CHARGER_CURRENT_NONE
+ bool "Disable charge current"
+
+endchoice \ No newline at end of file
diff --git a/app/boards/arm/mikoto/Kconfig.board b/app/boards/arm/mikoto/Kconfig.board
new file mode 100644
index 0000000000..067c2fbe7a
--- /dev/null
+++ b/app/boards/arm/mikoto/Kconfig.board
@@ -0,0 +1,8 @@
+# mikoto board configuration
+
+# Copyright (c) 2020 The ZMK Contributors
+# SPDX-License-Identifier: MIT
+
+config BOARD_MIKOTO_520
+ bool "mikoto_520"
+ depends on SOC_NRF52840_QIAA
diff --git a/app/boards/arm/mikoto/Kconfig.defconfig b/app/boards/arm/mikoto/Kconfig.defconfig
new file mode 100644
index 0000000000..2ca77b9e62
--- /dev/null
+++ b/app/boards/arm/mikoto/Kconfig.defconfig
@@ -0,0 +1,40 @@
+# Electronut Labs Papyr board configuration
+
+# Copyright (c) 2020 The ZMK Contributors
+# SPDX-License-Identifier: MIT
+
+if BOARD_MIKOTO_520
+
+config BOARD
+ default "mikoto"
+
+if USB
+
+config USB_NRFX
+ default y
+
+config USB_DEVICE_STACK
+ default y
+
+endif # USB
+
+config BT_CTLR
+ default BT
+
+config ZMK_BLE
+ default y
+
+config ZMK_USB
+ default y
+
+config PINMUX
+ default y
+
+choice BOARD_MIKOTO_CHARGER_CURRENT
+ default BOARD_MIKOTO_CHARGER_CURRENT_100MA
+endchoice
+
+config ZMK_BATTERY_VOLTAGE_DIVIDER
+ default y
+
+endif # BOARD_MIKOTO_520
diff --git a/app/boards/arm/mikoto/arduino_pro_micro_pins.dtsi b/app/boards/arm/mikoto/arduino_pro_micro_pins.dtsi
new file mode 100644
index 0000000000..7c5cd12f95
--- /dev/null
+++ b/app/boards/arm/mikoto/arduino_pro_micro_pins.dtsi
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2020 The ZMK Contributors
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+
+/ {
+ pro_micro: connector {
+ compatible = "arduino-pro-micro";
+ #gpio-cells = <2>;
+ gpio-map-mask = <0xffffffff 0xffffffc0>;
+ gpio-map-pass-thru = <0 0x3f>;
+ gpio-map
+ = <0 0 &gpio0 4 0> /* D0 */
+ , <1 0 &gpio0 8 0> /* D1 */
+ , <2 0 &gpio0 17 0> /* D2 */
+ , <3 0 &gpio0 20 0> /* D3 */
+ , <4 0 &gpio0 22 0> /* D4/A6 */
+ , <5 0 &gpio0 24 0> /* D5 */
+ , <6 0 &gpio1 0 0> /* D6/A7 */
+ , <7 0 &gpio1 2 0> /* D7 */
+ , <8 0 &gpio1 4 0> /* D8/A8 */
+ , <9 0 &gpio1 6 0> /* D9/A9 */
+ , <10 0 &gpio0 9 0> /* D10/A10 */
+ , <16 0 &gpio0 10 0> /* D16 */
+ , <14 0 &gpio1 13 0> /* D14 */
+ , <15 0 &gpio0 2 0> /* D15 */
+ , <18 0 &gpio0 29 0> /* D18/A0 */
+ , <19 0 &gpio0 31 0> /* D19/A1 */
+ , <20 0 &gpio0 25 0> /* D20/A2 */
+ , <21 0 &gpio0 11 0> /* D21/A3 */
+ ;
+ };
+
+ pro_micro_a: connector_a {
+ compatible = "arduino-pro-micro";
+ #gpio-cells = <2>;
+ gpio-map-mask = <0xffffffff 0xffffffc0>;
+ gpio-map-pass-thru = <0 0x3f>;
+ gpio-map
+ = <0 0 &gpio0 29 0> /* D18/A0 */
+ , <1 0 &gpio0 31 0> /* D19/A1 */
+ , <2 0 &gpio0 25 0> /* D20/A2 */
+ , <3 0 &gpio0 11 0> /* D21/A3 */
+ , <6 0 &gpio0 22 0> /* D4/A6 */
+ , <7 0 &gpio1 0 0> /* D6/A7 */
+ , <8 0 &gpio1 4 0> /* D8/A8 */
+ , <9 0 &gpio1 6 0> /* D9/A9 */
+ , <10 0 &gpio0 9 0> /* D10/A10 */
+ ;
+ };
+};
+
+
+pro_micro_d: &pro_micro {};
+pro_micro_i2c: &i2c0 {};
+pro_micro_spi: &spi0 {};
+pro_micro_serial: &uart0 {};
diff --git a/app/boards/arm/mikoto/board.cmake b/app/boards/arm/mikoto/board.cmake
new file mode 100644
index 0000000000..fa847d5059
--- /dev/null
+++ b/app/boards/arm/mikoto/board.cmake
@@ -0,0 +1,5 @@
+# SPDX-License-Identifier: MIT
+
+board_runner_args(nrfjprog "--nrf-family=NRF52" "--softreset")
+include(${ZEPHYR_BASE}/boards/common/blackmagicprobe.board.cmake)
+include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)
diff --git a/app/boards/arm/mikoto/mikoto_520.dts b/app/boards/arm/mikoto/mikoto_520.dts
new file mode 100644
index 0000000000..20703e8514
--- /dev/null
+++ b/app/boards/arm/mikoto/mikoto_520.dts
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2020 The ZMK Contributors
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+/dts-v1/;
+#include <nordic/nrf52840_qiaa.dtsi>
+#include "arduino_pro_micro_pins.dtsi"
+
+/ {
+ model = "mikoto";
+ compatible = "zhiayang,mikoto";
+
+ chosen {
+ zephyr,code-partition = &code_partition;
+ zephyr,sram = &sram0;
+ zephyr,flash = &flash0;
+ };
+
+ leds {
+ compatible = "gpio-leds";
+ blue_led: led_0 {
+ gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;
+ label = "Blue LED";
+ };
+ };
+
+ ext-power {
+ compatible = "zmk,ext-power-generic";
+ label = "EXT_POWER";
+ control-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
+ };
+
+ vbatt {
+ compatible = "zmk,battery-voltage-divider";
+ label = "BATTERY";
+ io-channels = <&adc 2>;
+ output-ohms = <10000000>;
+ full-ohms = <(10000000 + 4000000)>;
+ };
+};
+
+&adc {
+ status = "okay";
+};
+
+&gpiote {
+ status = "okay";
+};
+
+&gpio0 {
+ status = "okay";
+};
+
+&gpio1 {
+ status = "okay";
+};
+
+&i2c0 {
+ compatible = "nordic,nrf-twi";
+ sda-pin = <17>;
+ scl-pin = <20>;
+};
+
+&uart0 {
+ compatible = "nordic,nrf-uarte";
+ tx-pin = <8>;
+ rx-pin = <4>;
+};
+
+&usbd {
+ status = "okay";
+};
+
+
+&flash0 {
+ /*
+ * For more information, see:
+ * http://docs.zephyrproject.org/latest/devices/dts/flash_partitions.html
+ */
+ partitions {
+ compatible = "fixed-partitions";
+ #address-cells = <1>;
+ #size-cells = <1>;
+
+ sd_partition: partition@0 {
+ label = "softdevice";
+ reg = <0x00000000 0x00026000>;
+ };
+ code_partition: partition@26000 {
+ label = "code_partition";
+ reg = <0x00026000 0x000c6000>;
+ };
+
+ /*
+ * The flash starting at 0x000ec000 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@ec000 {
+ label = "storage";
+ reg = <0x000ec000 0x00008000>;
+ };
+
+ boot_partition: partition@f4000 {
+ label = "adafruit_boot";
+ reg = <0x000f4000 0x0000c000>;
+ };
+ };
+};
diff --git a/app/boards/arm/mikoto/mikoto_520.yaml b/app/boards/arm/mikoto/mikoto_520.yaml
new file mode 100644
index 0000000000..8d9f49ae85
--- /dev/null
+++ b/app/boards/arm/mikoto/mikoto_520.yaml
@@ -0,0 +1,15 @@
+identifier: mikoto_520
+name: mikoto_520
+type: mcu
+arch: arm
+toolchain:
+ - zephyr
+ - gnuarmemb
+ - xtools
+supported:
+ - adc
+ - usb_device
+ - ble
+ - ieee802154
+ - pwm
+ - watchdog
diff --git a/app/boards/arm/mikoto/mikoto_520.zmk.yml b/app/boards/arm/mikoto/mikoto_520.zmk.yml
new file mode 100644
index 0000000000..91dcc9e09a
--- /dev/null
+++ b/app/boards/arm/mikoto/mikoto_520.zmk.yml
@@ -0,0 +1,10 @@
+file_format: "1"
+id: mikoto_520
+name: Mikoto 5.20
+type: board
+arch: arm
+outputs:
+ - usb
+ - ble
+url: https://github.com/zhiayang/mikoto
+exposes: [pro_micro]
diff --git a/app/boards/arm/mikoto/mikoto_520_defconfig b/app/boards/arm/mikoto/mikoto_520_defconfig
new file mode 100644
index 0000000000..925711c005
--- /dev/null
+++ b/app/boards/arm/mikoto/mikoto_520_defconfig
@@ -0,0 +1,20 @@
+# SPDX-License-Identifier: MIT
+
+CONFIG_SOC_SERIES_NRF52X=y
+CONFIG_SOC_NRF52840_QIAA=y
+CONFIG_BOARD_MIKOTO_520=y
+
+# Enable MPU
+CONFIG_ARM_MPU=y
+
+# enable GPIO
+CONFIG_GPIO=y
+
+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
diff --git a/app/boards/arm/mikoto/pinmux.c b/app/boards/arm/mikoto/pinmux.c
new file mode 100644
index 0000000000..59a38fbf7e
--- /dev/null
+++ b/app/boards/arm/mikoto/pinmux.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2020 The ZMK Contributors
+ *
+ * SPDX-License-Identifier: MIT
+ */
+
+#include <kernel.h>
+#include <device.h>
+#include <init.h>
+#include <drivers/gpio.h>
+#include <sys/sys_io.h>
+#include <devicetree.h>
+
+static int pinmux_mikoto_init(const struct device *port) {
+ ARG_UNUSED(port);
+
+#if CONFIG_BOARD_MIKOTO_520
+ const struct device *p0 = device_get_binding("GPIO_0");
+ const struct device *p1 = device_get_binding("GPIO_1");
+#if CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_40MA
+ gpio_pin_configure(p0, 26, GPIO_INPUT | GPIO_PULL_DOWN);
+ gpio_pin_configure(p1, 15, GPIO_INPUT);
+#elif CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_100MA
+ gpio_pin_configure(p0, 26, GPIO_OUTPUT);
+ gpio_pin_set(p0, 26, 0);
+ gpio_pin_configure(p1, 15, GPIO_INPUT);
+#elif CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_150MA
+ gpio_pin_configure(p0, 26, GPIO_OUTPUT);
+ gpio_pin_set(p0, 26, 0);
+ gpio_pin_configure(p1, 15, GPIO_INPUT | GPIO_PULL_DOWN);
+#elif CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_250MA
+ gpio_pin_configure(p0, 26, GPIO_INPUT);
+ gpio_pin_configure(p1, 15, GPIO_OUTPUT);
+ gpio_pin_set(p1, 15, 0);
+#elif CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_350MA
+ gpio_pin_configure(p0, 26, GPIO_OUTPUT);
+ gpio_pin_set(p0, 26, 0);
+ gpio_pin_configure(p1, 15, GPIO_OUTPUT);
+ gpio_pin_set(p1, 15, 0);
+#elif CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_NONE
+ gpio_pin_configure(p0, 26, GPIO_INPUT);
+ gpio_pin_configure(p1, 15, GPIO_INPUT);
+#endif
+#endif
+ return 0;
+}
+
+SYS_INIT(pinmux_mikoto_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);