Skip to content

Commit 07201b6

Browse files
koffesgreg-fer
authored andcommitted
applications: nrf5340_audio: Moved contin_array
Tests and code moved. Signed-off-by: Kristoffer Rist Skøien <kristoffer.skoien@nordicsemi.no> Co-authored-by: Grzegorz Ferenc <Grzegorz.Ferenc@nordicsemi.no>
1 parent 80c4ae3 commit 07201b6

File tree

20 files changed

+133
-56
lines changed

20 files changed

+133
-56
lines changed

.github/test-spec.yml

+1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
- "applications/nrf5340_audio/**/*"
4444
- "boards/arm/nrf5340_audio_dk_nrf5340/**/*"
4545
- "tests/nrf5340_audio/**/*"
46+
- "tests/lib/contin_array/**/*"
4647

4748
"CI-iot-samples-test":
4849
- "include/modem/at_monitor.h"

CODEOWNERS

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ Kconfig* @tejlmand
116116
/lib/modem_jwt/ @jayteemo @SeppoTakalo
117117
/lib/modem_attest_token/ @jayteemo
118118
/lib/qos/ @simensrostad
119+
/lib/contin_array/ @koffes @alexsven @erikrobstad @rick1082 @gWacey
119120
/modules/ @tejlmand
120121
/modules/mcuboot/ @de-nordic @nordicjm
121122
/modules/cjson/ @simensrostad @plskeggs @sigvartmh

applications/nrf5340_audio/Kconfig.defaults

+4
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ config SENSOR
6565
bool
6666
default y
6767

68+
config CONTIN_ARRAY
69+
bool
70+
default y
71+
6872
# I2S
6973
config NRFX_I2S
7074
bool

