Skip to content

Commit 7d7b4ae

Browse files
committed
samples: port radio_test to ncs-bm
changed the implementation of the sample to the subsystems and modules available in sdk-nrf-bm: - use shell_print instead of printk everywhere - use sample-specific clock_init() function - cleaned-up prj.conf, disabled SD explicitly Signed-off-by: Ivan Iushkov <ivan.iushkov@nordicsemi.no>
1 parent 44b69f0 commit 7d7b4ae

6 files changed

Lines changed: 176 additions & 232 deletions

File tree

samples/peripherals/radio_test/README.rst

Lines changed: 7 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -25,113 +25,17 @@ The sample supports the following development kits:
2525

2626
The following board variants do **not** have DFU capabilities:
2727

28-
.. list-table::
29-
:header-rows: 1
30-
31-
* - Hardware platform
32-
- PCA
33-
- SoftDevice
34-
- Board target
35-
* - `nRF54L15 DK`_
36-
- PCA10156
37-
- S115
38-
- bm_nrf54l15dk/nrf54l15/cpuapp/s115_softdevice
39-
* - `nRF54L15 DK`_ (emulating nRF54L10)
40-
- PCA10156
41-
- S115
42-
- bm_nrf54l15dk/nrf54l10/cpuapp/s115_softdevice
43-
* - `nRF54L15 DK`_ (emulating nRF54L05)
44-
- PCA10156
45-
- S115
46-
- bm_nrf54l15dk/nrf54l05/cpuapp/s115_softdevice
47-
* - `nRF54LM20 DK`_
48-
- PCA10184
49-
- S115
50-
- bm_nrf54lm20dk/nrf54lm20a/cpuapp/s115_softdevice
51-
* - nRF54LS05 DK
52-
- PCA10214
53-
- S115
54-
- bm_nrf54ls05dk/nrf54ls05b/cpuapp/s115_softdevice
55-
* - `nRF54LV10 DK`_
56-
- PCA10188
57-
- S115
58-
- bm_nrf54lv10dk/nrf54lv10/cpuapp/s115_softdevice
59-
* - `nRF54L15 DK`_
60-
- PCA10156
61-
- S145
62-
- bm_nrf54l15dk/nrf54l15/cpuapp/s145_softdevice
63-
* - `nRF54L15 DK`_ (emulating nRF54L10)
64-
- PCA10156
65-
- S145
66-
- bm_nrf54l15dk/nrf54l10/cpuapp/s145_softdevice
67-
* - `nRF54L15 DK`_ (emulating nRF54L05)
68-
- PCA10156
69-
- S145
70-
- bm_nrf54l15dk/nrf54l05/cpuapp/s145_softdevice
71-
* - `nRF54LM20 DK`_
72-
- PCA10184
73-
- S145
74-
- bm_nrf54lm20dk/nrf54lm20a/cpuapp/s145_softdevice
75-
* - nRF54LS05 DK
76-
- PCA10214
77-
- S145
78-
- bm_nrf54ls05dk/nrf54ls05b/cpuapp/s145_softdevice
79-
* - `nRF54LV10 DK`_
80-
- PCA10188
81-
- S145
82-
- bm_nrf54lv10dk/nrf54lv10/cpuapp/s145_softdevice
28+
.. include:: /includes/supported_boards_all_non-mcuboot_variants_s115.txt
29+
30+
.. include:: /includes/supported_boards_all_non-mcuboot_variants_s145.txt
8331

8432
.. group-tab:: MCUboot board variants
8533

8634
The following board variants have DFU capabilities:
8735

