Skip to content

Commit

Permalink
[nrf fromtree] tests: drivers: Verify NRF GPIO driver with GPIO_NRFX_…
Browse files Browse the repository at this point in the history
…INTERRUPT=n

Verify NRF GPIO driver with NRFX interrupts disabled.
Verify that driver handles properly 'get' and 'set' api methods.
When calling interrupt enable driver should report
'function not implemented' error.

Signed-off-by: Bartosz Miller <[email protected]>
(cherry picked from commit bb3efaa)
  • Loading branch information
nordic-bami authored and rlubos committed Sep 16, 2024
1 parent de695ea commit 96aa87c
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tests/drivers/gpio/gpio_nrf/README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@ Nordic Semiconductor specific GPIO functions
############################################
The suite specified here tests NRF specific
GPIO pin drive strength settings.

The suite is perfomed with CONFIG_GPIO_NRFX_INTERRUPT=n
to ensure that the driver is able to properly handle
the GPIO manipulation without interrupt support.
1 change: 1 addition & 0 deletions tests/drivers/gpio/gpio_nrf/prj.conf
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
CONFIG_ZTEST=y
CONFIG_GPIO=y
CONFIG_GPIO_NRFX_INTERRUPT=n
34 changes: 34 additions & 0 deletions tests/drivers/gpio/gpio_nrf/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,38 @@ ZTEST(gpio_nrf, test_gpio_high_drive_strength)
err);
}

/*
* Nordic Semiconductor specific,
* gpio manipulation with disabled NRFX interrupts
*/
ZTEST(gpio_nrf, test_gpio_manipulation_nrfx_int_disabled)
{
int response;
const struct device *port;

port = DEVICE_DT_GET(TEST_NODE);
zassert_true(device_is_ready(port), "GPIO dev is not ready");

response = gpio_pin_configure(port, TEST_PIN, GPIO_OUTPUT | GPIO_ACTIVE_HIGH);
zassert_ok(response, "Pin configuration failed: %d", response);

response = gpio_pin_set(port, TEST_PIN, 0);
zassert_ok(response, "Pin low state set failed: %d", response);

response = gpio_pin_set(port, TEST_PIN, 1);
zassert_ok(response, "Pin high state set failed: %d", response);

response = gpio_pin_toggle(port, TEST_PIN);
zassert_ok(response, "Pin toggle failed: %d", response);

response = gpio_pin_configure(port, TEST_PIN, GPIO_INPUT | GPIO_PULL_DOWN);
zassert_ok(response, "Failed to configure pin as input with pull down: %d", response);

response = gpio_pin_get(port, TEST_PIN);
zassert_equal(response, 0, "Invalid pin state: %d", response);

response = gpio_pin_interrupt_configure(port, TEST_PIN, GPIO_INT_ENABLE | GPIO_INT_HIGH_1);
zassert_equal(response, -ENOSYS);
}

ZTEST_SUITE(gpio_nrf, NULL, NULL, NULL, NULL, NULL);

0 comments on commit 96aa87c

Please sign in to comment.