Skip to content

Commit

Permalink
Applications: nrf5340_audio: Structure cleanup
Browse files Browse the repository at this point in the history
OCT-2705
Moved zbus to specific file

Signed-off-by: Kristoffer Rist Skøien <[email protected]>
  • Loading branch information
koffes committed May 30, 2024
1 parent 5893d4f commit fbfe170
Show file tree
Hide file tree
Showing 23 changed files with 38 additions and 72 deletions.
1 change: 0 additions & 1 deletion applications/nrf5340_audio/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/src/utils/fw_info_app.c.in"

# Target sources below are specific to the nRF5340 Audio DK HW
target_sources(app PRIVATE
src/nrf5340_audio_common.c
${CMAKE_BINARY_DIR}/fw_info_app.c
)

Expand Down
4 changes: 0 additions & 4 deletions applications/nrf5340_audio/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ module = MAIN
module-str = main
source "subsys/logging/Kconfig.template.log_config"

module = NRF5340_AUDIO_COMMON
module-str = nrf5340_audio_common
source "subsys/logging/Kconfig.template.log_config"

config PRINT_STACK_USAGE_MS
depends on THREAD_ANALYZER && INIT_STACKS
int "Print stack usage every x milliseconds"
Expand Down
5 changes: 3 additions & 2 deletions applications/nrf5340_audio/broadcast_sink/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <zephyr/zbus/zbus.h>

#include "broadcast_sink.h"
#include "nrf5340_audio_common.h"
#include "zbus_common.h"
#include "nrf5340_audio_dk.h"
#include "led.h"
#include "button_assignments.h"
Expand All @@ -20,6 +20,7 @@
#include "bt_rendering_and_capture.h"
#include "audio_datapath.h"
#include "le_audio_rx.h"
#include "fw_info_app.h"

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(main, CONFIG_MAIN_LOG_LEVEL);
Expand Down Expand Up @@ -454,7 +455,7 @@ int main(void)
ret = nrf5340_audio_dk_init();
ERR_CHK(ret);

ret = nrf5340_audio_common_init();
ret = fw_info_app_print();
ERR_CHK(ret);

ret = bt_mgmt_init();
Expand Down
5 changes: 3 additions & 2 deletions applications/nrf5340_audio/broadcast_source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
#include <zephyr/zbus/zbus.h>

#include "broadcast_source.h"
#include "nrf5340_audio_common.h"
#include "zbus_common.h"
#include "nrf5340_audio_dk.h"
#include "led.h"
#include "button_assignments.h"
#include "macros_common.h"
#include "audio_system.h"
#include "bt_mgmt.h"
#include "fw_info_app.h"

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(main, CONFIG_MAIN_LOG_LEVEL);
Expand Down Expand Up @@ -323,7 +324,7 @@ int main(void)
ret = nrf5340_audio_dk_init();
ERR_CHK(ret);

ret = nrf5340_audio_common_init();
ret = fw_info_app_print();
ERR_CHK(ret);

ret = bt_mgmt_init();
Expand Down
2 changes: 1 addition & 1 deletion applications/nrf5340_audio/doc/firmware_architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ Since the application architecture is the same for all applications and the code
Communication between modules
=============================

Communication between modules is primarily done through Zephyr's :ref:`zephyr:zbus` to make sure that there are as few dependencies as possible. Each of the buses used by the applications has their message structures described in :file:`nrf5340_audio_common.h`.
Communication between modules is primarily done through Zephyr's :ref:`zephyr:zbus` to make sure that there are as few dependencies as possible. Each of the buses used by the applications has their message structures described in :file:`zbus_common.h`.

.. _nrf53_audio_app_overview_architecture_usb:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#ifndef _NRF5340_AUDIO_COMMON_H_
#define _NRF5340_AUDIO_COMMON_H_
#ifndef _ZBUS_COMMON_H_
#define _ZBUS_COMMON_H_

#include <zephyr/bluetooth/audio/audio.h>

Expand Down Expand Up @@ -89,11 +89,4 @@ struct content_control_msg {
enum content_control_evt_type event;
};

/**
* @brief Initialize the software modules that are common for all the audio samples.
*
* @return 0 if successful, error otherwise.
*/
int nrf5340_audio_common_init(void);

#endif /* _NRF5340_AUDIO_COMMON_H_ */
#endif /* _ZBUS_COMMON_H_ */
2 changes: 1 addition & 1 deletion applications/nrf5340_audio/src/audio/audio_datapath.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <tone.h>
#include <pcm_mix.h>

#include "nrf5340_audio_common.h"
#include "zbus_common.h"
#include "macros_common.h"
#include "led.h"
#include "audio_i2s.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <zephyr/bluetooth/uuid.h>

#include "bt_content_ctrl_media_internal.h"
#include "nrf5340_audio_common.h"
#include "zbus_common.h"
#include "macros_common.h"

#include <zephyr/logging/log.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include <zephyr/bluetooth/conn.h>

