Skip to content

Commit 3661cde

Browse files
eren-terzioglulupyuen
authored andcommitted
esp32[c3|c6|h2]: Add I2S support
Add I2S support for risc-v based Espressif devices Signed-off-by: Eren Terzioglu <eren.terzioglu@espressif.com>
1 parent f286a63 commit 3661cde

File tree

30 files changed

+4390
-2
lines changed

30 files changed

+4390
-2
lines changed

Documentation/platforms/risc-v/esp32c3/boards/esp32c3-generic/index.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,29 @@ You can scan for all I2C devices using the following command::
208208

209209
nsh> i2c dev 0x00 0x7f
210210

211+
i2schar
212+
-------
213+
214+
This configuration enables the I2S character device and the i2schar example
215+
app, which provides an easy-to-use way of testing the I2S peripheral,
216+
enabling both the TX and the RX for those peripherals.
217+
218+
**I2S pinout**
219+
220+
============ ========== =========================================
221+
ESP32-C3 Pin Signal Pin Description
222+
============ ========== =========================================
223+
0 MCLK Master Clock
224+
4 SCLK Bit Clock (SCLK)
225+
5 LRCK Word Select (LRCLK)
226+
18 DOUT Data Out
227+
19 DIN Data In
228+
============ ========== =========================================
229+
230+
After successfully built and flashed, run on the boards's terminal::
231+
232+
nsh> i2schar
233+
211234
nimble
212235
------
213236

Documentation/platforms/risc-v/esp32c6/boards/esp32c6-devkitc/index.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,29 @@ You can scan for all I2C devices using the following command::
191191

192192
nsh> i2c dev 0x00 0x7f
193193

194+
i2schar
195+
-------
196+
197+
This configuration enables the I2S character device and the i2schar example
198+
app, which provides an easy-to-use way of testing the I2S peripheral,
199+
enabling both the TX and the RX for those peripherals.
200+
201+
**I2S pinout**
202+
203+
============ ========== =========================================
204+
ESP32-C3 Pin Signal Pin Description
205+
============ ========== =========================================
206+
0 MCLK Master Clock
207+
4 SCLK Bit Clock (SCLK)
208+
5 LRCK Word Select (LRCLK)
209+
18 DOUT Data Out
210+
19 DIN Data In
211+
============ ========== =========================================
212+
213+
After successfully built and flashed, run on the boards's terminal::
214+
215+
nsh> i2schar
216+
194217
motor
195218
-------
196219

Documentation/platforms/risc-v/esp32c6/boards/esp32c6-devkitm/index.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,29 @@ You can scan for all I2C devices using the following command::
175175

176176
nsh> i2c dev 0x00 0x7f
177177

178+
i2schar
179+
-------
180+
181+
This configuration enables the I2S character device and the i2schar example
182+
app, which provides an easy-to-use way of testing the I2S peripheral,
183+
enabling both the TX and the RX for those peripherals.
184+
185+
**I2S pinout**
186+
187+
============ ========== =========================================
188+
ESP32-C3 Pin Signal Pin Description
189+
============ ========== =========================================
190+
0 MCLK Master Clock
191+
4 SCLK Bit Clock (SCLK)
192+
5 LRCK Word Select (LRCLK)
193+
18 DOUT Data Out
194+
19 DIN Data In
195+
============ ========== =========================================
196+
197+
After successfully built and flashed, run on the boards's terminal::
198+
199+
nsh> i2schar
200+
178201
mcuboot_nsh
179202
--------------------
180203

Documentation/platforms/risc-v/esp32c6/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ eFuse Yes
282282
GPIO Yes
283283
HMAC No
284284
I2C Yes
285-
I2S No
285+
I2S Yes
286286
Int. Temp. Yes
287287
LED No
288288
LED_PWM Yes

Documentation/platforms/risc-v/esp32h2/boards/esp32h2-devkit/index.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,29 @@ You can scan for all I2C devices using the following command::
174174

175175
nsh> i2c dev 0x00 0x7f
176176

177+
i2schar
178+
-------
179+
180+
This configuration enables the I2S character device and the i2schar example
181+
app, which provides an easy-to-use way of testing the I2S peripheral,
182+
enabling both the TX and the RX for those peripherals.
183+
184+
**I2S pinout**
185+
186+
============ ========== =========================================
187+
ESP32-C3 Pin Signal Pin Description
188+
============ ========== =========================================
189+
0 MCLK Master Clock
190+
4 SCLK Bit Clock (SCLK)
191+
5 LRCK Word Select (LRCLK)
192+
10 DOUT Data Out
193+
11 DIN Data In
194+
============ ========== =========================================
195+
196+
After successfully built and flashed, run on the boards's terminal::
197+
198+
nsh> i2schar
199+
177200
mcuboot_nsh
178201
--------------------
179202

Documentation/platforms/risc-v/esp32h2/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ eFuse Yes
282282
GPIO Yes
283283
HMAC No
284284
I2C Yes
285-
I2S No
285+
I2S Yes
286286
Int. Temp. Yes
287287
LED No
288288
LED_PWM Yes

arch/risc-v/src/common/espressif/Kconfig

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,19 @@ config ESPRESSIF_LEDC
321321
select PWM
322322
select ARCH_HAVE_PWM_MULTICHAN
323323

324+
config ESPRESSIF_I2S
325+
bool
326+
default n
327+
328+
config ESPRESSIF_I2S0
329+
bool "I2S 0"
330+
default n
331+
select ESPRESSIF_I2S
332+
select I2S
333+
select ESPRESSIF_DMA
334+
select ESPRESSIF_GPIO_IRQ
335+
select SCHED_HPWORK
336+
324337
config ESPRESSIF_I2C
325338
bool
326339
default n
@@ -1647,6 +1660,125 @@ endif # PWM_MULTICHAN && PWM_NCHANNELS > 1
16471660

