mirror of
https://github.com/esphome/esphome.git
synced 2026-09-28 07:20:24 +00:00
[nrf52] disable USB if not configured by esphome to save power (#19493)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
pre-commit-ci-lite[bot]
parent
3da7533159
commit
26abc1325e
@@ -428,6 +428,10 @@ async def to_code(config: ConfigType) -> None:
|
||||
)
|
||||
zephyr_add_prj_conf("REBOOT", True)
|
||||
|
||||
# some boards enable USB by default.
|
||||
# disable it to prevent extra current consumption.
|
||||
zephyr_add_prj_conf("USB_DEVICE_STACK", False, False)
|
||||
|
||||
|
||||
@coroutine_with_priority(CoroPriority.DIAGNOSTICS)
|
||||
async def _dfu_to_code(dfu_config):
|
||||
@@ -436,6 +440,10 @@ async def _dfu_to_code(dfu_config):
|
||||
if CONF_RESET_PIN in dfu_config:
|
||||
pin = await cg.gpio_pin_expression(dfu_config[CONF_RESET_PIN])
|
||||
cg.add(var.set_reset_pin(pin))
|
||||
|
||||
# DFU uses cdc rate callback to enter bootloader which was disabled explicitly to save power.
|
||||
zephyr_add_prj_conf("USB_DEVICE_STACK", True)
|
||||
zephyr_add_prj_conf("USB_CDC_ACM", True)
|
||||
zephyr_add_prj_conf("CDC_ACM_DTE_RATE_CALLBACK_SUPPORT", True)
|
||||
await cg.register_component(var, dfu_config)
|
||||
|
||||
|
||||
@@ -176,7 +176,10 @@ def zephyr_to_code(config: ConfigType) -> None:
|
||||
|
||||
@coroutine_with_priority(CoroPriority.FINAL)
|
||||
async def _cdc_acm_to_code(config: ConfigType) -> None:
|
||||
if "CONFIG_CDC_ACM_DTE_RATE_CALLBACK_SUPPORT" in zephyr_data()[KEY_PRJ_CONF][""]:
|
||||
need_cdc_cb = zephyr_data()[KEY_PRJ_CONF][""].get(
|
||||
"CONFIG_CDC_ACM_DTE_RATE_CALLBACK_SUPPORT", (False,)
|
||||
)[0]
|
||||
if need_cdc_cb:
|
||||
var = cg.new_Pvariable(config[CONF_CDC_ACM])
|
||||
await cg.register_component(var, {})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user