← index #8641PR #3489
Related · high · value 1.277
QUERY · ISSUE

ESP32-C3 I2S

openby dave1167opened 2022-05-06updated 2025-01-03
port-esp32

Hi,
Is there any technical reason why I2S is missing from the ESP32-C3 build? Is there a likelihood it will be included in the future?
Many thanks

CANDIDATE · PULL REQUEST

esp32: Add I2S peripheral support.

closedby aykevlopened 2017-12-14updated 2021-07-13

Implementation of hardware I2S for the ESP32.

This appears to be the first I2S implementation for MicroPython. I've followed the proposed I2S machine API mostly, but did not follow it exactly. This is the current API / example code:

import machine
i2s = machine.I2S([0,] bclk=4, ws=15, data_out=2, data_in=22, [samplerate=48000,] [bitdepth=16])
buffer = ... # generate sine wave or something
while True:
    i2s.write(buffer)

# also implemented
i2s.deinit()
i2s.init(...) # throws an error if initialized already

Not yet implemented, mostly due to lacking hardware:

  • communication format, e.g. MSB/LSB.
  • clock: the ESP32 has an APLL clock, but I'm not sure what it's purpose is
  • callbacks (for now, i2s.write() blocks if the buffer is full)
  • reading from the I2S bus
  • not setting the data_in pin (not sure if this is possible)
  • change parameters
  • stop/start (without deinit) - by default it keeps looping existing data if the buffer isn't filled fast enough
  • internal ADC

Which of these (if any) should be implemented before it can be merged?

Documentation: https://esp-idf.readthedocs.io/en/latest/api-reference/peripherals/i2s.html

Keyboard

j / / n
next pair
k / / p
previous pair
1 / / h
show query pane
2 / / l
show candidate pane
c
copy suggested comment
r
toggle reasoning
g i
go to index
?
show this help
esc
close overlays

press ? or esc to close

copied