Skip to content

Nrfx 6234 tdm #2917

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

/* i2s-node0 is the transmitter/receiver */

/ {
aliases {
i2s-tx = &tdm130;
};
};

&pinctrl {
tdm130_default_alt: tdm130_default_alt {
group1 {

Check warning on line 17 in samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

View workflow job for this annotation

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

LEADING_SPACE

samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay:17 please, no spaces at the start of a line

Check failure on line 17 in samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

View workflow job for this annotation

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

CODE_INDENT

samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay:17 code indent should use tabs where possible
psels = <NRF_PSEL(TDM_SCK_M, 1, 3)>,

Check warning on line 18 in samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

View workflow job for this annotation

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

LEADING_SPACE

samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay:18 please, no spaces at the start of a line

Check failure on line 18 in samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

View workflow job for this annotation

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

CODE_INDENT

samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay:18 code indent should use tabs where possible
<NRF_PSEL(TDM_FSYNC_M, 1, 6)>,

Check warning on line 19 in samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

View workflow job for this annotation

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

LEADING_SPACE

samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay:19 please, no spaces at the start of a line

Check failure on line 19 in samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

View workflow job for this annotation

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

CODE_INDENT

samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay:19 code indent should use tabs where possible
<NRF_PSEL(TDM_SDOUT, 1, 4)>,

Check warning on line 20 in samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

View workflow job for this annotation

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

LEADING_SPACE

samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay:20 please, no spaces at the start of a line

Check failure on line 20 in samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

View workflow job for this annotation

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

CODE_INDENT

samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay:20 code indent should use tabs where possible
<NRF_PSEL(TDM_SDIN, 1, 5)>,

Check warning on line 21 in samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

View workflow job for this annotation

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

LEADING_SPACE

samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay:21 please, no spaces at the start of a line

Check failure on line 21 in samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

View workflow job for this annotation

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

CODE_INDENT

samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay:21 code indent should use tabs where possible
<NRF_PSEL(TDM_MCK, 1, 2)>; /* Define MCLK pin */

Check warning on line 22 in samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

View workflow job for this annotation

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

LEADING_SPACE

samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay:22 please, no spaces at the start of a line

Check failure on line 22 in samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

View workflow job for this annotation

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

CODE_INDENT

samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay:22 code indent should use tabs where possible
};

Check warning on line 23 in samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

View workflow job for this annotation

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

LEADING_SPACE

samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay:23 please, no spaces at the start of a line

Check failure on line 23 in samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

View workflow job for this annotation

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

CODE_INDENT

samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay:23 code indent should use tabs where possible
};

Check warning on line 24 in samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

View workflow job for this annotation

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

LEADING_SPACE

samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay:24 please, no spaces at the start of a line
};

&tdm130 {
status = "okay";

Check warning on line 28 in samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

View workflow job for this annotation

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

LEADING_SPACE

samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay:28 please, no spaces at the start of a line
pinctrl-0 = <&tdm130_default_alt>;

Check warning on line 29 in samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay

View workflow job for this annotation

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

LEADING_SPACE

samples/drivers/i2s/output/boards/nrf54h20dk_nrf54h20_cpuapp.overlay:29 please, no spaces at the start of a line
pinctrl-names = "default";
memory-regions = <&cpuapp_dma_region>;
mck-frequency = <6144000>;
mck-clock-source = "ACLK";
sck-clock-source = "ACLK";
};

&audiopll {
status = "okay";
frequency = <NRFS_AUDIOPLL_FREQ_AUDIO_44K1>;
};
// #define NRFS_AUDIOPLL_FREQ_AUDIO_44K1 11289591
21 changes: 17 additions & 4 deletions samples/drivers/i2s/output/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include <zephyr/kernel.h>
#include <zephyr/drivers/i2s.h>
#include <zephyr/sys/iterable_sections.h>
#include <zephyr/linker/devicetree_regions.h>

