Skip to content

Commit

Permalink
Add custom board example
Browse files Browse the repository at this point in the history
  • Loading branch information
felipejfc committed Jul 11, 2024
1 parent 171a9b2 commit 2fa8919
Show file tree
Hide file tree
Showing 17 changed files with 462 additions and 0 deletions.
13 changes: 13 additions & 0 deletions examples/custom_board/boards/arm/nice_nano/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# SPDX-License-Identifier: MIT

config BOARD_ENABLE_DCDC
bool "Enable DCDC mode"
select SOC_DCDC_NRF52X
default y
depends on (BOARD_NICE_NANO || BOARD_NICE_NANO_V2)

config BOARD_ENABLE_DCDC_HV
bool "High voltage DCDC converter"
select SOC_DCDC_NRF52X_HV
default y
depends on (BOARD_NICE_NANO_V2)
13 changes: 13 additions & 0 deletions examples/custom_board/boards/arm/nice_nano/Kconfig.board
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# nice!nano board configuration

# Copyright (c) 2020 Pete Johanson
# SPDX-License-Identifier: MIT

config BOARD_NICE_NANO
bool "nice!nano"
depends on SOC_NRF52840_QIAA

config BOARD_NICE_NANO_V2
bool "nice!nano v2"
depends on SOC_NRF52840_QIAA

19 changes: 19 additions & 0 deletions examples/custom_board/boards/arm/nice_nano/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Copyright (c) 2021 The ZMK Contributors
# SPDX-License-Identifier: MIT

if BOARD_NICE_NANO || BOARD_NICE_NANO_V2

config BOARD
default "nice_nano"

if USB_DEVICE_STACK

config USB_NRFX
default y

endif # USB_DEVICE_STACK

config BT_CTLR
default BT

endif # BOARD_NICE_NANO || BOARD_NICE_NANO_V2
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2020 Pete Johanson
*
* 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 8 0> /* D0 */
, <1 0 &gpio0 6 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 &gpio0 11 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 11 0> /* D14 */
, <15 0 &gpio1 13 0> /* D15 */
, <18 0 &gpio1 15 0> /* D18/A0 */
, <19 0 &gpio0 2 0> /* D19/A1 */
, <20 0 &gpio0 29 0> /* D20/A2 */
, <21 0 &gpio0 31 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 &gpio1 15 0> /* D18/A0 */
, <1 0 &gpio0 2 0> /* D19/A1 */
, <2 0 &gpio0 29 0> /* D20/A2 */
, <3 0 &gpio0 31 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: &spi1 {};
pro_micro_serial: &uart0 {};
5 changes: 5 additions & 0 deletions examples/custom_board/boards/arm/nice_nano/board.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: MIT

board_runner_args(nrfjprog "--nrf-family=NRF52" "--softreset")
include(${ZEPHYR_BASE}/boards/common/uf2.board.cmake)
include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)
56 changes: 56 additions & 0 deletions examples/custom_board/boards/arm/nice_nano/nice_nano-pinctrl.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2022 The ZMK Contributors
* SPDX-License-Identifier: MIT
*/

&pinctrl {
uart0_default: uart0_default {
group1 {
psels = <NRF_PSEL(UART_RX, 0, 8)>;
bias-pull-up;
};
group2 {
psels = <NRF_PSEL(UART_TX, 0, 6)>;
};
};

uart0_sleep: uart0_sleep {
group1 {
psels = <NRF_PSEL(UART_RX, 0, 8)>,
<NRF_PSEL(UART_TX, 0, 6)>;
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;
};
};

spi1_default: spi1_default {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 1, 13)>,
<NRF_PSEL(SPIM_MOSI, 0, 10)>,
<NRF_PSEL(SPIM_MISO, 1, 11)>;
};
};

spi1_sleep: spi1_sleep {
group1 {
psels = <NRF_PSEL(SPIM_SCK, 1, 13)>,
<NRF_PSEL(SPIM_MOSI, 0, 10)>,
<NRF_PSEL(SPIM_MISO, 1, 11)>;
low-power-enable;
};
};
};
27 changes: 27 additions & 0 deletions examples/custom_board/boards/arm/nice_nano/nice_nano.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2021 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/

/dts-v1/;
#include "nice_nano.dtsi"

