Skip to content

Commit f4b3865

Browse files
JiafeiPandkalowsk
authored andcommitted
tests: gpio: gpio_basic_api: config to input if disconnected not supported
If GPIO_DISCONNECTED is not supported by GPIO driver, then try to configure the pin to be input, otherwise there will be some unstable signal between two test pins. Signed-off-by: Jiafei Pan <Jiafei.Pan@nxp.com>
1 parent a6af366 commit f4b3865

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

tests/drivers/gpio/gpio_basic_api/src/test_config_trigger.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ ZTEST(after_flash_gpio_config_trigger, test_gpio_config_twice_trigger)
3030
cb_cnt = 0;
3131

3232
ret = gpio_pin_configure(dev_out, PIN_OUT, GPIO_DISCONNECTED);
33+
if (ret == -ENOTSUP) {
34+
TC_PRINT("NOTE: cannot configure pin as disconnected; trying as input\n");
35+
ret = gpio_pin_configure(dev_out, PIN_OUT, GPIO_INPUT | GPIO_PULL_UP);
36+
}
37+
zassert_ok(ret, "config PIN_OUT failed");
3338

3439
/* 1. Configure PIN_IN callback */
3540
ret = gpio_pin_configure(dev_in, PIN_IN, GPIO_INPUT);
@@ -81,6 +86,11 @@ ZTEST(after_flash_gpio_config_trigger, test_gpio_config_trigger)
8186
cb_cnt = 0;
8287

8388
ret = gpio_pin_configure(dev_out, PIN_OUT, GPIO_DISCONNECTED);
89+
if (ret == -ENOTSUP) {
90+
TC_PRINT("NOTE: cannot configure pin as disconnected; trying as input\n");
91+
ret = gpio_pin_configure(dev_out, PIN_OUT, GPIO_INPUT | GPIO_PULL_UP);
92+
}
93+
zassert_ok(ret, "config PIN_OUT failed");
8494

8595
/* 1. Configure PIN_IN callback */
8696
ret = gpio_pin_configure(dev_in, PIN_IN, GPIO_INPUT);

0 commit comments

Comments
 (0)