Skip to content

Commit

Permalink
[nrf fromlist] tests: drivers: comparator: add gpio_loopback test suite
Browse files Browse the repository at this point in the history
Add test suite which uses GPIO loopback to produce a "very low" and
"very high" voltage at the positive input of the comparator using the
output of a GPIO. The negative input is set to a voltage between the
high and low output voltages of the GPIO using whichever internal
reference is available to the comparator.

Upstream PR: zephyrproject-rtos/zephyr#79724

Signed-off-by: Bjarki Arge Andreasen <[email protected]>
  • Loading branch information
bjarki-andreasen committed Oct 17, 2024
1 parent 868ee37 commit 7a5b99a
Show file tree
Hide file tree
Showing 17 changed files with 434 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/drivers/comparator/gpio_loopback/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Copyright (c) 2024 Nordic Semiconductor
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(comparator_gpio_loopback)

target_sources(app PRIVATE src/test.c)
50 changes: 50 additions & 0 deletions tests/drivers/comparator/gpio_loopback/boards/frdm_ke15z.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2024 Nordic Semiconductor
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <nxp/kinetis/MKE17Z256VLL7-pinctrl.h>
#include <zephyr/dt-bindings/gpio/gpio.h>

/*
* PTA1 looped back to PTA0
*/

/ {
aliases {
test-comp = &cmp0;
};

zephyr,user {
test-gpios = <&gpioa 1 GPIO_ACTIVE_HIGH>;
};
};

&gpioa {
status = "okay";
};

&pinctrl {
cmp0_default: cmp0_default {
group0 {
pinmux = <ACMP0_IN0_PTA0>;
drive-strength = "high";
};
};
};

&cmp0 {
pinctrl-0 = <&cmp0_default>;
pinctrl-names = "default";
status = "okay";

positive-mux-input = "IN0";
positive-port-input = "MUX";
negative-mux-input = "IN0";
negative-port-input = "DAC";

dac-vref-source = "VIN1";
dac-value = <128>;
dac-enable;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2024 Nordic Semiconductor
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/dt-bindings/gpio/gpio.h>

/*
* P0.05 looped back to P0.04
*/

/ {
aliases {
test-comp = &comp;
};

zephyr,user {
test-gpios = <&gpio0 5 GPIO_ACTIVE_HIGH>;
};
};

&gpio0{
status = "okay";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2024 Nordic Semiconductor
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/dt-bindings/gpio/gpio.h>

/*
* P1.03 looped back to P1.02
*/

/ {
aliases {
test-comp = &comp;
};

zephyr,user {
test-gpios = <&gpio1 3 GPIO_ACTIVE_HIGH>;
};
};

&gpio1 {
status = "okay";
};

/* Temporary workaround to reserve P1.03 for cpuapp */
&led1 {
gpios = < &gpio1 0x3 0x0 >;
};

/* Temporary workaround to reserve P1.02 for cpuapp */
&led2 {
gpios = < &gpio1 0x2 0x0 >;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2024 Nordic Semiconductor
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/dt-bindings/gpio/gpio.h>

/*
* P1.10 looped back to P1.11
*/

/ {
aliases {
test-comp = &comp;
};

zephyr,user {
test-gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
};
};

&gpio1 {
status = "okay";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Copyright (c) 2024 Nordic Semiconductor
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/dt-bindings/gpio/gpio.h>

/*
* P1.10 looped back to P1.11
*/

/ {
aliases {
test-comp = &comp;
};

zephyr,user {
test-gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
};
};

&gpio1 {
status = "okay";
};
6 changes: 6 additions & 0 deletions tests/drivers/comparator/gpio_loopback/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

CONFIG_ZTEST=y
CONFIG_GPIO=y
CONFIG_COMPARATOR=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2024 Nordic Semiconductor
*
* SPDX-License-Identifier: Apache-2.0
*/

&comp {
main-mode = "SE";
psel = "AIN0"; /* P0.04 */
refsel = "VDD";
sp-mode = "HIGH";
th-up = <34>;
th-down = <30>;
isource = "DISABLED";
status = "okay";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2024 Nordic Semiconductor
*
* SPDX-License-Identifier: Apache-2.0
*/

&comp {
main-mode = "SE";
psel = "AIN2"; /* P1.02 */
refsel = "INT_1V2";
sp-mode = "HIGH";
th-up = <63>;
th-down = <59>;
isource = "DISABLED";
status = "okay";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2024 Nordic Semiconductor
*
* SPDX-License-Identifier: Apache-2.0
*/

&comp {
main-mode = "SE";
psel = "AIN4"; /* P1.11 */
refsel = "INT_1V2";
sp-mode = "HIGH";
th-up = <63>;
th-down = <59>;
isource = "DISABLED";
status = "okay";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

name: gpio_loopback_nrf_comp

boards:
nrf54h20dk/nrf54h20/cpuapp:
append:
EXTRA_DTC_OVERLAY_FILE: boards/nrf54h20dk_nrf54h20_cpuapp.overlay
nrf54l15dk/nrf54l15/cpuapp:
append:
EXTRA_DTC_OVERLAY_FILE: boards/nrf54l15dk_nrf54l15_cpuapp.overlay
nrf5340dk/nrf5340/cpuapp:
append:
EXTRA_DTC_OVERLAY_FILE: boards/nrf5340dk_nrf5340_cpuapp.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright (c) 2024 Nordic Semiconductor
*
* SPDX-License-Identifier: Apache-2.0
*/

&comp {
compatible = "nordic,nrf-lpcomp";
psel = "AIN0"; /* P0.04 */
refsel = "VDD_4_8";
status = "okay";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright (c) 2024 Nordic Semiconductor
*
* SPDX-License-Identifier: Apache-2.0
*/

&comp {
compatible = "nordic,nrf-lpcomp";
psel = "AIN2"; /* P1.02 */
refsel = "VDD_4_8";
status = "okay";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* Copyright (c) 2024 Nordic Semiconductor
*
* SPDX-License-Identifier: Apache-2.0
*/

&comp {
compatible = "nordic,nrf-lpcomp";
psel = "AIN4"; /* P1.11 */
refsel = "VDD_4_8";
status = "okay";
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

name: gpio_loopback_nrf_lpcomp

boards:
nrf54h20dk/nrf54h20/cpuapp:
append:
EXTRA_DTC_OVERLAY_FILE: boards/nrf54h20dk_nrf54h20_cpuapp.overlay
nrf54l15dk/nrf54l15/cpuapp:
append:
EXTRA_DTC_OVERLAY_FILE: boards/nrf54l15dk_nrf54l15_cpuapp.overlay
nrf5340dk/nrf5340/cpuapp:
append:
EXTRA_DTC_OVERLAY_FILE: boards/nrf5340dk_nrf5340_cpuapp.overlay
Loading

0 comments on commit 7a5b99a

Please sign in to comment.