I2S#
Introduction#
A serial communication protocol called I2S, or Inter-IC Sound, is intended to convey digital audio data between integrated circuits (ICs) in electronic devices. Connecting audio components like digital signal processors, digital-to-analog converters, and microphones is a popular usage for it.
In an I2S connection, one device typically serves as the master, generating the clock signals, while the other device operates as the slave, synchronizing its data transmission to the master's clock.
The following is a brief discussion of the I2S peripheral's capability for
Programmable audio resolutions
Sampling rates
Full duplex communication
Configuration#
The I2S module supports 5 resolutions, which can be programmable audio resolutions sl_i2s_data_resolution_t I2S also supports 11 audio sampling rates sl_i2s_sampling_rate_t
For more information on configuring available parameters refer to the respective peripheral example readme document.
Usage#
The default I2S is Initialised and configured with the 16 bit resolution and 8 kHz sampling rate. Just after calling the register callback it will goes to transmit-receive mode and communicates over Interrupt given.
I2S also had some of the apis with which one can configure the power modes, unregister the callback, get the data count and abort the transfer.
Modules#
Enumerations#
Enumeration for different I2S callback events.
Enumeration for I2S power state.
Enumeration for I2S Primary and Secondary modes.
Enumeration for SAI protocol type.
Enumeration for I2S SYNC/ASYNC modes.
Enumeration for I2S transfer type.
Enumeration for I2S transfer data size.
Enumeration for I2S audio data resolutions.
Enumeration for I2S sample rates.
Typedefs#
Renamed signal event structure.
Renamed status structure.
Renamed I2S driver structure.
Created I2S handle type.
Variables#
Release version number.
sqa version number
dev version number
Primary/Secondary mode.
SYNC/ASYNC mode.
I2S/PCM (currently only I2S is supported)
Audio data resolutions.
data size
Audio sampling rate.
Tx/Rx.
Functions#
This API Initializes the I2S peripheral.
This API uninitialize I2S peripheral.
This API configure I2S power mode.
This API configures transmitter/Receiver parameters for I2S transfer.
This API transmit I2S data.
This API receive I2S data.
This API Registers the user callback function.
This API un-registers the user callback function.
This API returns the transmitted data count.
This API return receives data count.
Get the release, sqa, and dev version of I2S.
This API return I2S peripheral status.
This API aborts I2S transfer.
Enumeration Documentation#
i2s_event_typedef_t#
i2s_event_typedef_t
Enumeration for different I2S callback events.
Enumerator | |
---|---|
SL_I2S_SEND_COMPLETE | Send complete event. |
SL_I2S_RECEIVE_COMPLETE | Receive lost event. |
SL_I2S_TX_UNDERFLOW | Tx underflow event. |
SL_I2S_RX_OVERFLOW | Rx Overflow event. |
SL_I2S_FRAME_ERROR | Frame error event. |
56
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_i2s_power_state_t#
sl_i2s_power_state_t
Enumeration for I2S power state.
Enumerator | |
---|---|
SL_I2S_POWER_OFF | Power mode OFF. |
SL_I2S_LOW_POWER | Low power mode. |
SL_I2S_FULL_POWER | Full power mode. |
65
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_i2s_mode_t#
sl_i2s_mode_t
Enumeration for I2S Primary and Secondary modes.
Enumerator | |
---|---|
SL_I2S_MASTER | I2S primary mode. |
SL_I2S_SLAVE | I2S secondary mode. |
72
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_sai_protocol_t#
sl_sai_protocol_t
Enumeration for SAI protocol type.
Enumerator | |
---|---|
SL_I2S_PROTOCOL | I2S protocol. |
SL_PCM_PROTOCOL | PCM protocol, currently not supported in the driver. |
78
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_i2s_sync_t#
sl_i2s_sync_t
Enumeration for I2S SYNC/ASYNC modes.
Enumerator | |
---|---|
SL_I2S_SYNC | I2S synchronous mode. |
SL_I2S_ASYNC | I2S asynchronous mode. |
84
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_i2s_xfer_type_t#
sl_i2s_xfer_type_t
Enumeration for I2S transfer type.
Enumerator | |
---|---|
SL_I2S_TRANSMIT | I2S transmit. |
SL_I2S_RECEIVE | I2S receive. |
SL_I2S_SEND_ABORT | I2S abort transmit. |
SL_I2S_RECEIVE_ABORT | I2S abort receive. |
90
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_i2s_xfer_size_t#
sl_i2s_xfer_size_t
Enumeration for I2S transfer data size.
Enumerator | |
---|---|
SL_I2S_DATA_SIZE8 | 8 bits |
SL_I2S_DATA_SIZE16 | 16 bits |
SL_I2S_DATA_SIZE32 | 32 bits |
98
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_i2s_data_resolution_t#
sl_i2s_data_resolution_t
Enumeration for I2S audio data resolutions.
Enumerator | |
---|---|
SL_I2S_RESOLUTION_12 | 12 bit resolution |
SL_I2S_RESOLUTION_16 | 16 bit resolution |
SL_I2S_RESOLUTION_20 | 20 bit resolution |
SL_I2S_RESOLUTION_24 | 24 bit resolution |
105
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_i2s_sampling_rate_t#
sl_i2s_sampling_rate_t
Enumeration for I2S sample rates.
Enumerator | |
---|---|
SL_I2S_SAMPLING_RATE_8000 | 8kHz |
SL_I2S_SAMPLING_RATE_11025 | 11.025kHz |
SL_I2S_SAMPLING_RATE_16000 | 16kHz |
SL_I2S_SAMPLING_RATE_22050 | 22.05kHz |
SL_I2S_SAMPLING_RATE_24000 | 24kHz |
SL_I2S_SAMPLING_RATE_32000 | 32kHz |
SL_I2S_SAMPLING_RATE_44100 | 44.1kHz |
SL_I2S_SAMPLING_RATE_48000 | 48kHz |
SL_I2S_SAMPLING_RATE_88200 | 88.2kHz |
SL_I2S_SAMPLING_RATE_96000 | 96kHz |
SL_I2S_SAMPLING_RATE_192000 | 192kHz |
113
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
Typedef Documentation#
sl_i2s_signal_event_t#
typedef ARM_SAI_SignalEvent_t sl_i2s_signal_event_t
Renamed signal event structure.
50
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_i2s_status_t#
typedef ARM_SAI_STATUS sl_i2s_status_t
Renamed status structure.
51
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_i2s_driver_t#
typedef ARM_DRIVER_SAI sl_i2s_driver_t
Renamed I2S driver structure.
52
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_i2s_handle_t#
typedef const void* sl_i2s_handle_t
Created I2S handle type.
53
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
Variable Documentation#
release#
uint8_t sl_i2s_version_t::release
Release version number.
129
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
major#
uint8_t sl_i2s_version_t::major
sqa version number
130
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
minor#
uint8_t sl_i2s_version_t::minor
dev version number
131
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
mode#
uint16_t sl_i2s_xfer_config_t::mode
Primary/Secondary mode.
136
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sync#
uint16_t sl_i2s_xfer_config_t::sync
SYNC/ASYNC mode.
137
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
protocol#
uint16_t sl_i2s_xfer_config_t::protocol
I2S/PCM (currently only I2S is supported)
138
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
resolution#
uint16_t sl_i2s_xfer_config_t::resolution
Audio data resolutions.
139
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
data_size#
uint32_t sl_i2s_xfer_config_t::data_size
data size
140
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sampling_rate#
uint32_t sl_i2s_xfer_config_t::sampling_rate
Audio sampling rate.
141
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
transfer_type#
uint32_t sl_i2s_xfer_config_t::transfer_type
Tx/Rx.
142
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
Function Documentation#
sl_si91x_i2s_init#
sl_status_t sl_si91x_i2s_init (uint32_t i2s_instance, sl_i2s_handle_t * i2s_handle)
This API Initializes the I2S peripheral.
[in] | i2s_instance | instance , 0 - I2S0 1 - I2S1 |
[in] | i2s_handle | Double Pointer to the I2S driver handle |
This API enable clock for I2S peripheral and configure SCLK, WSCLK, DIN and DOUT pins. Pass the address of the pointer for storing the I2S handle, which can be used in the future for other function calls.
Pre-condition:
none
Returns
status 0 if successful, else error code is as follow
SL_STATUS_OK (0x0000) - Success
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid
SL_STATUS_NULL_POINTER (0x0022) - Invalid null pointer received as argument
SL_STATUS_BUSY (0x0004) - Driver is busy
164
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_si91x_i2s_deinit#
sl_status_t sl_si91x_i2s_deinit (sl_i2s_handle_t * i2s_handle)
This API uninitialize I2S peripheral.
[in] | i2s_handle | Pointer to the I2S driver handle |
This API disable the DMA instance used for I2S transfer and power down I2S peripheral by disabling the clock supply to I2S
Pre-condition:
Returns
status 0 if successful, else error code is as follow
SL_STATUS_OK (0x0000) - Success
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid
SL_STATUS_NULL_POINTER (0x0022) - Invalid null pointer received as argument
Note
When I2S module is used in combination with other periperals, while deinitializing in the application, refer to the notes below:
Whenever sl_si91x_i2s_deinit() gets called, it will disable the clock for the peripheral. To power off the peripheral we have to power down the power domain (PERI_EFUSE) which contains the different peripherals mentioned below. i.e USART, UART, I2C, SSI Master, SSI Slave, Generic-SPI Master, I2S Master, I2S Slave, Micro-DMA Controller, Config Timer, Random-Number Generator, CRC Accelerator, SIO, QEI, MCPWM and EFUSE. Use below API to power down the particular power domain if other peripherals are not being used: sl_si91x_peri_efuse_power_down(power_down);
A few peripherals (ULP Peripherals, UULP Peripherals, GPDMA and SDIO-SPI) have seperate domains; those can be powered down indepedently. For additional details, refer to the Power architecture section in the Hardware Reference Manual. Here ULP_UART has a separate power domain ULPSS_PWRGATE_ULP_UART, which can be power down independently. Refer to rsi_power_save.h file for all power gates definitions.
191
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_si91x_i2s_configure_power_mode#
sl_status_t sl_si91x_i2s_configure_power_mode (sl_i2s_handle_t i2s_handle, sl_i2s_power_state_t state)
This API configure I2S power mode.
[in] | i2s_handle | Pointer to the I2S driver handle |
[in] | state | state, SL_I2S_POWER_OFF/SL_I2S_FULL_POWER |
The supported modes are POWER_OFF - I2S peripheral clocks and I2S DMA channel is disabled. FULL_POWER - Enable I2S peripheral clocks and configure I2S DMA channel.
Pre-conditions:
Returns
status 0 if successful, else error code is as follow
SL_STATUS_OK (0x0000) - Success
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid
SL_STATUS_NULL_POINTER (0x0022) - Invalid null pointer received as argument
208
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_si91x_i2s_config_transmit_receive#
sl_status_t sl_si91x_i2s_config_transmit_receive (sl_i2s_handle_t i2s_handle, sl_i2s_xfer_config_t * xfer_config)
This API configures transmitter/Receiver parameters for I2S transfer.
[in] | i2s_handle | Pointer to the I2S driver handle |
[in] | xfer_config | of structure which stores transfer parameters |
This API configures I2S DMA transmit and receive channels. Configuring transfer_type to SL_I2S_TRANSMIT will configure Tx channel and SL_I2S_RECEIVE will configure the Rx channel.
Pre-condition:
Returns
status 0 if successful, else error code is as follow
SL_STATUS_OK (0x0000) - Success
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid
SL_STATUS_NULL_POINTER (0x0022) - Invalid null pointer received as argument
226
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_si91x_i2s_transmit_data#
sl_status_t sl_si91x_i2s_transmit_data (sl_i2s_handle_t i2s_handle, const void * data, uint32_t size)
This API transmit I2S data.
[in] | i2s_handle | Pointer to the I2S driver handle |
[in] | data | of transmit data |
[in] | size | size |
This API configures I2S tx DMA channel descriptors and trigger DMA transfer. sl_si91x_i2s_config_transmit_receive() should be called with transfer_type set to SL_I2S_TRANSMIT before sending data.
Pre-conditions:
Returns
status 0 if successful, else error code is as follow
SL_STATUS_OK (0x0000) - Success
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid
SL_STATUS_NULL_POINTER (0x0022) - Invalid null pointer received as argument
246
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_si91x_i2s_receive_data#
sl_status_t sl_si91x_i2s_receive_data (sl_i2s_handle_t i2s_handle, const void * data, uint32_t size)
This API receive I2S data.
[in] | i2s_handle | Pointer to the I2S driver handle |
[in] | data | of receive data |
[in] | size | size |
This API configures I2S rx DMA channel descriptors and enables DMA channel to receive data. sl_si91x_i2s_config_transmit_receive() should be called with transfer_type set to SL_I2S_RECEIVE before receiving data.
Pre-conditions:
Returns
status 0 if successful, else error code is as follow
SL_STATUS_OK (0x0000) - Success
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid
SL_STATUS_NULL_POINTER (0x0022) - Invalid null pointer received as argument
266
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_si91x_i2s_register_event_callback#
sl_status_t sl_si91x_i2s_register_event_callback (sl_i2s_handle_t i2s_handle, sl_i2s_signal_event_t callback_event)
This API Registers the user callback function.
[in] | i2s_handle | Pointer to the I2S driver handle |
[in] | callback_event | Pointer to the function which needs to be called at the time of interrupt |
Transfer complete event can be notified using this callback. Callbacks should be registered before starting the I2S transfer.
Pre-conditions:
Returns
status 0 if successful, else error code as follows
SL_STATUS_OK (0x0000) - Success
SL_STATUS_NULL_POINTER (0x0022) - The parameter is a null pointer
SL_STATUS_BUSY (0x0004) - Driver is busy
283
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_si91x_i2s_unregister_event_callback#
sl_status_t sl_si91x_i2s_unregister_event_callback (sl_i2s_handle_t i2s_handle)
This API un-registers the user callback function.
[in] | i2s_handle | Pointer to the I2S driver handle |
This function can be used only if callbacks are registered before using sl_si91x_i2s_register_event_callback()
Pre-condition:
Returns
status 0 if successful, else error code SL_STATUS_OK (0x0000) - Success
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid
SL_STATUS_NULL_POINTER (0x0022) - Invalid null pointer received as argument
298
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_si91x_i2s_get_transmit_data_count#
uint32_t sl_si91x_i2s_get_transmit_data_count (sl_i2s_handle_t i2s_handle)
This API returns the transmitted data count.
[in] | i2s_handle | Pointer to the I2S driver handle |
Get the transmit data count of I2S. If an active I2S transfer is started, this function can be used to get several data bytes transferred.
Pre-conditions:
Returns
uint32_t value of the tx data count
313
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_si91x_i2s_get_receive_data_count#
uint32_t sl_si91x_i2s_get_receive_data_count (sl_i2s_handle_t i2s_handle)
This API return receives data count.
[in] | i2s_handle | Pointer to the I2S driver handle |
Get the received data count of I2S. If I2S is configured for receive, this function can be used to get several data bytes received.
Pre-conditions:
Returns
uint32_t value of the RX data count
329
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_si91x_i2s_get_version#
sl_i2s_version_t sl_si91x_i2s_get_version (void )
Get the release, sqa, and dev version of I2S.
N/A |
Pre-condition:
none
Returns
(sl_i2s_version_t) type structure
339
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_si91x_i2s_get_status#
sl_i2s_status_t sl_si91x_i2s_get_status (sl_i2s_handle_t i2s_handle)
This API return I2S peripheral status.
[in] | i2s_handle | Pointer to the I2S driver handle |
Get following transfer status of I2S,
Frame error
Rx busy
Rx overflow
Tx busy
Tx underflow
Pre-conditions:
Returns
(sl_i2s_status_t) type structure
357
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h
sl_si91x_i2s_end_transfer#
sl_status_t sl_si91x_i2s_end_transfer (sl_i2s_handle_t i2s_handle, sl_i2s_xfer_type_t abort_type)
This API aborts I2S transfer.
[in] | i2s_handle | Pointer to the I2S driver handle |
[in] | abort_type | type, ARM_SAI_ABORT_SEND/ARM_SAI_ABORT_RECEIVE |
This API disable I2S clocks and DMA channel. This API also stops WSCLK generation.
Pre-conditions:
sl_si91x_i2s_transmit_data/sl_si91x_i2s_receive_data
Returns
status 0 if successful, else error code is as follows
SL_STATUS_OK (0x0000) - Success
SL_STATUS_INVALID_PARAMETER (0x0021) - Parameters are invalid
SL_STATUS_NULL_POINTER (0x0022) - Invalid null pointer received as argument
376
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2s.h