Skip to content

Commit a1b84fd

Browse files
samples: drivers: i2s: echo: add MAX32655 support
- reduced block length from 100ms to 33.33ms to compile for low ram - add compile time conditional option to slave mode - add overlay file for max32655fthr Signed-off-by: Anuj Pathak <[email protected]>
1 parent 6905acd commit a1b84fd

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2025 Croxel Inc.
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
i2s_rxtx: &i2s0 {
8+
status = "okay";
9+
};
10+
11+
&i2c1 {
12+
max9867: max9867@18 {
13+
compatible = "adi,max9867";
14+
reg = <0x18>;
15+
};
16+
};

samples/drivers/i2s/echo/src/main.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,19 @@
2121
#define I2S_TX_NODE DT_NODELABEL(i2s_tx)
2222
#endif
2323

24+
/* Reduce echo delay when running on low ram devices */
25+
#if CONFIG_SRAM_SIZE <= 48
26+
#define ECHO_DELAY 30
27+
#else
28+
#define ECHO_DELAY 10
29+
#endif
30+
2431
#define SAMPLE_FREQUENCY 44100
2532
#define SAMPLE_BIT_WIDTH 16
2633
#define BYTES_PER_SAMPLE sizeof(int16_t)
2734
#define NUMBER_OF_CHANNELS 2
28-
/* Such block length provides an echo with the delay of 100 ms. */
29-
#define SAMPLES_PER_BLOCK ((SAMPLE_FREQUENCY / 10) * NUMBER_OF_CHANNELS)
35+
/* Such block length provides an echo with the delay of 100ms or 33.33ms */
36+
#define SAMPLES_PER_BLOCK ((SAMPLE_FREQUENCY / ECHO_DELAY) * NUMBER_OF_CHANNELS)
3037
#define INITIAL_BLOCKS 2
3138
#define TIMEOUT 1000
3239

@@ -298,7 +305,15 @@ int main(void)
298305
config.word_size = SAMPLE_BIT_WIDTH;
299306
config.channels = NUMBER_OF_CHANNELS;
300307
config.format = I2S_FMT_DATA_FORMAT_I2S;
308+
/*
309+
* On MAX32655FTHR, MAX9867 MCLK is connected to external 12.2880 crystal
310+
* thus using slave mode
311+
*/
312+
#if CONFIG_BOARD_MAX32655FTHR_MAX32655_M4
313+
config.options = I2S_OPT_BIT_CLK_SLAVE | I2S_OPT_FRAME_CLK_SLAVE;
314+
#else
301315
config.options = I2S_OPT_BIT_CLK_MASTER | I2S_OPT_FRAME_CLK_MASTER;
316+
#endif
302317
config.frame_clk_freq = SAMPLE_FREQUENCY;
303318
config.mem_slab = &mem_slab;
304319
config.block_size = BLOCK_SIZE;

0 commit comments

Comments
 (0)