Skip to content

Commit

Permalink
Merge branch 'feature/bytes_encoder_config_update_v5.2' into 'release…
Browse files Browse the repository at this point in the history
…/v5.2'

feat(rmt): support update bytes encoder configurations at runtime (v5.2)

See merge request espressif/esp-idf!28381
  • Loading branch information
suda-morris committed Feb 18, 2024
2 parents 18d0413 + 414306b commit df558f4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
17 changes: 16 additions & 1 deletion components/driver/rmt/include/driver/rmt_encoder.h
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -98,6 +98,21 @@ typedef struct {
*/
esp_err_t rmt_new_bytes_encoder(const rmt_bytes_encoder_config_t *config, rmt_encoder_handle_t *ret_encoder);

/**
* @brief Update the configuration of the bytes encoder
*
* @note The configurations of the bytes encoder is also set up by `rmt_new_bytes_encoder()`.
* This function is used to update the configuration of the bytes encoder at runtime.
*
* @param[in] bytes_encoder Bytes encoder handle, created by e.g `rmt_new_bytes_encoder()`
* @param[in] config Bytes encoder configuration
* @return
* - ESP_OK: Update RMT bytes encoder successfully
* - ESP_ERR_INVALID_ARG: Update RMT bytes encoder failed because of invalid argument
* - ESP_FAIL: Update RMT bytes encoder failed because of other error
*/
esp_err_t rmt_bytes_encoder_update_config(rmt_encoder_handle_t bytes_encoder, const rmt_bytes_encoder_config_t *config);

/**
* @brief Create RMT copy encoder, which copies the given RMT symbols into RMT memory
*
Expand Down
12 changes: 11 additions & 1 deletion components/driver/rmt/rmt_encoder.c
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand Down Expand Up @@ -275,6 +275,16 @@ esp_err_t rmt_new_bytes_encoder(const rmt_bytes_encoder_config_t *config, rmt_en
return ret;
}

esp_err_t rmt_bytes_encoder_update_config(rmt_encoder_handle_t bytes_encoder, const rmt_bytes_encoder_config_t *config)
{
ESP_RETURN_ON_FALSE(bytes_encoder && config, ESP_ERR_INVALID_ARG, TAG, "invalid argument");
rmt_bytes_encoder_t *encoder = __containerof(bytes_encoder, rmt_bytes_encoder_t, base);
encoder->bit0 = config->bit0;
encoder->bit1 = config->bit1;
encoder->flags.msb_first = config->flags.msb_first;
return ESP_OK;
}

esp_err_t rmt_new_copy_encoder(const rmt_copy_encoder_config_t *config, rmt_encoder_handle_t *ret_encoder)
{
esp_err_t ret = ESP_OK;
Expand Down

0 comments on commit df558f4

Please sign in to comment.