mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
rmt: define RMT_ENCODING_RESET in rmt_encode_state_t
Closes https://github.com/espressif/esp-idf/issues/11200
This commit is contained in:
parent
420ebd208a
commit
b5572b1db0
@ -23,6 +23,7 @@ typedef struct rmt_encoder_t rmt_encoder_t;
|
||||
* @brief RMT encoding state
|
||||
*/
|
||||
typedef enum {
|
||||
RMT_ENCODING_RESET = 0, /*!< The encoding session is in reset state */
|
||||
RMT_ENCODING_COMPLETE = (1 << 0), /*!< The encoding session is finished, the caller can continue with subsequent encoding */
|
||||
RMT_ENCODING_MEM_FULL = (1 << 1), /*!< The encoding artifact memory is full, the caller should return from current encoding session */
|
||||
} rmt_encode_state_t;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -61,7 +61,7 @@ static size_t IRAM_ATTR rmt_encode_bytes(rmt_encoder_t *encoder, rmt_channel_han
|
||||
rmt_bytes_encoder_t *bytes_encoder = __containerof(encoder, rmt_bytes_encoder_t, base);
|
||||
rmt_tx_channel_t *tx_chan = __containerof(channel, rmt_tx_channel_t, base);
|
||||
const uint8_t *nd = (const uint8_t *)primary_data;
|
||||
rmt_encode_state_t state = 0;
|
||||
rmt_encode_state_t state = RMT_ENCODING_RESET;
|
||||
dma_descriptor_t *desc0 = NULL;
|
||||
dma_descriptor_t *desc1 = NULL;
|
||||
|
||||
@ -167,7 +167,7 @@ static size_t IRAM_ATTR rmt_encode_copy(rmt_encoder_t *encoder, rmt_channel_hand
|
||||
rmt_copy_encoder_t *copy_encoder = __containerof(encoder, rmt_copy_encoder_t, base);
|
||||
rmt_tx_channel_t *tx_chan = __containerof(channel, rmt_tx_channel_t, base);
|
||||
rmt_symbol_word_t *symbols = (rmt_symbol_word_t *)primary_data;
|
||||
rmt_encode_state_t state = 0;
|
||||
rmt_encode_state_t state = RMT_ENCODING_RESET;
|
||||
dma_descriptor_t *desc0 = NULL;
|
||||
dma_descriptor_t *desc1 = NULL;
|
||||
|
||||
|
@ -567,7 +567,7 @@ static void IRAM_ATTR rmt_tx_mark_eof(rmt_tx_channel_t *tx_chan)
|
||||
|
||||
static size_t IRAM_ATTR rmt_encode_check_result(rmt_tx_channel_t *tx_chan, rmt_tx_trans_desc_t *t)
|
||||
{
|
||||
rmt_encode_state_t encode_state = 0;
|
||||
rmt_encode_state_t encode_state = RMT_ENCODING_RESET;
|
||||
rmt_encoder_handle_t encoder = t->encoder;
|
||||
size_t encoded_symbols = encoder->encode(encoder, &tx_chan->base, t->payload, t->payload_bytes, &encode_state);
|
||||
if (encode_state & RMT_ENCODING_COMPLETE) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -29,8 +29,8 @@ TEST_RMT_ENCODER_ATTR
|
||||
static size_t rmt_encode_led_strip(rmt_encoder_t *encoder, rmt_channel_handle_t channel, const void *primary_data, size_t data_size, rmt_encode_state_t *ret_state)
|
||||
{
|
||||
rmt_led_strip_encoder_t *led_encoder = __containerof(encoder, rmt_led_strip_encoder_t, base);
|
||||
rmt_encode_state_t session_state = 0;
|
||||
rmt_encode_state_t state = 0;
|
||||
rmt_encode_state_t session_state = RMT_ENCODING_RESET;
|
||||
rmt_encode_state_t state = RMT_ENCODING_RESET;
|
||||
size_t encoded_symbols = 0;
|
||||
switch (led_encoder->state) {
|
||||
case 0:
|
||||
@ -47,7 +47,7 @@ static size_t rmt_encode_led_strip(rmt_encoder_t *encoder, rmt_channel_handle_t
|
||||
encoded_symbols += led_encoder->copy_encoder->encode(led_encoder->copy_encoder, channel, &led_encoder->reset_code, sizeof(led_encoder->reset_code), &session_state);
|
||||
if (session_state & RMT_ENCODING_COMPLETE) {
|
||||
state |= RMT_ENCODING_COMPLETE;
|
||||
led_encoder->state = 0; // back to the initial encoding session
|
||||
led_encoder->state = RMT_ENCODING_RESET; // back to the initial encoding session
|
||||
}
|
||||
if (session_state & RMT_ENCODING_MEM_FULL) {
|
||||
state |= RMT_ENCODING_MEM_FULL;
|
||||
@ -73,7 +73,7 @@ static esp_err_t rmt_led_strip_encoder_reset(rmt_encoder_t *encoder)
|
||||
rmt_led_strip_encoder_t *led_encoder = __containerof(encoder, rmt_led_strip_encoder_t, base);
|
||||
rmt_encoder_reset(led_encoder->bytes_encoder);
|
||||
rmt_encoder_reset(led_encoder->copy_encoder);
|
||||
led_encoder->state = 0;
|
||||
led_encoder->state = RMT_ENCODING_RESET;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
@ -122,8 +122,8 @@ typedef struct {
|
||||
static size_t rmt_encode_nec_protocol(rmt_encoder_t *encoder, rmt_channel_handle_t channel, const void *primary_data, size_t data_size, rmt_encode_state_t *ret_state)
|
||||
{
|
||||
rmt_nec_protocol_encoder_t *nec_encoder = __containerof(encoder, rmt_nec_protocol_encoder_t, base);
|
||||
rmt_encode_state_t session_state = 0;
|
||||
rmt_encode_state_t state = 0;
|
||||
rmt_encode_state_t session_state = RMT_ENCODING_RESET;
|
||||
rmt_encode_state_t state = RMT_ENCODING_RESET;
|
||||
size_t encoded_symbols = 0;
|
||||
const rmt_symbol_word_t nec_leading_symbol = {
|
||||
.level0 = 1,
|
||||
@ -162,7 +162,7 @@ static size_t rmt_encode_nec_protocol(rmt_encoder_t *encoder, rmt_channel_handle
|
||||
encoded_symbols += nec_encoder->copy_encoder->encode(nec_encoder->copy_encoder, channel, &nec_ending_symbol, sizeof(nec_ending_symbol), &session_state);
|
||||
if (session_state & RMT_ENCODING_COMPLETE) {
|
||||
state |= RMT_ENCODING_COMPLETE;
|
||||
nec_encoder->state = 0; // back to the initial encoding session
|
||||
nec_encoder->state = RMT_ENCODING_RESET; // back to the initial encoding session
|
||||
}
|
||||
if (session_state & RMT_ENCODING_MEM_FULL) {
|
||||
state |= RMT_ENCODING_MEM_FULL;
|
||||
@ -188,7 +188,7 @@ static esp_err_t rmt_nec_protocol_encoder_reset(rmt_encoder_t *encoder)
|
||||
rmt_nec_protocol_encoder_t *nec_encoder = __containerof(encoder, rmt_nec_protocol_encoder_t, base);
|
||||
rmt_encoder_reset(nec_encoder->copy_encoder);
|
||||
rmt_encoder_reset(nec_encoder->bytes_encoder);
|
||||
nec_encoder->state = 0;
|
||||
nec_encoder->state = RMT_ENCODING_RESET;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
@ -419,8 +419,8 @@ Then we can construct the NEC :cpp:member:`rmt_encoder_t::encode` function in th
|
||||
static size_t rmt_encode_ir_nec(rmt_encoder_t *encoder, rmt_channel_handle_t channel, const void *primary_data, size_t data_size, rmt_encode_state_t *ret_state)
|
||||
{
|
||||
rmt_ir_nec_encoder_t *nec_encoder = __containerof(encoder, rmt_ir_nec_encoder_t, base);
|
||||
rmt_encode_state_t session_state = 0;
|
||||
rmt_encode_state_t state = 0;
|
||||
rmt_encode_state_t session_state = RMT_ENCODING_RESET;
|
||||
rmt_encode_state_t state = RMT_ENCODING_RESET;
|
||||
size_t encoded_symbols = 0;
|
||||
ir_nec_scan_code_t *scan_code = (ir_nec_scan_code_t *)primary_data;
|
||||
rmt_encoder_handle_t copy_encoder = nec_encoder->copy_encoder;
|
||||
@ -461,7 +461,7 @@ Then we can construct the NEC :cpp:member:`rmt_encoder_t::encode` function in th
|
||||
encoded_symbols += copy_encoder->encode(copy_encoder, channel, &nec_encoder->nec_ending_symbol,
|
||||
sizeof(rmt_symbol_word_t), &session_state);
|
||||
if (session_state & RMT_ENCODING_COMPLETE) {
|
||||
nec_encoder->state = 0; // back to the initial encoding session
|
||||
nec_encoder->state = RMT_ENCODING_RESET; // back to the initial encoding session
|
||||
state |= RMT_ENCODING_COMPLETE; // telling the caller the NEC encoding has finished
|
||||
}
|
||||
if (session_state & RMT_ENCODING_MEM_FULL) {
|
||||
|
@ -51,8 +51,8 @@ static size_t rmt_encode_dshot_esc(rmt_encoder_t *encoder, rmt_channel_handle_t
|
||||
rmt_dshot_esc_encoder_t *dshot_encoder = __containerof(encoder, rmt_dshot_esc_encoder_t, base);
|
||||
rmt_encoder_handle_t bytes_encoder = dshot_encoder->bytes_encoder;
|
||||
rmt_encoder_handle_t copy_encoder = dshot_encoder->copy_encoder;
|
||||
rmt_encode_state_t session_state = 0;
|
||||
rmt_encode_state_t state = 0;
|
||||
rmt_encode_state_t session_state = RMT_ENCODING_RESET;
|
||||
rmt_encode_state_t state = RMT_ENCODING_RESET;
|
||||
size_t encoded_symbols = 0;
|
||||
|
||||
// convert user data into dshot frame
|
||||
@ -76,7 +76,7 @@ static size_t rmt_encode_dshot_esc(rmt_encoder_t *encoder, rmt_channel_handle_t
|
||||
sizeof(rmt_symbol_word_t), &session_state);
|
||||
if (session_state & RMT_ENCODING_COMPLETE) {
|
||||
state |= RMT_ENCODING_COMPLETE;
|
||||
dshot_encoder->state = 0; // switch to next state when current encoding session finished
|
||||
dshot_encoder->state = RMT_ENCODING_RESET; // switch to next state when current encoding session finished
|
||||
}
|
||||
if (session_state & RMT_ENCODING_MEM_FULL) {
|
||||
state |= RMT_ENCODING_MEM_FULL;
|
||||
@ -102,7 +102,7 @@ static esp_err_t rmt_dshot_encoder_reset(rmt_encoder_t *encoder)
|
||||
rmt_dshot_esc_encoder_t *dshot_encoder = __containerof(encoder, rmt_dshot_esc_encoder_t, base);
|
||||
rmt_encoder_reset(dshot_encoder->bytes_encoder);
|
||||
rmt_encoder_reset(dshot_encoder->copy_encoder);
|
||||
dshot_encoder->state = 0;
|
||||
dshot_encoder->state = RMT_ENCODING_RESET;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
@ -21,8 +21,8 @@ typedef struct {
|
||||
static size_t rmt_encode_ir_nec(rmt_encoder_t *encoder, rmt_channel_handle_t channel, const void *primary_data, size_t data_size, rmt_encode_state_t *ret_state)
|
||||
{
|
||||
rmt_ir_nec_encoder_t *nec_encoder = __containerof(encoder, rmt_ir_nec_encoder_t, base);
|
||||
rmt_encode_state_t session_state = 0;
|
||||
rmt_encode_state_t state = 0;
|
||||
rmt_encode_state_t session_state = RMT_ENCODING_RESET;
|
||||
rmt_encode_state_t state = RMT_ENCODING_RESET;
|
||||
size_t encoded_symbols = 0;
|
||||
ir_nec_scan_code_t *scan_code = (ir_nec_scan_code_t *)primary_data;
|
||||
rmt_encoder_handle_t copy_encoder = nec_encoder->copy_encoder;
|
||||
@ -63,7 +63,7 @@ static size_t rmt_encode_ir_nec(rmt_encoder_t *encoder, rmt_channel_handle_t cha
|
||||
encoded_symbols += copy_encoder->encode(copy_encoder, channel, &nec_encoder->nec_ending_symbol,
|
||||
sizeof(rmt_symbol_word_t), &session_state);
|
||||
if (session_state & RMT_ENCODING_COMPLETE) {
|
||||
nec_encoder->state = 0; // back to the initial encoding session
|
||||
nec_encoder->state = RMT_ENCODING_RESET; // back to the initial encoding session
|
||||
state |= RMT_ENCODING_COMPLETE;
|
||||
}
|
||||
if (session_state & RMT_ENCODING_MEM_FULL) {
|
||||
@ -90,7 +90,7 @@ static esp_err_t rmt_ir_nec_encoder_reset(rmt_encoder_t *encoder)
|
||||
rmt_ir_nec_encoder_t *nec_encoder = __containerof(encoder, rmt_ir_nec_encoder_t, base);
|
||||
rmt_encoder_reset(nec_encoder->copy_encoder);
|
||||
rmt_encoder_reset(nec_encoder->bytes_encoder);
|
||||
nec_encoder->state = 0;
|
||||
nec_encoder->state = RMT_ENCODING_RESET;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
@ -22,8 +22,8 @@ static size_t rmt_encode_led_strip(rmt_encoder_t *encoder, rmt_channel_handle_t
|
||||
rmt_led_strip_encoder_t *led_encoder = __containerof(encoder, rmt_led_strip_encoder_t, base);
|
||||
rmt_encoder_handle_t bytes_encoder = led_encoder->bytes_encoder;
|
||||
rmt_encoder_handle_t copy_encoder = led_encoder->copy_encoder;
|
||||
rmt_encode_state_t session_state = 0;
|
||||
rmt_encode_state_t state = 0;
|
||||
rmt_encode_state_t session_state = RMT_ENCODING_RESET;
|
||||
rmt_encode_state_t state = RMT_ENCODING_RESET;
|
||||
size_t encoded_symbols = 0;
|
||||
switch (led_encoder->state) {
|
||||
case 0: // send RGB data
|
||||
@ -40,7 +40,7 @@ static size_t rmt_encode_led_strip(rmt_encoder_t *encoder, rmt_channel_handle_t
|
||||
encoded_symbols += copy_encoder->encode(copy_encoder, channel, &led_encoder->reset_code,
|
||||
sizeof(led_encoder->reset_code), &session_state);
|
||||
if (session_state & RMT_ENCODING_COMPLETE) {
|
||||
led_encoder->state = 0; // back to the initial encoding session
|
||||
led_encoder->state = RMT_ENCODING_RESET; // back to the initial encoding session
|
||||
state |= RMT_ENCODING_COMPLETE;
|
||||
}
|
||||
if (session_state & RMT_ENCODING_MEM_FULL) {
|
||||
@ -67,7 +67,7 @@ static esp_err_t rmt_led_strip_encoder_reset(rmt_encoder_t *encoder)
|
||||
rmt_led_strip_encoder_t *led_encoder = __containerof(encoder, rmt_led_strip_encoder_t, base);
|
||||
rmt_encoder_reset(led_encoder->bytes_encoder);
|
||||
rmt_encoder_reset(led_encoder->copy_encoder);
|
||||
led_encoder->state = 0;
|
||||
led_encoder->state = RMT_ENCODING_RESET;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,7 @@ static size_t rmt_encode_musical_score(rmt_encoder_t *encoder, rmt_channel_handl
|
||||
{
|
||||
rmt_musical_score_encoder_t *score_encoder = __containerof(encoder, rmt_musical_score_encoder_t, base);
|
||||
rmt_encoder_handle_t copy_encoder = score_encoder->copy_encoder;
|
||||
rmt_encode_state_t session_state = 0;
|
||||
rmt_encode_state_t session_state = RMT_ENCODING_RESET;
|
||||
buzzer_musical_score_t *score = (buzzer_musical_score_t *)primary_data;
|
||||
uint32_t rmt_raw_symbol_duration = score_encoder->resolution / score->freq_hz / 2;
|
||||
rmt_symbol_word_t musical_score_rmt_symbol = {
|
||||
|
@ -31,7 +31,7 @@ static size_t rmt_encode_stepper_motor_curve(rmt_encoder_t *encoder, rmt_channel
|
||||
{
|
||||
rmt_stepper_curve_encoder_t *motor_encoder = __containerof(encoder, rmt_stepper_curve_encoder_t, base);
|
||||
rmt_encoder_handle_t copy_encoder = motor_encoder->copy_encoder;
|
||||
rmt_encode_state_t session_state = 0;
|
||||
rmt_encode_state_t session_state = RMT_ENCODING_RESET;
|
||||
uint32_t points_num = *(uint32_t *)primary_data;
|
||||
size_t encoded_symbols = 0;
|
||||
if (motor_encoder->flags.is_accel_curve) {
|
||||
@ -127,7 +127,7 @@ static size_t rmt_encode_stepper_motor_uniform(rmt_encoder_t *encoder, rmt_chann
|
||||
{
|
||||
rmt_stepper_uniform_encoder_t *motor_encoder = __containerof(encoder, rmt_stepper_uniform_encoder_t, base);
|
||||
rmt_encoder_handle_t copy_encoder = motor_encoder->copy_encoder;
|
||||
rmt_encode_state_t session_state = 0;
|
||||
rmt_encode_state_t session_state = RMT_ENCODING_RESET;
|
||||
uint32_t target_freq_hz = *(uint32_t *)primary_data;
|
||||
uint32_t symbol_duration = motor_encoder->resolution / target_freq_hz / 2;
|
||||
rmt_symbol_word_t freq_sample = {
|
||||
|
Loading…
Reference in New Issue
Block a user