Change Mikoto board

This commit is contained in:
HeavyDutySoul 2023-10-06 17:34:05 +03:00
parent 63d3058465
commit a559896f34
8 changed files with 187 additions and 143 deletions

View file

@ -1,12 +1,12 @@
config BOARD_ENABLE_DCDC config BOARD_ENABLE_DCDC
bool "Enable DCDC mode" bool "Enable DCDC mode"
select SOC_DCDC_NRF52X select SOC_DCDC_NRF52X
default y default y
depends on (BOARD_MIKOTO_520) depends on (BOARD_MIKOTO_520)
choice BOARD_MIKOTO_CHARGER_CURRENT choice BOARD_MIKOTO_CHARGER_CURRENT
prompt "Charge current to supply to attached batteries" prompt "Charge current to supply to attached batteries"
depends on (BOARD_MIKOTO_520) depends on (BOARD_MIKOTO_520)
config BOARD_MIKOTO_CHARGER_CURRENT_40MA config BOARD_MIKOTO_CHARGER_CURRENT_40MA
bool "40mA charge current, for battery capacity 40mAh or higher" bool "40mA charge current, for battery capacity 40mAh or higher"

View file

@ -4,5 +4,5 @@
# SPDX-License-Identifier: MIT # SPDX-License-Identifier: MIT
config BOARD_MIKOTO_520 config BOARD_MIKOTO_520
bool "mikoto_520" bool "mikoto_520"
depends on SOC_NRF52840_QIAA depends on SOC_NRF52840_QIAA

View file

@ -6,29 +6,29 @@
if BOARD_MIKOTO_520 if BOARD_MIKOTO_520
config BOARD config BOARD
default "mikoto" default "mikoto"
if USB if USB
config USB_NRFX config USB_NRFX
default y default y
config USB_DEVICE_STACK config USB_DEVICE_STACK
default y default y
endif # USB endif # USB
config BT_CTLR config BT_CTLR
default BT default BT
config ZMK_BLE config ZMK_BLE
default y default y
config ZMK_USB config ZMK_USB
default y default y
config PINMUX config PINMUX
default y default y
choice BOARD_MIKOTO_CHARGER_CURRENT choice BOARD_MIKOTO_CHARGER_CURRENT
default BOARD_MIKOTO_CHARGER_CURRENT_40MA default BOARD_MIKOTO_CHARGER_CURRENT_40MA

View file

@ -6,50 +6,50 @@
/ { / {
pro_micro: connector { pro_micro: connector {
compatible = "arduino-pro-micro"; compatible = "arduino-pro-micro";
#gpio-cells = <2>; #gpio-cells = <2>;
gpio-map-mask = <0xffffffff 0xffffffc0>; gpio-map-mask = <0xffffffff 0xffffffc0>;
gpio-map-pass-thru = <0 0x3f>; gpio-map-pass-thru = <0 0x3f>;
gpio-map gpio-map
= <0 0 &gpio0 4 0> /* D0 */ = <0 0 &gpio0 4 0> /* D0 */
, <1 0 &gpio0 8 0> /* D1 */ , <1 0 &gpio0 8 0> /* D1 */
, <2 0 &gpio0 17 0> /* D2 */ , <2 0 &gpio0 17 0> /* D2 */
, <3 0 &gpio0 20 0> /* D3 */ , <3 0 &gpio0 20 0> /* D3 */
, <4 0 &gpio0 22 0> /* D4/A6 */ , <4 0 &gpio0 22 0> /* D4/A6 */
, <5 0 &gpio0 24 0> /* D5 */ , <5 0 &gpio0 24 0> /* D5 */
, <6 0 &gpio1 8 0> /* D6/A7 */ , <6 0 &gpio1 8 0> /* D6/A7 */
, <7 0 &gpio1 2 0> /* D7 */ , <7 0 &gpio1 2 0> /* D7 */
, <8 0 &gpio1 4 0> /* D8/A8 */ , <8 0 &gpio1 4 0> /* D8/A8 */
, <9 0 &gpio1 6 0> /* D9/A9 */ , <9 0 &gpio1 6 0> /* D9/A9 */
, <10 0 &gpio0 9 0> /* D10/A10 */ , <10 0 &gpio0 9 0> /* D10/A10 */
, <16 0 &gpio0 10 0> /* D16 */ , <16 0 &gpio0 10 0> /* D16 */
, <14 0 &gpio1 13 0> /* D14 */ , <14 0 &gpio1 13 0> /* D14 */
, <15 0 &gpio0 2 0> /* D15 */ , <15 0 &gpio0 2 0> /* D15 */
, <18 0 &gpio0 29 0> /* D18/A0 */ , <18 0 &gpio0 29 0> /* D18/A0 */
, <19 0 &gpio0 31 0> /* D19/A1 */ , <19 0 &gpio0 31 0> /* D19/A1 */
, <20 0 &gpio0 25 0> /* D20/A2 */ , <20 0 &gpio0 25 0> /* D20/A2 */
, <21 0 &gpio0 11 0> /* D21/A3 */ , <21 0 &gpio0 11 0> /* D21/A3 */
; ;
}; };
pro_micro_a: connector_a { pro_micro_a: connector_a {
compatible = "arduino-pro-micro"; compatible = "arduino-pro-micro";
#gpio-cells = <2>; #gpio-cells = <2>;
gpio-map-mask = <0xffffffff 0xffffffc0>; gpio-map-mask = <0xffffffff 0xffffffc0>;
gpio-map-pass-thru = <0 0x3f>; gpio-map-pass-thru = <0 0x3f>;
gpio-map gpio-map
= <0 0 &gpio0 29 0> /* D18/A0 */ = <0 0 &gpio0 29 0> /* D18/A0 */
, <1 0 &gpio0 31 0> /* D19/A1 */ , <1 0 &gpio0 31 0> /* D19/A1 */
, <2 0 &gpio0 25 0> /* D20/A2 */ , <2 0 &gpio0 25 0> /* D20/A2 */
, <3 0 &gpio0 11 0> /* D21/A3 */ , <3 0 &gpio0 11 0> /* D21/A3 */
, <6 0 &gpio0 22 0> /* D4/A6 */ , <6 0 &gpio0 22 0> /* D4/A6 */
, <7 0 &gpio1 0 0> /* D6/A7 */ , <7 0 &gpio1 0 0> /* D6/A7 */
, <8 0 &gpio1 4 0> /* D8/A8 */ , <8 0 &gpio1 4 0> /* D8/A8 */
, <9 0 &gpio1 6 0> /* D9/A9 */ , <9 0 &gpio1 6 0> /* D9/A9 */
, <10 0 &gpio0 9 0> /* D10/A10 */ , <10 0 &gpio0 9 0> /* D10/A10 */
; ;
}; };
}; };