88-
.. list-table::
89-
:header-rows: 1
90-
91-
* - Hardware platform
92-
- PCA
93-
- SoftDevice
94-
- Board target
95-
* - `nRF54L15 DK`_
96-
- PCA10156
97-
- S115
98-
- bm_nrf54l15dk/nrf54l15/cpuapp/s115_softdevice/mcuboot
99-
* - `nRF54L15 DK`_ (emulating nRF54L10)
100-
- PCA10156
101-
- S115
102-
- bm_nrf54l15dk/nrf54l10/cpuapp/s115_softdevice/mcuboot
103-
* - `nRF54L15 DK`_ (emulating nRF54L05)
104-
- PCA10156
105-
- S115
106-
- bm_nrf54l15dk/nrf54l05/cpuapp/s115_softdevice/mcuboot
107-
* - `nRF54LM20 DK`_
108-
- PCA10184
109-
- S115
110-
- bm_nrf54lm20dk/nrf54lm20a/cpuapp/s115_softdevice/mcuboot
111-
* - `nRF54LV10 DK`_
112-
- PCA10188
113-
- S115
114-
- bm_nrf54lv10dk/nrf54lv10/cpuapp/s115_softdevice/mcuboot
115-
* - `nRF54L15 DK`_
116-
- PCA10156
117-
- S145
118-
- bm_nrf54l15dk/nrf54l15/cpuapp/s145_softdevice/mcuboot
119-
* - `nRF54L15 DK`_ (emulating nRF54L10)
120-
- PCA10156
121-
- S145
122-
- bm_nrf54l15dk/nrf54l10/cpuapp/s145_softdevice/mcuboot
123-
* - `nRF54L15 DK`_ (emulating nRF54L05)
124-
- PCA10156
125-
- S145
126-
- bm_nrf54l15dk/nrf54l05/cpuapp/s145_softdevice/mcuboot
127-
* - `nRF54LM20 DK`_
128-
- PCA10184
129-
- S145
130-
- bm_nrf54lm20dk/nrf54lm20a/cpuapp/s145_softdevice/mcuboot
131-
* - `nRF54LV10 DK`_
132-
- PCA10188
133-
- S145
134-
- bm_nrf54lv10dk/nrf54lv10/cpuapp/s145_softdevice/mcuboot
36+
.. include:: /includes/supported_boards_all_mcuboot_variants_s115.txt
37+
38+
.. include:: /includes/supported_boards_all_mcuboot_variants_s145.txt
13539

13640

13741
The sample also requires one of the following testing devices:
@@ -149,7 +53,7 @@ Overview
14953
********
15054

15155
To run the tests, connect to the development kit through the serial port and send shell commands.
152-
Zephyr's :ref:`zephyr:shell_api` module is used to handle the commands.
56+
Shell subsystem is used to handle the commands.
15357
At any time during the tests, you can dynamically set the radio parameters, such as output power, bit rate, and channel.
15458
In sweep mode, you can set the time for which the radio scans each channel from one millisecond to 99 milliseconds, in steps of one millisecond.
15559
The sample also allows you to send a data pattern to another development kit.
@@ -274,30 +178,3 @@ Complete the following steps:
274178
#. Set the kit in the TX sweep mode using the ``start_tx_sweep`` command.
275179
#. Start the `RSSI Viewer app`_ and select the kit to communicate with.
276180
#. On the application chart, observe the TX sweep in the form of a wave that starts at 2420 MHz frequency and ends with 2480 MHz.
277-
278-
Dependencies
279-
************
280-
281-
This sample uses the following |NCS| libraries:
282-
283-
* :ref:`shell_ipc_readme`
284-
285-
This sample has the following nrfx dependencies:
286-
287-
* :file:`nrfx/drivers/include/nrfx_timer.h`
288-
* :file:`nrfx/hal/nrf_power.h`
289-
* :file:`nrfx/hal/nrf_radio.h`
290-
291-
In addition, it uses the following Zephyr libraries:
292-
293-
* :ref:`zephyr:device_model_api`:
294-
295-
* :file:`drivers/clock_control.h`
296-
297-
* :ref:`zephyr:kernel_api`:
298-
299-
* :file:`include/init.h`
300-
301-
* :ref:`zephyr:shell_api`:
302-
303-
* :file:`include/shell/shell.h`

samples/peripherals/radio_test/prj.conf

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,27 @@
44
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
#
66

7-
CONFIG_CONSOLE_HANDLER=y
7+
# Logging
8+
CONFIG_LOG=y
9+
CONFIG_LOG_BACKEND_BM_UARTE=y
10+
11+
# Shell
812
CONFIG_SHELL=y
13+
CONFIG_SHELL_BACKEND_BM_UARTE=y
914

10-
CONFIG_DYNAMIC_INTERRUPTS=y
15+
# Optional shell features
16+
CONFIG_SHELL_HELP=y
17+
CONFIG_SHELL_TAB=y
18+
CONFIG_SHELL_TAB_AUTOCOMPLETION=y
19+
CONFIG_SHELL_HISTORY=y
1120

21+
# HW used by radio_test
1222
CONFIG_NRFX_TIMER=y
1323
CONFIG_NRFX_GPPI=y
1424

15-
CONFIG_ENTROPY_GENERATOR=y
16-
CONFIG_NRF_SECURITY=y
25+
# Use fake PRNG to reduce HW dependencies
26+
CONFIG_TEST_RANDOM_GENERATOR=y
1727

18-
CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=1024
28+
# Disable SoftDevice.
29+
# The radio_test sample needs to controlr radio and other relevant periperhals on its own.
30+
CONFIG_SOFTDEVICE=n

samples/peripherals/radio_test/src/main.c

Lines changed: 52 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,56 +4,30 @@
44
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
*/
66