/ {
chosen {
zmk,battery = &vbatt;
};

// Node name must match original "EXT_POWER" label to preserve user settings.
EXT_POWER {
compatible = "zmk,ext-power-generic";
control-gpios = <&gpio0 13 GPIO_ACTIVE_LOW>;
};

vbatt: vbatt {
compatible = "zmk,battery-voltage-divider";
io-channels = <&adc 2>;
output-ohms = <2000000>;
full-ohms = <(2000000 + 806000)>;
};
};
117 changes: 117 additions & 0 deletions examples/custom_board/boards/arm/nice_nano/nice_nano.dtsi
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
/*
* Copyright (c) 2021 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/

#include <nordic/nrf52840_qiaa.dtsi>
#include "nice_nano-pinctrl.dtsi"
#include "arduino_pro_micro_pins.dtsi"

/ {
model = "nice!nano";
compatible = "nice,nano";

chosen {
zephyr,code-partition = &code_partition;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,ieee802154 = &ieee802154;
};

leds {
compatible = "gpio-leds";
red_led: led_0 {
gpios = <&gpio0 15 GPIO_ACTIVE_HIGH>;
};
};

aliases {
redled = &red_led;
};
};

&ieee802154 {
status = "okay";
};


&adc {
status = "okay";
};

&gpiote {
status = "okay";
};

&gpio0 {
status = "okay";
};

&gpio1 {
status = "okay";
};

&i2c0 {
compatible = "nordic,nrf-twi";
pinctrl-0 = <&i2c0_default>;
pinctrl-1 = <&i2c0_sleep>;
pinctrl-names = "default", "sleep";
};

&spi1 {
compatible = "nordic,nrf-spim";
pinctrl-0 = <&spi1_default>;
pinctrl-1 = <&spi1_sleep>;
pinctrl-names = "default", "sleep";
};

&uart0 {
compatible = "nordic,nrf-uarte";
current-speed = <115200>;
pinctrl-0 = <&uart0_default>;
pinctrl-1 = <&uart0_sleep>;
pinctrl-names = "default", "sleep";
};

zephyr_udc0: &usbd {
compatible = "nordic,nrf-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 {
reg = <0x00000000 0x00026000>;
};
code_partition: partition@26000 {
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 {
reg = <0x000ec000 0x00008000>;
};

boot_partition: partition@f4000 {
reg = <0x000f4000 0x0000c000>;
};
};
};
15 changes: 15 additions & 0 deletions examples/custom_board/boards/arm/nice_nano/nice_nano.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
identifier: nice_nano
name: nice!nano
type: mcu
arch: arm
toolchain:
- zephyr
- gnuarmemb
- xtools
supported:
- adc
- usb_device
- ble
- ieee802154
- pwm
- watchdog
10 changes: 10 additions & 0 deletions examples/custom_board/boards/arm/nice_nano/nice_nano.zmk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
file_format: "1"
id: nice_nano
name: nice!nano v1
type: board
arch: arm
outputs:
- usb
- ble
url: https://nicekeyboards.com/nice-nano
exposes: [pro_micro]
27 changes: 27 additions & 0 deletions examples/custom_board/boards/arm/nice_nano/nice_nano_defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-License-Identifier: MIT

CONFIG_SOC_SERIES_NRF52X=y
CONFIG_SOC_NRF52840_QIAA=y
CONFIG_BOARD_NICE_NANO=y

# Enable MPU
CONFIG_ARM_MPU=y

# enable GPIO
CONFIG_GPIO=y

# Use pinctrl
CONFIG_PINCTRL=y

CONFIG_USE_DT_CODE_PARTITION=y
CONFIG_BUILD_OUTPUT_UF2=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

CONFIG_ZMK_USB=y
CONFIG_ZMK_BLE=y
25 changes: 25 additions & 0 deletions examples/custom_board/boards/arm/nice_nano/nice_nano_v2.dts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2021 The ZMK Contributors
*
* SPDX-License-Identifier: MIT
*/

/dts-v1/;
#include "nice_nano.dtsi"

/ {
chosen {
zmk,battery = &vbatt;
};

// Node name must match original "EXT_POWER" label to preserve user settings.
EXT_POWER {
compatible = "zmk,ext-power-generic";
control-gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>;
init-delay-ms = <50>;
};

vbatt: vbatt {
compatible = "zmk,battery-nrf-vddh";
};
};
Loading

0 comments on commit 2fa8919

Please sign in to comment.