Skip to content

Commit

Permalink
[nrf fromlist] tests: drivers: audio: dmic_api: Enable test execution…
Browse files Browse the repository at this point in the history
… 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]>
  • Loading branch information
nordic-segl committed Dec 13, 2024
1 parent 99faf47 commit 9e85819
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 7 deletions.
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 @@ static const struct device *dmic_dev = DEVICE_DT_GET(DT_ALIAS(dmic_dev));
#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

0 comments on commit 9e85819

Please sign in to comment.