Inter-IC Sound (I²S) Initialization and Configuration#

The WiSeConnect software development kit (SDK) provides a unified Inter-IC Sound (I²S) driver application programming interface (API) for SiWx917 devices. The driver supports multiple I²S instances with configurable operating modes, transfer types, and power-management features.

This guide walks you through the complete initialization and configuration process for I²S communication, from project setup to verification on hardware.

Step 1. Create or Open a Project#

  1. Launch Simplicity Studio.

  2. Create a new SiWx917 project or open an existing one.

  3. For a quick start, start from a WiSeConnect I²S example:

    • sl_si91x_i2s_primary

    • sl_si91x_i2s_secondary

    • sl_si91x_i2s_loopback

    • sl_si91x_ulp_i2s

  4. Connect the SiWx917 radio board. Simplicity Studio detects it automatically and shows it in Connected Devices.

    Board auto detectionBoard auto detection
    Figure: Board detection in Simplicity Studio

  5. From Example Projects and Demos, search for I2S, select an example, and click Create.

    I2S example searchI2S example search
    Figure: Searching for I²S example projects in Simplicity Studio

  6. Review the example’s readme.md for supported hardware and expected console output. I2S driver Primary exampleI2S driver Primary example

Typical Project Structure#

  • autogen/ – Auto-generated configuration headers and linker scripts

  • config/ – Platform-specific configuration headers

  • resources/ – Images and documentation assets

  • simplicity_sdk/ – Gecko SDK platform and third-party libraries

  • wiseconnect3_sdk_4.0.0/ – WiSeConnect SDK components and resources

  • sl_si91x_i2s_primary.slcp – Project configuration file

  • sl_si91x_i2s_primary.pintool – Pin Tool configuration for I²S pins

  • app.c / app.h – Application source and header files

  • main.c – Application entry point

  • readme.md – Example documentation and usage instructions

Step 2. Add the I²S Component#

If your project does not already include I²S:

  1. Open the project’s .slcp file.

  2. Go to the Software Components tab.

  3. Search for I2S.

  4. Add the required instances, for example:

    • I2S0 for HP audio

    • ULP_I2S for low-power audio

  5. To add more instances, select Add New Instance.

Simplicity Studio pulls in driver code and configuration automatically.

I2S Component in Simplicity StudioI2S Component in Simplicity Studio
Figure: Adding the I²S component in Simplicity Studio

Step 3. Configure I²S with Universal Configurator (UC)#

  1. In the Software Components view, select the I²S instance and click Install (if not already installed).

  2. Click Configure to open Universal Configurator (UC).

  3. Set the key parameters:
    I2S UC ConfigureI2S UC Configure

    Parameter

    Description

    Options / Range

    Resolution

    Bits per audio sample

    16, 24, or 32 bits

    Channel

    Channel instance

    Channel 0, Channel 1

    Sampling rate

    Audio sample rate

    8 kHz – 192 kHz

    Selected module

    I²S hardware instance

    I2S0

    DIN (data in)

    Audio data input pin

    GPIO_XX

    DOUT (data out)

    Audio data output pin

    GPIO_XX

    SCLK (bit clock)

    Serial clock pin

    GPIO_XX

    WSCLK (word select / LR clock)

    Left-right channel clock pin

    GPIO_XX

  4. Use the Pin Tool view to verify and adjust pin routing as needed.

    • Select pins from the drop-down list in UC.

    • Configure pin routing using the Pin Tool.

      Pins for I2SPins for I2S
      Figure: Recommended I²S pin selections

      Pins for ULP_I2SPins for ULP_I2S
      Figure: Recommended ULP I²S pin selections

    • UC stores these settings in auto-generated configuration files under autogen/.

Step 4. Configuration Parameters and Data Structures#

The I²S driver uses configuration structures and enums to describe operating mode, protocol, and transfer parameters.

Example Transfer Configuration#

typedef struct {
  uint16_t mode;          // Primary (controller) or Secondary (target) mode
  uint16_t sync;          // Synchronous or Asynchronous mode
  uint16_t protocol;      // Protocol (I²S or PCM)
  uint16_t resolution;    // Audio data resolution
  uint32_t data_size;     // Data word size (bits)
  uint32_t sampling_rate; // Audio sampling rate (Hz)
  uint32_t transfer_type; // Transfer type (Transmit or Receive)
} sl_i2s_xfer_config_t;

