diff --git a/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuapp.yaml b/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuapp.yaml index a3ddb5db1c6..4da5c7e9951 100644 --- a/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuapp.yaml +++ b/boards/nordic/nrf54l15dk/nrf54l15dk_nrf54l15_cpuapp.yaml @@ -15,6 +15,7 @@ flash: 324 supported: - adc - counter + - dmic - gpio - i2c - pwm diff --git a/drivers/audio/dmic_nrfx_pdm.c b/drivers/audio/dmic_nrfx_pdm.c index 98183e23254..4d5de03000e 100644 --- a/drivers/audio/dmic_nrfx_pdm.c +++ b/drivers/audio/dmic_nrfx_pdm.c @@ -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 || @@ -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 diff --git a/tests/drivers/audio/dmic_api/boards/nrf54l15dk_nrf54l15_cpuapp.overlay b/tests/drivers/audio/dmic_api/boards/nrf54l15dk_nrf54l15_cpuapp.overlay new file mode 100644 index 00000000000..a77b6baf38f --- /dev/null +++ b/tests/drivers/audio/dmic_api/boards/nrf54l15dk_nrf54l15_cpuapp.overlay @@ -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 = , + ; + }; + }; +}; + +dmic_dev: &pdm20 { + status = "okay"; + pinctrl-0 = <&pdm20_default_alt>; + pinctrl-names = "default"; + clock-source = "PCLK32M"; +}; diff --git a/tests/drivers/audio/dmic_api/src/main.c b/tests/drivers/audio/dmic_api/src/main.c index 488490e219c..7f697e4539b 100644 --- a/tests/drivers/audio/dmic_api/src/main.c +++ b/tests/drivers/audio/dmic_api/src/main.c @@ -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 +#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