mirror of
https://github.com/esphome/esphome.git
synced 2026-10-01 17:00:21 +00:00
[zephyr_mcumgr] add LED which is controled by bootloader (#16322)
Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
This commit is contained in:
co-authored by
Jonathan Swoboda
parent
b4f2334b99
commit
45b9c8b94c
@@ -1,3 +1,4 @@
|
||||
from esphome import pins
|
||||
import esphome.codegen as cg
|
||||
from esphome.components.nrf52.boards import BOOTLOADER_CONFIG
|
||||
from esphome.components.nrf52.framework import include_west_project
|
||||
@@ -19,6 +20,10 @@ import esphome.config_validation as cv
|
||||
from esphome.const import (
|
||||
CONF_HARDWARE_UART,
|
||||
CONF_ID,
|
||||
CONF_INVERTED,
|
||||
CONF_NUMBER,
|
||||
CONF_PIN,
|
||||
CONF_STATUS,
|
||||
KEY_CORE,
|
||||
KEY_FRAMEWORK_VERSION,
|
||||
Framework,
|
||||
@@ -67,6 +72,11 @@ CONFIG_SCHEMA = cv.All(
|
||||
): cv.one_of(*UARTS, upper=True),
|
||||
}
|
||||
),
|
||||
cv.Optional(CONF_STATUS): cv.Schema(
|
||||
{
|
||||
cv.Required(CONF_PIN): pins.gpio_output_pin_schema,
|
||||
}
|
||||
),
|
||||
}
|
||||
)
|
||||
.extend(BASE_OTA_SCHEMA)
|
||||
@@ -165,6 +175,32 @@ async def to_code(config: ConfigType) -> None:
|
||||
}};
|
||||
"""
|
||||
)
|
||||
if CONF_STATUS in config:
|
||||
pin_conf = config[CONF_STATUS][CONF_PIN]
|
||||
pin_num = pin_conf[CONF_NUMBER]
|
||||
port = pin_num // 32
|
||||
pin_in_port = pin_num % 32
|
||||
active_flag = (
|
||||
"GPIO_ACTIVE_LOW" if pin_conf[CONF_INVERTED] else "GPIO_ACTIVE_HIGH"
|
||||
)
|
||||
zephyr_add_prj_conf("MCUBOOT_INDICATION_LED", True, image="mcuboot")
|
||||
zephyr_add_overlay(
|
||||
f"""
|
||||
#include <dt-bindings/gpio/gpio.h>
|
||||
/ {{
|
||||
mcuboot_leds {{
|
||||
compatible = "gpio-leds";
|
||||
mcuboot_led0: mcuboot_led0 {{
|
||||
gpios = <&gpio{port} {pin_in_port} {active_flag}>;
|
||||
}};
|
||||
}};
|
||||
aliases {{
|
||||
mcuboot-led0 = &mcuboot_led0;
|
||||
}};
|
||||
}};
|
||||
""",
|
||||
image="mcuboot",
|
||||
)
|
||||
framework_ver = CORE.data[KEY_CORE][KEY_FRAMEWORK_VERSION]
|
||||
if framework_ver >= cv.Version(2, 9, 2):
|
||||
zephyr_data()[KEY_SYSBUILD] = True
|
||||
|
||||
@@ -2,3 +2,7 @@ zephyr_ble_server:
|
||||
|
||||
ota:
|
||||
- platform: zephyr_mcumgr
|
||||
status:
|
||||
pin:
|
||||
number: P0.15
|
||||
inverted: true
|
||||
|
||||
Reference in New Issue
Block a user