Skip to content

esp32: Add I2S peripheral support.#3489

Closed
aykevl wants to merge 1 commit intomicropython:masterfrom
aykevl:esp32-i2s
Closed

esp32: Add I2S peripheral support.#3489
aykevl wants to merge 1 commit intomicropython:masterfrom
aykevl:esp32-i2s

Conversation

@aykevl
Copy link
Copy Markdown
Contributor

@aykevl aykevl commented Dec 14, 2017

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

Comment thread ports/esp32/machine_i2s.c
.communication_format = I2S_COMM_FORMAT_I2S | I2S_COMM_FORMAT_I2S_MSB,
.intr_alloc_flags = ESP_INTR_FLAG_LEVEL1,
.dma_buf_count = 8,
.dma_buf_len = 64,
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've noticed this must be configurable somehow. For example, for stereo 48kHz 20ms packets (Opus) it needs to be at least 120.

@AidanTek
Copy link
Copy Markdown

Hello - I'm very interested in helping to make this happen, I see your pull request is from some time ago, I'm new to firmware but have experience with audio and embedded audio design. I have a variety of ESP32 versions and also audio codecs for both input and output (PCM5102A and PCM1808) more than happy to help where I can

@nevercast
Copy link
Copy Markdown
Contributor

A newer PR for the same is here: #4471

tannewt added a commit to tannewt/circuitpython that referenced this pull request Sep 30, 2020
…ection

ESP32S2: Enter station mode before connecting
@dpgeorge
Copy link
Copy Markdown
Member

I2S was implemented in 8a5bfe4

@dpgeorge dpgeorge closed this Jul 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants