I2C#
Introduction#
Inter-Integrated Circuit (I2C) is a serial communication protocol widely used in microcontrollers and integrated circuits for communication between various peripheral devices and sensors. I2C uses only two wires: a serial data line (SDA) and a serial clock line (SCL), making it efficient in terms of pin usage, especially in systems with limited pin counts.
I2C is favored in embedded systems for its simplicity, flexibility, and low pin count requirements. Common use cases include:
Sensor Integration: Connecting various sensors for data collection.
Sensor Hubs and Fusion Algorithms: Combining sensor data for enhanced applications.
Memory Expansion: Adding EEPROMs or other memory devices.
Real-Time Clock (RTC): Maintaining accurate timekeeping.
Display Interfaces: Driving LCDs and other display modules.
Peripheral Control: Managing additional peripheral devices.
Communication with Other Microcontrollers and Modules: Enabling inter-device communication.
System Configuration and Control: Configuring system settings and parameters.
Configuration#
I2C can be configured using several parameters, including:
Mode: Leader or Follower mode (sl_i2c_mode_t)
Transfer Type: Using interrupts or DMA (sl_i2c_transfer_type_t)
Operating Speed: Various speed modes (sl_i2c_operating_mode_t)
These configurations are encapsulated in the sl_i2c_config_t structure and initialized using the sl_i2c_driver_init() API.
For more details on configuration parameters, see the respective peripheral example readme document.
Usage#
After defining the I2C configuration structures and passing an instance of sl_i2c_config_t, the common I2C functions can be used to initiate and configure the I2C module. The typical flow for implementation is as follows:
Initialize the I2C driver: sl_i2c_driver_init
Set the follower address (if in follower mode): sl_i2c_driver_set_follower_address
Configure the FIFO threshold: sl_i2c_driver_configure_fifo_threshold
Perform data operations:
Blocking mode use below APIs:
Receive data:sl_i2c_driver_receive_data_blocking
Send data:sl_i2c_driver_send_data_blocking
Non-blocking mode (Recommended for larger buffers):
Receive data:sl_i2c_driver_receive_data_non_blocking
Send data:sl_i2c_driver_send_data_non_blocking
Deinitialize the I2C driver: sl_i2c_driver_deinit
Recommendations:
For larger buffer transfers (greater than 16 bytes), prefer non-blocking APIs to avoid stalling the CPU, especially in high-throughput applications.
When using non-blocking APIs, ensure that the transfer type is configured as SL_I2C_USING_DMA to leverage DMA for efficient data handling.
When using blocking APIs, ensure that the transfer type is configured as SL_I2C_USING_INTERRUPT.
Modules#
Enumerations#
Enumeration to represent I2C instances.
Enumeration to represent I2C driver status values.
Enumeration to represent I2C transfer type.
Enumeration to represent I2C operating modes.
Enumeration to represent I2C power modes.
Typedefs#
Callback function type for I2C driver events.
Functions#
To initialize the I2C module and configure its parameters.
To configure the follower address of the I2C module.
To configure the TX and RX FIFO threshold levels for the I2C instance.
To read the current I2C clock frequency.
To send data in blocking mode.
To send data in non-blocking mode using DMA.
To receive data in blocking mode.
To receive data in non-blocking mode using DMA.
To transmit and then receive data from an I2C device in blocking mode.
To de-initialize the I2C peripheral and clock.
To configure the I2C pins.
To re-configure the I2C leader device on power mode changes.
To enable or disable repeated start and combined format transfer.
To wait until the I2C bus is idle.
Macros#
I2C Peripheral.
I2C0 DMA RX channel number.
I2C1 DMA TX channel number.
I2C1 DMA RX channel number.
ULP_I2C DMA TX channel number.
ULP_I2C DMA RX channel number.
ULP_I2C DMA TX channel number for backward compatibility.
ULP_I2C DMA RX channel number for backward compatibility.
Enumeration Documentation#
sl_i2c_instance_t#
sl_i2c_instance_t
Enumeration to represent I2C instances.
This enumeration defines the different I2C instances available in the system.
Enumerator | |
---|---|
SL_I2C0 | I2C Instance 0. |
SL_I2C1 | I2C Instance 1. |
SL_I2C2 | I2C Instance 2 (ULP_I2C). |
SL_ULP_I2C | ULP_I2C Instance. |
SL_I2C_LAST | Last member of enum for validation. |
89
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
sl_i2c_status_t#
sl_i2c_status_t
Enumeration to represent I2C driver status values.
This enumeration defines the various status values that can be returned by the I2C driver.
Enumerator | |
---|---|
SL_I2C_SUCCESS | Operation completed successfully. |
SL_I2C_IDLE | I2C is idle. |
SL_I2C_7BIT_ADD | I2C 7-bit address transfer. |
SL_I2C_10BIT_ADD | I2C 10-bit address transfer. |
SL_I2C_10BIT_ADD_WITH_REP_START | I2C 10-bit address transfer with repeated start. |
SL_I2C_ACKNOWLEDGE | I2C acknowledge received. |
SL_I2C_NACK | I2C not acknowledge received. |
SL_I2C_DATA_TRANSFER_COMPLETE | I2C data transfer complete. |
SL_I2C_ARIBITRATION_LOST | I2C arbitration lost. |
SL_I2C_BUS_ERROR | I2C bus error. |
SL_I2C_BUS_HOLD | I2C bus held by another master. |
SL_I2C_SDA_ERROR | I2C SDA at loopback path is not equal to SDA output. |
SL_I2C_SCL_ERROR | I2C SCL at loopback path is not equal to SCL output. |
SL_I2C_CALLBACK_BUSY | I2C instance callback already registered. |
SL_I2C_DMA_TRANSFER_ERROR | I2C DMA transfer error. |
SL_I2C_INVALID_PARAMETER | Invalid parameter. |
SL_I2C_TIMEOUT | I2C timeout for blocking calls. |
102
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
sl_i2c_transfer_type_t#
sl_i2c_transfer_type_t
Enumeration to represent I2C transfer type.
This enumeration defines the different transfer types that can be used by the I2C driver.
Enumerator | |
---|---|
SL_I2C_USING_NON_DMA | The driver will use polling to perform I2C transfer. |
SL_I2C_USING_INTERRUPT | Same as SL_I2C_USING_NON_DMA, retained for backward compatibility. |
SL_I2C_USING_DMA | The driver will use DMA to perform I2C transfer. |
SL_I2C_TRANFER_TYPE_LAST | For Validation. |
127
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
sl_i2c_operating_mode_t#
sl_i2c_operating_mode_t
Enumeration to represent I2C operating modes.
This enumeration defines the different operating modes available for the I2C driver.
Enumerator | |
---|---|
SL_I2C_STANDARD_MODE | Standard-mode, bidirectional data transfers up to 100 kbit/s. |
SL_I2C_FAST_MODE | Fast-mode, bidirectional data transfers up to 400 kbit/s. |
SL_I2C_HIGH_SPEED_MODE | High-speed mode, bidirectional data transfers up to 3.4 Mbit/s. |
SL_I2C_FAST_PLUS_MODE | Fast-mode Plus, bidirectional data transfers up to 1 Mbit/s. |
SL_I2C_OPERATING_MODE_LAST | Last member for validation purposes. |
139
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
sl_i2c_power_modes_t#
sl_i2c_power_modes_t
Enumeration to represent I2C power modes.
This enumeration defines the different power modes available for the I2C driver.
Enumerator | |
---|---|
SL_I2C_ULP_MODE | Ultra-Low Power (ULP) mode for the I2C driver. |
SL_I2C_HP_MODE | High Power (HP) mode for the I2C driver. |
SL_I2C_POWER_MODE_LAST | Last member for validation purposes. |
217
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
Typedef Documentation#
sl_i2c_callback_t#
typedef void(* sl_i2c_callback_t) (sl_i2c_instance_t i2c_instance, uint32_t status) )(sl_i2c_instance_t i2c_instance, uint32_t status)
Callback function type for I2C driver events.
[in] | i2c_instance | The I2C instance that generated the event. |
[in] | status | The status code indicating the result of the I2C operation. |
This typedef defines the callback function type that is used by the I2C driver to notify the application of various I2C events.
156
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
Function Documentation#
sl_i2c_driver_init#
sl_i2c_status_t sl_i2c_driver_init (sl_i2c_instance_t i2c_instance, const sl_i2c_config_t * p_user_config)
To initialize the I2C module and configure its parameters.
[in] | i2c_instance | The I2C instance to be initialized. See sl_i2c_instance_t. |
[in] | p_user_config | A pointer to the I2C configuration structure. See sl_i2c_config_t. |
This function configures the I2C instance with the specified settings, including I2C leader/follower mode, operating mode (bus speed), and transfer type (interrupt or DMA). If DMA is selected as the transfer type, the function will also initialize the DMA module. Additionally, it registers the callback for the I2C instance, clears any pending interrupts, and configures the SDL and SCL pins as per the instance requirements.
Returns
sl_i2c_status_t Status of the initialization:
SL_I2C_SUCCESS - Initialization was successful.
SL_I2C_CALLBACK_BUSY - The driver is currently busy and cannot process the request.
SL_I2C_INVALID_PARAMETER - One or more parameters are invalid.
243
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
sl_i2c_driver_set_follower_address#
sl_i2c_status_t sl_i2c_driver_set_follower_address (sl_i2c_instance_t i2c_instance, uint16_t address)
To configure the follower address of the I2C module.
[in] | i2c_instance | The I2C instance to be configured. See sl_i2c_instance_t. |
[in] | address | The follower's own address (supports 7-Bit and 10-Bit addressing) between the range of 1-1023. |
This API is intended to be used only in follower mode after initializing the I2C instance. It updates the follower address register so that the I2C leader device can initiate transfers with the address that matches the follower device's address register.
Pre-conditions:
sl_i2c_driver_init must be called prior.
I2C mode must be set to follower mode.
Returns
sl_i2c_status_t Status code indicating the result of the operation:
SL_I2C_SUCCESS - Operation was successful.
SL_I2C_INVALID_PARAMETER - Invalid parameters were provided.
266
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
sl_i2c_driver_configure_fifo_threshold#
sl_i2c_status_t sl_i2c_driver_configure_fifo_threshold (sl_i2c_instance_t i2c_instance, uint8_t tx_threshold_value, uint8_t rx_threshold_value)
To configure the TX and RX FIFO threshold levels for the I2C instance.
[in] | i2c_instance | The I2C instance to be configured. See sl_i2c_instance_t. |
[in] | tx_threshold_value | The TX FIFO threshold value, which must be between 0 and 255. |
[in] | rx_threshold_value | The RX FIFO threshold value, which must be between 0 and 255. |
This API allows you to set the threshold levels for the transmit (TX) and receive (RX) FIFO buffers. The valid range is 0-255, where 0 corresponds to a threshold of 1 byte entry, and 255 corresponds to a threshold of 256 byte entries. Note that the value must not exceed the depth of the hardware buffer. Whenever the buffer reaches the threshold value, the respective interrupt occurs.
Pre-condition:
sl_i2c_driver_init must be called prior.
Returns
sl_i2c_status_t Status code indicating the result of the operation:
SL_I2C_SUCCESS - Operation was successful.
SL_I2C_INVALID_PARAMETER - Invalid parameters were provided.
288
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
sl_i2c_driver_get_frequency#
sl_i2c_status_t sl_i2c_driver_get_frequency (sl_i2c_instance_t i2c_instance, uint32_t * frequency)
To read the current I2C clock frequency.
[in] | i2c_instance | The I2C instance used. See sl_i2c_instance_t. |
[out] | frequency | Pointer to a variable where the current system core clock frequency will be stored. |
This API retrieves the current system core clock frequency in Hz by reading the system core clock frequency.
Pre-condition:
sl_i2c_driver_init must be called prior.
Returns
sl_i2c_status_t Status code indicating the result of the operation:
SL_I2C_SUCCESS - Operation was successful.
SL_I2C_INVALID_PARAMETER - Invalid parameters were provided.
309
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
sl_i2c_driver_send_data_blocking#
sl_i2c_status_t sl_i2c_driver_send_data_blocking (sl_i2c_instance_t i2c_instance, uint16_t address, uint8_t * tx_buffer, uint32_t tx_len)
To send data in blocking mode.
[in] | i2c_instance | The I2C instance to be used. See sl_i2c_instance_t. |
[in] | address | Follower address (7-bit: 0-0x7F, 10-bit: 0-0x3FF). Ignored in follower mode. |
[in] | tx_buffer | Pointer to the transmit data buffer. |
[in] | tx_len | Data length in bytes (range: 1-80,000). |
This API sends data in blocking mode, where it sets the follower address if used for leader mode. The call remains blocked until the last byte is transferred.
Pre-conditions:
sl_i2c_driver_init must be called prior.
Transfer type must be set to 'using interrupt'.
sl_i2c_driver_set_follower_address (if sending from follower).
Note
It is recommended to use up to 80,000 bytes maximum transfer length, but this limit may vary depending on the available RAM size.
Returns
sl_i2c_status_t Status code indicating the result:
SL_I2C_SUCCESS - Operation was successful.
SL_I2C_INVALID_PARAMETER - Invalid parameters were provided.
337
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
sl_i2c_driver_send_data_non_blocking#
sl_i2c_status_t sl_i2c_driver_send_data_non_blocking (sl_i2c_instance_t i2c_instance, uint16_t address, uint32_t * tx_buffer, uint32_t tx_len, sl_i2c_dma_config_t * p_dma_config)
To send data in non-blocking mode using DMA.
[in] | i2c_instance | I2C Instance. |
[in] | address | Follower address can be provided in 7-bit length (0-0x7F) or in 10-bit length(0-0x3FF). |
[in] | tx_buffer | A pointer to transmit data buffer |
[in] | tx_len | Data length in number of bytes in the range of 1-30000 bytes. |
[in] | p_dma_config | A pointer to DMA configuration structure sl_i2c_dma_config_t. |
This API sends data using DMA in a non-blocking mode. It sets the follower address when used in leader mode, configures the DMA TX and RX channels, registers the DMA callback, and enables the DMA channels. The transfer complete flag SL_I2C_DATA_TRANSFER_COMPLETE is updated after data transfer completion.
Pre-conditions:
Here transfer-type should be set as DMA-type
sl_i2c_driver_set_follower_address, if used in salve application
Note
Maximum tx_len values can be 30000 (receives back in around 4 seconds)
The
tx_buffer
parameter is of typeuint32_t
. It is recommended to use 8-bit (0-7 bits) data in the buffer, with the remaining bits filled in by the driver internally.
Returns
status 0 if successful, else error code as follow
SL_I2C_SUCCESS (0x0000) - Success
SL_I2C_INVALID_PARAMETER (0x000F) - Parameters are invalid
SL_I2C_DMA_TRANSFER_ERROR (0x000E) - DMA parameters are invalid
369
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
sl_i2c_driver_receive_data_blocking#
sl_i2c_status_t sl_i2c_driver_receive_data_blocking (sl_i2c_instance_t i2c_instance, uint16_t address, uint8_t * rx_buffer, uint32_t rx_len)
To receive data in blocking mode.
[in] | i2c_instance | The I2C instance to be used. See sl_i2c_instance_t. |
[in] | address | Follower address (7-bit: 0-0x7F, 10-bit: 0-0x3FF). Ignored in follower mode. |
[in] | rx_buffer | Pointer to the receive data buffer. |
[in] | rx_len | Data length in bytes (range: 1-80,000). |
This API receives data in blocking mode, where it sets the follower address if used in leader mode. The call remains blocked until the last byte is received.
Pre-conditions:
sl_i2c_driver_init must be called prior.
Transfer type must be set to 'using interrupt'.
sl_i2c_driver_set_follower_address (if receiving from follower).
Note
It is recommended to use up to 80,000 bytes maximum transfer length, but this limit may vary depending on the available RAM size.
Returns
sl_i2c_status_t Status code indicating the result:
SL_I2C_SUCCESS - Operation was successful.
SL_I2C_INVALID_PARAMETER - Invalid parameters were provided.
401
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
sl_i2c_driver_receive_data_non_blocking#
sl_i2c_status_t sl_i2c_driver_receive_data_non_blocking (sl_i2c_instance_t i2c_instance, uint16_t address, uint8_t * rx_buffer, uint32_t rx_len, sl_i2c_dma_config_t * p_dma_config)
To receive data in non-blocking mode using DMA.
[in] | i2c_instance | The I2C instance to be used. See sl_i2c_instance_t. |
[in] | address | Follower address, which can be in 7-bit (0-0x7F) or 10-bit (0-0x3FF) format. |
[in] | rx_buffer | Pointer to the receive data buffer. |
[in] | rx_len | Data length in bytes, ranging from 1 to 30,000. |
[in] | p_dma_config | Pointer to the DMA configuration structure. See sl_i2c_dma_config_t. |
This API receives data using DMA in non-blocking mode. It sets the follower address when used in leader mode, configures DMA RX and TX channels, registers the DMA callback, and enables the DMA channels. The transfer complete flag SL_I2C_DATA_TRANSFER_COMPLETE is updated after data transfer completion.
Pre-conditions:
sl_i2c_driver_init must be called prior.
Transfer type must be set to 'using DMA'.
sl_i2c_driver_set_follower_address if used in follower application.
Note
Maximum rx_len values can be 30000 (receives back in around 4 seconds).
The default values cannot be any of the reserved address locations: that is, 0x00 to 0x07, or 0x78 to 0x7f.
Returns
status 0 if successful, else error code as follow
SL_I2C_SUCCESS (0x0000) - Success
SL_I2C_INVALID_PARAMETER (0x000F) - Parameters are invalid
SL_I2C_DMA_TRANSFER_ERROR (0x000E) - DMA parameters are invalid
435
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
sl_i2c_driver_transfer_data#
sl_i2c_status_t sl_i2c_driver_transfer_data (sl_i2c_instance_t i2c_instance, sl_i2c_transfer_config_t const * p_transfer_config, uint16_t address)
To transmit and then receive data from an I2C device in blocking mode.
[in] | i2c_instance | The I2C instance to be used. See sl_i2c_instance_t. |
[in] | p_transfer_config | Follower address, which can be in 7-bit (0-0x7F) or 10-bit (0-0x3FF) format. |
[in] | address | Pointer to the transfer configuration structure. See sl_i2c_transfer_config_t. |
This API first transmits data and then receives data from an I2C device in blocking mode. It sets the follower address when used in leader mode.
Pre-conditions:
sl_i2c_driver_init must be called prior.
Transfer type must be set to 'using interrupt'.
sl_i2c_driver_set_follower_address if used in follower application.
Note
It is recommended to use up to 80,000 bytes maximum transfer length, but this limit may vary depending on the available RAM size.
The default values cannot be any of the reserved address locations: 0x00 to 0x07, or 0x78 to 0x7f.
Returns
sl_i2c_status_t Status code indicating the result:
SL_I2C_SUCCESS - Operation was successful.
SL_I2C_INVALID_PARAMETER - Invalid parameters were provided.
467
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
sl_i2c_driver_deinit#
sl_i2c_status_t sl_i2c_driver_deinit (sl_i2c_instance_t i2c_instance)
To de-initialize the I2C peripheral and clock.
[in] | i2c_instance | The I2C instance to be de-initialized. See sl_i2c_instance_t. |
This API de-initializes the I2C peripheral, disables the peripheral clock, and unregisters the callback.
Pre-condition:
sl_i2c_driver_init must be called prior.
Returns
sl_i2c_status_t Status code indicating the result:
SL_I2C_SUCCESS - Operation was successful.
SL_I2C_INVALID_PARAMETER - Invalid parameters were provided.
Note
When the I2C module is used in combination with other peripherals, refer to the following notes:
When
sl_i2c_driver_deinit()
is called, it will disable the clock for the peripheral. To power off the peripheral, the power domain (PERI_EFUSE) containing different peripherals (e.g., 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) must be powered down. Use the following API to power down the specific power domain if other peripherals are not being used:sl_si91x_peri_efuse_power_down(power_down)
.Some peripherals (ULP Peripherals, UULP Peripherals, GPDMA, and SDIO-SPI) have separate domains that can be powered down independently. For additional details, see the Power Architecture section in the Hardware Reference Manual. The ULP_UART has a separate power domain (ULPSS_PWRGATE_ULP_UART) that can be powered down independently. See the
rsi_power_save.h
file for all power gate definitions.
497
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
sl_si91x_i2c_pin_init#
sl_i2c_status_t sl_si91x_i2c_pin_init (sl_i2c_pin_init_t * pin_init)
To configure the I2C pins.
[in] | pin_init | Pointer to the pin initialization structure. See sl_i2c_pin_init_t. |
Configures the SDA and SCL pins and enables internal pull-ups for the SDA and SCL lines of the follower device.
Returns
sl_i2c_status_t Status code indicating the result:
SL_I2C_SUCCESS - Operation was successful.
SL_I2C_INVALID_PARAMETER - Invalid parameters were provided.
512
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
sl_i2c_driver_leader_reconfig_on_power_mode_change#
sl_i2c_status_t sl_i2c_driver_leader_reconfig_on_power_mode_change (sl_i2c_power_modes_t new_power_mode)
To re-configure the I2C leader device on power mode changes.
[in] | new_power_mode | New power state to switch to. See sl_i2c_power_modes_t. |
Re-configures the I2C leader instance (ULP_I2C) for ULP/HP mode, adjusting the I2C clock frequency required for the I2C operating (speed) mode to run in ULP/HP mode.
Pre-conditions:
sl_i2c_driver_init must be called prior.
The instance should be in ULP mode when switching to HP mode.
The instance should be in HP mode when switching to ULP mode.
The instance used should be the ULP-I2C instance.
Returns
sl_i2c_status_t Status code indicating the result:
SL_I2C_SUCCESS - Success.
SL_I2C_INVALID_PARAMETER - Invalid parameters were provided.
534
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
sl_i2c_driver_enable_repeated_start#
sl_i2c_status_t sl_i2c_driver_enable_repeated_start (sl_i2c_instance_t i2c_instance, boolean_t enable_rep_start)
To enable or disable repeated start and combined format transfer.
[in] | i2c_instance | The I2C instance to be configured. See sl_i2c_instance_t. |
[in] | enable_rep_start | Boolean value: true to enable, false to disable repeated start. |
This API should be called by a leader application to enable repeated start before starting data transfer. By enabling this, combined format transfers can be used, allowing the I2C to perform combined write/read operations to the same or different followers without releasing the line, ensuring that the operation is not interrupted.
Pre-condition:
sl_i2c_driver_init must be called prior.
Returns
sl_i2c_status_t Status code indicating the result:
SL_I2C_SUCCESS - Operation was successful.
SL_I2C_INVALID_PARAMETER - Invalid parameters were provided.
555
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
sl_si91x_i2c_wait_till_i2c_is_idle#
sl_i2c_status_t sl_si91x_i2c_wait_till_i2c_is_idle (sl_i2c_instance_t i2c_instance)
To wait until the I2C bus is idle.
[in] | i2c_instance | The I2C instance to be checked. See sl_i2c_instance_t. |
This API polls the activity status bit of the leader and follower to determine if the I2C bus is idle. It can be used for synchronization purposes.
Returns
sl_i2c_status_t Status code indicating the result:
SL_I2C_SUCCESS - Success.
SL_I2C_INVALID_PARAMETER - Parameters are invalid.
571
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
Macro Definition Documentation#
SL_I2C0_DMA_TX_CHANNEL#
#define SL_I2C0_DMA_TX_CHANNELValue:
31
I2C Peripheral.
Overview#
I2C standard compliant bus interface with open-drain pins. Configurable as Primary or Secondary. Four speed modes: Standard Mode (100 kbps), Fast Mode (400 kbps), Fast Mode Plus (1 Mbps), and High-Speed Mode (3.4 Mbps). 7 or 10-bit addressing. 7 or 10-bit combined format transfers. Support for clock synchronization and bus clear. Programmable SDA hold time. Integrated transmit and receive buffers with support for DMA. Bulk transmit mode in I2C slave mode. Interrupt-based operation (polled mode also available).
Initialization#
Call init API with the init parameters. Call set follower address API in follower mode. Call set FIFO threshold API. I2C0 DMA TX channel number
72
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
SL_I2C0_DMA_RX_CHANNEL#
#define SL_I2C0_DMA_RX_CHANNELValue:
30
I2C0 DMA RX channel number.
73
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
SL_I2C1_DMA_TX_CHANNEL#
#define SL_I2C1_DMA_TX_CHANNELValue:
3
I2C1 DMA TX channel number.
74
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
SL_I2C1_DMA_RX_CHANNEL#
#define SL_I2C1_DMA_RX_CHANNELValue:
2
I2C1 DMA RX channel number.
75
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
SL_ULP_I2C_DMA_TX_CHANNEL#
#define SL_ULP_I2C_DMA_TX_CHANNELValue:
5
ULP_I2C DMA TX channel number.
76
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
SL_ULP_I2C_DMA_RX_CHANNEL#
#define SL_ULP_I2C_DMA_RX_CHANNELValue:
4
ULP_I2C DMA RX channel number.
77
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
SL_I2C2_DMA_TX_CHANNEL#
#define SL_I2C2_DMA_TX_CHANNELValue:
SL_ULP_I2C_DMA_TX_CHANNEL
ULP_I2C DMA TX channel number for backward compatibility.
78
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h
SL_I2C2_DMA_RX_CHANNEL#
#define SL_I2C2_DMA_RX_CHANNELValue:
SL_ULP_I2C_DMA_RX_CHANNEL
ULP_I2C DMA RX channel number for backward compatibility.
79
of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h