Skip to content

Commit

Permalink
samples: i2s: add esp32 boards
Browse files Browse the repository at this point in the history
Adds esp32 boards to i2s samples

Signed-off-by: Marcio Ribeiro <[email protected]>
  • Loading branch information
wmrsouza committed Feb 13, 2025
1 parent 1478ce8 commit af06cff
Show file tree
Hide file tree
Showing 11 changed files with 164 additions and 51 deletions.
3 changes: 3 additions & 0 deletions samples/drivers/i2s/echo/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ config STOP_START_STREAMS_SW1
depends on $(dt_alias_enabled,sw1)
select GPIO
default y

config DOESNT_SUPPORT_I2S_DIR_BOTH

Check warning on line 21 in samples/drivers/i2s/echo/Kconfig

View workflow job for this annotation

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

TYPO_SPELLING

samples/drivers/i2s/echo/Kconfig:21 'DOESNT' may be misspelled - perhaps 'DOESN'T'?
bool "Driver does not support I2S_DIR_BOTH operations"
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_DOESNT_SUPPORT_I2S_DIR_BOTH=y

Check warning on line 1 in samples/drivers/i2s/echo/boards/esp32_devkitc_wrover_procpu.conf

View workflow job for this annotation

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

TYPO_SPELLING

samples/drivers/i2s/echo/boards/esp32_devkitc_wrover_procpu.conf:1 'DOESNT' may be misspelled - perhaps 'DOESN'T'?
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/


&i2s0_default {
group1 {
pinmux = <I2S0_O_WS_GPIO33>,
<I2S0_O_BCK_GPIO32>,
<I2S0_O_SD_GPIO27>,
<I2S0_I_WS_GPIO26>,
<I2S0_I_BCK_GPIO25>;
output-enable;
};
group2 {
pinmux = <I2S0_I_SD_GPIO18>;
input-enable;
};
};

i2s_rxtx: &i2s0 {
status = "okay";

interrupts = <I2S0_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>,
<I2S0_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
interrupt-names = "tx", "rx";

Check failure on line 29 in samples/drivers/i2s/echo/boards/esp32_devkitc_wrover_procpu.overlay

View workflow job for this annotation

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

TRAILING_WHITESPACE

samples/drivers/i2s/echo/boards/esp32_devkitc_wrover_procpu.overlay:29 trailing whitespace
};
1 change: 1 addition & 0 deletions samples/drivers/i2s/echo/boards/esp32s2_devkitc.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_DOESNT_SUPPORT_I2S_DIR_BOTH=y

Check warning on line 1 in samples/drivers/i2s/echo/boards/esp32s2_devkitc.conf

View workflow job for this annotation

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

TYPO_SPELLING

samples/drivers/i2s/echo/boards/esp32s2_devkitc.conf:1 'DOESNT' may be misspelled - perhaps 'DOESN'T'?
30 changes: 30 additions & 0 deletions samples/drivers/i2s/echo/boards/esp32s2_devkitc.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/


&i2s0_default {
group1 {
pinmux = <I2S0_O_WS_GPIO17>,
<I2S0_O_BCK_GPIO16>,
<I2S0_O_SD_GPIO15>,
<I2S0_I_WS_GPIO11>,
<I2S0_I_BCK_GPIO10>;
output-enable;
};
group2 {
pinmux = <I2S0_I_SD_GPIO18>;
input-enable;
};
};

