mirror of
https://github.com/espressif/esp-idf
synced 2025-03-10 09:39:10 -04:00
Merge branch 'bugfix/fix_bugs_in_rtcio_unit_test' into 'master'
bugfix(ut): fix rtcio pullup/pulldown and rtcio hold unit test Closes IDFCI-96 See merge request espressif/esp-idf!10015
This commit is contained in:
commit
3b617dd94c
@ -22,6 +22,56 @@
|
||||
#define TEST_COUNT 10
|
||||
static const char *TAG = "rtcio_test";
|
||||
|
||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
||||
#define TEST_GPIO_PIN_COUNT 16
|
||||
const int s_test_map[TEST_GPIO_PIN_COUNT] = {
|
||||
// GPIO_NUM_0, //GPIO0 // Workaround: GPIO0 is strap pin, can not be used pullup/pulldown test.
|
||||
GPIO_NUM_2, //GPIO2
|
||||
GPIO_NUM_4, //GPIO4
|
||||
// GPIO_NUM_12, //GPIO12 // Workaround: GPIO12 is strap pin, can not be used pullup/pulldown test.
|
||||
GPIO_NUM_13, //GPIO13
|
||||
GPIO_NUM_14, //GPIO14
|
||||
GPIO_NUM_15, //GPIO15
|
||||
GPIO_NUM_25, //GPIO25
|
||||
GPIO_NUM_26, //GPIO26
|
||||
GPIO_NUM_27, //GPIO27
|
||||
GPIO_NUM_32, //GPIO32
|
||||
GPIO_NUM_33, //GPIO33
|
||||
GPIO_NUM_34, //GPIO34
|
||||
GPIO_NUM_35, //GPIO35
|
||||
GPIO_NUM_36, //GPIO36
|
||||
GPIO_NUM_37, //GPIO37
|
||||
GPIO_NUM_38, //GPIO38
|
||||
GPIO_NUM_39, //GPIO39
|
||||
};
|
||||
#elif defined CONFIG_IDF_TARGET_ESP32S2
|
||||
#define TEST_GPIO_PIN_COUNT 20
|
||||
const int s_test_map[TEST_GPIO_PIN_COUNT] = {
|
||||
// GPIO_NUM_0, //GPIO0 // Workaround: GPIO0 is strap pin, can not be used pullup/pulldown test.
|
||||
GPIO_NUM_1, //GPIO1
|
||||
GPIO_NUM_2, //GPIO2
|
||||
GPIO_NUM_3, //GPIO3
|
||||
GPIO_NUM_4, //GPIO4
|
||||
GPIO_NUM_5, //GPIO5
|
||||
GPIO_NUM_6, //GPIO6
|
||||
GPIO_NUM_7, //GPIO7
|
||||
GPIO_NUM_8, //GPIO8
|
||||
GPIO_NUM_9, //GPIO9
|
||||
GPIO_NUM_10, //GPIO10
|
||||
GPIO_NUM_11, //GPIO11
|
||||
GPIO_NUM_12, //GPIO12
|
||||
GPIO_NUM_13, //GPIO13
|
||||
GPIO_NUM_14, //GPIO14
|
||||
GPIO_NUM_15, //GPIO15
|
||||
GPIO_NUM_16, //GPIO16
|
||||
GPIO_NUM_17, //GPIO17
|
||||
// GPIO_NUM_18, //GPIO18 // Workaround: IO18 is pullup outside in ESP32S2-Saola Runner.
|
||||
GPIO_NUM_19, //GPIO19
|
||||
GPIO_NUM_20, //GPIO20
|
||||
GPIO_NUM_21, //GPIO21
|
||||
};
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Test output/input function.
|
||||
*/
|
||||
@ -71,33 +121,33 @@ TEST_CASE("RTCIO pullup/pulldown test", "[rtcio]")
|
||||
{
|
||||
ESP_LOGI(TAG, "RTCIO pullup/pulldown test");
|
||||
// init rtcio
|
||||
for (int i = 0; i < GPIO_PIN_COUNT; i++) {
|
||||
int num = rtc_io_number_get(i);
|
||||
if (rtc_gpio_is_valid_gpio(i) && num > 0 && rtc_io_desc[num].pullup != 0) {
|
||||
RTCIO_CHECK( rtc_gpio_init(i) );
|
||||
RTCIO_CHECK( rtc_gpio_set_direction(i, RTC_GPIO_MODE_INPUT_ONLY) );
|
||||
RTCIO_CHECK( rtc_gpio_pullup_dis(i) );
|
||||
RTCIO_CHECK( rtc_gpio_pulldown_dis(i) );
|
||||
ESP_LOGI(TAG, "gpio %d init", i);
|
||||
for (int i = 0; i < TEST_GPIO_PIN_COUNT; i++) {
|
||||
int num = rtc_io_number_get(s_test_map[i]);
|
||||
if (rtc_gpio_is_valid_gpio(s_test_map[i]) && num > 0 && rtc_io_desc[num].pullup != 0) {
|
||||
RTCIO_CHECK( rtc_gpio_init(s_test_map[i]) );
|
||||
RTCIO_CHECK( rtc_gpio_set_direction(s_test_map[i], RTC_GPIO_MODE_INPUT_ONLY) );
|
||||
RTCIO_CHECK( rtc_gpio_pullup_dis(s_test_map[i]) );
|
||||
RTCIO_CHECK( rtc_gpio_pulldown_dis(s_test_map[i]) );
|
||||
ESP_LOGI(TAG, "gpio %d init", s_test_map[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int cnt = 0; cnt < TEST_COUNT; cnt++) {
|
||||
uint32_t level = cnt % 2;
|
||||
ESP_LOGI(TAG, "RTCIO pull level %d", level);
|
||||
for (int i = 0; i < GPIO_PIN_COUNT; i++) {
|
||||
int num = rtc_io_number_get(i);
|
||||
if (rtc_gpio_is_valid_gpio(i) && num > 0 && rtc_io_desc[num].pullup != 0) {
|
||||
for (int i = 0; i < TEST_GPIO_PIN_COUNT; i++) {
|
||||
int num = rtc_io_number_get(s_test_map[i]);
|
||||
if (rtc_gpio_is_valid_gpio(s_test_map[i]) && num > 0 && rtc_io_desc[num].pullup != 0) {
|
||||
if (level) {
|
||||
RTCIO_CHECK( rtc_gpio_pulldown_dis(i) );
|
||||
RTCIO_CHECK( rtc_gpio_pullup_en(i) );
|
||||
RTCIO_CHECK( rtc_gpio_pulldown_dis(s_test_map[i]) );
|
||||
RTCIO_CHECK( rtc_gpio_pullup_en(s_test_map[i]) );
|
||||
} else {
|
||||
RTCIO_CHECK( rtc_gpio_pullup_dis(i) );
|
||||
RTCIO_CHECK( rtc_gpio_pulldown_en(i) );
|
||||
RTCIO_CHECK( rtc_gpio_pullup_dis(s_test_map[i]) );
|
||||
RTCIO_CHECK( rtc_gpio_pulldown_en(s_test_map[i]) );
|
||||
}
|
||||
vTaskDelay(20 / portTICK_RATE_MS);
|
||||
if (rtc_gpio_get_level(i) != level) {
|
||||
ESP_LOGE(TAG, "RTCIO pullup/pulldown test err, gpio%d", i);
|
||||
if (rtc_gpio_get_level(s_test_map[i]) != level) {
|
||||
ESP_LOGE(TAG, "RTCIO pullup/pulldown test err, gpio%d", s_test_map[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -105,10 +155,10 @@ TEST_CASE("RTCIO pullup/pulldown test", "[rtcio]")
|
||||
}
|
||||
|
||||
// Deinit rtcio
|
||||
for (int i = 0; i < GPIO_PIN_COUNT; i++) {
|
||||
int num = rtc_io_number_get(i);
|
||||
if (rtc_gpio_is_valid_gpio(i) && num > 0 && rtc_io_desc[num].pullup != 0) {
|
||||
RTCIO_CHECK( rtc_gpio_deinit(i) );
|
||||
for (int i = 0; i < TEST_GPIO_PIN_COUNT; i++) {
|
||||
int num = rtc_io_number_get(s_test_map[i]);
|
||||
if (rtc_gpio_is_valid_gpio(s_test_map[i]) && num > 0 && rtc_io_desc[num].pullup != 0) {
|
||||
RTCIO_CHECK( rtc_gpio_deinit(s_test_map[i]) );
|
||||
}
|
||||
}
|
||||
ESP_LOGI(TAG, "RTCIO pullup/pulldown test over");
|
||||
@ -188,7 +238,11 @@ TEST_CASE("RTCIO output hold test", "[rtcio]")
|
||||
}
|
||||
|
||||
//unhold all rtcio.
|
||||
rtc_gpio_force_hold_dis_all();
|
||||
for (int i = 0; i < GPIO_PIN_COUNT; i++) {
|
||||
if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(i)) {
|
||||
RTCIO_CHECK( rtc_gpio_hold_dis(i) );
|
||||
}
|
||||
}
|
||||
|
||||
// check the unhold status
|
||||
for (int cnt = 0; cnt < 4; cnt++) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user