View file

@ -0,0 +1,39 @@
/*
* Copyright (c) 2022 The ZMK Contributors
* SPDX-License-Identifier: MIT
*/
&pinctrl {
uart0_default: uart0_default {
group1 {
psels = <NRF_PSEL(UART_RX, 0, 4)>;
bias-pull-up;
};
group2 {
psels = <NRF_PSEL(UART_TX, 0, 8)>;
};
};
uart0_sleep: uart0_sleep {
group1 {
psels = <NRF_PSEL(UART_RX, 0, 4)>,
<NRF_PSEL(UART_TX, 0, 8)>;
low-power-enable;
};
};
i2c0_default: i2c0_default {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 17)>,
<NRF_PSEL(TWIM_SCL, 0, 20)>;
};
};
i2c0_sleep: i2c0_sleep {
group1 {
psels = <NRF_PSEL(TWIM_SDA, 0, 17)>,
<NRF_PSEL(TWIM_SCL, 0, 20)>;
low-power-enable;
};
};
};

View file

@ -7,116 +7,119 @@
/dts-v1/; /dts-v1/;
#include <nordic/nrf52840_qiaa.dtsi> #include <nordic/nrf52840_qiaa.dtsi>
#include "arduino_pro_micro_pins.dtsi" #include "arduino_pro_micro_pins.dtsi"
#include "mikoto_520-pinctrl.dtsi"
/ { / {
model = "mikoto"; model = "mikoto";
compatible = "zhiayang,mikoto"; compatible = "zhiayang,mikoto";
chosen { chosen {
zephyr,code-partition = &code_partition; zephyr,code-partition = &code_partition;
zephyr,sram = &sram0; zephyr,sram = &sram0;
zephyr,flash = &flash0; zephyr,flash = &flash0;
zephyr,console = &cdc_acm_uart; zephyr,console = &cdc_acm_uart;
zmk,battery = &vbatt; zmk,battery = &vbatt;
}; };
leds { leds {
compatible = "gpio-leds"; compatible = "gpio-leds";
blue_led: led_0 { blue_led: led_0 {
gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>; gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;
label = "Blue LED"; label = "Blue LED";
}; };
}; };
ext-power { ext-power {
compatible = "zmk,ext-power-generic"; compatible = "zmk,ext-power-generic";
label = "EXT_POWER"; label = "EXT_POWER";
control-gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>; control-gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
init-delay-ms = <50>; init-delay-ms = <50>;
}; };
vbatt: vbatt { vbatt: vbatt {
compatible = "zmk,battery-voltage-divider"; compatible = "zmk,battery-voltage-divider";
label = "BATTERY"; label = "BATTERY";
io-channels = <&adc 1>; io-channels = <&adc 1>;
output-ohms = <10000000>; output-ohms = <10000000>;
full-ohms = <(10000000 + 4000000)>; full-ohms = <(10000000 + 4000000)>;
}; };
}; };
&adc { &adc {
status = "okay"; status = "okay";
}; };
&gpiote { &gpiote {
status = "okay"; status = "okay";
}; };
&gpio0 { &gpio0 {
status = "okay"; status = "okay";
}; };
&gpio1 { &gpio1 {
status = "okay"; status = "okay";
}; };
&i2c0 { &i2c0 {
compatible = "nordic,nrf-twi"; compatible = "nordic,nrf-twi";
sda-pin = <17>; pinctrl-0 = <&i2c0_default>;
scl-pin = <20>; pinctrl-1 = <&i2c0_sleep>;
pinctrl-names = "default", "sleep";
}; };
&uart0 { &uart0 {
compatible = "nordic,nrf-uarte"; compatible = "nordic,nrf-uarte";
tx-pin = <8>; current-speed = <115200>;
rx-pin = <4>; pinctrl-0 = <&uart0_default>;
pinctrl-1 = <&uart0_sleep>;
pinctrl-names = "default", "sleep";
}; };
&usbd { &usbd {
status = "okay"; status = "okay";
cdc_acm_uart: cdc_acm_uart { cdc_acm_uart: cdc_acm_uart {
compatible = "zephyr,cdc-acm-uart"; compatible = "zephyr,cdc-acm-uart";
label = "CDC_ACM_0"; label = "CDC_ACM_0";
}; };
}; };
&flash0 { &flash0 {
/* /*
* For more information, see: * For more information, see:
* http://docs.zephyrproject.org/latest/devices/dts/flash_partitions.html * 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>;
sd_partition: partition@0 { sd_partition: partition@0 {
label = "mbr"; label = "mbr";
reg = <0x00000000 0x00001000>; reg = <0x00000000 0x00001000>;
}; };
code_partition: partition@1000 { code_partition: partition@1000 {
label = "code_partition"; label = "code_partition";
reg = <0x00001000 0x000d3000>; reg = <0x00001000 0x000d3000>;
}; };
/* /*
* The flash starting at 0x000ec000 and ending at * The flash starting at 0x000ec000 and ending at
* 0x000f3fff 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@ec000 { storage_partition: partition@ec000 {
label = "storage"; label = "storage";
reg = <0x000ec000 0x00008000>; reg = <0x000ec000 0x00008000>;
}; };
boot_partition: partition@f4000 { boot_partition: partition@f4000 {
label = "adafruit_boot"; label = "adafruit_boot";
reg = <0x000f4000 0x0000c000>; reg = <0x000f4000 0x0000c000>;
}; };
}; };
}; };

View file

@ -7,6 +7,8 @@ CONFIG_BOARD_MIKOTO_520=y
# Enable MPU # Enable MPU
CONFIG_ARM_MPU=y CONFIG_ARM_MPU=y
CONFIG_PINCTRL=y
# enable GPIO # enable GPIO
CONFIG_GPIO=y CONFIG_GPIO=y

View file

@ -4,19 +4,19 @@
* SPDX-License-Identifier: MIT * SPDX-License-Identifier: MIT
*/ */
#include <kernel.h> #include <zephyr/kernel.h>
#include <device.h> #include <zephyr/device.h>
#include <init.h> #include <zephyr/init.h>
#include <drivers/gpio.h> #include <zephyr/drivers/gpio.h>
#include <sys/sys_io.h> #include <zephyr/sys/sys_io.h>
#include <devicetree.h> #include <zephyr/devicetree.h>
static int pinmux_mikoto_init(const struct device *port) { static int pinmux_mikoto_init(const struct device *port) {
ARG_UNUSED(port); ARG_UNUSED(port);
#if CONFIG_BOARD_MIKOTO_520 #if CONFIG_BOARD_MIKOTO_520
const struct device *p0 = device_get_binding("GPIO_0"); const struct device *p0 = DEVICE_DT_GET(DT_NODELABEL(gpio0));
const struct device *p1 = device_get_binding("GPIO_1"); const struct device *p1 = DEVICE_DT_GET(DT_NODELABEL(gpio1));
#if CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_40MA #if CONFIG_BOARD_MIKOTO_CHARGER_CURRENT_40MA
gpio_pin_configure(p0, 26, GPIO_INPUT | GPIO_PULL_DOWN); gpio_pin_configure(p0, 26, GPIO_INPUT | GPIO_PULL_DOWN);
gpio_pin_configure(p1, 15, GPIO_INPUT); gpio_pin_configure(p1, 15, GPIO_INPUT);