test(rmt): the way to keep io level after channel delete

Closes https://github.com/espressif/esp-idf/issues/15049
This commit is contained in:
morris
2024-10-14 18:26:06 +08:00
parent bd5945d1cc
commit c4173b298d
2 changed files with 37 additions and 7 deletions

View File

@@ -100,7 +100,7 @@ TEST_CASE("rmt channel install & uninstall", "[rmt]")
#endif // SOC_RMT_SUPPORT_DMA
}
TEST_CASE("RMT interrupt priority", "[rmt]")
TEST_CASE("rmt interrupt priority", "[rmt]")
{
rmt_tx_channel_config_t tx_channel_cfg = {
.mem_block_symbols = SOC_RMT_MEM_WORDS_PER_CHANNEL,

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -10,6 +10,7 @@
#include "freertos/task.h"
#include "unity.h"
#include "driver/rmt_tx.h"
#include "driver/gpio.h"
#include "esp_timer.h"
#include "soc/soc_caps.h"
#include "test_util_rmt_encoders.h"
@@ -23,12 +24,24 @@
TEST_CASE("rmt bytes encoder", "[rmt]")
{
// If you want to keep the IO level after unintall the RMT channel, a workaround is to set the pull up/down register here
// because when we uninstall the RMT channel, we will also disable the GPIO output
gpio_config_t io_conf = {
.pin_bit_mask = (1ULL << TEST_RMT_GPIO_NUM_B),
.mode = GPIO_MODE_INPUT,
.pull_up_en = GPIO_PULLUP_DISABLE,
// Note: make sure the test board doesn't have a pull-up resistor attached to the GPIO, otherwise this test case will fail in the check
.pull_down_en = GPIO_PULLDOWN_ENABLE,
.intr_type = GPIO_INTR_DISABLE,
};
TEST_ESP_OK(gpio_config(&io_conf));
rmt_tx_channel_config_t tx_channel_cfg = {
.mem_block_symbols = SOC_RMT_MEM_WORDS_PER_CHANNEL,
.clk_src = RMT_CLK_SRC_DEFAULT,
.resolution_hz = 1000000, // 1MHz, 1 tick = 1us
.trans_queue_depth = 4,
.gpio_num = TEST_RMT_GPIO_NUM_A,
.gpio_num = TEST_RMT_GPIO_NUM_B,
.intr_priority = 3
};
printf("install tx channel\r\n");
@@ -73,14 +86,31 @@ TEST_CASE("rmt bytes encoder", "[rmt]")
vTaskDelay(pdMS_TO_TICKS(500));
printf("disable tx channel\r\n");
TEST_ESP_OK(rmt_disable(tx_channel));
printf("remove tx channel\r\n");
TEST_ESP_OK(rmt_del_channel(tx_channel));
vTaskDelay(pdMS_TO_TICKS(500));
// check the IO level after uninstall the RMT channel
TEST_ASSERT_EQUAL(0, gpio_get_level(TEST_RMT_GPIO_NUM_B));
printf("install tx channel again\r\n");
TEST_ESP_OK(rmt_new_tx_channel(&tx_channel_cfg, &tx_channel));
printf("enable tx channel\r\n");
TEST_ESP_OK(rmt_enable(tx_channel));
printf("start transaction\r\n");
TEST_ESP_OK(rmt_transmit(tx_channel, bytes_encoder, (uint8_t[]) {
0x00, 0x01, 0x02, 0x03, 0x04, 0x05
}, 6, &transmit_config));
// adding extra delay here for visualizing
vTaskDelay(pdMS_TO_TICKS(500));
TEST_ESP_OK(rmt_disable(tx_channel));
printf("remove tx channel and encoder\r\n");
TEST_ESP_OK(rmt_del_channel(tx_channel));
TEST_ESP_OK(rmt_del_encoder(bytes_encoder));
// Test if intr_priority check works
tx_channel_cfg.intr_priority = 4; // 4 is an invalid interrupt priority
TEST_ESP_ERR(rmt_new_tx_channel(&tx_channel_cfg, &tx_channel), ESP_ERR_INVALID_ARG);
}
static void test_rmt_channel_single_trans(size_t mem_block_symbols, bool with_dma)