Skip to content

Commit bb3efaa

Browse files
nordic-baminashif
authored andcommitted
tests: drivers: Verify NRF GPIO driver with GPIO_NRFX_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]>
1 parent 96852bc commit bb3efaa

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

tests/drivers/gpio/gpio_nrf/README.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@ Nordic Semiconductor specific GPIO functions
22
############################################
33
The suite specified here tests NRF specific
44
GPIO pin drive strength settings.
5+
6+
The suite is perfomed with CONFIG_GPIO_NRFX_INTERRUPT=n
7+
to ensure that the driver is able to properly handle
8+
the GPIO manipulation without interrupt support.

tests/drivers/gpio/gpio_nrf/prj.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
CONFIG_ZTEST=y
22
CONFIG_GPIO=y
3+
CONFIG_GPIO_NRFX_INTERRUPT=n

tests/drivers/gpio/gpio_nrf/src/main.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,38 @@ ZTEST(gpio_nrf, test_gpio_high_drive_strength)
5858
err);
5959
}
6060

61+
/*
62+
* Nordic Semiconductor specific,
63+
* gpio manipulation with disabled NRFX interrupts
64+
*/
65+
ZTEST(gpio_nrf, test_gpio_manipulation_nrfx_int_disabled)
66+
{
67+
int response;
68+
const struct device *port;
69+
70+
port = DEVICE_DT_GET(TEST_NODE);
71+
zassert_true(device_is_ready(port), "GPIO dev is not ready");
72+
73+
response = gpio_pin_configure(port, TEST_PIN, GPIO_OUTPUT | GPIO_ACTIVE_HIGH);
74+
zassert_ok(response, "Pin configuration failed: %d", response);
75+
76+
response = gpio_pin_set(port, TEST_PIN, 0);
77+
zassert_ok(response, "Pin low state set failed: %d", response);
78+
79+
response = gpio_pin_set(port, TEST_PIN, 1);
80+
zassert_ok(response, "Pin high state set failed: %d", response);
81+
82+
response = gpio_pin_toggle(port, TEST_PIN);
83+
zassert_ok(response, "Pin toggle failed: %d", response);
84+
85+
response = gpio_pin_configure(port, TEST_PIN, GPIO_INPUT | GPIO_PULL_DOWN);
86+
zassert_ok(response, "Failed to configure pin as input with pull down: %d", response);
87+
88+
response = gpio_pin_get(port, TEST_PIN);
89+
zassert_equal(response, 0, "Invalid pin state: %d", response);
90+
91+
response = gpio_pin_interrupt_configure(port, TEST_PIN, GPIO_INT_ENABLE | GPIO_INT_HIGH_1);
92+
zassert_equal(response, -ENOSYS);
93+
}
94+
6195
ZTEST_SUITE(gpio_nrf, NULL, NULL, NULL, NULL, NULL);

0 commit comments

Comments
 (0)