XIAO ESP32C3 and I2S. How to?

https://espressif-docs.readthedocs-hosted.com/projects/arduino-esp32/en/latest/api/i2s.html

apparently

I do not have I2S hardware to test
but check this link… some data copied below

The I²S bus consists of at least three lines:

Note

All lines can be attached to almost any pin and this change can occur even during operation.

  • Bit clock line
    • Officially “continuous serial clock (SCK)”. Typically written “bit clock (BCLK)”.
    • In this library function parameter sckPin or constant PIN_I2S_SCK.
  • Word clock line
    • Officially “word select (WS)”. Typically called “left-right clock (LRCLK)” or “frame sync (FS)”.
    • 0 = Left channel, 1 = Right channel
    • In this library function parameter fsPin or constant PIN_I2S_FS.
  • Data line
    • Officially “serial data (SD)”, but can be called SDATA, SDIN, SDOUT, DACDAT, ADCDAT, etc.
    • Unlike Arduino I2S with single data pin switching between input and output, in ESP core driver use separate data line for input and output.
    • For backward compatibility, the shared data pin is sdPin or constant PIN_I2S_SD when using simplex mode.
    • When using in duplex mode, there are two data lines:
      • Output data line is called outSdPin for function parameter, or constant PIN_I2S_SD_OUT
      • Input data line is called inSdPin for function parameter, or constant PIN_I2S_SD_IN

Pin setup

Pins can be changed in two ways- 1st constants, 2nd functions.

Note

Shared data pin can be equal to any other data pin, but must not be equal to clock pin nor frame sync pin! Input and Output pins must not be equal, but one of them can be equal to shared data pin!

sckPin != fsPin != outSdPin != inSdPin

Copy to clipboard

sckPin != fsPin != sdPin

Copy to clipboard

By default, the pin numbers are defined in constants in the header file. You can redefine any of those constants before including I2S.h. This way the driver will use these new default values and you will not need to specify pins in your code. The constants and their default values are:

  • PIN_I2S_SCK 14
  • PIN_I2S_FS 25
  • PIN_I2S_SD 26
  • PIN_I2S_SD_OUT 26
  • PIN_I2S_SD_IN 35

The second option to change pins is using the following functions. These functions can be called on either on initialized or uninitialized object.

setAllPins

Set all pins using given values in parameters. This is simply a wrapper of four functions mentioned above.

int setAllPins(int sckPin, int fsPin, int sdPin, int outSdPin, int inSdPin)

Copy to clipboard

Set all pins to default i.e. take values from constants mentioned above. This simply calls the the function with the following constants.

  • PIN_I2S_SCK 14
  • PIN_I2S_FS 25
  • PIN_I2S_SD 26
  • PIN_I2S_SD_OUT 26
  • PIN_I2S_SD_IN 35

int setAllPins()