mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
rmt: add iram safe test
Closes https://github.com/espressif/esp-idf/issues/9487
This commit is contained in:
parent
f24983a942
commit
6f2ac1ce2a
@ -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
|
||||
|
@ -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")
|
||||
|
@ -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));
|
||||
}
|
||||
|
@ -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)
|
||||
|
180
components/driver/test_apps/rmt/main/test_rmt_iram.c
Normal file
180
components/driver/test_apps/rmt/main/test_rmt_iram.c
Normal file
@ -0,0 +1,180 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#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
|
@ -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");
|
||||
|
@ -6,8 +6,16 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/cdefs.h>
|
||||
#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);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user