applications/nrf5340_audio/src/utils/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
target_sources(app PRIVATE
88
${CMAKE_CURRENT_SOURCE_DIR}/board_version.c
99
${CMAKE_CURRENT_SOURCE_DIR}/channel_assignment.c
10-
${CMAKE_CURRENT_SOURCE_DIR}/contin_array.c
1110
${CMAKE_CURRENT_SOURCE_DIR}/data_fifo.c
1211
${CMAKE_CURRENT_SOURCE_DIR}/error_handler.c
1312
${CMAKE_CURRENT_SOURCE_DIR}/pcm_stream_channel_modifier.c

applications/nrf5340_audio/src/utils/Kconfig

-4
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ module = CHAN_ASSIGNMENT
4848
module-str = chan-assignment
4949
source "subsys/logging/Kconfig.template.log_config"
5050

51-
module = CONTIN_ARRAY
52-
module-str = contin-array
53-
source "subsys/logging/Kconfig.template.log_config"
54-
5551
module = DATA_FIFO
5652
module-str = data-fifo
5753
source "subsys/logging/Kconfig.template.log_config"

applications/nrf5340_audio/src/utils/contin_array.h

-30
This file was deleted.
+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
.. _lib_contin_array:
2+
3+
Continuous array
4+
################
5+
6+
.. contents::
7+
:local:
8+
:depth: 2
9+
10+
The continuous array library introduces an array that you can loop over, for example if you want to create a period of a Pulse-code modulated (PCM) sine wave.
11+
You can use it to test playback with applications that support audio development kits, for example the :ref:`nrf53_audio_app`.
12+
13+
The library introduces the :c:func:`contin_array_create` function, which takes an array that the user wants to loop over.
14+
For more information, see `API documentation`_.
15+
16+
Configuration
17+
*************
18+
19+
To enable the library, set the :kconfig:option:`CONFIG_CONTIN_ARRAY` Kconfig option to ``y`` in the project configuration file :file:`prj.conf`.
20+
21+
API documentation
22+
*****************
23+
24+
| Header file: :file:`include/contin_array.h`
25+
| Source file: :file:`lib/contin_array/contin_array.c`
26+
27+
.. doxygengroup:: contin_array
28+
:project: nrf
29+
:members:

doc/nrf/releases/release-notes-changelog.rst

+5
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,11 @@ Libraries for NFC
340340
Other libraries
341341
---------------
342342

343+
* :ref:`lib_contin_array` library:
344+
345+
* Separated the library from the :ref:`nrf53_audio_app` and moved it to :file:`lib/contin_array`.
346+
Updated code and documentation accordingly.
347+
343348
* :ref:`lib_location` library:
344349

345350
* Updated:

include/contin_array.h

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (c) 2018 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#ifndef CONTIN_ARRAY_H
8+
#define CONTIN_ARRAY_H
9+
10+
#include <zephyr/kernel.h>
11+
12+
/**
13+
* @file contin_array.h
14+
*
15+
* @defgroup contin_array Continuous array
16+
* @{
17+
* @brief Basic continuous array.
18+
*/
19+
20+
/** @brief Creates a continuous array from a finite array.
21+
*
22+
* @param pcm_cont Pointer to the destination array.
23+
* @param pcm_cont_size Size of pcm_cont.
24+
* @param pcm_finite Pointer to an array of samples or data.
25+
* @param pcm_finite_size Size of pcm_finite.
26+
* @param finite_pos Variable used internally. Must be set
27+
* to 0 for the first run and not changed.
28+
*
29+
* @note This function serves the purpose of e.g. having a set of audio samples
30+
* stored in pcm_finite. This can then be fetched in smaller pieces into ram and
31+
* played back in a loop using the results in pcm_cont.
32+
* The function keeps track of the current position in finite_pos,
33+
* so that the function can be called multiple times and maintain the correct
34+
* position in pcm_finite.
35+
*
36+
* @retval 0 If the operation was successful.
37+
* @retval -EPERM If any sizes are zero.
38+
* @retval -ENXIO On NULL pointer.
39+
*/
40+
int contin_array_create(void *pcm_cont, uint32_t pcm_cont_size, void const *const pcm_finite,
41+
uint32_t pcm_finite_size, uint32_t *const finite_pos);
42+
43+
/**
44+
* @}
45+
*/
46+
#endif /* CONTIN_ARRAY_H */

lib/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,4 @@ add_subdirectory_ifdef(CONFIG_MODEM_ANTENNA modem_antenna)
4040
add_subdirectory_ifdef(CONFIG_QOS qos)
4141
add_subdirectory_ifdef(CONFIG_IDENTITY_KEY identity_key)
4242
add_subdirectory_ifdef(CONFIG_SFLOAT sfloat)
43+
add_subdirectory_ifdef(CONFIG_CONTIN_ARRAY contin_array)

lib/Kconfig

+1
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@ rsource "modem_antenna/Kconfig"
4141
rsource "qos/Kconfig"
4242
rsource "identity_key/Kconfig"
4343
rsource "sfloat/Kconfig"
44+
rsource "contin_array/Kconfig"
4445

4546
endmenu

lib/contin_array/CMakeLists.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#
2+
# Copyright (c) 2022 Nordic Semiconductor
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
zephyr_library()
8+
zephyr_library_sources(
9+
contin_array.c
10+
)
11+
12+
zephyr_include_directories(.)

lib/contin_array/Kconfig

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Continuous Array creator
2+
#
3+
# Copyright (c) 2022 Nordic Semiconductor
4+
#
5+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
6+
#
7+
8+
config CONTIN_ARRAY
9+
bool "Continuous array library"
10+
help
11+
Enable continuous array library
12+
13+
if CONTIN_ARRAY
14+
15+
module = CONTIN_ARRAY
16+
module-str = Continuous array
17+
source "${ZEPHYR_BASE}/subsys/logging/Kconfig.template.log_config"
18+
19+
endif #CONTIN_ARRAY

tests/lib/contin_array/CMakeLists.txt

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (c) 2018 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
10+
project(contin_array)
11+
12+
FILE(GLOB app_sources src/*.c)
13+
target_sources(app PRIVATE ${app_sources})
File renamed without changes.
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
CONFIG_ZTEST=y
22
CONFIG_IRQ_OFFLOAD=y
3+
CONFIG_CONTIN_ARRAY=y
File renamed without changes.

tests/nrf5340_audio/contin_array/CMakeLists.txt

-21
This file was deleted.

0 commit comments

Comments
 (0)