From 3c04dde222161543c136f59223d8739bb7c49dae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20Arg=C3=BCelles?= Date: Thu, 14 Sep 2023 11:26:16 +0700 Subject: [PATCH] tests: gpio_basic_api: use GPIO flags from DT MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When configuring in/out pins for callback tests, pass the GPIO flags coming from the in/out-gpios respective nodes. Signed-off-by: Manuel Argüelles --- tests/drivers/gpio/gpio_basic_api/src/test_callback_manage.c | 4 ++-- tests/drivers/gpio/gpio_basic_api/src/test_callback_trigger.c | 4 ++-- tests/drivers/gpio/gpio_basic_api/src/test_gpio.h | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/tests/drivers/gpio/gpio_basic_api/src/test_callback_manage.c b/tests/drivers/gpio/gpio_basic_api/src/test_callback_manage.c index 97e217f298a43f9..3a409009c70163d 100644 --- a/tests/drivers/gpio/gpio_basic_api/src/test_callback_manage.c +++ b/tests/drivers/gpio/gpio_basic_api/src/test_callback_manage.c @@ -43,12 +43,12 @@ static int init_callback(const struct device *dev, } if (rc == 0) { /* 1. set PIN_OUT */ - rc = gpio_pin_configure(dev, PIN_OUT, GPIO_OUTPUT_LOW); + rc = gpio_pin_configure(dev, PIN_OUT, (GPIO_OUTPUT_LOW | PIN_OUT_FLAGS)); } if (rc == 0) { /* 2. configure PIN_IN callback, but don't enable */ - rc = gpio_pin_configure(dev, PIN_IN, GPIO_INPUT); + rc = gpio_pin_configure(dev, PIN_IN, (GPIO_INPUT | PIN_IN_FLAGS)); } if (rc == 0) { diff --git a/tests/drivers/gpio/gpio_basic_api/src/test_callback_trigger.c b/tests/drivers/gpio/gpio_basic_api/src/test_callback_trigger.c index 2209e9882309c4c..868e38223993ea2 100644 --- a/tests/drivers/gpio/gpio_basic_api/src/test_callback_trigger.c +++ b/tests/drivers/gpio/gpio_basic_api/src/test_callback_trigger.c @@ -40,7 +40,7 @@ static int test_callback(int mode) gpio_pin_interrupt_configure(dev, PIN_OUT, GPIO_INT_DISABLE); /* 1. set PIN_OUT to logical initial state inactive */ - uint32_t out_flags = GPIO_OUTPUT_LOW; + uint32_t out_flags = GPIO_OUTPUT_LOW | PIN_OUT_FLAGS; if ((mode & GPIO_INT_LOW_0) != 0) { out_flags = GPIO_OUTPUT_HIGH | GPIO_ACTIVE_LOW; @@ -54,7 +54,7 @@ static int test_callback(int mode) } /* 2. configure PIN_IN callback and trigger condition */ - rc = gpio_pin_configure(dev, PIN_IN, GPIO_INPUT); + rc = gpio_pin_configure(dev, PIN_IN, (GPIO_INPUT | PIN_IN_FLAGS)); if (rc != 0) { TC_ERROR("config PIN_IN fail: %d\n", rc); goto err_exit; diff --git a/tests/drivers/gpio/gpio_basic_api/src/test_gpio.h b/tests/drivers/gpio/gpio_basic_api/src/test_gpio.h index 38a15dc3dce4d6d..ba3d3ae5eba23d0 100644 --- a/tests/drivers/gpio/gpio_basic_api/src/test_gpio.h +++ b/tests/drivers/gpio/gpio_basic_api/src/test_gpio.h @@ -25,7 +25,9 @@ #define DEV_IN DT_GPIO_CTLR(DT_INST(0, test_gpio_basic_api), in_gpios) #define DEV DEV_OUT /* DEV_OUT should equal DEV_IN, we test for this */ #define PIN_OUT DT_GPIO_PIN(DT_INST(0, test_gpio_basic_api), out_gpios) +#define PIN_OUT_FLAGS DT_GPIO_FLAGS(DT_INST(0, test_gpio_basic_api), out_gpios) #define PIN_IN DT_GPIO_PIN(DT_INST(0, test_gpio_basic_api), in_gpios) +#define PIN_IN_FLAGS DT_GPIO_FLAGS(DT_INST(0, test_gpio_basic_api), in_gpios) #elif DT_NODE_HAS_STATUS(DT_ALIAS(gpio_0), okay) #define DEV DT_GPIO_CTLR(DT_ALIAS(gpio_0))