From 467d44970e7079203fe91a82421273fb56f529ee Mon Sep 17 00:00:00 2001 From: morris Date: Wed, 9 Sep 2020 15:28:14 +0800 Subject: [PATCH] rmt: support setting loop count at runtime --- components/driver/include/driver/rmt.h | 13 +++++++++++++ components/driver/rmt.c | 11 +++++++++++ 2 files changed, 24 insertions(+) diff --git a/components/driver/include/driver/rmt.h b/components/driver/include/driver/rmt.h index 210bddc073..930aac01ce 100644 --- a/components/driver/include/driver/rmt.h +++ b/components/driver/include/driver/rmt.h @@ -859,6 +859,19 @@ esp_err_t rmt_add_channel_to_group(rmt_channel_t channel); esp_err_t rmt_remove_channel_from_group(rmt_channel_t channel); #endif +#if SOC_RMT_SUPPORT_TX_LOOP_COUNT +/** + * @brief Set loop count for RMT TX channel + * + * @param channel RMT channel + * @param count loop count + * @return + * - ESP_ERR_INVALID_ARG Parameter error + * - ESP_OK Success + */ +esp_err_t rmt_set_tx_loop_count(rmt_channel_t channel, uint32_t count); +#endif + /** * @brief Reset RMT TX/RX memory index. * diff --git a/components/driver/rmt.c b/components/driver/rmt.c index 1b266a3249..74b5e3116b 100644 --- a/components/driver/rmt.c +++ b/components/driver/rmt.c @@ -1365,3 +1365,14 @@ esp_err_t rmt_memory_rw_rst(rmt_channel_t channel) return ESP_OK; } #endif + +#if SOC_RMT_SUPPORT_TX_LOOP_COUNT +esp_err_t rmt_set_tx_loop_count(rmt_channel_t channel, uint32_t count) +{ + RMT_CHECK(RMT_IS_TX_CHANNEL(channel), RMT_CHANNEL_ERROR_STR, ESP_ERR_INVALID_ARG); + RMT_ENTER_CRITICAL(); + rmt_ll_tx_set_loop_count(rmt_contex.hal.regs, channel, count); + RMT_EXIT_CRITICAL(); + return ESP_OK; +} +#endif