forked from nrfconnect/sdk-zephyr
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nrf fromlist] 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. Upstream PR: zephyrproject-rtos/zephyr#79724 Signed-off-by: Bjarki Arge Andreasen <[email protected]>
- Loading branch information
1 parent
868ee37
commit 7a5b99a
Showing
17 changed files
with
434 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
50
tests/drivers/comparator/gpio_loopback/boards/frdm_ke15z.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
25 changes: 25 additions & 0 deletions
25
tests/drivers/comparator/gpio_loopback/boards/nrf5340dk_nrf5340_cpuapp.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ∁ | ||
}; | ||
|
||
zephyr,user { | ||
test-gpios = <&gpio0 5 GPIO_ACTIVE_HIGH>; | ||
}; | ||
}; | ||
|
||
&gpio0{ | ||
status = "okay"; | ||
}; |
35 changes: 35 additions & 0 deletions
35
tests/drivers/comparator/gpio_loopback/boards/nrf54h20dk_nrf54h20_cpuapp.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ∁ | ||
}; | ||
|
||
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 >; | ||
}; |
25 changes: 25 additions & 0 deletions
25
tests/drivers/comparator/gpio_loopback/boards/nrf54l15dk_nrf54l15_cpuapp.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ∁ | ||
}; | ||
|
||
zephyr,user { | ||
test-gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>; | ||
}; | ||
}; | ||
|
||
&gpio1 { | ||
status = "okay"; | ||
}; |
25 changes: 25 additions & 0 deletions
25
tests/drivers/comparator/gpio_loopback/boards/nrf54l15pdk_nrf54l15_cpuapp.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ∁ | ||
}; | ||
|
||
zephyr,user { | ||
test-gpios = <&gpio1 10 GPIO_ACTIVE_HIGH>; | ||
}; | ||
}; | ||
|
||
&gpio1 { | ||
status = "okay"; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
16 changes: 16 additions & 0 deletions
16
...rivers/comparator/gpio_loopback/snippets/nrf_comp/boards/nrf5340dk_nrf5340_cpuapp.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
}; |
16 changes: 16 additions & 0 deletions
16
...vers/comparator/gpio_loopback/snippets/nrf_comp/boards/nrf54h20dk_nrf54h20_cpuapp.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
}; |
16 changes: 16 additions & 0 deletions
16
...vers/comparator/gpio_loopback/snippets/nrf_comp/boards/nrf54l15dk_nrf54l15_cpuapp.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
}; |
15 changes: 15 additions & 0 deletions
15
tests/drivers/comparator/gpio_loopback/snippets/nrf_comp/snippet.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
12 changes: 12 additions & 0 deletions
12
...vers/comparator/gpio_loopback/snippets/nrf_lpcomp/boards/nrf5340dk_nrf5340_cpuapp.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
}; |
12 changes: 12 additions & 0 deletions
12
...rs/comparator/gpio_loopback/snippets/nrf_lpcomp/boards/nrf54h20dk_nrf54h20_cpuapp.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
}; |
12 changes: 12 additions & 0 deletions
12
...rs/comparator/gpio_loopback/snippets/nrf_lpcomp/boards/nrf54l15dk_nrf54l15_cpuapp.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
}; |
15 changes: 15 additions & 0 deletions
15
tests/drivers/comparator/gpio_loopback/snippets/nrf_lpcomp/snippet.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.