tests: gpio_api_1pin: rpi_pico2: Support using external pulldowns

Extend gpio_api_1pin so that tests can require a test fixture to provide
an external pulldown resistor to the board under test. Use the new
test-gpio-external-pulldown device tree binding to define where that
GPIO is, and, finally, add a device tree overlay for the Raspberry Pi
Pico 2 board that defines where the pulldown provided by the fixture
will be.

Tested locally using `--fixture gpio_external_pull_down` when running
Twister on the command line, or by creating and using a Hardware Map
file, in combination with a modified Pico 2.

Signed-off-by: Andrew Featherstone <andrew.featherstone@gmail.com>
This commit is contained in:
Andrew Featherstone 2024-10-04 15:44:29 +01:00 committed by Benjamin Cabé
parent dae7787542
commit aeecc3c282
4 changed files with 58 additions and 10 deletions

View file

@ -0,0 +1,13 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2024 Andrew Featherstone <andrew.featherstone@gmail.com>
*/
/ {
resources {
compatible = "test-gpio-external-pulldown";
/* Choice of pin on the header is arbitrary. */
gpios = <&pico_header 15 GPIO_ACTIVE_HIGH>;
};
};

View file

@ -0,0 +1,18 @@
#
# Copyright (c) 2024 Andrew Featherstone <andrew.featherstone@gmail.com>
#
# SPDX-License-Identifier: Apache-2.0
#
description: |
This binding provides resources required to build and run the
tests/drivers/gpio/gpio_api_1pin test in Zephyr on certain hardware.
compatible: "test-gpio-external-pulldown"
properties:
gpios:
type: phandle-array
required: true
description: |
Identity of a GPIO that will be configured as both an output and input.

View file

@ -11,10 +11,18 @@
#include <zephyr/drivers/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)
#define TEST_PIN_DTS_FLAGS DT_GPIO_FLAGS(DT_ALIAS(led0), gpios)
/* If possible, use a dedicated GPIO with an external pulldown resistor.
* Otherwise, fallback to repurposing led0 as a GPIO. The latter won't always
* work as expected when reconfigured as an input.
*/
#if DT_NODE_HAS_STATUS(DT_INST(0, test_gpio_external_pulldown), okay)
#define TEST_NODE DT_GPIO_CTLR(DT_INST(0, test_gpio_external_pulldown), gpios)
#define TEST_PIN DT_GPIO_PIN(DT_INST(0, test_gpio_external_pulldown), gpios)
#define TEST_PIN_DTS_FLAGS DT_GPIO_FLAGS(DT_INST(0, test_gpio_external_pulldown), gpios)
#elif 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)
#define TEST_PIN_DTS_FLAGS DT_GPIO_FLAGS(DT_ALIAS(led0), gpios)
#else
#error Unsupported board
#endif

View file

@ -1,16 +1,19 @@
common:
tags:
- drivers
- gpio
depends_on: gpio
min_flash: 48
tests:
drivers.gpio.1pin:
tags:
- drivers
- gpio
depends_on: gpio
min_flash: 48
filter: >
dt_enabled_alias_with_parent_compat("led0", "gpio-leds")
and not dt_compat_enabled("test-gpio-external-pulldown")
# Fix exclude when we can exclude just sim run
platform_exclude:
- mps2/an385
- mps2/an521/cpu0
- neorv32
filter: dt_enabled_alias_with_parent_compat("led0", "gpio-leds")
drivers.gpio.1pin.aw9523b:
tags:
- drivers
@ -27,3 +30,9 @@ tests:
dt_compat_enabled("arduino-header-r3")
extra_dtc_overlay_files:
- "boards/aw9523b_on_arduino_header.overlay"
drivers.gpio.1pin.external_pull_down:
# For testing boards that require a test fixture that provides a pulldown
# resistor on the GPIO used for the test.
filter: dt_compat_enabled("test-gpio-external-pulldown")
harness_config:
fixture: gpio_external_pull_down