tests: drivers: Extend test coverage for NRF GPIO driver
Add more test cases for NRF specific GPIO features Signed-off-by: Bartosz Miller <bartosz.miller@nordicsemi.no>
This commit is contained in:
parent
792fd57d96
commit
aa67e5872a
10
tests/drivers/gpio/gpio_nrf/CMakeLists.txt
Normal file
10
tests/drivers/gpio/gpio_nrf/CMakeLists.txt
Normal file
|
@ -0,0 +1,10 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cmake_minimum_required(VERSION 3.20.0)
|
||||
|
||||
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
||||
project(gpio_nrf_specific)
|
||||
|
||||
target_sources(app PRIVATE
|
||||
src/main.c
|
||||
)
|
4
tests/drivers/gpio/gpio_nrf/README.txt
Normal file
4
tests/drivers/gpio/gpio_nrf/README.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
Nordic Semiconductor specific GPIO functions
|
||||
############################################
|
||||
The suite specified here tests NRF specific
|
||||
GPIO pin drive strength settings.
|
2
tests/drivers/gpio/gpio_nrf/prj.conf
Normal file
2
tests/drivers/gpio/gpio_nrf/prj.conf
Normal file
|
@ -0,0 +1,2 @@
|
|||
CONFIG_ZTEST=y
|
||||
CONFIG_GPIO=y
|
61
tests/drivers/gpio/gpio_nrf/src/main.c
Normal file
61
tests/drivers/gpio/gpio_nrf/src/main.c
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright (c) 2024 Nordic Semiconductor ASA
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/kernel.h>
|
||||
#include <zephyr/drivers/gpio.h>
|
||||
#include <zephyr/dt-bindings/gpio/nordic-nrf-gpio.h>
|
||||
#include <zephyr/ztest.h>
|
||||
|
||||
#if DT_NODE_HAS_PROP(DT_ALIAS(led0), gpios)
|
||||
#define TEST_NODE DT_GPIO_CTLR(DT_ALIAS(led0), gpios)
|
||||
#define TEST_PIN DT_GPIO_PIN(DT_ALIAS(led0), gpios)
|
||||
#else
|
||||
#error Unsupported board
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Nordic Semiconductor specific pin drive configurations
|
||||
*/
|
||||
ZTEST(gpio_nrf, test_gpio_high_drive_strength)
|
||||
{
|
||||
int err;
|
||||
const struct device *port;
|
||||
|
||||
port = DEVICE_DT_GET(TEST_NODE);
|
||||
zassert_true(device_is_ready(port), "GPIO dev is not ready");
|
||||
|
||||
err = gpio_pin_configure(port, TEST_PIN, GPIO_PUSH_PULL | NRF_GPIO_DRIVE_S0H1);
|
||||
zassert_equal(
|
||||
err, 0,
|
||||
"Failed to configure the pin as an P-P output with drive: NRF_GPIO_DRIVE_S0H1, err=%d",
|
||||
err);
|
||||
|
||||
err = gpio_pin_configure(port, TEST_PIN, GPIO_PUSH_PULL | NRF_GPIO_DRIVE_H0S1);
|
||||
zassert_equal(
|
||||
err, 0,
|
||||
"Failed to configure the pin as an P-P output with drive: NRF_GPIO_DRIVE_H0S1, err=%d",
|
||||
err);
|
||||
|
||||
err = gpio_pin_configure(port, TEST_PIN, GPIO_PUSH_PULL | NRF_GPIO_DRIVE_H0H1);
|
||||
zassert_equal(
|
||||
err, 0,
|
||||
"Failed to configure the pin as an P-P output with drive: NRF_GPIO_DRIVE_H0H1, err=%d",
|
||||
err);
|
||||
|
||||
err = gpio_pin_configure(port, TEST_PIN, GPIO_OPEN_DRAIN | NRF_GPIO_DRIVE_H0S1);
|
||||
zassert_equal(
|
||||
err, 0,
|
||||
"Failed to configure the pin as an O-D output with drive: NRF_GPIO_DRIVE_H0S1, err=%d",
|
||||
err);
|
||||
|
||||
err = gpio_pin_configure(port, TEST_PIN, GPIO_OPEN_SOURCE | NRF_GPIO_DRIVE_S0H1);
|
||||
zassert_equal(
|
||||
err, 0,
|
||||
"Failed to configure the pin as an O-S output with drive: NRF_GPIO_DRIVE_S0H1, err=%d",
|
||||
err);
|
||||
}
|
||||
|
||||
ZTEST_SUITE(gpio_nrf, NULL, NULL, NULL, NULL, NULL);
|
7
tests/drivers/gpio/gpio_nrf/testcase.yaml
Normal file
7
tests/drivers/gpio/gpio_nrf/testcase.yaml
Normal file
|
@ -0,0 +1,7 @@
|
|||
common:
|
||||
tags: drivers gpio
|
||||
depends_on: gpio
|
||||
harness: ztest
|
||||
tests:
|
||||
drivers.gpio.gpio_nrf:
|
||||
filter: dt_compat_enabled("nordic,nrf-gpio") and dt_nodelabel_enabled("led0")
|
Loading…
Reference in a new issue