wt2: shared PWM brightness for the status LED (heartbeat/TX/flashes)

Ports the T096 "Option 1" design (single LED, get/set leds on|off
persisted + get/set leds.brightness 0-100 RAM-only) to the Wireless
Tracker V2, which has the same single-LED-multi-purpose situation
(status_led doubles as heartbeat/message-flash/shutdown-flash/TX
indicator, same as T096's P0.28).

Adds a new ledc0 PWM channel on GPIO18 (same physical pin as the
existing plain-GPIO status_led) with heartbeat-pwm-led/lora-tx-pwm-led
aliases -- the shared C++ logic (helpers/ui/ui_common.c,
adapters/board/ZephyrBoard.cpp, helpers/led_gate.c/h,
helpers/CommonCLI.cpp) already existed from the T096 commits and needed
no changes, being board-agnostic behind DT_NODE_EXISTS checks.

CONFIG_PWM=y deliberately NOT in the board defconfig: WT2 builds via
--sysbuild (mcuboot + app as two images sharing that defconfig), and
mcuboot's minimal kernel config has no k_sem_give()/k_sem_take(), which
the ESP32 PWM LED driver needs -- CONFIG_PWM=y there links the app image
fine but fails mcuboot's link. New boards/common/esp32s3_pwm_led.conf
scopes it to the app image only via EXTRA_CONF_FILE, alongside the
existing esp32s3_usb.conf.
This commit is contained in:
ZephCore T096
2026-10-08 18:26:59 +02:00
parent c8c456b64a
commit 4905191b1c
3 changed files with 54 additions and 0 deletions
@@ -0,0 +1,15 @@
# Enable PWM on ESP32-S3 sysbuild targets (shared heartbeat/TX LED brightness,
# see the heartbeat-pwm-led / lora-tx-pwm-led devicetree aliases consumed by
# helpers/ui/ui_common.c and adapters/board/ZephyrBoard.cpp).
#
# Deliberately NOT in the board *_defconfig: that file is shared by every
# sysbuild image for the board, including mcuboot, whose minimal kernel
# config has no k_sem_give()/k_sem_take() -- CONFIG_PWM=y there links fine for
# the app image but fails mcuboot's link with "undefined reference to
# z_impl_k_sem_give/take" (drivers/pwm/pwm_led_esp32.c uses a semaphore).
# EXTRA_CONF_FILE scopes this to the app ("zephcore") image only.
#
# Build with:
# -DEXTRA_CONF_FILE="boards/common/esp32s3_usb.conf;boards/common/esp32s3_pwm_led.conf"
CONFIG_PWM=y
@@ -72,4 +72,11 @@
output-low;
};
};
ledc0_default: ledc0_default {
group1 {
pinmux = <LEDC_CH0_GPIO18>;
output-enable;
};
};
};
@@ -30,6 +30,7 @@
#include <zephyr/dt-bindings/input/input-event-codes.h>
#include <zephyr/dt-bindings/lora/sx126x.h>
#include <zephyr/dt-bindings/gpio/espressif-esp32-gpio.h>
#include <zephyr/dt-bindings/pwm/pwm.h>
#include "heltec_wireless_tracker_v2-pinctrl.dtsi"
/ {
@@ -39,6 +40,8 @@
aliases {
led0 = &status_led;
lora-tx-led = &status_led;
heartbeat-pwm-led = &pwm_status_led;
lora-tx-pwm-led = &pwm_status_led;
uart-0 = &uart0;
uart-2 = &uart2;
i2c-0 = &i2c0;
@@ -69,6 +72,22 @@
};
};
/* Same GPIO18 net as status_led above, driven through the LEDC PWM
* peripheral instead of a raw GPIO write. Single LED doubling as
* heartbeat, message/shutdown flash and LoRa TX indicator (same
* "Option 1" shared-brightness pattern as T096, see helpers/ui/ui_common.c
* and adapters/board/ZephyrBoard.cpp: heartbeat-pwm-led/lora-tx-pwm-led
* aliases give every one of those events a single 0-100 brightness knob,
* RAM-only, on top of the existing persisted on/off gate. */
pwm_leds {
compatible = "pwm-leds";
pwm_status_led: pwm_led_gpio18 {
label = "Status PWM LED";
pwms = <&ledc0 0 PWM_MSEC(10) PWM_POLARITY_NORMAL>;
};
};
buttons: buttons {
compatible = "gpio-keys";
@@ -231,6 +250,19 @@
status = "okay";
};
&ledc0 {
pinctrl-0 = <&ledc0_default>;
pinctrl-names = "default";
status = "okay";
#address-cells = <1>;
#size-cells = <0>;
channel0@0 {
reg = <0x0>;
timer = <0>;
};
};
&i2c0 {
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;