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:
Bartosz Miller 2024-04-12 14:31:51 +02:00 committed by Fabio Baltieri
parent 792fd57d96
commit aa67e5872a
5 changed files with 84 additions and 0 deletions

View 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
)

View file

@ -0,0 +1,4 @@
Nordic Semiconductor specific GPIO functions
############################################
The suite specified here tests NRF specific
GPIO pin drive strength settings.

View file

@ -0,0 +1,2 @@
CONFIG_ZTEST=y
CONFIG_GPIO=y

View 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);

View 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")