Skip to content

Commit c47d9d9

Browse files
committed
[nrf fromlist] tests: drivers: audio: dmic_api: Enable test execution on nrf54l15
Enable execution of dmic_api test on nrf54l15: - add 'dmic' to the list of supported peripherals; - add overlay for nrf54l15; - align Nordic's implementation of PDM driver to pass the test. Upstream PR #: 82436 Signed-off-by: Sebastian Głąb <[email protected]>
1 parent a8ca36c commit c47d9d9

File tree

4 files changed

+45
-7
lines changed

4 files changed

+45
-7
lines changed

boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuapp.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ flash: 324
1515
supported:
1616
- adc
1717
- counter
18+
- dmic
1819
- gpio
1920
- i2c
2021
- pwm

drivers/audio/dmic_nrfx_pdm.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,6 @@ static int dmic_nrfx_pdm_configure(const struct device *dev,
403403

404404
channel->act_num_streams = 1;
405405
channel->act_chan_map_hi = 0;
406-
channel->act_chan_map_lo = def_map;
407406

408407
if (channel->req_num_streams != 1 ||
409408
channel->req_num_chan > 2 ||
@@ -434,9 +433,13 @@ static int dmic_nrfx_pdm_configure(const struct device *dev,
434433
nrfx_cfg.mode = channel->req_num_chan == 1
435434
? NRF_PDM_MODE_MONO
436435
: NRF_PDM_MODE_STEREO;
437-
nrfx_cfg.edge = channel->req_chan_map_lo == def_map
438-
? NRF_PDM_EDGE_LEFTFALLING
439-
: NRF_PDM_EDGE_LEFTRISING;
436+
if (channel->req_chan_map_lo == def_map) {
437+
nrfx_cfg.edge = NRF_PDM_EDGE_LEFTFALLING;
438+
channel->act_chan_map_lo = def_map;
439+
} else {
440+
nrfx_cfg.edge = NRF_PDM_EDGE_LEFTRISING;
441+
channel->act_chan_map_lo = alt_map;
442+
}
440443
#if NRF_PDM_HAS_MCLKCONFIG
441444
nrfx_cfg.mclksrc = drv_cfg->clk_src == ACLK
442445
? NRF_PDM_MCLKSRC_ACLK
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright (c) 2024 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/ {
8+
aliases {
9+
dmic-dev = &pdm20;
10+
};
11+
};
12+
13+
&pinctrl {
14+
pdm20_default_alt: pdm20_default_alt {
15+
group1 {
16+
psels = <NRF_PSEL(PDM_CLK, 1, 12)>,
17+
<NRF_PSEL(PDM_DIN, 1, 13)>;
18+
};
19+
};
20+
};
21+
22+
dmic_dev: &pdm20 {
23+
status = "okay";
24+
pinctrl-0 = <&pdm20_default_alt>;
25+
pinctrl-names = "default";
26+
clock-source = "PCLK32M";
27+
};

tests/drivers/audio/dmic_api/src/main.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,21 @@ static const struct device *dmic_dev = DEVICE_DT_GET(DT_ALIAS(dmic_dev));
2121
#define BYTES_PER_SAMPLE sizeof(int16_t)
2222
#define SLAB_ALIGN 4
2323
#define MAX_SAMPLE_RATE 48000
24+
#elif DT_HAS_COMPAT_STATUS_OKAY(nordic_nrf_pdm)
25+
#define PDM_CHANNELS 2
26+
#define SAMPLE_BIT_WIDTH 16
27+
#define BYTES_PER_SAMPLE sizeof(int16_t)
28+
#define SLAB_ALIGN 4
29+
#define MAX_SAMPLE_RATE 48000
30+
#else
31+
#error "Unsupported DMIC device"
32+
#endif
33+
2434
/* Milliseconds to wait for a block to be read. */
2535
#define READ_TIMEOUT 1000
2636
/* Size of a block for 100 ms of audio data. */
2737
#define BLOCK_SIZE(_sample_rate, _number_of_channels) \
2838
(BYTES_PER_SAMPLE * (_sample_rate / 10) * _number_of_channels)
29-
#else
30-
#error "Unsupported DMIC device"
31-
#endif
3239

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

0 commit comments

Comments
 (0)