Example Event Enumeration#

typedef enum {
  SL_I2S_SEND_COMPLETE    = ARM_SAI_EVENT_SEND_COMPLETE,    // Send complete event
  SL_I2S_RECEIVE_COMPLETE = ARM_SAI_EVENT_RECEIVE_COMPLETE, // Receive complete event
  SL_I2S_TX_UNDERFLOW     = ARM_SAI_EVENT_TX_UNDERFLOW,     // DOUT underrun event
  SL_I2S_RX_OVERFLOW      = ARM_SAI_EVENT_RX_OVERFLOW,      // DIN overflow event
  SL_I2S_FRAME_ERROR      = ARM_SAI_EVENT_FRAME_ERROR       // Frame error event
} i2s_event_typedef_t;

Power States and Modes#

typedef enum {
  SL_I2S_POWER_OFF  = ARM_POWER_OFF,  // Power off mode
  SL_I2S_FULL_POWER = ARM_POWER_FULL  // Full power mode
} sl_i2s_power_state_t;

typedef enum {
  SL_I2S_MASTER = ARM_SAI_MODE_MASTER, // I²S primary (controller) mode
  SL_I2S_SLAVE  = ARM_SAI_MODE_SLAVE   // I²S secondary (target) mode
} sl_i2s_mode_t;

Step 5. Autogenerated Initialization Code#

When you add or modify I²S components, Simplicity Studio automatically generates configuration and driver files.

  • In the UC interface, click View Source to inspect the generated code.

    I2S Autogen init codeI2S Autogen init codeFigure: Auto-generated I²S initialization code in UC

Step 6. Initialize I²S in Your Application#

Use WiSeConnect SDK APIs to initialize and configure I²S. The driver source and header files are located in:

/wiseconnect3_sdk_<version>/components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
/wiseconnect3_sdk_<version>/components/device/silabs/si91x/mcu/drivers/unified_api/src/sl_si91x_i2s.c

Example Initialization Code#

status = sl_si91x_i2s_init(I2S_INSTANCE, &i2s_driver_handle);
if (status != SL_STATUS_OK) {
  DEBUGOUT("I²S initialization failed. Error code: %u\r\n", status);
} else {
  DEBUGOUT("I²S initialization successful.\r\n");
}

// Configure full power mode
status = sl_si91x_i2s_configure_power_mode(i2s_driver_handle, SL_I2S_FULL_POWER);
if (status != SL_STATUS_OK) {
  DEBUGOUT("I²S power mode configuration failed.\r\n");
} else {
  DEBUGOUT("I²S power mode configuration successful.\r\n");
}

// Register user callback
status = sl_si91x_i2s_register_event_callback(i2s_driver_handle, callback_event);
if (status != SL_STATUS_OK) {
  DEBUGOUT("I²S callback registration failed.\r\n");
} else {
  DEBUGOUT("I²S callback registration successful.\r\n");
}

Step 7. Customize for Advanced Use Cases#

You can modify the generated configuration or initialization code to support advanced scenarios, such as:

  • User-defined callback handlers

  • Dynamic DMA channel allocation

  • Power-state-based reinitialization

For additional examples, see the I²S Usage Scenarios.

Step 8. Build, Flash, and Test#

After configuration, build and flash the firmware to your SiWx917 device. Use the VCOM console in Simplicity Studio or an external terminal application to monitor logs and verify I²S operation.

Step-by-Step: Build, Flash, and Test#

  1. Build the project in Simplicity Studio.
    I2S build projectI2S build project

  2. Flash the firmware to the SiWx917 device.
    I2S flash deviceI2S flash device
    I2S program fileI2S program file

  3. Verify I²S operation using the serial console or debugger.

    • Connected devices view:Connected devicesConnected devices

    • Connect devices:Connect devicesConnect devices

    • Launch console:Launch consoleLaunch console

    • View console settings:Console settingsConsole settings

    • Console logs for Primary and Secondary:

      How to view logs:

      1. Open the console and select the serial1 tab.

      2. Place the cursor in the input field at the bottom.

      3. Press Enter to activate the console.

      Primary log example:Primary logsPrimary logs
      Secondary log example:
      Secondary logsSecondary logs

Note: You can also use terminal applications such as Tera Term or PuTTY instead of the Simplicity Studio VCOM console.

References#

Related Example Projects