I2C#

Modules#

sl_i2c_config_t

sl_i2c_dma_config_t

sl_i2c_transfer_config_t

sl_i2c_pin_init_t

Enumerations#

enum
SL_I2C0
SL_I2C1
SL_I2C2
SL_I2C_LAST
}

Enumeration to represent i2c instances.

enum
SL_I2C_SUCCESS
SL_I2C_IDLE
SL_I2C_7BIT_ADD
SL_I2C_10BIT_ADD
SL_I2C_10BIT_ADD_WITH_REP_START
SL_I2C_ACKNOWLEDGE
SL_I2C_NACK
SL_I2C_DATA_TRANSFER_COMPLETE
SL_I2C_ARIBITRATION_LOST
SL_I2C_BUS_ERROR
SL_I2C_BUS_HOLD
SL_I2C_SDA_ERROR
SL_I2C_SCL_ERROR
SL_I2C_CALLBACK_BUSY
SL_I2C_DMA_TRANSFER_ERROR
SL_I2C_INVALID_PARAMETER
}

Enumeration to represent i2c driver status values.

enum
SL_I2C_USING_INTERRUPT
SL_I2C_USING_DMA
SL_I2C_TRANFER_TYPE_LAST
}

Enumeration to represent i2c transfer type.

enum
SL_I2C_STANDARD_MODE = 1
SL_I2C_FAST_MODE
SL_I2C_HIGH_SPEED_MODE
SL_I2C_FAST_PLUS_MODE
SL_I2C_OPERATING_MODE_LAST
}

Enumeration to represent i2c operating mode.

Typedefs#

typedef void(*
sl_i2c_callback_t)(sl_i2c_instance_t i2c_instance, uint32_t status)

Callback for I2C Driver.

Functions#

sl_i2c_driver_init(sl_i2c_instance_t i2c_instance, const sl_i2c_config_t *p_user_config)

Initialize the I2C Module and clock.

sl_i2c_driver_set_follower_address(sl_i2c_instance_t i2c_instance, uint16_t address)

This API configures the follower address of the I2C module.

sl_i2c_driver_configure_fifo_threshold(sl_i2c_instance_t i2c_instance, uint8_t tx_threshold_value, uint8_t rx_threshold_value)

This function is used to configure the TX and RX FIFO threshold values.

sl_i2c_driver_get_frequency(sl_i2c_instance_t i2c_instance, uint32_t *frequency)

This API gets the current frequency of I2C transfer in MHz, by reading the system core clock frequency.

sl_i2c_driver_send_data_blocking(sl_i2c_instance_t i2c_instance, uint16_t address, uint8_t *tx_buffer, uint32_t tx_len)

This function sends the data in blocking mode (using interrupt), also sets the follower address when used in Leader application.

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)

This function sends the data in non-blocking mode (using DMA), also sets the follower address when used in Leader application.

sl_i2c_driver_receive_data_blocking(sl_i2c_instance_t i2c_instance, uint16_t address, uint8_t *rx_buffer, uint32_t rx_len)

This function receives the data in blocking mode (using interrupt), also sets the follower address when used in Leader application.

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)

This function receives the data in non-blocking mode (using DMA), also sets the follower address when used in Leader application.

sl_i2c_driver_transfer_data(sl_i2c_instance_t i2c_instance, sl_i2c_transfer_config_t const *p_transfer_config, uint16_t address)

This function transmits and receives the data in blocking mode also sets the follower address when used in Leader application.

sl_i2c_driver_deinit(sl_i2c_instance_t i2c_instance)

De-initializes the I2C peripheral, disables clock, and unregisters the callback.

sl_si91x_i2c_pin_init(sl_i2c_pin_init_t *pin_init)

Set the Pin configuration for I2C.

Enumeration Documentation#

sl_i2c_instance_t#

sl_i2c_instance_t

Enumeration to represent i2c instances.

Enumerator
SL_I2C0

I2C Instance 0.

SL_I2C1

I2C Instance 1.

SL_I2C2

I2C Instance 2.

SL_I2C_LAST

Last member of enum for validation.


Definition at line 82 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.

Enumerator
SL_I2C_SUCCESS

Success.

SL_I2C_IDLE

I2C 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 ACK.

SL_I2C_NACK

I2C NACK.

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 I2C Bus.

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.


Definition at line 90 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.

Enumerator
SL_I2C_USING_INTERRUPT

The driver will use interrupts to perform I2C transfer.

SL_I2C_USING_DMA

The driver will use DMA to perform I2C transfer.

SL_I2C_TRANFER_TYPE_LAST

For Validation.


Definition at line 110 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 mode.

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 of enum for validation.


Definition at line 117 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 for I2C Driver.


Definition at line 125 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)

Initialize the I2C Module and clock.

Parameters
[in]i2c_instance

I2C Instance to be initialized sl_i2c_instance_t

[in]p_user_config

A pointer to I2C configuration structure sl_i2c_config_t