16481661
endmenu # LEDC configuration
16491662

1663+
menu "I2S Configuration"
1664+
depends on ESPRESSIF_I2S
1665+
1666+
config ESPRESSIF_I2S_MAXINFLIGHT
1667+
int "I2S queue size"
1668+
default 4
1669+
---help---
1670+
This is the total number of transfers, both RX and TX, that can be
1671+
enqueued before the caller is required to wait. This setting
1672+
determines the number certain queue data structures that will be
1673+
pre-allocated.
1674+
1675+
if ESPRESSIF_I2S0
1676+
1677+
config ESPRESSIF_I2S0_RX
1678+
bool "Enable I2S receiver"
1679+
default y
1680+
---help---
1681+
Enable I2S receiver (port 0)
1682+
1683+
config ESPRESSIF_I2S0_TX
1684+
bool "Enable I2S transmitter"
1685+
default y
1686+
---help---
1687+
Enable I2S transmitter (port 0)
1688+
1689+
choice ESPRESSIF_I2S0_ROLE
1690+
prompt "I2S0 role"
1691+
default ESPRESSIF_I2S0_ROLE_MASTER
1692+
---help---
1693+
Selects the operation role of the I2S0.
1694+
1695+
config ESPRESSIF_I2S0_ROLE_MASTER
1696+
bool "Master"
1697+
1698+
config ESPRESSIF_I2S0_ROLE_SLAVE
1699+
bool "Slave"
1700+
1701+
endchoice # I2S0 role
1702+
1703+
choice ESPRESSIF_I2S0_DATA_BIT_WIDTH
1704+
prompt "Bit width"
1705+
default ESPRESSIF_I2S0_DATA_BIT_WIDTH_16BIT
1706+
---help---
1707+
Selects the valid data bits per sample.
1708+
Note that this option may be overwritten by the audio
1709+
according to the bit width of the file being played
1710+
1711+
config ESPRESSIF_I2S0_DATA_BIT_WIDTH_8BIT
1712+
bool "8 bits"
1713+
1714+
config ESPRESSIF_I2S0_DATA_BIT_WIDTH_16BIT
1715+
bool "16 bits"
1716+
1717+
config ESPRESSIF_I2S0_DATA_BIT_WIDTH_24BIT
1718+
bool "24 bits"
1719+
1720+
config ESPRESSIF_I2S0_DATA_BIT_WIDTH_32BIT
1721+
bool "32 bits"
1722+
1723+
endchoice # Bit width
1724+
1725+
config ESPRESSIF_I2S0_SAMPLE_RATE
1726+
int "I2S0 sample rate"
1727+
default 44100
1728+
range 8000 48000
1729+
---help---
1730+
Selects the sample rate.
1731+
Note that this option may be overwritten by the audio
1732+
according to the bit width of the file being played
1733+
1734+
config ESPRESSIF_I2S0_BCLKPIN
1735+
int "I2S0 BCLK pin"
1736+
default 4
1737+
range 0 48
1738+
1739+
config ESPRESSIF_I2S0_WSPIN
1740+
int "I2S0 WS pin"
1741+
default 5
1742+
range 0 48
1743+
1744+
config ESPRESSIF_I2S0_DINPIN
1745+
int "I2S0 DIN pin"
1746+
depends on ESPRESSIF_I2S0_RX
1747+
default 19 if !ESPRESSIF_ESP32H2
1748+
default 11 if ESPRESSIF_ESP32H2
1749+
range 0 48
1750+
1751+
config ESPRESSIF_I2S0_DOUTPIN
1752+
int "I2S0 DOUT pin"
1753+
depends on ESPRESSIF_I2S0_TX
1754+
default 18 if !ESPRESSIF_ESP32H2
1755+
default 10 if ESPRESSIF_ESP32H2
1756+
range 0 48
1757+
1758+
config ESPRESSIF_I2S0_MCLK
1759+
bool "Enable I2S Master Clock"
1760+
depends on ESPRESSIF_I2S0_ROLE_MASTER
1761+
default n
1762+
---help---
1763+
Enable I2S master clock
1764+
1765+
config ESPRESSIF_I2S0_MCLKPIN
1766+
int "I2S MCLK pin"
1767+
depends on ESPRESSIF_I2S0_MCLK
1768+
default 0
1769+
range 0 48
1770+
1771+
endif # ESPRESSIF_I2S0
1772+
1773+
config I2S_DMADESC_NUM
1774+
int "I2S DMA maximum number of descriptors"
1775+
default 2
1776+
---help---
1777+
Configure the maximum number of out-link/in-link descriptors to
1778+
be chained for an I2S DMA transfer.
1779+
1780+
endmenu # I2S configuration
1781+
16501782
menu "I2C Configuration"
16511783
depends on ESPRESSIF_I2C
16521784

arch/risc-v/src/common/espressif/Make.defs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ ifeq ($(CONFIG_ESPRESSIF_I2C),y)
116116
endif
117117
endif
118118

119+
ifeq ($(CONFIG_ESPRESSIF_I2S),y)
120+
CHIP_CSRCS += esp_i2s.c
121+
endif
122+
119123
ifeq ($(CONFIG_ESPRESSIF_SPI),y)
120124
ifeq ($(CONFIG_ESPRESSIF_SPI_PERIPH),y)
121125
CHIP_CSRCS += esp_spi.c

0 commit comments

Comments
 (0)