7-
#include <zephyr/sys/printk.h>
8-
#include <zephyr/drivers/clock_control.h>
9-
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
10-
#include <zephyr/pm/device_runtime.h>
11-
#if defined(NRF54L15_XXAA)
12-
#include <hal/nrf_clock.h>
13-
#endif /* defined(NRF54L15_XXAA) */
7+
#include <zephyr/shell/shell.h>
8+
#include <bm/shell/backend_bm_uarte.h>
149
#include <nrfx.h>
10+
#include <hal/nrf_clock.h>
1511
/* TODO: DRGN-27733 Remove the alternative condition for nRF54LS05B
1612
* when the errata has been applied to this chip and the errata
1713
* check can be used instead.
1814
*/
1915
#if NRF54L_ERRATA_20_PRESENT || defined(NRF54LS05B_ENGA_XXAA)
2016
#include <hal/nrf_power.h>
2117
#endif /* NRF54L_ERRATA_20_PRESENT */
22-
#if defined(NRF54LM20A_XXAA)
23-
#include <hal/nrf_clock.h>
24-
#endif /* defined(NRF54LM20A_XXAA) */
2518

26-
/* Empty trim value */
27-
#define TRIM_VALUE_EMPTY 0xFFFFFFFF
19+
#include "radio_test.h"
20+
21+
const struct shell *sh;
2822

2923
static void clock_init(void)
3024
{
31-
int err;
32-
int res;
33-
struct onoff_manager *clk_mgr;
34-
struct onoff_client clk_cli;
35-
36-
clk_mgr = z_nrf_clock_control_get_onoff(CLOCK_CONTROL_NRF_SUBSYS_HF);
37-
if (!clk_mgr) {
38-
printk("Unable to get the Clock manager\n");
39-
return;
25+
nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_HFCLKSTARTED);
26+
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLKSTART);
27+
while (!nrf_clock_event_check(NRF_CLOCK, NRF_CLOCK_EVENT_HFCLKSTARTED)) {
28+
/* spin until HFXO is up */
4029
}
41-
42-
sys_notify_init_spinwait(&clk_cli.notify);
43-
44-
err = onoff_request(clk_mgr, &clk_cli);
45-
if (err < 0) {
46-
printk("Clock request failed: %d\n", err);
47-
return;
48-
}
49-
50-
do {
51-
err = sys_notify_fetch_result(&clk_cli.notify, &res);
52-
if (!err && res) {
53-
printk("Clock could not be started: %d\n", res);
54-
return;
55-
}
56-
} while (err);
30+
nrf_clock_event_clear(NRF_CLOCK, NRF_CLOCK_EVENT_HFCLKSTARTED);
5731

5832
#if NRF54L_ERRATA_20_PRESENT
5933
if (nrf54l_errata_20()) {
@@ -70,15 +44,53 @@ static void clock_init(void)
7044
/* MLTPAN-39 */
7145
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_PLLSTART);
7246
#endif /* defined(NRF54LM20A_XXAA) */
73-
74-
printk("Clock has started\n");
7547
}
7648

7749
int main(void)
7850
{
79-
printk("Starting Radio Test sample\n");
51+
sh = shell_backend_bm_uarte_get_ptr();
52+
const struct shell_backend_config_flags cfg_flags =
53+
SHELL_DEFAULT_BACKEND_CONFIG_FLAGS;
54+
55+
shell_init(sh, NULL, cfg_flags, false, 0);
56+
shell_start(sh);
57+
58+
shell_print(sh, "Starting Radio Test sample");
8059

8160
clock_init();
8261

62+
struct radio_test_config *p_radio_test_conf = radio_cmd_get_test_config();
63+
int err = radio_test_init(p_radio_test_conf);
64+
65+
if (err)
66+
{
67+
shell_error(sh, "radio_test_init() failed: %d", err);
68+
}
69+
70+
while (true) {
71+
/*
72+
* Process all received data from the shell backend, calling registered command
73+
* handlers like sample_terminate_cmd if the command and arguments match.
74+
*/
75+
shell_process(sh);
76+
77+
/*
78+
* Ensure no events are missed while we check if there is pending RX data to
79+
* be processed.
80+
*/
81+
unsigned int key = irq_lock();
82+
83+
radio_test_process_rx_timeout();
84+
85+
if (shell_backend_bm_uarte_rx_ready()) {
86+
/* Process pending RX data */
87+
irq_unlock(key);
88+
continue;
89+
}
90+
91+
/* Idle until next event */
92+
k_cpu_atomic_idle(key);
93+
}
94+
8395
return 0;
8496
}

0 commit comments

Comments
 (0)