Sets I2C instance mode, operating mode (bus-speed), frequency, and transfer type (using Interrupt or DMA). If the transfer type is DMA, it initializes DMA as well. Registers I2C instance callback and clears pending interrupts. Configures SDL and SCL pins as per the instance.

Returns


Definition at line 178 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)

This API configures the follower address of the I2C module.

Parameters
[in]i2c_instance

I2C Instance sl_i2c_instance_t

[in]address

Follower own address

Should be used only in Follower mode after instance initialization.

Returns


Definition at line 195 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)

This function is used to configure the TX and RX FIFO threshold values.

Parameters
[in]i2c_instance

I2C Instance sl_i2c_instance_t

[in]tx_threshold_value

Transmit FIFO threshold value

[in]rx_threshold_value

Receive FIFO threshold value

The valid range is 0-255, with the additional restriction that hardware does not allow this value to be set to a value larger than the depth of the buffer. A value of 0 sets the threshold for 1 entry, and a value of 255 sets the threshold for 256 entries.

Returns


Definition at line 215 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)

This API gets the current frequency of I2C transfer in MHz, by reading the system core clock frequency.

Parameters
[in]i2c_instance

I2C Instance sl_i2c_instance_t

[out]frequency

Currently configured frequency.

Returns


Definition at line 233 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)

This function sends the data in blocking mode (using interrupt), also sets the follower address when used in Leader application.

Parameters
[in]i2c_instance

I2C Instance sl_i2c_instance_t

[in]address

Follower address, in follower mode, this parameter will be ignored

[in]tx_buffer

A pointer to transmit data buffer

[in]tx_len

Data length in number of bytes

Sets transmit empty interrupt and enables I2C interrupts.

Note

  • Maximum tx_len used can be 80000 (receives in around 10 seconds)

Returns


Definition at line 256 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)

This function sends the data in non-blocking mode (using DMA), also sets the follower address when used in Leader application.

Parameters
[in]i2c_instance

I2C Instance.

[in]address

Follower address

[in]tx_buffer

A pointer to transmit data buffer

[in]tx_len

Data length in number of bytes

[in]p_dma_config

A pointer to DMA configuration structure sl_i2c_dma_config_t

Configures DMA rx and tx channels.

Note

  • Maximum tx_len values can be 30000 (receives back in around 4 seconds)

Returns


Definition at line 283 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)

This function receives the data in blocking mode (using interrupt), also sets the follower address when used in Leader application.

Parameters
[in]i2c_instance

I2C Instance sl_i2c_instance_t

[in]address

Follower address, in follower mode this parameter will be ignored

[in]rx_buffer

A pointer to receive data buffer

[in]rx_len

Data length in number of bytes

Sets receive full interrupt while receiving data. Sets transmit empty interrupt while sending data.

Note

  • Maximum rx_len used can be 80000 (receives in around 10 seconds)

Returns


Definition at line 311 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)

This function receives the data in non-blocking mode (using DMA), also sets the follower address when used in Leader application.

Parameters
[in]i2c_instance

I2C Instance sl_i2c_instance_t

[in]address

Follower address

[in]rx_buffer

A pointer to receive data buffer

[in]rx_len

Data length in number of bytes

[in]p_dma_config

A pointer to DMA configuration structure sl_i2c_dma_config_t

Configures DMA rx and tx channels.

Note

  • Maximum rx_len values can be 30000 (receives back in around 4 seconds)

Returns


Definition at line 338 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)

This function transmits and receives the data in blocking mode also sets the follower address when used in Leader application.

Parameters
[in]i2c_instance

I2C Instance sl_i2c_instance_t

[in]p_transfer_config

Follower address

[in]address

A pointer to transfer configuration structure sl_i2c_transfer_config_t

Sets receive full interrupt and enables I2C interrupts.

Note

  • Maximum tx_len & rx_len values can be 80000 (sends & receives back in around 20 seconds)

Returns


Definition at line 363 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)

De-initializes the I2C peripheral, disables clock, and unregisters the callback.

Parameters
[in]i2c_instance

I2C Instance sl_i2c_instance_t

Returns


Definition at line 379 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)

Set the Pin configuration for I2C.

Parameters
[in]pin_init

Pointer to pin init structure sl_i2c_pin_init_t

It configures the SDA and SCL pins.

Returns


Definition at line 390 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_CHANNEL
Value:
31

I2C Peripheral.

Overview#

I2C standard compliant bus interface with open-drain pins Configurable as Master or Slave Four speed modes: Standard Mode (100 kbps), Fast Mode (400 kbps), Fast Mode Plus (1Mbps) 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


Definition at line 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_CHANNEL
Value:
30

Definition at line 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_CHANNEL
Value:
3

Definition at line 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_CHANNEL
Value:
2

Definition at line 75 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_CHANNEL
Value:
5

Definition at line 76 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_CHANNEL
Value:
4

Definition at line 77 of file components/device/silabs/si91x/mcu/drivers/unified_api/inc/sl_si91x_i2c.h