pwm cleanup

This commit is contained in:
liquidraver
2026-10-09 08:38:37 +02:00
parent 119d1249b1
commit c60b5e1bae
10 changed files with 23 additions and 32 deletions
+3 -10
View File
@@ -44,15 +44,8 @@ LOG_MODULE_REGISTER(zephcore_observer_main, CONFIG_ZEPHCORE_MAIN_LOG_LEVEL);
/* ========== LED (optional) ========== */
/* True when a board aliases its heartbeat or TX-activity LED to a PWM node.
* On ESP32, configuring led0 as plain GPIO after the PWM driver has already
* routed the pin takes the pin back from the LEDC peripheral (the GPIO
* matrix only serves one signal at a time), so on those boards led0 must be
* left to the PWM driver instead of reconfigured here. */
#define ZEPHCORE_HAS_PWM_SHARED_LED \
(DT_NODE_EXISTS(DT_ALIAS(heartbeat_pwm_led)) || DT_NODE_EXISTS(DT_ALIAS(lora_tx_pwm_led)))
#if DT_NODE_HAS_PROP(DT_ALIAS(led0), gpios) && !ZEPHCORE_HAS_PWM_SHARED_LED
/* With a PWM LED, led0 is the same pin and belongs to the PWM driver. */
#if DT_NODE_HAS_PROP(DT_ALIAS(led0), gpios) && !IS_ENABLED(CONFIG_ZEPHCORE_LED_PWM)
#include <zephyr/drivers/gpio.h>
#define LED0_NODE DT_ALIAS(led0)
static const struct gpio_dt_spec led0 = GPIO_DT_SPEC_GET(LED0_NODE, gpios);
@@ -328,7 +321,7 @@ int main(void)
LOG_INF("=== ZephCore Observer starting ===");
/* Configure LED */
#if DT_NODE_HAS_PROP(DT_ALIAS(led0), gpios) && !ZEPHCORE_HAS_PWM_SHARED_LED
#if DT_NODE_HAS_PROP(DT_ALIAS(led0), gpios) && !IS_ENABLED(CONFIG_ZEPHCORE_LED_PWM)
if (gpio_is_ready_dt(&led0)) {
gpio_pin_configure_dt(&led0, GPIO_OUTPUT_INACTIVE);
}