#define SAMPLE_NO 64

Expand Down Expand Up @@ -40,7 +41,7 @@
}
}

#define NUM_BLOCKS 20
#define NUM_BLOCKS 5
#define BLOCK_SIZE (2 * sizeof(data))

#ifdef CONFIG_NOCACHE_MEMORY
Expand All @@ -49,9 +50,21 @@
#define MEM_SLAB_CACHE_ATTR
#endif /* CONFIG_NOCACHE_MEMORY */

#define TDM(idx) DT_NODELABEL(tdm##idx)
#define TDM_PROP(idx, prop) DT_PROP(TDM(idx), prop)
#define TDM_HAS_PROP(idx, prop) DT_NODE_HAS_PROP(TDM(idx), prop)

#define TDM_MEMORY_SECTION(idx) \
COND_CODE_1(TDM_HAS_PROP(idx, memory_regions), \
(__attribute__((__section__(LINKER_DT_NODE_REGION_NAME( \

Check failure on line 59 in samples/drivers/i2s/output/src/main.c

View workflow job for this annotation

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

CODE_INDENT

samples/drivers/i2s/output/src/main.c:59 code indent should use tabs where possible

Check notice on line 59 in samples/drivers/i2s/output/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

samples/drivers/i2s/output/src/main.c:59 -#define TDM(idx) DT_NODELABEL(tdm##idx) -#define TDM_PROP(idx, prop) DT_PROP(TDM(idx), prop) -#define TDM_HAS_PROP(idx, prop) DT_NODE_HAS_PROP(TDM(idx), prop) +#define TDM(idx) DT_NODELABEL(tdm##idx) +#define TDM_PROP(idx, prop) DT_PROP(TDM(idx), prop) +#define TDM_HAS_PROP(idx, prop) DT_NODE_HAS_PROP(TDM(idx), prop) -#define TDM_MEMORY_SECTION(idx) \ - COND_CODE_1(TDM_HAS_PROP(idx, memory_regions), \ +#define TDM_MEMORY_SECTION(idx) \ + COND_CODE_1(TDM_HAS_PROP(idx, memory_regions), \
DT_PHANDLE(TDM(idx), memory_regions)))))), \

Check failure on line 60 in samples/drivers/i2s/output/src/main.c

View workflow job for this annotation

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

CODE_INDENT

samples/drivers/i2s/output/src/main.c:60 code indent should use tabs where possible
())

Check failure on line 61 in samples/drivers/i2s/output/src/main.c

View workflow job for this annotation

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

CODE_INDENT

samples/drivers/i2s/output/src/main.c:61 code indent should use tabs where possible

#define BUFFER_MEM_REGION __attribute__((__section__("cpuapp_dma_region")))

static char MEM_SLAB_CACHE_ATTR __aligned(WB_UP(32))
_k_mem_slab_buf_tx_0_mem_slab[(NUM_BLOCKS) * WB_UP(BLOCK_SIZE)];
_k_mem_slab_buf_tx_0_mem_slab[(NUM_BLOCKS) * WB_UP(BLOCK_SIZE)] TDM_MEMORY_SECTION(130);

Check notice on line 67 in samples/drivers/i2s/output/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

