Skip to content

Commit 56e8bdb

Browse files
nordic-seglnordic-piks
authored andcommitted
tests: drivers: grtc: Add test to check GRTC clock output
Add test that checks possibility to output slow/fast clock signal from GRTC. Signed-off-by: Sebastian Głąb <[email protected]>
1 parent ad106e2 commit 56e8bdb

21 files changed

+444
-0
lines changed

CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -858,6 +858,7 @@
858858
/tests/drivers/flash/flash_rpc/ @nrfconnect/ncs-pluto
859859
/tests/drivers/flash_patch/ @nrfconnect/ncs-pluto
860860
/tests/drivers/fprotect/ @nrfconnect/ncs-pluto
861+
/tests/drivers/grtc/ @nrfconnect/ncs-low-level-test
861862
/tests/drivers/lpuart/ @nordic-krch @nrfconnect/ncs-low-level-test
862863
/tests/drivers/mspi/app_fault_timer/ @nrfconnect/ncs-low-level-test @nrfconnect/ncs-ll-ursus
863864
/tests/drivers/mspi/mspi_with_spis/ @nrfconnect/ncs-low-level-test

boards/nordic/nrf54lm20apdk/nrf54lm20apdk_nrf54lm20a-pinctrl.dtsi

+15
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,19 @@
7575
low-power-enable;
7676
};
7777
};
78+
79+
/omit-if-no-ref/ grtc_default: grtc_default {
80+
group1 {
81+
psels = <NRF_PSEL(GRTC_CLKOUT_FAST, 1, 7)>,
82+
<NRF_PSEL(GRTC_CLKOUT_32K, 0, 4)>;
83+
};
84+
};
85+
86+
/omit-if-no-ref/ grtc_sleep: grtc_sleep {
87+
group1 {
88+
psels = <NRF_PSEL(GRTC_CLKOUT_FAST, 1, 7)>,
89+
<NRF_PSEL(GRTC_CLKOUT_32K, 0, 4)>;
90+
low-power-enable;
91+
};
92+
};
7893
};

boards/nordic/nrf54lm20pdk/nrf54lm20pdk_nrf54lm20a-pinctrl.dtsi

