diff --git a/zephcore/CMakeLists.txt b/zephcore/CMakeLists.txt index f94de73..110cb99 100644 --- a/zephcore/CMakeLists.txt +++ b/zephcore/CMakeLists.txt @@ -222,7 +222,7 @@ set(ZEPHCORE_COMMON_CONF "${CMAKE_CURRENT_SOURCE_DIR}/boards/common/zephcore_com # Detect platform from board name and add platform-specific common config # For boards with qualifiers like "wio_tracker_l1/nrf52840", check both the full BOARD # string and the BOARD_QUALIFIERS which contains just the qualifier (e.g., "nrf52840") -if(BOARD MATCHES ".*nrf52.*" OR BOARD MATCHES "rak4631" OR BOARD MATCHES "rak_wismesh_tag" OR BOARD MATCHES "rak3401_1watt" OR BOARD MATCHES "wio_tracker" OR BOARD MATCHES "ikoka_nano" OR BOARD MATCHES "t1000_e" OR BOARD MATCHES "thinknode_m1" OR BOARD MATCHES "thinknode_m3" OR BOARD MATCHES "thinknode_m6" OR BOARD MATCHES "promicro_lr2021" OR BOARD MATCHES "promicro_sx1262" OR BOARD MATCHES "sensecap_solar" OR BOARD MATCHES "xiao_nrf52840" OR BOARD MATCHES "lilygo_techo") +if(BOARD MATCHES ".*nrf52.*" OR BOARD MATCHES "rak4631" OR BOARD MATCHES "rak_wismesh_tag" OR BOARD MATCHES "rak3401_1watt" OR BOARD MATCHES "wio_tracker" OR BOARD MATCHES "ikoka_nano" OR BOARD MATCHES "t1000_e" OR BOARD MATCHES "thinknode_m1" OR BOARD MATCHES "thinknode_m3" OR BOARD MATCHES "thinknode_m6" OR BOARD MATCHES "promicro_lr2021" OR BOARD MATCHES "promicro_sx1262" OR BOARD MATCHES "sensecap_solar" OR BOARD MATCHES "xiao_nrf52840" OR BOARD MATCHES "lilygo_techo" OR BOARD MATCHES "heltec_t114") set(ZEPHCORE_PLATFORM_CONF "${CMAKE_CURRENT_SOURCE_DIR}/boards/common/nrf52_common.conf") elseif(DEFINED BOARD_QUALIFIERS AND BOARD_QUALIFIERS MATCHES ".*nrf52.*") set(ZEPHCORE_PLATFORM_CONF "${CMAKE_CURRENT_SOURCE_DIR}/boards/common/nrf52_common.conf") diff --git a/zephcore/boards/nrf52840/heltec_t114/Kconfig.heltec_t114 b/zephcore/boards/nrf52840/heltec_t114/Kconfig.heltec_t114 new file mode 100644 index 0000000..c139e57 --- /dev/null +++ b/zephcore/boards/nrf52840/heltec_t114/Kconfig.heltec_t114 @@ -0,0 +1,6 @@ +# Copyright (c) 2026 ZephCore +# +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_HELTEC_T114 + select SOC_NRF52840_QIAA diff --git a/zephcore/boards/nrf52840/heltec_t114/board.cmake b/zephcore/boards/nrf52840/heltec_t114/board.cmake new file mode 100644 index 0000000..81f03cd --- /dev/null +++ b/zephcore/boards/nrf52840/heltec_t114/board.cmake @@ -0,0 +1,14 @@ +# Copyright (c) 2026 ZephCore +# +# SPDX-License-Identifier: Apache-2.0 + +board_runner_args(jlink "--device=nRF52840_xxAA" "--speed=4000") +board_runner_args(pyocd "--target=nrf52840" "--frequency=4000000") + +set(OPENOCD_NRF5_SUBFAMILY "nrf52") + +include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) +include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake) +include(${ZEPHYR_BASE}/boards/common/openocd-nrf5.board.cmake) +include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake) +include(${ZEPHYR_BASE}/boards/common/nrfutil.board.cmake) diff --git a/zephcore/boards/nrf52840/heltec_t114/board.conf b/zephcore/boards/nrf52840/heltec_t114/board.conf new file mode 100644 index 0000000..d152a90 --- /dev/null +++ b/zephcore/boards/nrf52840/heltec_t114/board.conf @@ -0,0 +1,20 @@ +# Heltec T114 — nRF52840 + SX1262 +# Board-specific configuration +# +# Hardware: +# - SX1262 LoRa (22 dBm, DIO2 RF switch, TCXO 1.8V, RX boosted) +# - ATGM336H GPS on UART0 (9600 baud, enable P0.21, reset P1.06 active-LOW) +# - Battery AIN2 (P0.04), 4.9:1 voltage divider, enable P0.06 +# - I2C0 (SDA=P0.07, SCL=P0.08) for sensors +# - ST7789 1.14" 240×135 TFT +# - LED: P1.03 (active-LOW, LoRa TX) +# - Button: P1.10 (active-LOW) + +# Board identification (matches Arduino MeshCore variant name) +CONFIG_ZEPHCORE_BOARD_NAME="Heltec T114" + +# Device Information Service model name +CONFIG_BT_DIS_MODEL_NUMBER_STR="Heltec T114" + +# SoftDevice firmware ID (s140 v6.1.1, same as RAK4631) +CONFIG_ZEPHCORE_SD_FWID=0x00B6 diff --git a/zephcore/boards/nrf52840/heltec_t114/board.yml b/zephcore/boards/nrf52840/heltec_t114/board.yml new file mode 100644 index 0000000..4a322a3 --- /dev/null +++ b/zephcore/boards/nrf52840/heltec_t114/board.yml @@ -0,0 +1,10 @@ +# Copyright (c) 2026 ZephCore +# +# SPDX-License-Identifier: Apache-2.0 + +board: + name: heltec_t114 + full_name: Heltec T114 + vendor: heltec + socs: + - name: nrf52840 diff --git a/zephcore/boards/nrf52840/heltec_t114/heltec_t114_nrf52840-pinctrl.dtsi b/zephcore/boards/nrf52840/heltec_t114/heltec_t114_nrf52840-pinctrl.dtsi new file mode 100644 index 0000000..a36dfc5 --- /dev/null +++ b/zephcore/boards/nrf52840/heltec_t114/heltec_t114_nrf52840-pinctrl.dtsi @@ -0,0 +1,62 @@ +/* + * Heltec T114 pin control definitions + * Copyright (c) 2026 ZephCore + * + * SPDX-License-Identifier: Apache-2.0 + * + * Pin mappings from MeshCore variants/heltec_t114 (variant.cpp, platformio.ini): + * - SPI2 (SX1262): SCK=P0.19, MOSI=P0.22, MISO=P0.23 + * - I2C0 (Wire1, sensors): SDA=P0.07, SCL=P0.08 + * - UART0 (GPS): TX=P1.07, RX=P1.05 + * - SPI3 (ST7789 display): SCK=P1.08, MOSI=P1.09 (no MISO needed) + */ + +&pinctrl { + spi2_default: spi2_default { + group1 { + psels = , + , + ; + }; + }; + + spi2_sleep: spi2_sleep { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; + + i2c0_default: i2c0_default { + group1 { + psels = , + ; + }; + }; + + i2c0_sleep: i2c0_sleep { + group1 { + psels = , + ; + low-power-enable; + }; + }; + + uart0_default: uart0_default { + group1 { + psels = , + ; + bias-pull-up; + }; + }; + + uart0_sleep: uart0_sleep { + group1 { + psels = , + ; + low-power-enable; + }; + }; +}; diff --git a/zephcore/boards/nrf52840/heltec_t114/heltec_t114_nrf52840.dts b/zephcore/boards/nrf52840/heltec_t114/heltec_t114_nrf52840.dts new file mode 100644 index 0000000..8a3c2c1 --- /dev/null +++ b/zephcore/boards/nrf52840/heltec_t114/heltec_t114_nrf52840.dts @@ -0,0 +1,230 @@ +/* + * Heltec T114 — nRF52840 + SX1262 + * Copyright (c) 2026 ZephCore + * + * SPDX-License-Identifier: Apache-2.0 + * + */ + +/dts-v1/; +#include +#include +#include +#include +#include +#include "heltec_t114_nrf52840-pinctrl.dtsi" + +/* Delete default partitions from nrf52840_partition.dtsi */ +/delete-node/ &boot_partition; +/delete-node/ &slot0_partition; +/delete-node/ &slot1_partition; +/delete-node/ &storage_partition; + +/ { + model = "Heltec T114"; + compatible = "heltec,t114"; + + chosen { + zephyr,code-partition = &code_partition; + zephyr,console = &cdc_acm_uart; + zephyr,shell-uart = &cdc_acm_uart; + }; + + leds { + compatible = "gpio-leds"; + + /* LED_BUILTIN on P1.03, active-LOW (LED_STATE_ON = LOW) */ + tx_led: led_0 { + gpios = <&gpio1 3 GPIO_ACTIVE_LOW>; + label = "LoRa TX LED"; + }; + }; + + buttons: buttons { + compatible = "gpio-keys"; + + user_button: button_0 { + gpios = <&gpio1 10 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + zephyr,code = ; + label = "User Button"; + }; + }; + + /* Input filter: user button long-press detection (1000ms) */ + user_btn_longpress { + compatible = "zephyr,input-longpress"; + input = <&buttons>; + input-codes = ; + short-codes = ; + long-codes = ; + long-delay-ms = <1000>; + }; + + /* Input filter: user button multi-tap detection + * 1 tap (400ms wait) → KEY_1 = page next on OLED + * 2 taps (400ms wait) → KEY_B = flood advert + * 3 taps (400ms wait) → KEY_D = buzzer mute toggle + * 4 taps (400ms wait) → KEY_C = GPS on/off + * 5 taps (immediate) → KEY_E = LED heartbeat toggle */ + user_btn_multitap { + compatible = "zephcore,input-multi-tap"; + /* No 'input' phandle — listen to ALL devices. + * KEY_A is emitted by the longpress pseudo-device, + * not by &buttons, so we must not filter by device. */ + input-codes = ; + tap-codes = ; + tap-delay-ms = <400>; + }; + + /* GPS power enable — P0.21, HIGH = GPS powered on */ + gps_en: gps-enable { + compatible = "gpio-leds"; + gps_enable_pin: gps_enable { + gpios = <&gpio0 21 GPIO_ACTIVE_HIGH>; + label = "GPS Enable"; + }; + }; + + /* GPS hardware reset — P1.06, active-LOW (PIN_GPS_RESET_ACTIVE=LOW) */ + gps_rst: gps-reset { + compatible = "gpio-leds"; + gps_reset_pin: gps_reset { + gpios = <&gpio1 6 GPIO_ACTIVE_LOW>; + label = "GPS Reset"; + }; + }; + + /* + * Battery ADC enable — P0.06, HIGH = enable divider for measurement. + * ZephyrBoard::getBattMilliVolts() calls regulator_{enable,disable} + * around each reading to save power. + */ + vbat_enable: vbat-enable { + compatible = "regulator-fixed"; + regulator-name = "vbat-enable"; + enable-gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>; + }; + + zephyr,user { + io-channels = <&adc 2>; + /* + * Full-scale = 3600 mV (ADC_GAIN_1_6 + ADC_REF_INTERNAL), + * voltage divider ratio = 4.9 (ADC_MULTIPLIER from variant.h). + * multiplier = 3600 * 4.9 = 17640 + */ + vbat-mv-multiplier = <17640>; + }; + + aliases { + led0 = &tx_led; + lora-tx-led = &tx_led; + sw0 = &user_button; + lora0 = &lora; + watchdog0 = &wdt0; + gps-enable = &gps_enable_pin; + gps-reset = &gps_reset_pin; + }; +}; + +®0 { + status = "okay"; +}; + +/* DC-DC converter (NRF52BoardDCDC) */ +®1 { + regulator-initial-mode = ; +}; + +&adc { + status = "okay"; + #address-cells = <1>; + #size-cells = <0>; + + /* Battery voltage on P0.04 (AIN2) — 4.9:1 divider, 3.0V ref in Arduino */ + channel@2 { + reg = <2>; + zephyr,gain = "ADC_GAIN_1_6"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,input-positive = ; + zephyr,resolution = <12>; + }; +}; + +&gpiote { + status = "okay"; +}; + +&gpio0 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; + +&i2c0 { + compatible = "nordic,nrf-twim"; + status = "okay"; + clock-frequency = ; + pinctrl-0 = <&i2c0_default>; + pinctrl-1 = <&i2c0_sleep>; + pinctrl-names = "default", "sleep"; + + #include "../../common/sensors-i2c.dtsi" +}; + +&uart0 { + compatible = "nordic,nrf-uarte"; + status = "okay"; + current-speed = <9600>; + pinctrl-0 = <&uart0_default>; + pinctrl-1 = <&uart0_sleep>; + pinctrl-names = "default", "sleep"; + + gnss: gnss { + compatible = "gnss-nmea-generic"; + }; +}; + +&spi2 { + compatible = "nordic,nrf-spim"; + status = "okay"; + cs-gpios = <&gpio0 24 GPIO_ACTIVE_LOW>; + pinctrl-0 = <&spi2_default>; + pinctrl-1 = <&spi2_sleep>; + pinctrl-names = "default", "sleep"; + + lora: lora@0 { + compatible = "semtech,sx1262"; + reg = <0>; + reset-gpios = <&gpio0 25 GPIO_ACTIVE_LOW>; + busy-gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>; + dio1-gpios = <&gpio0 20 (GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH)>; + dio2-tx-enable; + dio3-tcxo-voltage = ; + tcxo-power-startup-delay-ms = <5>; + spi-max-frequency = <8000000>; + rx-boosted; + }; +}; + +/* + * QSPI Flash (MX25R1635F 2MB) — DISABLED. + */ +&qspi { + status = "disabled"; +}; + +zephyr_udc0: &usbd { + compatible = "nordic,nrf-usbd"; + status = "okay"; + + cdc_acm_uart: cdc_acm_uart { + compatible = "zephyr,cdc-acm-uart"; + }; +}; + +/* SoftDevice s140 v6.1.1 flash layout (app@0x26000, bootloader@0xF4000) */ +#include "../../common/nrf52_partitions_sdv6.dtsi" +#include "../../common/nrf52_wakeup.dtsi" diff --git a/zephcore/boards/nrf52840/heltec_t114/heltec_t114_nrf52840.yaml b/zephcore/boards/nrf52840/heltec_t114/heltec_t114_nrf52840.yaml new file mode 100644 index 0000000..56f46e6 --- /dev/null +++ b/zephcore/boards/nrf52840/heltec_t114/heltec_t114_nrf52840.yaml @@ -0,0 +1,20 @@ +identifier: heltec_t114/nrf52840 +name: Heltec T114 +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb + - xtools +ram: 256 +flash: 1024 +supported: + - adc + - ble + - gpio + - i2c + - spi + - usb_device + - lora + - gnss +vendor: heltec diff --git a/zephcore/boards/nrf52840/heltec_t114/heltec_t114_nrf52840_defconfig b/zephcore/boards/nrf52840/heltec_t114/heltec_t114_nrf52840_defconfig new file mode 100644 index 0000000..d06a2a1 --- /dev/null +++ b/zephcore/boards/nrf52840/heltec_t114/heltec_t114_nrf52840_defconfig @@ -0,0 +1,21 @@ +# Copyright (c) 2026 ZephCore +# SPDX-License-Identifier: Apache-2.0 + +# Enable MPU +CONFIG_ARM_MPU=y + +# Enable hardware stack protection +CONFIG_HW_STACK_PROTECTION=y + +# Enable GPIO +CONFIG_GPIO=y + +# Enable UART driver +CONFIG_SERIAL=y + +# Enable console +CONFIG_CONSOLE=y + +# Build UF2 by default +CONFIG_BUILD_OUTPUT_UF2=y +CONFIG_USE_DT_CODE_PARTITION=y