Skip to content

Commit

Permalink
tests: gpio_basic_api: use GPIO flags from DT
Browse files Browse the repository at this point in the history
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 <manuel.arguelles@nxp.com>
  • Loading branch information
manuargue committed Sep 14, 2023
1 parent 7111e9e commit 3c04dde
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tests/drivers/gpio/gpio_basic_api/src/test_callback_manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions tests/drivers/gpio/gpio_basic_api/src/test_callback_trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions tests/drivers/gpio/gpio_basic_api/src/test_gpio.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 3c04dde

Please sign in to comment.