+15
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,19 @@
7575
low-power-enable;
7676
};
7777
};
78+
79+
/omit-if-no-ref/ grtc_default: grtc_default {
80+
group1 {
81+
psels = <NRF_PSEL(GRTC_CLKOUT_FAST, 1, 7)>,
82+
<NRF_PSEL(GRTC_CLKOUT_32K, 0, 4)>;
83+
};
84+
};
85+
86+
/omit-if-no-ref/ grtc_sleep: grtc_sleep {
87+
group1 {
88+
psels = <NRF_PSEL(GRTC_CLKOUT_FAST, 1, 7)>,
89+
<NRF_PSEL(GRTC_CLKOUT_32K, 0, 4)>;
90+
low-power-enable;
91+
};
92+
};
7893
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
2+
3+
cmake_minimum_required(VERSION 3.20.0)
4+
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
project(grtc_clk_out)
7+
8+
FILE(GLOB app_sources src/*.c)
9+
target_sources(app PRIVATE ${app_sources})
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
8+
config TEST_GRTC_FREQUENCY
9+
int "Expected frequency (Hz) at GRTC output pin"
10+
default 32768
11+
help
12+
GRTC can output clock signal on dedicated pin.
13+
This can be 32768 Hz signal or fast clock which is
14+
16 MHz divided by (1..255 * 2).
15+
16+
config TEST_GRTC_TOLERANCE
17+
int "Amount of additional/missing clock edges"
18+
default 100
19+
help
20+
Define tolerance for expected number of clock edges
21+
counted during 1 second interval.
22+
23+
source "Kconfig.zephyr"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
CONFIG_NRF_REGTOOL_VERBOSITY=2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/* Required loopback between:
8+
* GPIO P0.3 and P0.1 (GRTC 32k; defined @board; no other option)
9+
*/
10+
11+
/ {
12+
zephyr,user {
13+
gpios = <&gpio0 3 GPIO_ACTIVE_HIGH>; /* Connect to dedicated GRTC output */
14+
};
15+
};
16+
17+
&gpio0 {
18+
status = "okay";
19+
};
20+
21+
&gpiote130 {
22+
status = "okay";
23+
};
24+
25+
&grtc {
26+
pinctrl-0 = <&grtc_default>;
27+
pinctrl-1 = <&grtc_sleep>;
28+
pinctrl-names = "default", "sleep";
29+
clkout-32k;
30+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CONFIG_NRF_REGTOOL_VERBOSITY=2
2+
CONFIG_TEST_GRTC_FREQUENCY=50000
3+
CONFIG_TEST_GRTC_TOLERANCE=500
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/* Required loopback between:
8+
* GPIO P2.0 and P1.8 (GRTC fast; defined @board; can be changed to P2.5 or P9.0)
9+
*/
10+
11+
/ {
12+
zephyr,user {
13+
gpios = <&gpio2 0 GPIO_ACTIVE_HIGH>; /* Connect to dedicated GRTC output */
14+
};
15+
};
16+
17+
&gpio1 {
18+
status = "okay";
19+
};
20+
21+
&gpio2 {
22+
status = "okay";
23+
};
24+
25+
&gpiote130 {
26+
status = "okay";
27+
};
28+
29+
&grtc {
30+
pinctrl-0 = <&grtc_default>;
31+
pinctrl-1 = <&grtc_sleep>;
32+
pinctrl-names = "default", "sleep";
33+
clkout-fast-frequency = <50000>; /* 16 MHz / (160 * 2) */
34+
nordic,clockpin-enable = <NRF_FUN_GRTC_CLKOUT_FAST>;
35+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/* Required loopback between:
8+
* GPIO P0.0 and P0.4 (GRTC 32k; defined @board; no other option)
9+
*/
10+
11+
/ {
12+
zephyr,user {
13+
gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>; /* Connect to dedicated GRTC output */
14+
};
15+
};
16+
17+
&gpio0 {
18+
status = "okay";
19+
};
20+
21+
&gpiote20 {
22+
status = "okay";
23+
};
24+
25+
&grtc {
26+
pinctrl-0 = <&grtc_default>;
27+
pinctrl-1 = <&grtc_sleep>;
28+
pinctrl-names = "default", "sleep";
29+
clkout-32k;
30+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_TEST_GRTC_FREQUENCY=40000
2+
CONFIG_TEST_GRTC_TOLERANCE=400
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/* Required loopback between:
8+
* GPIO P0.0 and P1.8 (GRTC fast; defined @board; no other option)
9+
*/
10+
11+
/ {
12+
zephyr,user {
13+
gpios = <&gpio0 0 GPIO_ACTIVE_HIGH>; /* Connect to dedicated GRTC output */
14+
};
15+
};
16+
17+
&gpio0 {
18+
status = "okay";
19+
};
20+
21+
&gpio1 {
22+
status = "okay";
23+
};
24+
25+
&gpiote20 {
26+
status = "okay";
27+
};
28+
29+
&grtc {
30+
pinctrl-0 = <&grtc_default>;
31+
pinctrl-1 = <&grtc_sleep>;
32+
pinctrl-names = "default", "sleep";
33+
clkout-fast-frequency = <40000>; /* 16 MHz / (200 * 2) */
34+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/* Required loopback between:
8+
* GPIO P1.0 and P0.4 (GRTC 32k; defined @board; no other option)
9+
*/
10+
11+
/delete-node/ &led0; /* at P1.0 */
12+
/delete-node/ &button3; /* at P0.4 */
13+
14+
/ {
15+
zephyr,user {
16+
gpios = <&gpio1 0 GPIO_ACTIVE_HIGH>; /* Connect to dedicated GRTC output */
17+
};
18+
19+
aliases {
20+
/delete-property/ led0;
21+
/delete-property/ sw3;
22+
};
23+
};
24+
25+
&gpio0 {
26+
status = "okay";
27+
};
28+
29+
&gpio1 {
30+
status = "okay";
31+
};
32+
33+
&gpiote20 {
34+
status = "okay";
35+
};
36+
37+
&grtc {
38+
pinctrl-0 = <&grtc_default>;
39+
pinctrl-1 = <&grtc_sleep>;
40+
pinctrl-names = "default", "sleep";
41+
clkout-32k;
42+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/* Required loopback between:
8+
* GPIO P0.5 and P0.4 (GRTC 32k; defined @board; no other option)
9+
*/
10+
11+
/ {
12+
zephyr,user {
13+
gpios = <&gpio0 5 GPIO_ACTIVE_HIGH>; /* Connect to dedicated GRTC output */
14+
};
15+
};
16+
17+
&gpio0 {
18+
status = "okay";
19+
};
20+
21+
&grtc {
22+
pinctrl-0 = <&grtc_default>;
23+
pinctrl-1 = <&grtc_sleep>;
24+
pinctrl-names = "default", "sleep";
25+
clkout-32k;
26+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_TEST_GRTC_FREQUENCY=32000
2+
CONFIG_TEST_GRTC_TOLERANCE=320
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/* Required loopback between:
8+
* GPIO P1.8 and P1.7 (GRTC fast; defined @board; no other option)
9+
*/
10+
11+
/ {
12+
zephyr,user {
13+
gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>; /* Connect to dedicated GRTC output */
14+
};
15+
};
16+
17+
&gpio1 {
18+
status = "okay";
19+
};
20+
21+
&gpiote20 {
22+
status = "okay";
23+
};
24+
25+
&grtc {
26+
pinctrl-0 = <&grtc_default>;
27+
pinctrl-1 = <&grtc_sleep>;
28+
pinctrl-names = "default", "sleep";
29+
clkout-fast-frequency = <32000>; /* 16 MHz / (250 * 2) */
30+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_TEST_GRTC_FREQUENCY=32000
2+
CONFIG_TEST_GRTC_TOLERANCE=320
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/* Required loopback between:
8+
* GPIO P1.8 and P1.7 (GRTC fast; defined @board; no other option)
9+
*/
10+
11+
/ {
12+
zephyr,user {
13+
gpios = <&gpio1 8 GPIO_ACTIVE_HIGH>; /* Connect to dedicated GRTC output */
14+
};
15+
};
16+
17+
&gpio1 {
18+
status = "okay";
19+
};
20+
21+
&gpiote20 {
22+
status = "okay";
23+
};
24+
25+
&grtc {
26+
pinctrl-0 = <&grtc_default>;
27+
pinctrl-1 = <&grtc_sleep>;
28+
pinctrl-names = "default", "sleep";
29+
clkout-fast-frequency = <32000>; /* 16 MHz / (250 * 2) */
30+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
CONFIG_ZTEST=y
2+
CONFIG_SPEED_OPTIMIZATIONS=y

0 commit comments

Comments
 (0)