samples/drivers/i2s/output/src/main.c:67 - _k_mem_slab_buf_tx_0_mem_slab[(NUM_BLOCKS) * WB_UP(BLOCK_SIZE)] TDM_MEMORY_SECTION(130); +_k_mem_slab_buf_tx_0_mem_slab[(NUM_BLOCKS)*WB_UP(BLOCK_SIZE)] TDM_MEMORY_SECTION(130);
static STRUCT_SECTION_ITERABLE(k_mem_slab, tx_0_mem_slab) =
Z_MEM_SLAB_INITIALIZER(tx_0_mem_slab, _k_mem_slab_buf_tx_0_mem_slab,
WB_UP(BLOCK_SIZE), NUM_BLOCKS);
Expand All @@ -70,8 +83,8 @@
}
/* Configure I2S stream */
i2s_cfg.word_size = 16U;
i2s_cfg.channels = 2U;
i2s_cfg.format = I2S_FMT_DATA_FORMAT_I2S;
i2s_cfg.channels = 4U;
i2s_cfg.format = I2S_FMT_DATA_FORMAT_PCM_SHORT;
i2s_cfg.frame_clk_freq = 44100;
i2s_cfg.block_size = BLOCK_SIZE;
i2s_cfg.timeout = 2000;
Expand Down
27 changes: 25 additions & 2 deletions tests/drivers/i2s/i2s_api/src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,33 @@
#include <zephyr/ztest.h>
#include <zephyr/drivers/i2s.h>
#include "i2s_api_test.h"
#include <zephyr/linker/devicetree_regions.h>

K_MEM_SLAB_DEFINE(rx_mem_slab, BLOCK_SIZE, NUM_RX_BLOCKS, 32);
K_MEM_SLAB_DEFINE(tx_mem_slab, BLOCK_SIZE, NUM_TX_BLOCKS, 32);
#define TDM(idx) DT_NODELABEL(tdm##idx)
#define TDM_PROP(idx, prop) DT_PROP(TDM(idx), prop)
#define TDM_HAS_PROP(idx, prop) DT_NODE_HAS_PROP(TDM(idx), prop)


#define TDM_MEMORY_SECTION(idx) \
COND_CODE_1(TDM_HAS_PROP(idx, memory_regions), \
(__attribute__((__section__(LINKER_DT_NODE_REGION_NAME( \
DT_PHANDLE(TDM(idx), memory_regions)))))), \
())

#define BUFFER_MEM_REGION __attribute__((__section__("cpuapp_dma_region")))

char __aligned(WB_UP(32))
_k_mem_slab_buf_rx_mem_slab[(NUM_RX_BLOCKS + 2) * WB_UP(BLOCK_SIZE)] TDM_MEMORY_SECTION(130);
STRUCT_SECTION_ITERABLE(k_mem_slab, rx_mem_slab) =
Z_MEM_SLAB_INITIALIZER(rx_mem_slab, _k_mem_slab_buf_rx_mem_slab,
WB_UP(BLOCK_SIZE), NUM_RX_BLOCKS + 2);

char __aligned(WB_UP(32))
_k_mem_slab_buf_tx_mem_slab[(NUM_TX_BLOCKS) * WB_UP(BLOCK_SIZE)] TDM_MEMORY_SECTION(130);
STRUCT_SECTION_ITERABLE(k_mem_slab, tx_mem_slab) =
Z_MEM_SLAB_INITIALIZER(tx_mem_slab, _k_mem_slab_buf_tx_mem_slab,
WB_UP(BLOCK_SIZE), NUM_TX_BLOCKS);