#include "macros_common.h"
#include "nrf5340_audio_common.h"
#include "zbus_common.h"

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(bt_mgmt_adv, CONFIG_BT_MGMT_ADV_LOG_LEVEL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#include <zephyr/sys/byteorder.h>

#include "macros_common.h"
#include "nrf5340_audio_common.h"
#include "zbus_common.h"
#include "button_handler.h"
#include "button_assignments.h"
#include "bt_mgmt_ctlr_cfg_internal.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include "bt_mgmt.h"
#include "macros_common.h"
#include "nrf5340_audio_common.h"
#include "zbus_common.h"

#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(bt_mgmt_scan);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include "bt_vol_rend_internal.h"
#include "bt_vol_ctlr_internal.h"
#include "nrf5340_audio_common.h"
#include "zbus_common.h"

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(bt_r_c, CONFIG_BT_RENDERING_AND_CAPTURE_LOG_LEVEL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <../subsys/bluetooth/audio/bap_endpoint.h>

#include "macros_common.h"
#include "nrf5340_audio_common.h"
#include "zbus_common.h"
#include "channel_assignment.h"

#include <zephyr/logging/log.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "macros_common.h"
#include "bt_le_audio_tx.h"
#include "le_audio.h"
#include "nrf5340_audio_common.h"
#include "zbus_common.h"

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(broadcast_source, CONFIG_BROADCAST_SOURCE_LOG_LEVEL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <zephyr/zbus/zbus.h>
#include <../subsys/bluetooth/audio/bap_stream.h>

#include "nrf5340_audio_common.h"
#include "zbus_common.h"
#include "audio_sync_timer.h"
#include "sdc_hci_vs.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <../subsys/bluetooth/audio/bap_endpoint.h>

#include "macros_common.h"
#include "nrf5340_audio_common.h"
#include "zbus_common.h"
#include "bt_le_audio_tx.h"
#include "le_audio.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <zephyr/bluetooth/audio/lc3.h>

#include "macros_common.h"
#include "nrf5340_audio_common.h"
#include "zbus_common.h"
#include "bt_le_audio_tx.h"
#include "le_audio.h"

Expand Down
2 changes: 1 addition & 1 deletion applications/nrf5340_audio/src/modules/button_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <ctype.h>

#include "macros_common.h"
#include "nrf5340_audio_common.h"
#include "zbus_common.h"

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(button_handler, CONFIG_MODULE_BUTTON_HANDLER_LOG_LEVEL);
Expand Down
2 changes: 1 addition & 1 deletion applications/nrf5340_audio/src/modules/hw_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include <zephyr/zbus/zbus.h>

#include "macros_common.h"
#include "nrf5340_audio_common.h"
#include "zbus_common.h"
#include "cs47l63.h"
#include "cs47l63_spec.h"
#include "cs47l63_reg_conf.h"
Expand Down
35 changes: 0 additions & 35 deletions applications/nrf5340_audio/src/nrf5340_audio_common.c

This file was deleted.

9 changes: 9 additions & 0 deletions applications/nrf5340_audio/src/utils/nrf5340_audio_dk.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include <nrfx_clock.h>

#include "led.h"
#include "button_handler.h"
#include "button_assignments.h"
Expand Down Expand Up @@ -133,5 +135,12 @@ int nrf5340_audio_dk_init(void)
}
}

/* Use this to turn on 128 MHz clock for cpu_app */
ret = nrfx_clock_divider_set(NRF_CLOCK_DOMAIN_HFCLK, NRF_CLOCK_HFCLK_DIV_1);
ret -= NRFX_ERROR_BASE_NUM;
if (ret) {
return ret;
}

return 0;
}
5 changes: 3 additions & 2 deletions applications/nrf5340_audio/unicast_client/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <zephyr/zbus/zbus.h>

#include "unicast_client.h"
#include "nrf5340_audio_common.h"
#include "zbus_common.h"
#include "nrf5340_audio_dk.h"
#include "led.h"
#include "button_assignments.h"
Expand All @@ -21,6 +21,7 @@
#include "bt_rendering_and_capture.h"
#include "bt_content_ctrl.h"
#include "le_audio_rx.h"
#include "fw_info_app.h"

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(main, CONFIG_MAIN_LOG_LEVEL);
Expand Down Expand Up @@ -476,7 +477,7 @@ int main(void)
ret = nrf5340_audio_dk_init();
ERR_CHK(ret);

ret = nrf5340_audio_common_init();
ret = fw_info_app_print();
ERR_CHK(ret);

ret = bt_mgmt_init();
Expand Down
5 changes: 3 additions & 2 deletions applications/nrf5340_audio/unicast_server/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <zephyr/zbus/zbus.h>

#include "unicast_server.h"
#include "nrf5340_audio_common.h"
#include "zbus_common.h"
#include "nrf5340_audio_dk.h"
#include "led.h"
#include "button_assignments.h"
Expand All @@ -23,6 +23,7 @@
#include "bt_content_ctrl.h"
#include "le_audio.h"
#include "le_audio_rx.h"
#include "fw_info_app.h"

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(main, CONFIG_MAIN_LOG_LEVEL);
Expand Down Expand Up @@ -505,7 +506,7 @@ int main(void)
ret = nrf5340_audio_dk_init();
ERR_CHK(ret);

ret = nrf5340_audio_common_init();
ret = fw_info_app_print();
ERR_CHK(ret);

ret = bt_mgmt_init();
Expand Down

0 comments on commit fbfe170

Please sign in to comment.