Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nrf fromlist] tests: drivers: audio: dmic_api: Enable test execution… #2325

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuapp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ flash: 324
supported:
- adc
- counter
- dmic
- gpio
- i2c
- pwm
Expand Down
11 changes: 7 additions & 4 deletions drivers/audio/dmic_nrfx_pdm.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,6 @@ static int dmic_nrfx_pdm_configure(const struct device *dev,

channel->act_num_streams = 1;
channel->act_chan_map_hi = 0;
channel->act_chan_map_lo = def_map;

if (channel->req_num_streams != 1 ||
channel->req_num_chan > 2 ||
Expand Down Expand Up @@ -434,9 +433,13 @@ static int dmic_nrfx_pdm_configure(const struct device *dev,
nrfx_cfg.mode = channel->req_num_chan == 1
? NRF_PDM_MODE_MONO
: NRF_PDM_MODE_STEREO;
nrfx_cfg.edge = channel->req_chan_map_lo == def_map
? NRF_PDM_EDGE_LEFTFALLING
: NRF_PDM_EDGE_LEFTRISING;
if (channel->req_chan_map_lo == def_map) {
nrfx_cfg.edge = NRF_PDM_EDGE_LEFTFALLING;
channel->act_chan_map_lo = def_map;
} else {
nrfx_cfg.edge = NRF_PDM_EDGE_LEFTRISING;
channel->act_chan_map_lo = alt_map;
}
#if NRF_PDM_HAS_MCLKCONFIG
nrfx_cfg.mclksrc = drv_cfg->clk_src == ACLK
? NRF_PDM_MCLKSRC_ACLK
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
aliases {
dmic-dev = &pdm20;
};
};

&pinctrl {
pdm20_default_alt: pdm20_default_alt {
group1 {
psels = <NRF_PSEL(PDM_CLK, 1, 12)>,
<NRF_PSEL(PDM_DIN, 1, 13)>;
};
};
};

dmic_dev: &pdm20 {
status = "okay";
pinctrl-0 = <&pdm20_default_alt>;
pinctrl-names = "default";
clock-source = "PCLK32M";
};
13 changes: 10 additions & 3 deletions tests/drivers/audio/dmic_api/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,21 @@
#define BYTES_PER_SAMPLE sizeof(int16_t)
#define SLAB_ALIGN 4
#define MAX_SAMPLE_RATE 48000
#elif DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_pdm)
#define PDM_CHANNELS 2
#define SAMPLE_BIT_WIDTH 16
#define BYTES_PER_SAMPLE sizeof(int16_t)
#define SLAB_ALIGN 4
#define MAX_SAMPLE_RATE 48000

Check notice on line 29 in tests/drivers/audio/dmic_api/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

tests/drivers/audio/dmic_api/src/main.c:29 -#define PDM_CHANNELS 2 +#define PDM_CHANNELS 2 #define SAMPLE_BIT_WIDTH 16 #define BYTES_PER_SAMPLE sizeof(int16_t) -#define SLAB_ALIGN 4 +#define SLAB_ALIGN 4
#else
#error "Unsupported DMIC device"
#endif

/* Milliseconds to wait for a block to be read. */
#define READ_TIMEOUT 1000
/* Size of a block for 100 ms of audio data. */
#define BLOCK_SIZE(_sample_rate, _number_of_channels) \
(BYTES_PER_SAMPLE * (_sample_rate / 10) * _number_of_channels)
#else
#error "Unsupported DMIC device"
#endif

/* Driver will allocate blocks from this slab to receive audio data into them.
* Application, after getting a given block from the driver and processing its
Expand Down
Loading