Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1fbc5f5

Browse files
committedMar 17, 2025·
applications: nrf5340_audio: LED module for kits with other LED setup
The LED module is currently written in a way that’s highly dependent on all of the LEDs present on the audio DK, which prevents the application from running on the nRF5340 DK. The module must be refactored so that it can still show the state of the application with a different selection of LEDs. Signed-off-by: Graham Wacey <graham.wacey@nordicsemi.no>
1 parent 2d2264f commit 1fbc5f5

31 files changed

+616
-413
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include <dt-bindings/led/led.h>
8+
9+
/ {
10+
audioleds: audioleds {
11+
compatible = "gpio-leds";
12+
status = "okay";
13+
14+
led_device_type: led_device_type {
15+
gpios = <&gpio0 7 GPIO_ACTIVE_HIGH>,
16+
<&gpio0 25 GPIO_ACTIVE_HIGH>,
17+
<&gpio0 26 GPIO_ACTIVE_HIGH>;
18+
label = "RGB LED 0";
19+
};
20+
21+
rgb2: rgb-2 {
22+
gpios = <&gpio0 28 GPIO_ACTIVE_HIGH>,
23+
<&gpio0 29 GPIO_ACTIVE_HIGH>,
24+
<&gpio0 30 GPIO_ACTIVE_HIGH>;
25+
label = "RGB LED 1";
26+
};
27+
28+
led_conn_status: led_conn_status {
29+
gpios = <&gpio0 31 GPIO_ACTIVE_HIGH>;
30+
label = "Blue LED 0";
31+
};
32+
33+
led_sync_status: led_sync_status {
34+
gpios = <&gpio1 0 GPIO_ACTIVE_HIGH>;
35+
label = "Green LED 0";
36+
};
37+
38+
led_app_status: led_app_status {
39+
gpios = <&gpio1 1 GPIO_ACTIVE_HIGH>;
40+
label = "Green LED 1";
41+
};
42+
};
43+
};

