Skip to content

Commit cd0d63d

Browse files
bjarki-andreasenrlubos
authored andcommitted
[nrf fromtree] tests: drivers: comparator: add gpio_loopback test suite
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. Signed-off-by: Bjarki Arge Andreasen <[email protected]> (cherry picked from commit 3272db8)
1 parent 54ceaf9 commit cd0d63d

16 files changed

+409
-0
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Copyright (c) 2024 Nordic Semiconductor
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.20.0)
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
project(comparator_gpio_loopback)
7+
8+
target_sources(app PRIVATE src/test.c)
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <nxp/kinetis/MKE17Z256VLL7-pinctrl.h>
8+
#include <zephyr/dt-bindings/gpio/gpio.h>
9+
10+
/*
11+
* PTA1 looped back to PTA0
12+
*/
13+
14+
/ {
15+
aliases {
16+
test-comp = &cmp0;
17+
};
18+
19+
zephyr,user {
20+
test-gpios = <&gpioa 1 GPIO_ACTIVE_HIGH>;
21+
};
22+
};
23+
24+
&gpioa {
25+
status = "okay";
26+
};
27+
28+
&pinctrl {
29+
cmp0_default: cmp0_default {
30+
group0 {
31+
pinmux = <ACMP0_IN0_PTA0>;
32+
drive-strength = "high";
33+
};
34+
};
35+
};
36+
37+
&cmp0 {
38+
pinctrl-0 = <&cmp0_default>;
39+
pinctrl-names = "default";
40+
status = "okay";
41+
42+
positive-mux-input = "IN0";
43+
positive-port-input = "MUX";
44+
negative-mux-input = "IN0";
45+
negative-port-input = "DAC";
46+
47+
dac-vref-source = "VIN1";
48+
dac-value = <128>;
49+
dac-enable;
50+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/dt-bindings/gpio/gpio.h>
8+
9+
/*
10+
* P0.05 looped back to P0.04
11+
*/
12+
13+
/ {
14+
aliases {
15+
test-comp = &comp;
16+
};
17+
18+
zephyr,user {
19+
test-gpios = <&gpio0 5 GPIO_ACTIVE_HIGH>;
20+
};
21+
};
22+
23+
&gpio0{
24+
status = "okay";
25+
};
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/dt-bindings/gpio/gpio.h>
8+
9+
/*
10+
* P1.03 looped back to P1.02
11+
*/
12+
13+
/ {
14+
aliases {
15+
test-comp = &comp;
16+
};
17+
18+
zephyr,user {
19+
test-gpios = <&gpio1 3 GPIO_ACTIVE_HIGH>;
20+
};
21+
};
22+
23+
&gpio1 {
24+
status = "okay";
25+
};
26+
27+
/* Temporary workaround to reserve P1.03 for cpuapp */
28+
&led1 {
29+
gpios = < &gpio1 0x3 0x0 >;
30+
};
31+
32+
/* Temporary workaround to reserve P1.02 for cpuapp */
33+
&led2 {
34+
gpios = < &gpio1 0x2 0x0 >;
35+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/dt-bindings/gpio/gpio.h>
8+
9+
/*
10+
* P1.10 looped back to P1.11
11+
*/
12+
13+
/ {
14+
aliases {
15+
test-comp = &comp;
16+
};
17+
18+
zephyr,user {
19+
test-gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>;
20+
};
21+
};
22+
23+
&gpio1 {
24+
status = "okay";
25+
};
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Copyright (c) 2024 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
CONFIG_ZTEST=y
5+
CONFIG_GPIO=y
6+
CONFIG_COMPARATOR=y
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
&comp {
8+
main-mode = "SE";
9+
psel = "AIN0"; /* P0.04 */
10+
refsel = "VDD";
11+
sp-mode = "HIGH";
12+
th-up = <34>;
13+
th-down = <30>;
14+
isource = "DISABLED";
15+
status = "okay";
16+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
&comp {
8+
main-mode = "SE";
9+
psel = "AIN2"; /* P1.02 */
10+
refsel = "INT_1V2";
11+
sp-mode = "HIGH";
12+
th-up = <63>;
13+
th-down = <59>;
14+
isource = "DISABLED";
15+
status = "okay";
16+
};
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
&comp {
8+
main-mode = "SE";
9+
psel = "AIN4"; /* P1.11 */
10+
refsel = "INT_1V2";
11+
sp-mode = "HIGH";
12+
th-up = <63>;
13+
th-down = <59>;
14+
isource = "DISABLED";
15+
status = "okay";
16+
};
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Copyright 2024 Nordic Semiconductor ASA
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
name: gpio_loopback_nrf_comp
5+
6+
boards:
7+
nrf54h20dk/nrf54h20/cpuapp:
8+
append:
9+
EXTRA_DTC_OVERLAY_FILE: boards/nrf54h20dk_nrf54h20_cpuapp.overlay
10+
nrf54l15dk/nrf54l15/cpuapp:
11+
append:
12+
EXTRA_DTC_OVERLAY_FILE: boards/nrf54l15dk_nrf54l15_cpuapp.overlay
13+
nrf5340dk/nrf5340/cpuapp:
14+
append:
15+
EXTRA_DTC_OVERLAY_FILE: boards/nrf5340dk_nrf5340_cpuapp.overlay

0 commit comments

Comments
 (0)