Check notice on line 37 in tests/drivers/i2s/i2s_api/src/common.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/i2s/i2s_api/src/common.c:37 -#define TDM(idx) DT_NODELABEL(tdm##idx) -#define TDM_PROP(idx, prop) DT_PROP(TDM(idx), prop) -#define TDM_HAS_PROP(idx, prop) DT_NODE_HAS_PROP(TDM(idx), prop) - - -#define TDM_MEMORY_SECTION(idx) \ - COND_CODE_1(TDM_HAS_PROP(idx, memory_regions), \ +#define TDM(idx) DT_NODELABEL(tdm##idx) +#define TDM_PROP(idx, prop) DT_PROP(TDM(idx), prop) +#define TDM_HAS_PROP(idx, prop) DT_NODE_HAS_PROP(TDM(idx), prop) + +#define TDM_MEMORY_SECTION(idx) \ + COND_CODE_1(TDM_HAS_PROP(idx, memory_regions), \ (__attribute__((__section__(LINKER_DT_NODE_REGION_NAME( \ DT_PHANDLE(TDM(idx), memory_regions)))))), \ ()) #define BUFFER_MEM_REGION __attribute__((__section__("cpuapp_dma_region"))) -char __aligned(WB_UP(32)) - _k_mem_slab_buf_rx_mem_slab[(NUM_RX_BLOCKS + 2) * WB_UP(BLOCK_SIZE)] TDM_MEMORY_SECTION(130); -STRUCT_SECTION_ITERABLE(k_mem_slab, rx_mem_slab) = - Z_MEM_SLAB_INITIALIZER(rx_mem_slab, _k_mem_slab_buf_rx_mem_slab, - WB_UP(BLOCK_SIZE), NUM_RX_BLOCKS + 2); - -char __aligned(WB_UP(32)) - _k_mem_slab_buf_tx_mem_slab[(NUM_TX_BLOCKS) * WB_UP(BLOCK_SIZE)] TDM_MEMORY_SECTION(130); -STRUCT_SECTION_ITERABLE(k_mem_slab, tx_mem_slab) = - Z_MEM_SLAB_INITIALIZER(tx_mem_slab, _k_mem_slab_buf_tx_mem_slab, - WB_UP(BLOCK_SIZE), NUM_TX_BLOCKS); +char __aligned(WB_UP(32)) +_k_mem_slab_buf_rx_mem_slab[(NUM_RX_BLOCKS + 2) * WB_UP(BLOCK_SIZE)] TDM_MEMORY_SECTION(130); +STRUCT_SECTION_ITERABLE(k_mem_slab, + rx_mem_slab) = Z_MEM_SLAB_INITIALIZER(rx_mem_slab, + _k_mem_slab_buf_rx_mem_slab, + WB_UP(BLOCK_SIZE), NUM_RX_BLOCKS + 2); + +char __aligned(WB_UP(32)) +_k_mem_slab_buf_tx_mem_slab[(NUM_TX_BLOCKS)*WB_UP(BLOCK_SIZE)] TDM_MEMORY_SECTION(130); +STRUCT_SECTION_ITERABLE(k_mem_slab, + tx_mem_slab) = Z_MEM_SLAB_INITIALIZER(tx_mem_slab, + _k_mem_slab_buf_tx_mem_slab, + WB_UP(BLOCK_SIZE), NUM_TX_BLOCKS);
/* The data_l represent a sine wave */
ZTEST_DMEM int16_t data_l[SAMPLE_NO] = {
6392, 12539, 18204, 23169, 27244, 30272, 32137, 32767, 32137,
Expand Down
20 changes: 17 additions & 3 deletions tests/drivers/i2s/i2s_speed/src/test_i2s_speed.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <zephyr/ztest.h>
#include <zephyr/drivers/i2s.h>
#include <zephyr/sys/iterable_sections.h>
#include <zephyr/linker/devicetree_regions.h>

#define I2S_DEV_NODE_RX DT_ALIAS(i2s_node0)
#ifdef CONFIG_I2S_TEST_SEPARATE_DEVICES
Expand All @@ -17,7 +18,7 @@
#define I2S_DEV_NODE_TX DT_ALIAS(i2s_node0)
#endif

#define NUM_BLOCKS 20
#define NUM_BLOCKS 5
#define SAMPLE_NO 64

/* The data_l represent a sine wave */
Expand Down Expand Up @@ -58,15 +59,28 @@
* RX blocks to satisfy this requirement
*/

#define TDM(idx) DT_NODELABEL(tdm##idx)
#define TDM_PROP(idx, prop) DT_PROP(TDM(idx), prop)
#define TDM_HAS_PROP(idx, prop) DT_NODE_HAS_PROP(TDM(idx), prop)


#define TDM_MEMORY_SECTION(idx) \
COND_CODE_1(TDM_HAS_PROP(idx, memory_regions), \
(__attribute__((__section__(LINKER_DT_NODE_REGION_NAME( \

Check notice on line 69 in tests/drivers/i2s/i2s_speed/src/test_i2s_speed.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/i2s/i2s_speed/src/test_i2s_speed.c:69 -#define TDM(idx) DT_NODELABEL(tdm##idx) -#define TDM_PROP(idx, prop) DT_PROP(TDM(idx), prop) -#define TDM_HAS_PROP(idx, prop) DT_NODE_HAS_PROP(TDM(idx), prop) - - -#define TDM_MEMORY_SECTION(idx) \ - COND_CODE_1(TDM_HAS_PROP(idx, memory_regions), \ +#define TDM(idx) DT_NODELABEL(tdm##idx) +#define TDM_PROP(idx, prop) DT_PROP(TDM(idx), prop) +#define TDM_HAS_PROP(idx, prop) DT_NODE_HAS_PROP(TDM(idx), prop) + +#define TDM_MEMORY_SECTION(idx) \ + COND_CODE_1(TDM_HAS_PROP(idx, memory_regions), \
DT_PHANDLE(TDM(idx), memory_regions)))))), \
())

#define BUFFER_MEM_REGION __attribute__((__section__("cpuapp_dma_region")))

char MEM_SLAB_CACHE_ATTR __aligned(WB_UP(32))
_k_mem_slab_buf_rx_0_mem_slab[(NUM_BLOCKS + 2) * WB_UP(BLOCK_SIZE)];
_k_mem_slab_buf_rx_0_mem_slab[(NUM_BLOCKS + 2) * WB_UP(BLOCK_SIZE)] TDM_MEMORY_SECTION(130);
STRUCT_SECTION_ITERABLE(k_mem_slab, rx_0_mem_slab) =
Z_MEM_SLAB_INITIALIZER(rx_0_mem_slab, _k_mem_slab_buf_rx_0_mem_slab,
WB_UP(BLOCK_SIZE), NUM_BLOCKS + 2);

char MEM_SLAB_CACHE_ATTR __aligned(WB_UP(32))
_k_mem_slab_buf_tx_0_mem_slab[(NUM_BLOCKS) * WB_UP(BLOCK_SIZE)];
_k_mem_slab_buf_tx_0_mem_slab[(NUM_BLOCKS) * WB_UP(BLOCK_SIZE)] TDM_MEMORY_SECTION(130);
STRUCT_SECTION_ITERABLE(k_mem_slab, tx_0_mem_slab) =

Check notice on line 83 in tests/drivers/i2s/i2s_speed/src/test_i2s_speed.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/i2s/i2s_speed/src/test_i2s_speed.c:83 - _k_mem_slab_buf_rx_0_mem_slab[(NUM_BLOCKS + 2) * WB_UP(BLOCK_SIZE)] TDM_MEMORY_SECTION(130); +_k_mem_slab_buf_rx_0_mem_slab[(NUM_BLOCKS + 2) * WB_UP(BLOCK_SIZE)] TDM_MEMORY_SECTION(130); STRUCT_SECTION_ITERABLE(k_mem_slab, rx_0_mem_slab) = Z_MEM_SLAB_INITIALIZER(rx_0_mem_slab, _k_mem_slab_buf_rx_0_mem_slab, WB_UP(BLOCK_SIZE), NUM_BLOCKS + 2); char MEM_SLAB_CACHE_ATTR __aligned(WB_UP(32)) - _k_mem_slab_buf_tx_0_mem_slab[(NUM_BLOCKS) * WB_UP(BLOCK_SIZE)] TDM_MEMORY_SECTION(130); +_k_mem_slab_buf_tx_0_mem_slab[(NUM_BLOCKS)*WB_UP(BLOCK_SIZE)] TDM_MEMORY_SECTION(130);
Z_MEM_SLAB_INITIALIZER(tx_0_mem_slab, _k_mem_slab_buf_tx_0_mem_slab,
WB_UP(BLOCK_SIZE), NUM_BLOCKS);

Expand Down
Loading