From f4a76612fa509e85c6eeb7a80157db3d2362caee Mon Sep 17 00:00:00 2001 From: Chen Jichang Date: Thu, 12 Jun 2025 18:18:30 +0800 Subject: [PATCH] feat(rmt): allow to set init level before any tx transmission Closes https://github.com/espressif/esp-idf/issues/16068 --- components/esp_driver_rmt/include/driver/rmt_tx.h | 1 + components/esp_driver_rmt/src/rmt_tx.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/components/esp_driver_rmt/include/driver/rmt_tx.h b/components/esp_driver_rmt/include/driver/rmt_tx.h index ebbd87ce22..b51a9f76e7 100644 --- a/components/esp_driver_rmt/include/driver/rmt_tx.h +++ b/components/esp_driver_rmt/include/driver/rmt_tx.h @@ -44,6 +44,7 @@ typedef struct { uint32_t with_dma: 1; /*!< If set, the driver will allocate an RMT channel with DMA capability */ uint32_t allow_pd: 1; /*!< If set, driver allows the power domain to be powered off when system enters sleep mode. This can save power, but at the expense of more RAM being consumed to save register context. */ + uint32_t init_level: 1; /*!< Set the initial level of the RMT channel signal */ } flags; /*!< TX channel config flags */ } rmt_tx_channel_config_t; diff --git a/components/esp_driver_rmt/src/rmt_tx.c b/components/esp_driver_rmt/src/rmt_tx.c index c696e2095f..e6006fa788 100644 --- a/components/esp_driver_rmt/src/rmt_tx.c +++ b/components/esp_driver_rmt/src/rmt_tx.c @@ -331,7 +331,7 @@ esp_err_t rmt_new_tx_channel(const rmt_tx_channel_config_t *config, rmt_channel_ // disable carrier modulation by default, can re-enable by `rmt_apply_carrier()` rmt_ll_tx_enable_carrier_modulation(hal->regs, channel_id, false); // idle level is determined by register value - rmt_ll_tx_fix_idle_level(hal->regs, channel_id, 0, true); + rmt_ll_tx_fix_idle_level(hal->regs, channel_id, config->flags.init_level, true); // always enable tx wrap, both DMA mode and ping-pong mode rely this feature rmt_ll_tx_enable_wrap(hal->regs, channel_id, true);