change(pm): change test_io_wakeup

This commit is contained in:
Lou Tianhao 2024-01-10 10:44:53 +08:00 committed by BOT
parent 0cdaf0008d
commit 229a974252
2 changed files with 56 additions and 6 deletions

View File

@ -344,6 +344,48 @@ static void register_gpio_control(void)
ESP_ERROR_CHECK(esp_console_cmd_register(&cmd));
}
static struct {
struct arg_end *end;
} wakeup_cause_args;
static int process_get_wakeup_cause(int argc, char **argv)
{
int nerrors = arg_parse(argc, argv, (void **) &wakeup_cause_args);
if (nerrors != 0) {
arg_print_errors(stderr, sleep_args.end, argv[0]);
return 1;
}
switch (esp_sleep_get_wakeup_cause()) {
case ESP_SLEEP_WAKEUP_EXT1: {
printf("Wake up from EXT1\n");
break;
}
case ESP_SLEEP_WAKEUP_GPIO: {
printf("Wake up from GPIO\n");
break;
}
default: {
printf("Wakeup cause err\n");
}
}
return 0;
}
static void register_get_wakeup_cause(void)
{
wakeup_cause_args.end = arg_end(1);
const esp_console_cmd_t cmd = {
.command = "cause",
.help = "get the wakeup cause",
.hint = NULL,
.func = &process_get_wakeup_cause,
.argtable = &wakeup_cause_args
};
ESP_ERROR_CHECK(esp_console_cmd_register(&cmd));
}
void register_io_wakeup_cmd(void)
{
register_sleep();
@ -355,4 +397,5 @@ void register_io_wakeup_cmd(void)
#if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP
register_rtcio_wakeup();
#endif
register_get_wakeup_cause();
}

View File

@ -16,13 +16,13 @@ TEST_CONFIGS = [
# ESP32S2: need to fix GPIO43 bug
# ESP32S3: need to fix GPIO33, GPIO34 and GPIO43 bug
available_gpio_nums = {
'esp32': [0, 2, 4, 5, 12, 13, 14, 15, 18, 19, 21, 22, 23, 27],
'esp32s2': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 21, 33, 34, 35, 36, 37, 38, 39, 40, 42, 45],
'esp32s3': [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 21, 35, 36, 37, 39, 40, 42, 45, 46],
'esp32c2': [0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 18],
'esp32c3': [0, 1, 2, 3, 4, 5, 6, 7, 9, 10, 18, 19],
'esp32': [2, 4, 5, 12, 13, 14, 15, 18, 19, 21, 22, 23, 27],
'esp32s2': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 21, 33, 34, 35, 36, 37, 38, 39, 40, 42, 45],
'esp32s3': [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 21, 35, 36, 37, 39, 40, 42, 45, 46],
'esp32c2': [0, 1, 2, 3, 4, 5, 6, 7, 10, 18],
'esp32c3': [0, 1, 2, 3, 4, 5, 6, 7, 10, 18, 19],
'esp32c6': [0, 1, 2, 3, 4, 5, 6, 7, 10, 11, 12, 13, 15, 18, 19, 20, 21, 22, 23],
'esp32h2': [0, 1, 2, 3, 4, 5, 9, 10, 11, 12, 22, 25, 26, 27],
'esp32h2': [0, 1, 2, 3, 4, 5, 10, 11, 12, 22, 25, 26, 27],
}
available_rtcio_nums = {
@ -80,6 +80,8 @@ def test_ext1_deepsleep(dut: Tuple[IdfDut, IdfDut]) -> None:
sleep(2)
wakee.write('cause')
wakee.expect('Wake up from EXT1', timeout=10)
wakee.write(f'ext1 -p {gpio_num} -d')
wakee.expect(f'io_wakeup_num = {gpio_num}', timeout=10)
@ -126,6 +128,8 @@ def test_rtcio_deepsleep(dut: Tuple[IdfDut, IdfDut]) -> None:
sleep(2)
wakee.write('cause')
wakee.expect('Wake up from GPIO', timeout=10)
wakee.write(f'rtcio -p {gpio_num} -d')
wakee.expect(f'io_wakeup_num = {gpio_num}', timeout=10)
@ -170,5 +174,8 @@ def test_gpio_wakeup_enable_lightsleep(dut: Tuple[IdfDut, IdfDut]) -> None:
wakee.expect('esp_light_sleep_start', timeout=10)
wakee.write('cause')
wakee.expect('Wake up from GPIO', timeout=10)
wakee.write(f'gpio -p {gpio_num} -d')
wakee.expect(f'io_wakeup_num = {gpio_num}', timeout=10)