From f24983a94275a1ce69c37b304f95e65be41f8329 Mon Sep 17 00:00:00 2001 From: morris Date: Sat, 6 Aug 2022 14:52:22 +0800 Subject: [PATCH 1/2] unity_utils: added helper function to disable cache and run user function --- components/driver/mcpwm/mcpwm_cap.c | 2 +- components/driver/mcpwm/mcpwm_cmpr.c | 2 +- components/driver/mcpwm/mcpwm_fault.c | 2 +- components/driver/mcpwm/mcpwm_oper.c | 2 +- components/driver/pulse_cnt.c | 2 +- .../test_apps/gptimer/main/CMakeLists.txt | 7 +- .../gptimer/main/test_gptimer_iram.c | 86 +++++-------------- .../test_apps/mcpwm/main/test_mcpwm_iram.c | 11 +-- .../test_apps/pulse_cnt/main/CMakeLists.txt | 7 +- .../pulse_cnt/main/test_pulse_cnt_iram.c | 18 ++-- components/unity/CMakeLists.txt | 6 +- components/unity/include/unity_test_utils.h | 1 + .../unity/include/unity_test_utils_cache.h | 25 ++++++ components/unity/unity_utils_cache.c | 22 +++++ 14 files changed, 99 insertions(+), 94 deletions(-) create mode 100644 components/unity/include/unity_test_utils_cache.h create mode 100644 components/unity/unity_utils_cache.c diff --git a/components/driver/mcpwm/mcpwm_cap.c b/components/driver/mcpwm/mcpwm_cap.c index 94667a6f14..e45804a905 100644 --- a/components/driver/mcpwm/mcpwm_cap.c +++ b/components/driver/mcpwm/mcpwm_cap.c @@ -317,7 +317,7 @@ esp_err_t mcpwm_capture_channel_register_event_callbacks(mcpwm_cap_channel_handl // lazy install interrupt service if (!cap_channel->intr) { - // we want the interrupt servie to be enabled after allocation successfully + // we want the interrupt service to be enabled after allocation successfully int isr_flags = MCPWM_INTR_ALLOC_FLAG & ~ ESP_INTR_FLAG_INTRDISABLED; ESP_RETURN_ON_ERROR(esp_intr_alloc_intrstatus(mcpwm_periph_signals.groups[group_id].irq_id, isr_flags, (uint32_t)mcpwm_ll_intr_get_status_reg(hal->dev), MCPWM_LL_EVENT_CAPTURE(cap_chan_id), diff --git a/components/driver/mcpwm/mcpwm_cmpr.c b/components/driver/mcpwm/mcpwm_cmpr.c index c0f9e82aad..6211d88919 100644 --- a/components/driver/mcpwm/mcpwm_cmpr.c +++ b/components/driver/mcpwm/mcpwm_cmpr.c @@ -160,7 +160,7 @@ esp_err_t mcpwm_comparator_register_event_callbacks(mcpwm_cmpr_handle_t cmpr, co // lazy install interrupt service if (!cmpr->intr) { - // we want the interrupt servie to be enabled after allocation successfully + // we want the interrupt service to be enabled after allocation successfully int isr_flags = MCPWM_INTR_ALLOC_FLAG & ~ ESP_INTR_FLAG_INTRDISABLED; ESP_RETURN_ON_ERROR(esp_intr_alloc_intrstatus(mcpwm_periph_signals.groups[group_id].irq_id, isr_flags, (uint32_t)mcpwm_ll_intr_get_status_reg(hal->dev), MCPWM_LL_EVENT_CMP_EQUAL(oper_id, cmpr_id), diff --git a/components/driver/mcpwm/mcpwm_fault.c b/components/driver/mcpwm/mcpwm_fault.c index e8b21f43e1..f17a32bfe8 100644 --- a/components/driver/mcpwm/mcpwm_fault.c +++ b/components/driver/mcpwm/mcpwm_fault.c @@ -243,7 +243,7 @@ esp_err_t mcpwm_fault_register_event_callbacks(mcpwm_fault_handle_t fault, const // lazy install interrupt service if (!gpio_fault->intr) { - // we want the interrupt servie to be enabled after allocation successfully + // we want the interrupt service to be enabled after allocation successfully int isr_flags = MCPWM_INTR_ALLOC_FLAG & ~ESP_INTR_FLAG_INTRDISABLED; ESP_RETURN_ON_ERROR(esp_intr_alloc_intrstatus(mcpwm_periph_signals.groups[group_id].irq_id, isr_flags, (uint32_t)mcpwm_ll_intr_get_status_reg(hal->dev), MCPWM_LL_EVENT_FAULT_MASK(fault_id), diff --git a/components/driver/mcpwm/mcpwm_oper.c b/components/driver/mcpwm/mcpwm_oper.c index 6a805f8ddc..852a57f958 100644 --- a/components/driver/mcpwm/mcpwm_oper.c +++ b/components/driver/mcpwm/mcpwm_oper.c @@ -233,7 +233,7 @@ esp_err_t mcpwm_operator_register_event_callbacks(mcpwm_oper_handle_t oper, cons // lazy install interrupt service if (!oper->intr) { - // we want the interrupt servie to be enabled after allocation successfully + // we want the interrupt service to be enabled after allocation successfully int isr_flags = MCPWM_INTR_ALLOC_FLAG & ~ ESP_INTR_FLAG_INTRDISABLED; ESP_RETURN_ON_ERROR(esp_intr_alloc_intrstatus(mcpwm_periph_signals.groups[group_id].irq_id, isr_flags, (uint32_t)mcpwm_ll_intr_get_status_reg(hal->dev), MCPWM_LL_EVENT_OPER_MASK(oper_id), diff --git a/components/driver/pulse_cnt.c b/components/driver/pulse_cnt.c index 875578e0b1..ee9e88ee87 100644 --- a/components/driver/pulse_cnt.c +++ b/components/driver/pulse_cnt.c @@ -98,7 +98,7 @@ struct pcnt_unit_t { struct pcnt_chan_t { pcnt_unit_t *unit; // pointer to the PCNT unit where it derives from - uint32_t channel_id; // channel ID, index from 0 + int channel_id; // channel ID, index from 0 int edge_gpio_num; int level_gpio_num; }; diff --git a/components/driver/test_apps/gptimer/main/CMakeLists.txt b/components/driver/test_apps/gptimer/main/CMakeLists.txt index 4170f3fd44..be6096026a 100644 --- a/components/driver/test_apps/gptimer/main/CMakeLists.txt +++ b/components/driver/test_apps/gptimer/main/CMakeLists.txt @@ -1,6 +1,9 @@ set(srcs "test_app_main.c" - "test_gptimer.c" - "test_gptimer_iram.c") + "test_gptimer.c") + +if(CONFIG_GPTIMER_ISR_IRAM_SAFE) + list(APPEND srcs "test_gptimer_iram.c") +endif() # In order for the cases defined by `TEST_CASE` to be linked into the final elf, # the component can be registered as WHOLE_ARCHIVE diff --git a/components/driver/test_apps/gptimer/main/test_gptimer_iram.c b/components/driver/test_apps/gptimer/main/test_gptimer_iram.c index fcf3cce7d1..2ff59fc5fa 100644 --- a/components/driver/test_apps/gptimer/main/test_gptimer_iram.c +++ b/components/driver/test_apps/gptimer/main/test_gptimer_iram.c @@ -5,102 +5,58 @@ */ #include -#include "sdkconfig.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "freertos/semphr.h" +#include #include "unity.h" +#include "unity_test_utils.h" +#include "esp_attr.h" #include "driver/gptimer.h" -#include "spi_flash_mmap.h" -#include "esp_flash.h" -#include "soc/soc_caps.h" - -#if CONFIG_GPTIMER_ISR_IRAM_SAFE - -typedef struct { - size_t buf_size; - uint8_t *buf; - size_t flash_addr; - size_t repeat_count; - SemaphoreHandle_t done_sem; -} read_task_arg_t; - -typedef struct { - size_t delay_time_us; - size_t repeat_count; -} block_task_arg_t; static bool IRAM_ATTR on_gptimer_alarm_cb(gptimer_handle_t timer, const gptimer_alarm_event_data_t *edata, void *user_ctx) { - block_task_arg_t *arg = (block_task_arg_t *)user_ctx; - esp_rom_delay_us(arg->delay_time_us); - arg->repeat_count++; + uint32_t *alarm_counts = (uint32_t *)user_ctx; + (*alarm_counts)++; return false; } -static void flash_read_task(void *varg) +static void IRAM_ATTR test_delay_post_cache_disable(void *args) { - read_task_arg_t *arg = (read_task_arg_t *)varg; - for (size_t i = 0; i < arg->repeat_count; i++) { - TEST_ESP_OK(esp_flash_read(NULL, arg->buf, arg->flash_addr, arg->buf_size)); - } - xSemaphoreGive(arg->done_sem); - vTaskDelete(NULL); + esp_rom_delay_us(1000); } -TEST_CASE("gptimer_iram_interrupt_safe", "[gptimer]") +TEST_CASE("gptimer_interrupt_iram_safe", "[gptimer]") { gptimer_handle_t gptimer = NULL; - const size_t size = 128; - uint8_t *buf = malloc(size); - TEST_ASSERT_NOT_NULL(buf); - SemaphoreHandle_t done_sem = xSemaphoreCreateBinary(); - TEST_ASSERT_NOT_NULL(done_sem); - read_task_arg_t read_arg = { - .buf_size = size, - .buf = buf, - .flash_addr = 0, - .repeat_count = 1000, - .done_sem = done_sem, - }; - - block_task_arg_t block_arg = { - .repeat_count = 0, - .delay_time_us = 100, - }; - gptimer_config_t timer_config = { .clk_src = GPTIMER_CLK_SRC_DEFAULT, .direction = GPTIMER_COUNT_UP, - .resolution_hz = 1 * 1000 * 1000, + .resolution_hz = 1 * 1000 * 1000, // 1MHz, 1 tick = 1us }; TEST_ESP_OK(gptimer_new_timer(&timer_config, &gptimer)); gptimer_event_callbacks_t cbs = { .on_alarm = on_gptimer_alarm_cb, }; + uint32_t alarm_counts = 0; + TEST_ESP_OK(gptimer_register_event_callbacks(gptimer, &cbs, &alarm_counts)); gptimer_alarm_config_t alarm_config = { .reload_count = 0, - .alarm_count = 120, + .alarm_count = 100, // 100us per alarm event .flags.auto_reload_on_alarm = true, }; TEST_ESP_OK(gptimer_set_alarm_action(gptimer, &alarm_config)); - TEST_ESP_OK(gptimer_register_event_callbacks(gptimer, &cbs, &block_arg)); TEST_ESP_OK(gptimer_enable(gptimer)); TEST_ESP_OK(gptimer_start(gptimer)); - xTaskCreatePinnedToCore(flash_read_task, "read_flash", 2048, &read_arg, 3, NULL, portNUM_PROCESSORS - 1); - // wait for task done - xSemaphoreTake(done_sem, portMAX_DELAY); - printf("alarm callback runs %d times\r\n", block_arg.repeat_count); - TEST_ASSERT_GREATER_THAN(1000, block_arg.repeat_count); + vTaskDelay(pdMS_TO_TICKS(10)); + + printf("disable flash cache and check the alarm events are still in working\r\n"); + for (int i = 0; i < 10; i++) { + unity_utils_run_cache_disable_stub(test_delay_post_cache_disable, NULL); + } + printf("alarm counts: %"PRIu32"\r\n", alarm_counts); + TEST_ASSERT_GREATER_THAN(150, alarm_counts); + // delete gptimer TEST_ESP_OK(gptimer_stop(gptimer)); TEST_ESP_OK(gptimer_disable(gptimer)); TEST_ESP_OK(gptimer_del_timer(gptimer)); - vSemaphoreDelete(done_sem); - free(buf); - // leave time for IDLE task to recycle deleted task - vTaskDelay(2); } - -#endif // CONFIG_GPTIMER_ISR_IRAM_SAFE diff --git a/components/driver/test_apps/mcpwm/main/test_mcpwm_iram.c b/components/driver/test_apps/mcpwm/main/test_mcpwm_iram.c index a59d59e670..d65159c859 100644 --- a/components/driver/test_apps/mcpwm/main/test_mcpwm_iram.c +++ b/components/driver/test_apps/mcpwm/main/test_mcpwm_iram.c @@ -9,9 +9,9 @@ #include "freertos/task.h" #include "freertos/event_groups.h" #include "unity.h" +#include "unity_test_utils.h" #include "soc/soc_caps.h" #include "esp_private/esp_clk.h" -#include "esp_private/spi_flash_os.h" #include "driver/mcpwm_cap.h" #include "driver/mcpwm_sync.h" #include "driver/gpio.h" @@ -28,15 +28,12 @@ static bool IRAM_ATTR test_capture_callback_iram_safe(mcpwm_cap_channel_handle_t return false; } -static void IRAM_ATTR test_mcpwm_capture_gpio_simulate(int gpio_sig) +static void IRAM_ATTR test_simulate_input_post_cache_disable(void *args) { - // disable flash cache - spi_flash_guard_get()->start(); + int gpio_sig = (int)args; gpio_set_level(gpio_sig, 1); esp_rom_delay_us(1000); gpio_set_level(gpio_sig, 0); - // enable flash cache - spi_flash_guard_get()->end(); } TEST_CASE("mcpwm_capture_iram_safe", "[mcpwm]") @@ -77,7 +74,7 @@ TEST_CASE("mcpwm_capture_iram_safe", "[mcpwm]") TEST_ESP_OK(mcpwm_capture_timer_start(cap_timer)); printf("disable cache, simulate GPIO capture signal\r\n"); - test_mcpwm_capture_gpio_simulate(cap_gpio); + unity_utils_run_cache_disable_stub(test_simulate_input_post_cache_disable, (void *)cap_gpio); printf("capture value: Pos=%"PRIu32", Neg=%"PRIu32"\r\n", cap_value[0], cap_value[1]); // Capture timer is clocked from APB by default diff --git a/components/driver/test_apps/pulse_cnt/main/CMakeLists.txt b/components/driver/test_apps/pulse_cnt/main/CMakeLists.txt index 4e70ee7087..3bfb46de82 100644 --- a/components/driver/test_apps/pulse_cnt/main/CMakeLists.txt +++ b/components/driver/test_apps/pulse_cnt/main/CMakeLists.txt @@ -1,7 +1,10 @@ set(srcs "test_app_main.c" "test_pulse_cnt_simulator.c" - "test_pulse_cnt.c" - "test_pulse_cnt_iram.c") + "test_pulse_cnt.c") + +if(CONFIG_PCNT_ISR_IRAM_SAFE) + list(APPEND srcs "test_pulse_cnt_iram.c") +endif() # In order for the cases defined by `TEST_CASE` to be linked into the final elf, # the component can be registered as WHOLE_ARCHIVE diff --git a/components/driver/test_apps/pulse_cnt/main/test_pulse_cnt_iram.c b/components/driver/test_apps/pulse_cnt/main/test_pulse_cnt_iram.c index e07c224df0..8803b17b10 100644 --- a/components/driver/test_apps/pulse_cnt/main/test_pulse_cnt_iram.c +++ b/components/driver/test_apps/pulse_cnt/main/test_pulse_cnt_iram.c @@ -10,16 +10,14 @@ #include "freertos/task.h" #include "freertos/semphr.h" #include "unity.h" +#include "unity_test_utils.h" #include "driver/pulse_cnt.h" #include "driver/gpio.h" #include "spi_flash_mmap.h" #include "esp_attr.h" #include "soc/soc_caps.h" -#include "esp_private/spi_flash_os.h" #include "test_pulse_cnt_board.h" -#if CONFIG_PCNT_ISR_IRAM_SAFE - static bool IRAM_ATTR test_pcnt_iram_safe_callback(pcnt_unit_handle_t unit, const pcnt_watch_event_data_t *event_data, void *user_data) { uint32_t *data = (uint32_t *)user_data; @@ -29,13 +27,10 @@ static bool IRAM_ATTR test_pcnt_iram_safe_callback(pcnt_unit_handle_t unit, cons return false; } -static void IRAM_ATTR test_pcnt_iram_simulation(int gpio_sig) +static void IRAM_ATTR test_simulate_input_post_cache_disable(void *args) { - // disable flash cache - spi_flash_guard_get()->start(); + int gpio_sig = (int)args; test_gpio_simulate_rising_edge(gpio_sig, 2); - // enable flash cache - spi_flash_guard_get()->end(); } TEST_CASE("pcnt_iram_interrupt_safe", "[pcnt]") @@ -83,8 +78,9 @@ TEST_CASE("pcnt_iram_interrupt_safe", "[pcnt]") printf("disable cache and check interrupt triggered\r\n"); TEST_ESP_OK(pcnt_unit_clear_count(unit)); - // the function that will disable the flash must be placed in the IRAM - test_pcnt_iram_simulation(TEST_PCNT_GPIO_A); + + // disable flash cache and run simulation + unity_utils_run_cache_disable_stub(test_simulate_input_post_cache_disable, (void *)TEST_PCNT_GPIO_A); // check if the interrupt has fired up TEST_ASSERT_EQUAL(1, num_of_event_triggered); @@ -101,5 +97,3 @@ TEST_CASE("pcnt_iram_interrupt_safe", "[pcnt]") TEST_ESP_OK(pcnt_del_channel(channelB)); TEST_ESP_OK(pcnt_del_unit(unit)); } - -#endif // CONFIG_PCNT_ISR_IRAM_SAFE diff --git a/components/unity/CMakeLists.txt b/components/unity/CMakeLists.txt index bc8818b32e..9659dbba89 100644 --- a/components/unity/CMakeLists.txt +++ b/components/unity/CMakeLists.txt @@ -17,7 +17,7 @@ if(CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER) list(APPEND srcs "unity_runner.c") # Note the following files are not compatible with the Linux target. # On Linux, these are masked because we also don't use the IDF test runner there - list(APPEND srcs "unity_utils_freertos.c") + list(APPEND srcs "unity_utils_freertos.c" "unity_utils_cache.c") list(APPEND requires "freertos") endif() @@ -39,6 +39,10 @@ idf_component_register(SRCS "${srcs}" INCLUDE_DIRS ${includes} REQUIRES ${requires}) +if(CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER) + idf_component_optional_requires(PRIVATE spi_flash) +endif() + if(NOT "${target}" STREQUAL "linux") target_compile_definitions(${COMPONENT_LIB} PUBLIC -DUNITY_INCLUDE_CONFIG_H diff --git a/components/unity/include/unity_test_utils.h b/components/unity/include/unity_test_utils.h index c9f38613e7..42afe6bb48 100644 --- a/components/unity/include/unity_test_utils.h +++ b/components/unity/include/unity_test_utils.h @@ -10,6 +10,7 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "unity_test_utils_memory.h" +#include "unity_test_utils_cache.h" #ifdef __cplusplus extern "C" { diff --git a/components/unity/include/unity_test_utils_cache.h b/components/unity/include/unity_test_utils_cache.h new file mode 100644 index 0000000000..6c33b6dead --- /dev/null +++ b/components/unity/include/unity_test_utils_cache.h @@ -0,0 +1,25 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Disable flash cache and run user stub function and then enable flash cache again + * + * @note You should make sure the passed-in function is in internal RAM. + * + * @param post_cache_disable User function to be invoked after cache is disabled. + * @param user_ctx User context to be passed to user function. + */ +void unity_utils_run_cache_disable_stub(void (*post_cache_disable)(void *), void *user_ctx); + +#ifdef __cplusplus +} +#endif diff --git a/components/unity/unity_utils_cache.c b/components/unity/unity_utils_cache.c new file mode 100644 index 0000000000..5d44ec0a0e --- /dev/null +++ b/components/unity/unity_utils_cache.c @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "unity.h" +#include "unity_test_utils_cache.h" +#include "esp_attr.h" +#include "esp_memory_utils.h" +#include "esp_private/spi_flash_os.h" + +IRAM_ATTR void unity_utils_run_cache_disable_stub(void (*post_cache_disable)(void *), void *user_ctx) +{ + // callback function must reside in IRAM + TEST_ASSERT_TRUE(esp_ptr_in_iram(post_cache_disable)); + // disable flash cache + spi_flash_guard_get()->start(); + post_cache_disable(user_ctx); + // enable flash cache + spi_flash_guard_get()->end(); +} From 6f2ac1ce2a14f8fa670edddef49b2801497201fa Mon Sep 17 00:00:00 2001 From: morris Date: Mon, 1 Aug 2022 14:16:47 +0800 Subject: [PATCH 2/2] rmt: add iram safe test Closes https://github.com/espressif/esp-idf/issues/9487 --- components/driver/deprecated/rmt_legacy.c | 16 +- .../legacy_rmt_driver/main/CMakeLists.txt | 1 - .../legacy_rmt_driver/main/test_legacy_rmt.c | 54 +++++- .../driver/test_apps/rmt/main/CMakeLists.txt | 4 + .../driver/test_apps/rmt/main/test_rmt_iram.c | 180 ++++++++++++++++++ .../driver/test_apps/rmt/main/test_rmt_rx.c | 14 +- .../rmt/main/test_util_rmt_encoders.c | 9 + .../test_apps/rmt/sdkconfig.ci.iram_safe | 1 + components/hal/esp32/include/hal/rmt_ll.h | 17 ++ components/hal/esp32c3/include/hal/rmt_ll.h | 20 ++ components/hal/esp32h2/include/hal/rmt_ll.h | 20 ++ components/hal/esp32s2/include/hal/rmt_ll.h | 18 ++ components/hal/esp32s3/include/hal/rmt_ll.h | 20 ++ 13 files changed, 348 insertions(+), 26 deletions(-) create mode 100644 components/driver/test_apps/rmt/main/test_rmt_iram.c diff --git a/components/driver/deprecated/rmt_legacy.c b/components/driver/deprecated/rmt_legacy.c index d0aadbb618..dbbc1886e6 100644 --- a/components/driver/deprecated/rmt_legacy.c +++ b/components/driver/deprecated/rmt_legacy.c @@ -936,13 +936,9 @@ esp_err_t rmt_driver_uninstall(rmt_channel_t channel) RMT_ENTER_CRITICAL(); // check channel's working mode if (p_rmt_obj[channel]->rx_buf) { - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_RX_DONE(RMT_DECODE_RX_CHANNEL(channel)), false); - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_RX_ERROR(RMT_DECODE_RX_CHANNEL(channel)), false); -#if SOC_RMT_SUPPORT_RX_PINGPONG - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_RX_THRES(RMT_DECODE_RX_CHANNEL(channel)), false); -#endif + rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_RX_MASK(RMT_DECODE_RX_CHANNEL(channel)) | RMT_LL_EVENT_RX_ERROR(RMT_DECODE_RX_CHANNEL(channel)), false); } else { - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_TX_DONE(channel) | RMT_LL_EVENT_TX_ERROR(channel) | RMT_LL_EVENT_TX_THRES(channel), false); + rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_TX_MASK(channel) | RMT_LL_EVENT_TX_ERROR(channel), false); } RMT_EXIT_CRITICAL(); @@ -1001,10 +997,10 @@ esp_err_t rmt_driver_install(rmt_channel_t channel, size_t rx_buf_size, int intr } #if CONFIG_RINGBUF_PLACE_ISR_FUNCTIONS_INTO_FLASH - if (intr_alloc_flags & ESP_INTR_FLAG_IRAM ) { - ESP_LOGE(TAG, "ringbuf ISR functions in flash, but used in IRAM interrupt"); - return ESP_ERR_INVALID_ARG; - } + if (intr_alloc_flags & ESP_INTR_FLAG_IRAM ) { + ESP_LOGE(TAG, "ringbuf ISR functions in flash, but used in IRAM interrupt"); + return ESP_ERR_INVALID_ARG; + } #endif #if !CONFIG_SPIRAM_USE_MALLOC diff --git a/components/driver/test_apps/legacy_rmt_driver/main/CMakeLists.txt b/components/driver/test_apps/legacy_rmt_driver/main/CMakeLists.txt index 7acd36f508..f8bd38290a 100644 --- a/components/driver/test_apps/legacy_rmt_driver/main/CMakeLists.txt +++ b/components/driver/test_apps/legacy_rmt_driver/main/CMakeLists.txt @@ -3,4 +3,3 @@ set(srcs "test_app_main.c" idf_component_register(SRCS ${srcs} WHOLE_ARCHIVE) -target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") diff --git a/components/driver/test_apps/legacy_rmt_driver/main/test_legacy_rmt.c b/components/driver/test_apps/legacy_rmt_driver/main/test_legacy_rmt.c index 35d1e1f79d..6e7e67ecdc 100644 --- a/components/driver/test_apps/legacy_rmt_driver/main/test_legacy_rmt.c +++ b/components/driver/test_apps/legacy_rmt_driver/main/test_legacy_rmt.c @@ -13,8 +13,8 @@ #include "esp_log.h" #include "esp_cpu.h" #include "unity.h" +#include "unity_test_utils.h" #include "esp_rom_gpio.h" - #include "ir_tools.h" #include "driver/rmt.h" @@ -295,7 +295,7 @@ static void do_nec_tx_rx(uint32_t flags) // build NEC codes cmd = 0x20; while (cmd <= 0x30) { - ESP_LOGI(TAG, "Send command 0x%x to address 0x%x", cmd, addr); + ESP_LOGI(TAG, "Send command 0x%"PRIx32" to address 0x%"PRIx32, cmd, addr); // Send new key code TEST_ESP_OK(s_ir_builder->build_frame(s_ir_builder, addr, cmd)); TEST_ESP_OK(s_ir_builder->get_result(s_ir_builder, &items, &length)); @@ -315,7 +315,7 @@ static void do_nec_tx_rx(uint32_t flags) length /= 4; // one RMT = 4 Bytes if (s_ir_parser->input(s_ir_parser, items, length) == ESP_OK) { if (s_ir_parser->get_scan_code(s_ir_parser, &addr, &cmd, &repeat) == ESP_OK) { - ESP_LOGI(TAG, "Scan Code %s --- addr: 0x%04x cmd: 0x%04x", repeat ? "(repeat)" : "", addr, cmd); + ESP_LOGI(TAG, "Scan Code %s --- addr: 0x%04"PRIx32" cmd: 0x%04"PRIx32, repeat ? "(repeat)" : "", addr, cmd); } } vRingbufferReturnItem(rb, (void *) items); @@ -397,7 +397,7 @@ TEST_CASE("RMT TX stop", "[rmt]") vTaskDelay(pdMS_TO_TICKS(1000)); // build NEC codes - ESP_LOGI(TAG, "Plan to send command 0x%x~0x%x to address 0x%x", cmd, cmd + count, addr); + ESP_LOGI(TAG, "Plan to send command 0x%"PRIx32"~0x%"PRIx32" to address 0x%"PRIx32, cmd, cmd + count, addr); for (int i = 0; i <= count; i++) { TEST_ESP_OK(s_ir_builder->build_frame(s_ir_builder, addr, cmd)); cmd++; @@ -417,7 +417,7 @@ TEST_CASE("RMT TX stop", "[rmt]") length /= 4; // one RMT = 4 Bytes if (s_ir_parser->input(s_ir_parser, frames, length) == ESP_OK) { if (s_ir_parser->get_scan_code(s_ir_parser, &addr, &cmd, &repeat) == ESP_OK) { - ESP_LOGI(TAG, "Scan Code %s --- addr: 0x%04x cmd: 0x%04x", repeat ? "(repeat)" : "", addr, cmd); + ESP_LOGI(TAG, "Scan Code %s --- addr: 0x%04"PRIx32"cmd: 0x%04"PRIx32, repeat ? "(repeat)" : "", addr, cmd); num++; } } @@ -527,12 +527,14 @@ TEST_CASE("RMT TX simultaneously", "[rmt]") TEST_ESP_OK(rmt_wait_tx_done(channel0, portMAX_DELAY)); TEST_ESP_OK(rmt_wait_tx_done(channel1, portMAX_DELAY)); - ESP_LOGI(TAG, "tx_end_time0=%u, tx_end_time1=%u", tx_end_time0, tx_end_time1); + ESP_LOGI(TAG, "tx_end_time0=%"PRIu32", tx_end_time1=%"PRIu32, tx_end_time0, tx_end_time1); TEST_ASSERT_LESS_OR_EQUAL_UINT32(2000, tx_end_time1 - tx_end_time0); TEST_ESP_OK(rmt_remove_channel_from_group(channel0)); TEST_ESP_OK(rmt_remove_channel_from_group(channel1)); + rmt_register_tx_end_callback(NULL, NULL); + TEST_ESP_OK(rmt_driver_uninstall(channel0)); TEST_ESP_OK(rmt_driver_uninstall(channel1)); @@ -568,7 +570,7 @@ TEST_CASE("RMT TX loop", "[rmt]") // register callback functions, invoked when tx loop count to ceiling rmt_register_tx_end_callback(rmt_tx_loop_end, NULL); // build NEC codes - ESP_LOGI(TAG, "Send command 0x%x to address 0x%x", cmd, addr); + ESP_LOGI(TAG, "Send command 0x%"PRIx32" to address 0x%"PRIx32, cmd, addr); // Send new key code TEST_ESP_OK(s_ir_builder->build_frame(s_ir_builder, addr, cmd)); TEST_ESP_OK(s_ir_builder->get_result(s_ir_builder, &items, &length)); @@ -582,7 +584,7 @@ TEST_CASE("RMT TX loop", "[rmt]") if (s_ir_parser->input(s_ir_parser, items, length) == ESP_OK) { if (s_ir_parser->get_scan_code(s_ir_parser, &addr, &cmd, &repeat) == ESP_OK) { count++; - ESP_LOGI(TAG, "Scan Code %s --- addr: 0x%04x cmd: 0x%04x", repeat ? "(repeat)" : "", addr, cmd); + ESP_LOGI(TAG, "Scan Code %s --- addr: 0x%04"PRIx32" cmd: 0x%04"PRIx32, repeat ? "(repeat)" : "", addr, cmd); } } vRingbufferReturnItem(rb, (void *) items); @@ -593,6 +595,42 @@ TEST_CASE("RMT TX loop", "[rmt]") } TEST_ASSERT_EQUAL(10, count); + rmt_register_tx_end_callback(NULL, NULL); rmt_clean_testbench(tx_channel, rx_channel); } #endif + +static void IRAM_ATTR test_delay_post_cache_disable(void *args) +{ + esp_rom_delay_us(10000); +} + +TEST_CASE("RMT Interrupt IRAM Safe", "[rmt]") +{ + rmt_config_t tx = { + .channel = RMT_CHANNEL_0, + .gpio_num = 0, + .mem_block_num = 1, + .clk_div = 40, + .rmt_mode = RMT_MODE_TX, + }; + TEST_ESP_OK(rmt_config(&tx)); + TEST_ESP_OK(rmt_set_source_clk(tx.channel, RMT_BASECLK_APB)); + // install interrupt with IRAM safe + TEST_ESP_OK(rmt_driver_install(tx.channel, 0, ESP_INTR_FLAG_IRAM)); + + // send a large buffer, ensure the RMT hardware is still in work when we disable the flash cache afterwords + rmt_item32_t items[256] = {}; + for (int i = 0; i < 256; i++) { + items[i].level0 = 0; + items[i].duration0 = 1; + items[i].level1 = 1; + items[i].duration1 = 1; + } + rmt_write_items(RMT_CHANNEL_0, items, 256, false); + + unity_utils_run_cache_disable_stub(test_delay_post_cache_disable, NULL); + + TEST_ESP_OK(rmt_wait_tx_done(RMT_CHANNEL_0, portMAX_DELAY)); + TEST_ESP_OK(rmt_driver_uninstall(RMT_CHANNEL_0)); +} diff --git a/components/driver/test_apps/rmt/main/CMakeLists.txt b/components/driver/test_apps/rmt/main/CMakeLists.txt index 84ab9ed8dd..c686daddcc 100644 --- a/components/driver/test_apps/rmt/main/CMakeLists.txt +++ b/components/driver/test_apps/rmt/main/CMakeLists.txt @@ -4,5 +4,9 @@ set(srcs "test_app_main.c" "test_rmt_rx.c" "test_util_rmt_encoders.c") +if(CONFIG_RMT_ISR_IRAM_SAFE) + list(APPEND srcs "test_rmt_iram.c") +endif() + idf_component_register(SRCS "${srcs}" WHOLE_ARCHIVE) diff --git a/components/driver/test_apps/rmt/main/test_rmt_iram.c b/components/driver/test_apps/rmt/main/test_rmt_iram.c new file mode 100644 index 0000000000..d0e150fab6 --- /dev/null +++ b/components/driver/test_apps/rmt/main/test_rmt_iram.c @@ -0,0 +1,180 @@ +/* + * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +#include +#include +#include "sdkconfig.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "unity.h" +#include "unity_test_utils.h" +#include "driver/rmt_tx.h" +#include "driver/rmt_rx.h" +#include "driver/gpio.h" +#include "esp_timer.h" +#include "soc/soc_caps.h" +#include "test_util_rmt_encoders.h" + +static void IRAM_ATTR test_delay_post_cache_disable(void *args) +{ + esp_rom_delay_us(10000); +} + +static void test_rmt_tx_iram_safe(size_t mem_block_symbols, bool with_dma) +{ + rmt_tx_channel_config_t tx_channel_cfg = { + .mem_block_symbols = mem_block_symbols, + .clk_src = RMT_CLK_SRC_DEFAULT, + .resolution_hz = 10000000, // 10MHz, 1 tick = 0.1us (led strip needs a high resolution) + .trans_queue_depth = 4, + .gpio_num = 0, + .flags.with_dma = with_dma, + }; + printf("install tx channel\r\n"); + rmt_channel_handle_t tx_channel_multi_leds = NULL; + TEST_ESP_OK(rmt_new_tx_channel(&tx_channel_cfg, &tx_channel_multi_leds)); + printf("install led strip encoder\r\n"); + rmt_encoder_handle_t led_strip_encoder = NULL; + TEST_ESP_OK(test_rmt_new_led_strip_encoder(&led_strip_encoder)); + printf("enable tx channel\r\n"); + TEST_ESP_OK(rmt_enable(tx_channel_multi_leds)); + + // Mutiple LEDs (ping-pong in the background) + printf("ping pong transmission: light up 100 RGB LEDs\r\n"); + rmt_transmit_config_t transmit_config = { + .loop_count = 0, // no loop + }; + + const int test_led_num = 100; + uint8_t leds_grb[test_led_num * 3]; + // color: Material Design Green-A200 (#69F0AE) + for (int i = 0; i < test_led_num * 3; i += 3) { + leds_grb[i + 0] = 0xF0; + leds_grb[i + 1] = 0x69; + leds_grb[i + 2] = 0xAE; + } + printf("start transmission and stop immediately, only a few LEDs are light up\r\n"); + TEST_ESP_OK(rmt_transmit(tx_channel_multi_leds, led_strip_encoder, leds_grb, test_led_num * 3, &transmit_config)); + // this second transmission will stay in the queue and shouldn't be dispatched until we restart the tx channel later + TEST_ESP_OK(rmt_transmit(tx_channel_multi_leds, led_strip_encoder, leds_grb, test_led_num * 3, &transmit_config)); + + unity_utils_run_cache_disable_stub(test_delay_post_cache_disable, NULL); + + // color: Material Design Orange-900 (#E65100) + for (int i = 0; i < test_led_num * 3; i += 3) { + leds_grb[i + 0] = 0x51; + leds_grb[i + 1] = 0xE6; + leds_grb[i + 2] = 0x00; + } + TEST_ESP_OK(rmt_transmit(tx_channel_multi_leds, led_strip_encoder, leds_grb, test_led_num * 3, &transmit_config)); + TEST_ESP_OK(rmt_tx_wait_all_done(tx_channel_multi_leds, -1)); + + printf("disable tx channel\r\n"); + TEST_ESP_OK(rmt_disable(tx_channel_multi_leds)); + printf("remove tx channel and led strip encoder\r\n"); + TEST_ESP_OK(rmt_del_channel(tx_channel_multi_leds)); + TEST_ESP_OK(rmt_del_encoder(led_strip_encoder)); +} + +TEST_CASE("rmt_tx_iram_safe_no_dma", "[rmt]") +{ + test_rmt_tx_iram_safe(SOC_RMT_MEM_WORDS_PER_CHANNEL, false); +} + +#if SOC_RMT_SUPPORT_DMA +TEST_CASE("rmt_tx_iram_safe_with_dma", "[rmt]") +{ + test_rmt_tx_iram_safe(1024, true); +} +#endif + + +static void IRAM_ATTR test_simulate_input_post_cache_disable(void *args) +{ + int gpio_num = (int)args; + // simulate input signal, should only be recognized as one RMT symbol + gpio_set_level(gpio_num, 0); + esp_rom_delay_us(50); + gpio_set_level(gpio_num, 1); + esp_rom_delay_us(50); + gpio_set_level(gpio_num, 0); + esp_rom_delay_us(20000); +} + +typedef struct { + TaskHandle_t task_to_notify; + size_t received_symbol_num; +} test_nec_rx_user_data_t; + +IRAM_ATTR +static bool test_rmt_rx_done_callback(rmt_channel_handle_t channel, const rmt_rx_done_event_data_t *edata, void *user_data) +{ + BaseType_t high_task_wakeup = pdFALSE; + test_nec_rx_user_data_t *test_user_data = (test_nec_rx_user_data_t *)user_data; + test_user_data->received_symbol_num = edata->num_symbols; + vTaskNotifyGiveFromISR(test_user_data->task_to_notify, &high_task_wakeup); + return high_task_wakeup == pdTRUE; +} + +static void test_rmt_rx_iram_safe(size_t mem_block_symbols, bool with_dma, rmt_clock_source_t clk_src) +{ + rmt_rx_channel_config_t rx_channel_cfg = { + .clk_src = clk_src, + .resolution_hz = 1000000, // 1MHz, 1 tick = 1us + .mem_block_symbols = mem_block_symbols, + .gpio_num = 0, + .flags.with_dma = with_dma, + .flags.io_loop_back = true, // the GPIO will act like a loopback + }; + printf("install rx channel\r\n"); + rmt_channel_handle_t rx_channel = NULL; + TEST_ESP_OK(rmt_new_rx_channel(&rx_channel_cfg, &rx_channel)); + + // initialize the GPIO level to low + TEST_ESP_OK(gpio_set_level(0, 0)); + + printf("register rx event callbacks\r\n"); + rmt_rx_event_callbacks_t cbs = { + .on_recv_done = test_rmt_rx_done_callback, + }; + test_nec_rx_user_data_t test_user_data = { + .task_to_notify = xTaskGetCurrentTaskHandle(), + }; + TEST_ESP_OK(rmt_rx_register_event_callbacks(rx_channel, &cbs, &test_user_data)); + + printf("enable rx channel\r\n"); + TEST_ESP_OK(rmt_enable(rx_channel)); + + rmt_symbol_word_t remote_codes[128]; + + rmt_receive_config_t receive_config = { + .signal_range_min_ns = 1250, + .signal_range_max_ns = 12000000, + }; + + // ready to receive + TEST_ESP_OK(rmt_receive(rx_channel, remote_codes, sizeof(remote_codes), &receive_config)); + + // disable the flash cache, and simulate input signal by GPIO + unity_utils_run_cache_disable_stub(test_simulate_input_post_cache_disable, 0); + TEST_ASSERT_EQUAL(1, test_user_data.received_symbol_num); + + printf("disable rx channels\r\n"); + TEST_ESP_OK(rmt_disable(rx_channel)); + printf("delete channels and encoder\r\n"); + TEST_ESP_OK(rmt_del_channel(rx_channel)); +} + +TEST_CASE("rmt_rx_iram_safe_no_dma", "[rmt]") +{ + test_rmt_rx_iram_safe(SOC_RMT_MEM_WORDS_PER_CHANNEL, false, RMT_CLK_SRC_DEFAULT); +} + +#if SOC_RMT_SUPPORT_DMA +TEST_CASE("rmt_rx_iram_safe_with_dma", "[rmt]") +{ + test_rmt_rx_iram_safe(128, true, RMT_CLK_SRC_DEFAULT); +} +#endif diff --git a/components/driver/test_apps/rmt/main/test_rmt_rx.c b/components/driver/test_apps/rmt/main/test_rmt_rx.c index 72559a4242..dfbcdac378 100644 --- a/components/driver/test_apps/rmt/main/test_rmt_rx.c +++ b/components/driver/test_apps/rmt/main/test_rmt_rx.c @@ -35,8 +35,8 @@ static bool test_rmt_rx_done_callback(rmt_channel_handle_t channel, const rmt_rx for (size_t i = 0; i < edata->num_symbols; i++) { esp_rom_printf("{%d:%d},{%d:%d}\r\n", remote_codes[i].level0, remote_codes[i].duration0, remote_codes[i].level1, remote_codes[i].duration1); } - vTaskNotifyGiveFromISR(test_user_data->task_to_notify, &high_task_wakeup); test_user_data->received_symbol_num = edata->num_symbols; + vTaskNotifyGiveFromISR(test_user_data->task_to_notify, &high_task_wakeup); return high_task_wakeup == pdTRUE; } @@ -100,7 +100,7 @@ static void test_rmt_rx_nec_carrier(size_t mem_block_symbols, bool with_dma, rmt 0x0440, 0x3003 // address, command }, 4, &transmit_config)); TEST_ASSERT_NOT_EQUAL(0, ulTaskNotifyTake(pdFALSE, pdMS_TO_TICKS(1000))); - TEST_ASSERT_EQUAL(test_user_data.received_symbol_num, 34); + TEST_ASSERT_EQUAL(34, test_user_data.received_symbol_num); TEST_ESP_OK(rmt_receive(rx_channel, remote_codes, sizeof(remote_codes), &receive_config)); printf("send NEC frame without carrier\r\n"); @@ -108,7 +108,7 @@ static void test_rmt_rx_nec_carrier(size_t mem_block_symbols, bool with_dma, rmt 0x0440, 0x3003 // address, command }, 4, &transmit_config)); TEST_ASSERT_NOT_EQUAL(0, ulTaskNotifyTake(pdFALSE, pdMS_TO_TICKS(1000))); - TEST_ASSERT_EQUAL(test_user_data.received_symbol_num, 34); + TEST_ASSERT_EQUAL(34, test_user_data.received_symbol_num); #if SOC_RMT_SUPPORT_RX_PINGPONG // ready to receive @@ -118,7 +118,7 @@ static void test_rmt_rx_nec_carrier(size_t mem_block_symbols, bool with_dma, rmt 0xFF00, 0xFF00, 0xFF00, 0xFF00 }, 8, &transmit_config)); TEST_ASSERT_NOT_EQUAL(0, ulTaskNotifyTake(pdFALSE, pdMS_TO_TICKS(1000))); - TEST_ASSERT_EQUAL(test_user_data.received_symbol_num, 66); + TEST_ASSERT_EQUAL(66, test_user_data.received_symbol_num); #else // ready to receive TEST_ESP_OK(rmt_receive(rx_channel, remote_codes, sizeof(remote_codes), &receive_config)); @@ -150,7 +150,7 @@ static void test_rmt_rx_nec_carrier(size_t mem_block_symbols, bool with_dma, rmt 0x0440, 0x3003 // address, command }, 4, &transmit_config)); TEST_ASSERT_NOT_EQUAL(0, ulTaskNotifyTake(pdFALSE, pdMS_TO_TICKS(1000))); - TEST_ASSERT_EQUAL(test_user_data.received_symbol_num, 34); + TEST_ASSERT_EQUAL(34, test_user_data.received_symbol_num); #if SOC_RMT_SUPPORT_RX_PINGPONG TEST_ESP_OK(rmt_receive(rx_channel, remote_codes, sizeof(remote_codes), &receive_config)); @@ -159,7 +159,7 @@ static void test_rmt_rx_nec_carrier(size_t mem_block_symbols, bool with_dma, rmt 0xFF00, 0xFF00, 0xFF00, 0xFF00 }, 8, &transmit_config)); TEST_ASSERT_NOT_EQUAL(0, ulTaskNotifyTake(pdFALSE, pdMS_TO_TICKS(1000))); - TEST_ASSERT_EQUAL(test_user_data.received_symbol_num, 66); + TEST_ASSERT_EQUAL(66, test_user_data.received_symbol_num); #endif // SOC_RMT_SUPPORT_RX_PINGPONG printf("disable modulation and demodulation for tx and rx channels\r\n"); @@ -173,7 +173,7 @@ static void test_rmt_rx_nec_carrier(size_t mem_block_symbols, bool with_dma, rmt 0x0440, 0x3003 // address, command }, 4, &transmit_config)); TEST_ASSERT_NOT_EQUAL(0, ulTaskNotifyTake(pdFALSE, pdMS_TO_TICKS(1000))); - TEST_ASSERT_EQUAL(test_user_data.received_symbol_num, 34); + TEST_ASSERT_EQUAL(34, test_user_data.received_symbol_num); TEST_ESP_OK(rmt_tx_wait_all_done(tx_channel, -1)); printf("disable tx and rx channels\r\n"); diff --git a/components/driver/test_apps/rmt/main/test_util_rmt_encoders.c b/components/driver/test_apps/rmt/main/test_util_rmt_encoders.c index e99bad5d53..ae69e35edb 100644 --- a/components/driver/test_apps/rmt/main/test_util_rmt_encoders.c +++ b/components/driver/test_apps/rmt/main/test_util_rmt_encoders.c @@ -6,8 +6,16 @@ #include #include #include +#include "sdkconfig.h" #include "unity.h" #include "driver/rmt_encoder.h" +#include "esp_attr.h" + +#if CONFIG_RMT_ISR_IRAM_SAFE +#define TEST_RMT_ENCODER_ATTR IRAM_ATTR +#else +#define TEST_RMT_ENCODER_ATTR +#endif typedef struct { rmt_encoder_t base; @@ -17,6 +25,7 @@ typedef struct { rmt_symbol_word_t reset_code; } rmt_led_strip_encoder_t; +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); diff --git a/components/driver/test_apps/rmt/sdkconfig.ci.iram_safe b/components/driver/test_apps/rmt/sdkconfig.ci.iram_safe index 086b2260dd..3e489aef4b 100644 --- a/components/driver/test_apps/rmt/sdkconfig.ci.iram_safe +++ b/components/driver/test_apps/rmt/sdkconfig.ci.iram_safe @@ -1,5 +1,6 @@ CONFIG_COMPILER_DUMP_RTL_FILES=y CONFIG_RMT_ISR_IRAM_SAFE=y +CONFIG_GPIO_CTRL_FUNC_IN_IRAM=y CONFIG_COMPILER_OPTIMIZATION_NONE=y # silent the error check, as the error string are stored in rodata, causing RTL check failure CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y diff --git a/components/hal/esp32/include/hal/rmt_ll.h b/components/hal/esp32/include/hal/rmt_ll.h index b1735e5e6b..9936a5cf78 100644 --- a/components/hal/esp32/include/hal/rmt_ll.h +++ b/components/hal/esp32/include/hal/rmt_ll.h @@ -504,48 +504,57 @@ static inline uint32_t rmt_ll_rx_get_interrupt_status(rmt_dev_t *dev, uint32_t c /////////////////////////////They might be removed in the next major release (ESP-IDF 6.0)////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_status_word(rmt_dev_t *dev, uint32_t channel) { return dev->status_ch[channel]; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_status_word(rmt_dev_t *dev, uint32_t channel) { return dev->status_ch[channel]; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel) { uint32_t div = HAL_FORCE_READ_U32_REG_FIELD(dev->conf_ch[channel].conf0, div_cnt); return div == 0 ? 256 : div; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel) { uint32_t div = HAL_FORCE_READ_U32_REG_FIELD(dev->conf_ch[channel].conf0, div_cnt); return div == 0 ? 256 : div; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_idle_thres(rmt_dev_t *dev, uint32_t channel) { return HAL_FORCE_READ_U32_REG_FIELD(dev->conf_ch[channel].conf0, idle_thres); } +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_mem_blocks(rmt_dev_t *dev, uint32_t channel) { return dev->conf_ch[channel].conf0.mem_size; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_mem_blocks(rmt_dev_t *dev, uint32_t channel) { return dev->conf_ch[channel].conf0.mem_size; } +__attribute__((always_inline)) static inline bool rmt_ll_tx_is_loop_enabled(rmt_dev_t *dev, uint32_t channel) { return dev->conf_ch[channel].conf1.tx_conti_mode; } +__attribute__((always_inline)) static inline rmt_clock_source_t rmt_ll_get_group_clock_src(rmt_dev_t *dev, uint32_t channel) { if (dev->conf_ch[channel].conf1.ref_always_on) { @@ -554,11 +563,13 @@ static inline rmt_clock_source_t rmt_ll_get_group_clock_src(rmt_dev_t *dev, uint return RMT_CLK_SRC_REF_TICK; } +__attribute__((always_inline)) static inline bool rmt_ll_tx_is_idle_enabled(rmt_dev_t *dev, uint32_t channel) { return dev->conf_ch[channel].conf1.idle_out_en; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_idle_level(rmt_dev_t *dev, uint32_t channel) { return dev->conf_ch[channel].conf1.idle_out_lv; @@ -570,11 +581,13 @@ static inline bool rmt_ll_is_mem_powered_down(rmt_dev_t *dev) return dev->conf_ch[0].conf0.mem_pd; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_mem_owner(rmt_dev_t *dev, uint32_t channel) { return dev->conf_ch[channel].conf1.mem_owner; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_end_interrupt_status(rmt_dev_t *dev) { uint32_t status = dev->int_st.val; @@ -582,6 +595,7 @@ static inline uint32_t rmt_ll_get_tx_end_interrupt_status(rmt_dev_t *dev) ((status & 0x1000) >> 8) | ((status & 0x8000) >> 10) | ((status & 0x40000) >> 12) | ((status & 0x200000) >> 14); } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_rx_end_interrupt_status(rmt_dev_t *dev) { uint32_t status = dev->int_st.val; @@ -589,6 +603,7 @@ static inline uint32_t rmt_ll_get_rx_end_interrupt_status(rmt_dev_t *dev) ((status & 0x2000) >> 9) | ((status & 0x10000) >> 11) | ((status & 0x80000) >> 13) | ((status & 0x400000) >> 15); } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_err_interrupt_status(rmt_dev_t *dev) { uint32_t status = dev->int_st.val; @@ -596,6 +611,7 @@ static inline uint32_t rmt_ll_get_tx_err_interrupt_status(rmt_dev_t *dev) ((status & 0x4000) >> 10) | ((status & 0x20000) >> 12) | ((status & 0x100000) >> 14) | ((status & 0x800000) >> 16); } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_rx_err_interrupt_status(rmt_dev_t *dev) { uint32_t status = dev->int_st.val; @@ -603,6 +619,7 @@ static inline uint32_t rmt_ll_get_rx_err_interrupt_status(rmt_dev_t *dev) ((status & 0x4000) >> 10) | ((status & 0x20000) >> 12) | ((status & 0x100000) >> 14) | ((status & 0x800000) >> 16); } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_thres_interrupt_status(rmt_dev_t *dev) { uint32_t status = dev->int_st.val; diff --git a/components/hal/esp32c3/include/hal/rmt_ll.h b/components/hal/esp32c3/include/hal/rmt_ll.h index 177e4ecea8..2658a453bf 100644 --- a/components/hal/esp32c3/include/hal/rmt_ll.h +++ b/components/hal/esp32c3/include/hal/rmt_ll.h @@ -684,48 +684,57 @@ static inline uint32_t rmt_ll_rx_get_interrupt_status(rmt_dev_t *dev, uint32_t c /////////////////////////////They might be removed in the next major release (ESP-IDF 6.0)////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_status_word(rmt_dev_t *dev, uint32_t channel) { return dev->tx_status[channel].val; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_status_word(rmt_dev_t *dev, uint32_t channel) { return dev->rx_status[channel].val; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel) { uint32_t div = HAL_FORCE_READ_U32_REG_FIELD(dev->tx_conf[channel], div_cnt); return div == 0 ? 256 : div; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel) { uint32_t div = HAL_FORCE_READ_U32_REG_FIELD(dev->rx_conf[channel].conf0, div_cnt); return div == 0 ? 256 : div; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_idle_thres(rmt_dev_t *dev, uint32_t channel) { return dev->rx_conf[channel].conf0.idle_thres; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_mem_blocks(rmt_dev_t *dev, uint32_t channel) { return dev->tx_conf[channel].mem_size; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_mem_blocks(rmt_dev_t *dev, uint32_t channel) { return dev->rx_conf[channel].conf0.mem_size; } +__attribute__((always_inline)) static inline bool rmt_ll_tx_is_loop_enabled(rmt_dev_t *dev, uint32_t channel) { return dev->tx_conf[channel].tx_conti_mode; } +__attribute__((always_inline)) static inline rmt_clock_source_t rmt_ll_get_group_clock_src(rmt_dev_t *dev, uint32_t channel) { rmt_clock_source_t clk_src = RMT_CLK_SRC_APB; @@ -743,11 +752,13 @@ static inline rmt_clock_source_t rmt_ll_get_group_clock_src(rmt_dev_t *dev, uint return clk_src; } +__attribute__((always_inline)) static inline bool rmt_ll_tx_is_idle_enabled(rmt_dev_t *dev, uint32_t channel) { return dev->tx_conf[channel].idle_out_en; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_idle_level(rmt_dev_t *dev, uint32_t channel) { return dev->tx_conf[channel].idle_out_lv; @@ -761,46 +772,55 @@ static inline bool rmt_ll_is_mem_powered_down(rmt_dev_t *dev) return (dev->sys_conf.mem_force_pd) || !(dev->sys_conf.mem_force_pu); } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_mem_owner(rmt_dev_t *dev, uint32_t channel) { return dev->rx_conf[channel].conf1.mem_owner; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_limit(rmt_dev_t *dev, uint32_t channel) { return dev->rx_lim[channel].rx_lim; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_end_interrupt_status(rmt_dev_t *dev) { return dev->int_st.val & 0x03; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_rx_end_interrupt_status(rmt_dev_t *dev) { return (dev->int_st.val >> 2) & 0x03; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_err_interrupt_status(rmt_dev_t *dev) { return (dev->int_st.val >> 4) & 0x03; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_rx_err_interrupt_status(rmt_dev_t *dev) { return (dev->int_st.val >> 6) & 0x03; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_thres_interrupt_status(rmt_dev_t *dev) { return (dev->int_st.val >> 8) & 0x03; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_rx_thres_interrupt_status(rmt_dev_t *dev) { return (dev->int_st.val >> 10) & 0x03; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_loop_interrupt_status(rmt_dev_t *dev) { return (dev->int_st.val >> 12) & 0x03; diff --git a/components/hal/esp32h2/include/hal/rmt_ll.h b/components/hal/esp32h2/include/hal/rmt_ll.h index ce76e09e73..5e9a3f38e0 100644 --- a/components/hal/esp32h2/include/hal/rmt_ll.h +++ b/components/hal/esp32h2/include/hal/rmt_ll.h @@ -684,48 +684,57 @@ static inline uint32_t rmt_ll_rx_get_interrupt_status(rmt_dev_t *dev, uint32_t c /////////////////////////////They might be removed in the next major release (ESP-IDF 6.0)////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_status_word(rmt_dev_t *dev, uint32_t channel) { return dev->tx_status[channel].val; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_status_word(rmt_dev_t *dev, uint32_t channel) { return dev->rx_status[channel].val; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel) { uint32_t div = HAL_FORCE_READ_U32_REG_FIELD(dev->tx_conf[channel], div_cnt); return div == 0 ? 256 : div; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel) { uint32_t div = HAL_FORCE_READ_U32_REG_FIELD(dev->rx_conf[channel].conf0, div_cnt); return div == 0 ? 256 : div; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_idle_thres(rmt_dev_t *dev, uint32_t channel) { return dev->rx_conf[channel].conf0.idle_thres; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_mem_blocks(rmt_dev_t *dev, uint32_t channel) { return dev->tx_conf[channel].mem_size; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_mem_blocks(rmt_dev_t *dev, uint32_t channel) { return dev->rx_conf[channel].conf0.mem_size; } +__attribute__((always_inline)) static inline bool rmt_ll_tx_is_loop_enabled(rmt_dev_t *dev, uint32_t channel) { return dev->tx_conf[channel].tx_conti_mode; } +__attribute__((always_inline)) static inline rmt_clock_source_t rmt_ll_get_group_clock_src(rmt_dev_t *dev, uint32_t channel) { rmt_clock_source_t clk_src = RMT_CLK_SRC_AHB; @@ -743,11 +752,13 @@ static inline rmt_clock_source_t rmt_ll_get_group_clock_src(rmt_dev_t *dev, uint return clk_src; } +__attribute__((always_inline)) static inline bool rmt_ll_tx_is_idle_enabled(rmt_dev_t *dev, uint32_t channel) { return dev->tx_conf[channel].idle_out_en; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_idle_level(rmt_dev_t *dev, uint32_t channel) { return dev->tx_conf[channel].idle_out_lv; @@ -761,46 +772,55 @@ static inline bool rmt_ll_is_mem_powered_down(rmt_dev_t *dev) return (dev->sys_conf.mem_force_pd) || !(dev->sys_conf.mem_force_pu); } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_mem_owner(rmt_dev_t *dev, uint32_t channel) { return dev->rx_conf[channel].conf1.mem_owner; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_limit(rmt_dev_t *dev, uint32_t channel) { return dev->rx_lim[channel].rx_lim; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_end_interrupt_status(rmt_dev_t *dev) { return dev->int_st.val & 0x03; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_rx_end_interrupt_status(rmt_dev_t *dev) { return (dev->int_st.val >> 2) & 0x03; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_err_interrupt_status(rmt_dev_t *dev) { return (dev->int_st.val >> 4) & 0x03; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_rx_err_interrupt_status(rmt_dev_t *dev) { return (dev->int_st.val >> 6) & 0x03; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_thres_interrupt_status(rmt_dev_t *dev) { return (dev->int_st.val >> 8) & 0x03; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_rx_thres_interrupt_status(rmt_dev_t *dev) { return (dev->int_st.val >> 10) & 0x03; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_loop_interrupt_status(rmt_dev_t *dev) { return (dev->int_st.val >> 12) & 0x03; diff --git a/components/hal/esp32s2/include/hal/rmt_ll.h b/components/hal/esp32s2/include/hal/rmt_ll.h index 5a453d1f32..49ad57b9f0 100644 --- a/components/hal/esp32s2/include/hal/rmt_ll.h +++ b/components/hal/esp32s2/include/hal/rmt_ll.h @@ -649,48 +649,57 @@ static inline uint32_t rmt_ll_rx_get_interrupt_status(rmt_dev_t *dev, uint32_t c /////////////////////////////They might be removed in the next major release (ESP-IDF 6.0)////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_status_word(rmt_dev_t *dev, uint32_t channel) { return dev->chnstatus[channel].val; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_status_word(rmt_dev_t *dev, uint32_t channel) { return dev->chnstatus[channel].val; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel) { uint32_t div = HAL_FORCE_READ_U32_REG_FIELD(dev->conf_ch[channel].conf0, div_cnt_chn); return div == 0 ? 256 : div; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel) { uint32_t div = HAL_FORCE_READ_U32_REG_FIELD(dev->conf_ch[channel].conf0, div_cnt_chn); return div == 0 ? 256 : div; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_idle_thres(rmt_dev_t *dev, uint32_t channel) { return HAL_FORCE_READ_U32_REG_FIELD(dev->conf_ch[channel].conf0, idle_thres_chn); } +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_mem_blocks(rmt_dev_t *dev, uint32_t channel) { return dev->conf_ch[channel].conf0.mem_size_chn; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_mem_blocks(rmt_dev_t *dev, uint32_t channel) { return dev->conf_ch[channel].conf0.mem_size_chn; } +__attribute__((always_inline)) static inline bool rmt_ll_tx_is_loop_enabled(rmt_dev_t *dev, uint32_t channel) { return dev->conf_ch[channel].conf1.tx_conti_mode_chn; } +__attribute__((always_inline)) static inline rmt_clock_source_t rmt_ll_get_group_clock_src(rmt_dev_t *dev, uint32_t channel) { if (dev->conf_ch[channel].conf1.ref_always_on_chn) { @@ -699,11 +708,13 @@ static inline rmt_clock_source_t rmt_ll_get_group_clock_src(rmt_dev_t *dev, uint return RMT_CLK_SRC_REF_TICK; } +__attribute__((always_inline)) static inline bool rmt_ll_tx_is_idle_enabled(rmt_dev_t *dev, uint32_t channel) { return dev->conf_ch[channel].conf1.idle_out_en_chn; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_idle_level(rmt_dev_t *dev, uint32_t channel) { return dev->conf_ch[channel].conf1.idle_out_lv_chn; @@ -717,41 +728,48 @@ static inline bool rmt_ll_is_mem_powered_down(rmt_dev_t *dev) return (dev->apb_conf.mem_force_pd) || !(dev->apb_conf.mem_force_pu); } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_mem_owner(rmt_dev_t *dev, uint32_t channel) { return dev->conf_ch[channel].conf1.mem_owner_chn; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_end_interrupt_status(rmt_dev_t *dev) { uint32_t status = dev->int_st.val; return ((status & 0x01) >> 0) | ((status & 0x08) >> 2) | ((status & 0x40) >> 4) | ((status & 0x200) >> 6); } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_rx_end_interrupt_status(rmt_dev_t *dev) { uint32_t status = dev->int_st.val; return ((status & 0x02) >> 1) | ((status & 0x10) >> 3) | ((status & 0x80) >> 5) | ((status & 0x400) >> 7); } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_err_interrupt_status(rmt_dev_t *dev) { uint32_t status = dev->int_st.val; return ((status & 0x04) >> 2) | ((status & 0x20) >> 4) | ((status & 0x100) >> 6) | ((status & 0x800) >> 8); } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_rx_err_interrupt_status(rmt_dev_t *dev) { uint32_t status = dev->int_st.val; return ((status & 0x04) >> 2) | ((status & 0x20) >> 4) | ((status & 0x100) >> 6) | ((status & 0x800) >> 8); } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_thres_interrupt_status(rmt_dev_t *dev) { uint32_t status = dev->int_st.val; return (status & 0xF000) >> 12; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_loop_interrupt_status(rmt_dev_t *dev) { uint32_t status = dev->int_st.val; diff --git a/components/hal/esp32s3/include/hal/rmt_ll.h b/components/hal/esp32s3/include/hal/rmt_ll.h index 7b2ba02876..2096a92624 100644 --- a/components/hal/esp32s3/include/hal/rmt_ll.h +++ b/components/hal/esp32s3/include/hal/rmt_ll.h @@ -722,48 +722,57 @@ static inline uint32_t rmt_ll_rx_get_interrupt_status(rmt_dev_t *dev, uint32_t c /////////////////////////////They might be removed in the next major release (ESP-IDF 6.0)////////////////////////////// //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_status_word(rmt_dev_t *dev, uint32_t channel) { return dev->chnstatus[channel].val; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_status_word(rmt_dev_t *dev, uint32_t channel) { return dev->chmstatus[channel].val; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel) { uint32_t div = HAL_FORCE_READ_U32_REG_FIELD(dev->chnconf0[channel], div_cnt_chn); return div == 0 ? 256 : div; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_channel_clock_div(rmt_dev_t *dev, uint32_t channel) { uint32_t div = HAL_FORCE_READ_U32_REG_FIELD(dev->chmconf[channel].conf0, div_cnt_chm); return div == 0 ? 256 : div; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_idle_thres(rmt_dev_t *dev, uint32_t channel) { return dev->chmconf[channel].conf0.idle_thres_chm; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_mem_blocks(rmt_dev_t *dev, uint32_t channel) { return dev->chnconf0[channel].mem_size_chn; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_mem_blocks(rmt_dev_t *dev, uint32_t channel) { return dev->chmconf[channel].conf0.mem_size_chm; } +__attribute__((always_inline)) static inline bool rmt_ll_tx_is_loop_enabled(rmt_dev_t *dev, uint32_t channel) { return dev->chnconf0[channel].tx_conti_mode_chn; } +__attribute__((always_inline)) static inline rmt_clock_source_t rmt_ll_get_group_clock_src(rmt_dev_t *dev, uint32_t channel) { rmt_clock_source_t clk_src = RMT_CLK_SRC_APB; @@ -781,11 +790,13 @@ static inline rmt_clock_source_t rmt_ll_get_group_clock_src(rmt_dev_t *dev, uint return clk_src; } +__attribute__((always_inline)) static inline bool rmt_ll_tx_is_idle_enabled(rmt_dev_t *dev, uint32_t channel) { return dev->chnconf0[channel].idle_out_en_chn; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_tx_get_idle_level(rmt_dev_t *dev, uint32_t channel) { return dev->chnconf0[channel].idle_out_lv_chn; @@ -799,46 +810,55 @@ static inline bool rmt_ll_is_mem_powered_down(rmt_dev_t *dev) return (dev->sys_conf.mem_force_pd) || !(dev->sys_conf.mem_force_pu); } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_mem_owner(rmt_dev_t *dev, uint32_t channel) { return dev->chmconf[channel].conf1.mem_owner_chm; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_rx_get_limit(rmt_dev_t *dev, uint32_t channel) { return dev->chm_rx_lim[channel].rx_lim_chm; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_end_interrupt_status(rmt_dev_t *dev) { return dev->int_st.val & 0x0F; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_rx_end_interrupt_status(rmt_dev_t *dev) { return (dev->int_st.val >> 16) & 0x0F; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_err_interrupt_status(rmt_dev_t *dev) { return (dev->int_st.val >> 4) & 0x0F; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_rx_err_interrupt_status(rmt_dev_t *dev) { return (dev->int_st.val >> 20) & 0x0F; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_thres_interrupt_status(rmt_dev_t *dev) { return (dev->int_st.val >> 8) & 0x0F; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_rx_thres_interrupt_status(rmt_dev_t *dev) { return (dev->int_st.val >> 24) & 0x0F; } +__attribute__((always_inline)) static inline uint32_t rmt_ll_get_tx_loop_interrupt_status(rmt_dev_t *dev) { return (dev->int_st.val >> 12) & 0x0F;