i2s_rxtx: &i2s0 {
status = "okay";

interrupts = <I2S0_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>,
<I2S0_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
interrupt-names = "tx", "rx";

Check failure on line 29 in samples/drivers/i2s/echo/boards/esp32s2_devkitc.overlay

View workflow job for this annotation

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

TRAILING_WHITESPACE

samples/drivers/i2s/echo/boards/esp32s2_devkitc.overlay:29 trailing whitespace
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_DOESNT_SUPPORT_I2S_DIR_BOTH=y

Check warning on line 1 in samples/drivers/i2s/echo/boards/esp32s3_devkitc_procpu.conf

View workflow job for this annotation

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

TYPO_SPELLING

samples/drivers/i2s/echo/boards/esp32s3_devkitc_procpu.conf:1 'DOESNT' may be misspelled - perhaps 'DOESN'T'?
52 changes: 14 additions & 38 deletions samples/drivers/i2s/echo/boards/esp32s3_devkitc_procpu.overlay
Original file line number Diff line number Diff line change
@@ -1,52 +1,28 @@
/*
* Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/

&pinctrl {
i2s0_pinconf: i2s0_pinconf {
group1 {
pinmux = <I2S0_MCLK_GPIO42>,
<I2S0_O_WS_GPIO41>,
<I2S0_O_BCK_GPIO40>,
<I2S0_O_SD_GPIO39>;
output-enable;
};
&i2s0_default {
group1 {
pinmux = <I2S0_MCLK_GPIO42>,
<I2S0_O_WS_GPIO41>,
<I2S0_O_BCK_GPIO40>,
<I2S0_O_SD_GPIO39>;
output-enable;
};

i2s1_pinconf: i2s1_pinconf {
group1 {
pinmux = <I2S1_MCLK_GPIO35>,
<I2S1_I_WS_GPIO36>,
<I2S1_I_BCK_GPIO37>;
output-enable;
};
group2 {
pinmux = <I2S1_I_SD_GPIO38>;
input-enable;
};
group2 {
pinmux = <I2S0_I_SD_GPIO38>;
input-enable;
};
};

i2s_tx: &i2s0 {
i2s_rxtx: &i2s0 {
status = "okay";

pinctrl-0 = <&i2s0_pinconf>;
pinctrl-names = "default";

dmas = <&dma 3>;
dma-names = "tx";
};

i2s_rx: &i2s1 {
status = "okay";

pinctrl-0 = <&i2s1_pinconf>;
pinctrl-names = "default";

dmas = <&dma 4>;
dma-names = "rx";
dmas = <&dma 2>, <&dma 3>;
dma-names = "rx", "tx";
};

&dma {
Expand Down
4 changes: 4 additions & 0 deletions samples/drivers/i2s/echo/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ static bool configure_streams(const struct device *i2s_dev_rx,
{
int ret;

#ifndef CONFIG_DOESNT_SUPPORT_I2S_DIR_BOTH

Check warning on line 157 in samples/drivers/i2s/echo/src/main.c

View workflow job for this annotation

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

TYPO_SPELLING

samples/drivers/i2s/echo/src/main.c:157 'DOESNT' may be misspelled - perhaps 'DOESN'T'?
if (i2s_dev_rx == i2s_dev_tx) {
ret = i2s_configure(i2s_dev_rx, I2S_DIR_BOTH, config);
if (ret == 0) {
Expand All @@ -167,6 +168,7 @@ static bool configure_streams(const struct device *i2s_dev_rx,
return false;
}
}
#endif /* CONFIG_DOESNT_SUPPORT_I2S_DIR_BOTH */

Check warning on line 171 in samples/drivers/i2s/echo/src/main.c

View workflow job for this annotation

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

TYPO_SPELLING

samples/drivers/i2s/echo/src/main.c:171 'DOESNT' may be misspelled - perhaps 'DOESN'T'?

ret = i2s_configure(i2s_dev_rx, I2S_DIR_RX, config);
if (ret < 0) {
Expand Down Expand Up @@ -215,6 +217,7 @@ static bool trigger_command(const struct device *i2s_dev_rx,
{
int ret;

#ifndef CONFIG_DOESNT_SUPPORT_I2S_DIR_BOTH

Check warning on line 220 in samples/drivers/i2s/echo/src/main.c

View workflow job for this annotation

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

TYPO_SPELLING

samples/drivers/i2s/echo/src/main.c:220 'DOESNT' may be misspelled - perhaps 'DOESN'T'?
if (i2s_dev_rx == i2s_dev_tx) {
ret = i2s_trigger(i2s_dev_rx, I2S_DIR_BOTH, cmd);
if (ret == 0) {
Expand All @@ -228,6 +231,7 @@ static bool trigger_command(const struct device *i2s_dev_rx,
return false;
}
}
#endif /* CONFIG_DOESNT_SUPPORT_I2S_DIR_BOTH */

Check warning on line 234 in samples/drivers/i2s/echo/src/main.c

View workflow job for this annotation

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

TYPO_SPELLING

samples/drivers/i2s/echo/src/main.c:234 'DOESNT' may be misspelled - perhaps 'DOESN'T'?

ret = i2s_trigger(i2s_dev_rx, I2S_DIR_RX, cmd);
if (ret < 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/

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

&i2s0_default {
group1 {
pinmux = <I2S0_O_WS_GPIO33>,
<I2S0_O_BCK_GPIO32>,
<I2S0_O_SD_GPIO27>;
output-enable;
};
group2 {
pinmux = <I2S0_I_SD_GPIO18>;
input-enable;
};
};

&i2s0 {
status = "okay";

interrupts = <I2S0_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
interrupt-names = "tx";
};
40 changes: 40 additions & 0 deletions samples/drivers/led/led_strip/boards/esp32s2_devkitc.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2025 Espressif Systems (Shanghai) Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/dt-bindings/led/led.h>

/ {
aliases {
led-strip = &led_strip;
};
};

&i2s0_default {
group1 {
pinmux = <I2S0_O_SD_GPIO18>;
output-enable;
};
};

i2s_led: &i2s0 {
status = "okay";

interrupts = <I2S0_INTR_SOURCE IRQ_DEFAULT_PRIORITY 0>;
interrupt-names = "tx";

led_strip: ws2812@0 {
compatible = "worldsemi,ws2812-i2s";
reg = <0>;

chain-length = <1>;
color-mapping = <LED_COLOR_ID_GREEN
LED_COLOR_ID_RED
LED_COLOR_ID_BLUE>;
reset-delay = <500>;
};

Check failure on line 38 in samples/drivers/led/led_strip/boards/esp32s2_devkitc.overlay

View workflow job for this annotation

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

TRAILING_WHITESPACE

samples/drivers/led/led_strip/boards/esp32s2_devkitc.overlay:38 trailing whitespace
};

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2024 Espressif Systems (Shanghai) Co., Ltd.
* Copyright (c) 2024-2025 Espressif Systems (Shanghai) Co., Ltd.
*
* SPDX-License-Identifier: Apache-2.0
*/
Expand All @@ -12,19 +12,24 @@
};
};

&i2s0_default {
group1 {
pinmux = <I2S0_O_SD_GPIO38>;
output-enable;
};
};

i2s_led: &i2s0 {
status = "okay";

pinctrl-0 = <&i2s0_pinconf>;

dmas = <&dma 3>;
dma-names = "tx";

led_strip: ws2812@0 {
compatible = "worldsemi,ws2812-i2s";

reg = <0>;
chain-length = <46>;
chain-length = <1>;
color-mapping = <LED_COLOR_ID_GREEN
LED_COLOR_ID_RED
LED_COLOR_ID_BLUE>;
Expand All @@ -35,12 +40,3 @@ i2s_led: &i2s0 {
&dma {
status = "okay";
};

&pinctrl {
i2s0_pinconf: i2s0_pinconf {
group1 {
pinmux = <I2S0_O_SD_GPIO38>;
output-enable;
};
};
};

0 comments on commit af06cff

Please sign in to comment.