‎applications/nrf5340_audio/boards/nrf5340_audio_dk_nrf5340_cpuapp_fota.overlay

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#include "nrf5340_audio_dk_nrf5340_cpuapp.overlay"
2+
13
/ {
24
chosen {
35
nordic,pm-ext-flash = &mx25r64;
@@ -9,7 +11,9 @@
911
};
1012

1113
&spi4 {
12-
cs-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>, <&gpio0 11 GPIO_ACTIVE_LOW>, <&gpio0 17 GPIO_ACTIVE_LOW>;
14+
cs-gpios = <&gpio1 10 GPIO_ACTIVE_LOW>,
15+
<&gpio0 11 GPIO_ACTIVE_LOW>,
16+
<&gpio0 17 GPIO_ACTIVE_LOW>;
1317
status = "okay";
1418
mx25r64: mx25r6435f@0 {
1519

@@ -34,6 +38,6 @@
3438

3539
&gpio_fwd {
3640
uart {
37-
gpios = < &gpio1 0x9 0x0 >, < &gpio1 0x8 0x0 >, < &gpio1 0xb 0x0 >;
41+
gpios = <&gpio1 0x9 0x0>, <&gpio1 0x8 0x0>, <&gpio1 0xb 0x0>;
3842
};
3943
};

‎applications/nrf5340_audio/boards/nrf5340dk_nrf5340_cpuapp.overlay

+57
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,28 @@
44
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
55
*/
66

7+
/ {
8+
audioleds: audioleds {
9+
compatible = "gpio-leds";
10+
status = "okay";
11+
12+
led_conn_status: led_conn_status {
13+
gpios = <&gpio0 28 GPIO_ACTIVE_LOW>;
14+
label = "Green LED 0";
15+
};
16+
17+
led_sync_status: led_sync_status {
18+
gpios = <&gpio0 29 GPIO_ACTIVE_LOW>;
19+
label = "Green LED 1";
20+
};
21+
22+
led_app_status: led_app_status {
23+
gpios = <&gpio0 30 GPIO_ACTIVE_LOW>;
24+
label = "Green LED 2";
25+
};
26+
};
27+
};
28+
729
&usbd {
830
hs_0: hs_0 {
931
compatible = "usb-audio-hs";
@@ -16,3 +38,38 @@
1638
hp-channel-r;
1739
};
1840
};
41+
42+
&pinctrl {
43+
i2s0_default: i2s0_default {
44+
group1 {
45+
psels = <NRF_PSEL(I2S_MCK, 0, 12)>;
46+
nordic,drive-mode = <NRF_DRIVE_H0H1>;
47+
};
48+
49+
group2 {
50+
psels = <NRF_PSEL(I2S_SCK_M, 0, 14)>,
51+
<NRF_PSEL(I2S_LRCK_M, 0, 16)>,
52+
<NRF_PSEL(I2S_SDOUT, 0, 13)>,
53+
<NRF_PSEL(I2S_SDIN, 0, 15)>;
54+
};
55+
};
56+
57+
i2s0_sleep: i2s0_sleep {
58+
group1 {
59+
psels = <NRF_PSEL(I2S_MCK, 0, 12)>,
60+
<NRF_PSEL(I2S_SCK_M, 0, 14)>,
61+
<NRF_PSEL(I2S_LRCK_M, 0, 16)>,
62+
<NRF_PSEL(I2S_SDOUT, 0, 13)>,
63+
<NRF_PSEL(I2S_SDIN, 0, 15)>;
64+
low-power-enable;
65+
};
66+
};
67+
};
68+
69+
&i2s0 {
70+
compatible = "nordic,nrf-i2s";
71+
status = "okay";
72+
pinctrl-0 = <&i2s0_default>;
73+
pinctrl-1 = <&i2s0_sleep>;
74+
pinctrl-names = "default", "sleep";
75+
};

‎applications/nrf5340_audio/broadcast_sink/main.c

+12-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111

1212
#include "broadcast_sink.h"
1313
#include "zbus_common.h"
14-
#include "nrf5340_audio_dk.h"
14+
#include "nrf5340_dk_init.h"
15+
#include "led_assignments.h"
1516
#include "led.h"
1617
#include "button_assignments.h"
1718
#include "macros_common.h"
@@ -208,7 +209,7 @@ static void le_audio_msg_sub_thread(void)
208209

209210
audio_system_start();
210211
stream_state_set(STATE_STREAMING);
211-
ret = led_blink(LED_APP_1_BLUE);
212+
ret = led_blink(LED_AUDIO_CONN_STATUS);
212213
ERR_CHK(ret);
213214

214215
break;
@@ -223,7 +224,7 @@ static void le_audio_msg_sub_thread(void)
223224

224225
stream_state_set(STATE_PAUSED);
225226
audio_system_stop();
226-
ret = led_on(LED_APP_1_BLUE);
227+
ret = led_on(LED_AUDIO_CONN_STATUS);
227228
ERR_CHK(ret);
228229

229230
break;
@@ -265,7 +266,7 @@ static void le_audio_msg_sub_thread(void)
265266
if (strm_state == STATE_STREAMING) {
266267
stream_state_set(STATE_PAUSED);
267268
audio_system_stop();
268-
ret = led_on(LED_APP_1_BLUE);
269+
ret = led_on(LED_AUDIO_CONN_STATUS);
269270
ERR_CHK(ret);
270271
}
271272

@@ -471,10 +472,12 @@ static int zbus_link_producers_observers(void)
471472
return ret;
472473
}
473474

474-
ret = zbus_chan_add_obs(&volume_chan, &volume_evt_sub, ZBUS_ADD_OBS_TIMEOUT_MS);
475-
if (ret) {
476-
LOG_ERR("Failed to add add volume sub");
477-
return ret;
475+
if (IS_ENABLED(CONFIG_BOARD_NRF5340_AUDIO_DK_NRF5340_CPUAPP)) {
476+
ret = zbus_chan_add_obs(&volume_chan, &volume_evt_sub, ZBUS_ADD_OBS_TIMEOUT_MS);
477+
if (ret) {
478+
LOG_ERR("Failed to add add volume sub");
479+
return ret;
480+
}
478481
}
479482

480483
ret = zbus_chan_add_obs(&bt_mgmt_chan, &bt_mgmt_evt_sub, ZBUS_ADD_OBS_TIMEOUT_MS);
@@ -566,7 +569,7 @@ int main(void)
566569

567570
LOG_DBG("Main started");
568571

569-
ret = nrf5340_audio_dk_init();
572+
ret = nrf5340_board_init();
570573
ERR_CHK(ret);
571574

572575
ret = fw_info_app_print();

‎applications/nrf5340_audio/broadcast_source/main.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
#include "broadcast_source.h"
1515
#include "zbus_common.h"
16-
#include "nrf5340_audio_dk.h"
16+
#include "nrf5340_dk_init.h"
17+
#include "led_assignments.h"
1718
#include "led.h"
1819
#include "button_assignments.h"
1920
#include "macros_common.h"
@@ -206,7 +207,7 @@ static void le_audio_msg_sub_thread(void)
206207

207208
audio_system_start();
208209
stream_state_set(STATE_STREAMING);
209-
ret = led_blink(LED_APP_1_BLUE);
210+
ret = led_blink(LED_AUDIO_CONN_STATUS);
210211
ERR_CHK(ret);
211212

212213
break;
@@ -223,7 +224,7 @@ static void le_audio_msg_sub_thread(void)
223224

224225
stream_state_set(STATE_PAUSED);
225226
audio_system_stop();
226-
ret = led_on(LED_APP_1_BLUE);
227+
ret = led_on(LED_AUDIO_CONN_STATUS);
227228
ERR_CHK(ret);
228229

229230
break;
@@ -558,7 +559,7 @@ int main(void)
558559
size_t ext_adv_buf_cnt = 0;
559560
size_t per_adv_buf_cnt = 0;
560561

561-
ret = nrf5340_audio_dk_init();
562+
ret = nrf5340_board_init();
562563
ERR_CHK(ret);
563564

564565
ret = fw_info_app_print();

‎applications/nrf5340_audio/doc/building.rst

+9-2
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,13 @@ Complete the following steps to build the application:
259259
* For headset device: ``-DCONFIG_AUDIO_DEV=1``
260260
* For gateway device: ``-DCONFIG_AUDIO_DEV=2``
261261

262+
#. Choose the configuration file for the device selected by using one of the following options:
263+
264+
* For unicast headset: ``-DEXTRA_CONF_FILE=".\unicast_server\overlay-unicast_server.conf"``
265+
* For unicast gateway: ``-DEXTRA_CONF_FILE=".\unicast_client\overlay-unicast_client.conf"``
266+
* For broadcast headset: ``-DEXTRA_CONF_FILE=".\broadcast_sink\overlay-broadcast_sink.conf"``
267+
* For broadcast gateway: ``-DEXTRA_CONF_FILE=".\broadcast_source\overlay-broadcast_source.conf"``
268+
262269
#. Choose the application version (:ref:`nrf53_audio_app_building_config_files`) by using one of the following options:
263270

264271
* For the debug version: No build flag needed.
@@ -269,9 +276,9 @@ Complete the following steps to build the application:
269276

270277
.. code-block:: console
271278
272-
west build -b nrf5340_audio_dk/nrf5340/cpuapp --pristine -- -DCONFIG_AUDIO_DEV=1 -DFILE_SUFFIX=release
279+
west build -b nrf5340_audio_dk/nrf5340/cpuapp --pristine -- -DCONFIG_AUDIO_DEV=1 -DEXTRA_CONF_FILE=".\unicast_server\overlay-unicast_server.conf" -DFILE_SUFFIX=release
273280
274-
This command creates the build files for headset device directly in the :file:`build` directory.
281+
This command creates the build files for a unicast headset device directly in the :file:`build` directory.
275282
What this means is that you cannot create build files for all devices you want to program, because the subsequent commands will overwrite the files in the :file:`build` directory.
276283

277284
To work around this standard west behavior, you can add the ``-d`` parameter to the ``west`` command to specify a custom build folder for each device.

‎applications/nrf5340_audio/doc/requirements.rst

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,15 @@ nRF5340 Audio application requirements
99

1010
The nRF5340 Audio applications are designed to be used only with the following hardware:
1111

12-
.. table-from-rows:: /includes/sample_board_rows.txt
13-
:header: heading
14-
:rows: nrf5340_audio_dk_nrf5340
12+
.. table-from-sample-yaml::
1513

1614
.. note::
1715
The applications supports PCA10121 revisions 1.0.0 or above.
1816
The applications are also compatible with the following pre-launch revisions:
1917

2018
* Revisions 0.8.0 and above.
2119

22-
You need at least two nRF5340 Audio development kits (one with the gateway firmware and one with headset firmware) to test each of the applications.
20+
You need at least two nRF5340 development kits (one with the gateway firmware and one with headset firmware) to test each of the applications.
2321
For CIS with TWS in mind, three kits are required.
2422

2523
If you want to test with other hardware (for example, a mobile phone or PC), it is highly recommended to test with Audio DKs on both the gateway and headset side first to verify basic functionality before moving on to testing with other vendors.

0 commit comments

Comments
 (0)
Please sign in to comment.