I2C - Inter-Integrated Circuit#

Inter-Integrated Circuit driver.


Introduction#

This is an I2C Driver.

Modules#

sl_i2c_dma_channel_info_t

sl_i2c_dma_descriptors_t

sl_i2c_init_params_t

sl_i2c_handle_t

Enumerations#

enum
SL_I2C_FREQ_STANDARD_MODE
SL_I2C_FREQ_FAST_MODE
SL_I2C_FREQ_FASTPLUS_MODE
}

Freq mode enum.

enum
SL_I2C_WRITE = 0
SL_I2C_READ = 1
SL_I2C_WRITE_READ = 2
}

Transfer direction enum.

enum
SL_I2C_EVENT_IN_PROGRESS = 0
SL_I2C_EVENT_COMPLETED = 1
SL_I2C_EVENT_ADDR_NACK = 2
SL_I2C_EVENT_DATA_NACK = 3
SL_I2C_EVENT_ARBITRATION_LOST = 4
SL_I2C_EVENT_BUS_ERROR = 5
SL_I2C_EVENT_CLOCK_TIMEOUT = 6
SL_I2C_EVENT_STOP = 7
SL_I2C_EVENT_SW_FAULT = 8
SL_I2C_EVENT_IDLE = 9
SL_I2C_EVENT_INVALID_ADDR = 10
SL_I2C_EVENT_TIMEOUT = 11
SL_I2C_EVENT_BUFFER_FULL = 12
}

I2C Transfer event enum.

enum
SL_I2C_STATE_ERROR = 0
SL_I2C_STATE_IDLE = 1
SL_I2C_STATE_SEND_START_AND_ADDR = 2
SL_I2C_STATE_ADDR_WAIT_FOR_ACK_OR_NACK = 3
SL_I2C_STATE_ADDR_2ND_BYTE_10BIT_WAIT_FOR_ACK_OR_NACK = 4
SL_I2C_STATE_ADDRESS_MATCH = 5
SL_I2C_STATE_10BIT_ADDRESS_MATCH = 6
SL_I2C_STATE_SEND_REPEATED_START_AND_ADDR = 7
SL_I2C_STATE_REPEATED_ADDR_WAIT_FOR_ACK_OR_NACK = 8
SL_I2C_STATE_REP_ADDR_MATCH = 9
SL_I2C_STATE_SEND_DATA = 10
SL_I2C_STATE_DATA_WAIT_FOR_ACK_OR_NACK = 11
SL_I2C_STATE_RECEIVE_DATA = 12
SL_I2C_STATE_SEND_STOP = 13
SL_I2C_STATE_WAIT_FOR_STOP = 14
SL_I2C_STATE_DONE = 15
}

I2C state enum.

Typedefs#

typedef sl_hal_ldma_descriptor_t

LDMA descriptor type for I2C DMA.

typedef sl_status_t(*
sl_i2c_transfer_complete_callback_t)(sl_i2c_handle_t *i2c_handle, void *user_data)

Transfer Complete Callback.

typedef sl_status_t(*
sl_i2c_event_callback_t)(sl_i2c_handle_t *i2c_handle, sl_i2c_event_t event, void *user_data)

I2C Event Callback.

Functions#

sl_status_t
sl_i2c_init(sl_i2c_handle_t *i2c_handle, const sl_i2c_init_params_t *init_params)

Initializes the I2C Module.

sl_status_t
sl_i2c_deinit(sl_i2c_handle_t *i2c_handle)

Deinitializes and resets the I2C instance.

sl_status_t
sl_i2c_set_frequency(sl_i2c_handle_t *i2c_handle, sl_i2c_freq_mode_t frequency_mode)

Sets the frequency of the I2C bus.

sl_status_t
sl_i2c_get_frequency(sl_i2c_handle_t *i2c_handle, sl_i2c_freq_mode_t *frequency_mode)

Get the current configured frequency of the I2C module.

sl_status_t
sl_i2c_set_follower_address(sl_i2c_handle_t *i2c_handle, uint16_t address, bool is_10bit_addr)

Set the follower device address for I2C communication.

sl_status_t
sl_i2c_configure_dma(sl_i2c_handle_t *i2c_handle, sl_i2c_dma_channel_info_t *dma_channel)

Configures the DMA channels for the I2C instance.

sl_status_t
sl_i2c_leader_send_blocking(sl_i2c_handle_t *i2c_handle, uint16_t address, const uint8_t *tx_buffer, uint32_t tx_len, uint32_t timeout)

Leader Mode: Send data to the specified follower device (blocking).

sl_status_t
sl_i2c_leader_receive_blocking(sl_i2c_handle_t *i2c_handle, uint16_t address, uint8_t *rx_buffer, uint32_t rx_len, uint32_t timeout)

Leader Mode: Receive data from the specified follower device (blocking).

sl_status_t
sl_i2c_leader_transfer_blocking(sl_i2c_handle_t *i2c_handle, uint16_t address, const uint8_t *tx_buffer, uint32_t tx_len, uint8_t *rx_buffer, uint32_t rx_len, uint32_t timeout)

Leader Mode: Send then receive data from the specified follower device (blocking).

sl_status_t
sl_i2c_leader_send_non_blocking(sl_i2c_handle_t *i2c_handle, uint16_t address, const uint8_t *tx_buffer, uint32_t tx_len, void *user_data)

Leader Mode: Send data to the specified follower device (non-blocking).

sl_status_t
sl_i2c_leader_receive_non_blocking(sl_i2c_handle_t *i2c_handle, uint16_t address, uint8_t *rx_buffer, uint32_t rx_len, void *user_data)

Leader Mode: Receive data from the specified follower device (non-blocking).

sl_status_t
sl_i2c_leader_transfer_non_blocking(sl_i2c_handle_t *i2c_handle, uint16_t address, const uint8_t *tx_buffer, uint32_t tx_len, uint8_t *rx_buffer, uint32_t rx_len, void *user_data)

Leader Mode: Send then receive data from the specified follower device (non-blocking).

sl_status_t
sl_i2c_follower_send_blocking(sl_i2c_handle_t *i2c_handle, const uint8_t *tx_buffer, uint32_t tx_len, uint32_t timeout)

Follower Mode: Send data to the I2C leader (blocking).

sl_status_t
sl_i2c_follower_receive_blocking(sl_i2c_handle_t *i2c_handle, uint8_t *rx_buffer, uint32_t rx_len, uint32_t timeout)

Follower Mode: Receive data from the I2C leader (blocking).

sl_status_t
sl_i2c_follower_send_non_blocking(sl_i2c_handle_t *i2c_handle, const uint8_t *tx_buffer, uint32_t tx_len, void *user_data)

Follower Mode: Send data to the I2C leader (non-blocking).

sl_status_t
sl_i2c_follower_receive_non_blocking(sl_i2c_handle_t *i2c_handle, uint8_t *rx_buffer, uint32_t rx_len, void *user_data)

Follower Mode: Receive data from the I2C leader (non-blocking).

sl_status_t
sl_i2c_set_transfer_complete_callback(sl_i2c_handle_t *i2c_handle, sl_i2c_transfer_complete_callback_t callback)

Register a transfer complete callback for non-blocking APIs.

sl_status_t
sl_i2c_set_event_callback(sl_i2c_handle_t *i2c_handle, sl_i2c_event_callback_t callback)

Register an event callback for non-blocking APIs.

Macros#

#define
SL_I2C_DMA_MAX_TX_DESCRIPTOR_COUNT 2
#define
SL_I2C_DMA_MAX_RX_DESCRIPTOR_COUNT 4

Enumeration Documentation#

sl_i2c_freq_mode_t#

sl_i2c_freq_mode_t

Freq mode enum.

Enumerator
SL_I2C_FREQ_STANDARD_MODE
SL_I2C_FREQ_FAST_MODE

Standard mode (up to 100 kHz) assuming using 4:4 ratio for Nlow:Nhigh.

SL_I2C_FREQ_FASTPLUS_MODE

Fast mode (up to 400 kHz) assuming using 6:3 ratio for Nlow:Nhigh.


sl_i2c_transfer_direction_t#

sl_i2c_transfer_direction_t

Transfer direction enum.

Enumerator
SL_I2C_WRITE
SL_I2C_READ

Write: Send data to the I2C bus.

SL_I2C_WRITE_READ

Read: Receive data from the I2C bus.


sl_i2c_event_t#

sl_i2c_event_t

I2C Transfer event enum.

Enumerator
SL_I2C_EVENT_IN_PROGRESS
SL_I2C_EVENT_COMPLETED

Transfer in progress.

SL_I2C_EVENT_ADDR_NACK

Transfer completed successfully.

SL_I2C_EVENT_DATA_NACK

Address byte not acknowledged.

SL_I2C_EVENT_ARBITRATION_LOST

Data byte not acknowledged.

SL_I2C_EVENT_BUS_ERROR

Arbitration lost.

SL_I2C_EVENT_CLOCK_TIMEOUT

Bus error occurred.

SL_I2C_EVENT_STOP

Clock timeout.

SL_I2C_EVENT_SW_FAULT

Transfer stopped.

SL_I2C_EVENT_IDLE

Transfer fault due to software.

SL_I2C_EVENT_INVALID_ADDR

Instance is idle.

SL_I2C_EVENT_TIMEOUT

Address invalid error.

SL_I2C_EVENT_BUFFER_FULL

Timeout.


sl_i2c_transaction_state_t#

sl_i2c_transaction_state_t

I2C state enum.

Enumerator
SL_I2C_STATE_ERROR
SL_I2C_STATE_IDLE

Indicates an error occurred.

SL_I2C_STATE_SEND_START_AND_ADDR

I2C is idle.

SL_I2C_STATE_ADDR_WAIT_FOR_ACK_OR_NACK

Send start and address byte.

SL_I2C_STATE_ADDR_2ND_BYTE_10BIT_WAIT_FOR_ACK_OR_NACK

Wait for ACK/NACK on address byte.

SL_I2C_STATE_ADDRESS_MATCH

Wait for ACK/NACK on 2nd byte (10-bit).

SL_I2C_STATE_10BIT_ADDRESS_MATCH

Wait for address matching.

SL_I2C_STATE_SEND_REPEATED_START_AND_ADDR

Wait for 10-bit address match.

SL_I2C_STATE_REPEATED_ADDR_WAIT_FOR_ACK_OR_NACK

Send repeated start and address byte.

SL_I2C_STATE_REP_ADDR_MATCH

Wait for ACK/NACK for repeated start.

SL_I2C_STATE_SEND_DATA

Wait for repeated start and address match.

SL_I2C_STATE_DATA_WAIT_FOR_ACK_OR_NACK

Send data byte.

SL_I2C_STATE_RECEIVE_DATA

Wait for ACK or NACK after sending data.

SL_I2C_STATE_SEND_STOP

Data to be received.

SL_I2C_STATE_WAIT_FOR_STOP

Send stop signal.

SL_I2C_STATE_DONE

Wait for stop condition.


Typedef Documentation#

sl_i2c_ldma_descriptor_t#

typedef sl_hal_ldma_descriptor_t sl_i2c_ldma_descriptor_t

LDMA descriptor type for I2C DMA.


sl_i2c_transfer_complete_callback_t#

typedef sl_status_t(* sl_i2c_transfer_complete_callback_t) (sl_i2c_handle_t *i2c_handle, void *user_data) )(sl_i2c_handle_t *i2c_handle, void *user_data)

Transfer Complete Callback.

Parameters
TypeDirectionArgument NameDescription
[in]i2c_handle

Pointer to the I2C driver handle.

[in]user_data

User-defined data provided during the asynchronous transaction

Note

  • Invoked exactly once when an asynchronous I2C operation completes successfully (no errors). This applies to:

    • Transmit (TX)

    • Receive (RX)

    • Combined Transmit-Receive (TX→RX / repeated-start)

Returns

  • Status code.


sl_i2c_event_callback_t#

typedef sl_status_t(* sl_i2c_event_callback_t) (sl_i2c_handle_t *i2c_handle, sl_i2c_event_t event, void *user_data) )(sl_i2c_handle_t *i2c_handle, sl_i2c_event_t event, void *user_data)

I2C Event Callback.

Parameters
TypeDirectionArgument NameDescription
[in]i2c_handle

Pointer to the I2C driver handle.

[in]event

Event type (see sl_i2c_event_t).

[in]user_data

User-defined data provided during the asynchronous transaction.

Note

  • Invoked on I2C events other than transfer completion.

Returns

  • Status code.


Function Documentation#

sl_i2c_init#

sl_status_t sl_i2c_init (sl_i2c_handle_t * i2c_handle, const sl_i2c_init_params_t * init_params)

Initializes the I2C Module.

Parameters
TypeDirectionArgument NameDescription
sl_i2c_handle_t *[out]i2c_handle

A pointer to the I2C instance handle.

const sl_i2c_init_params_t *[in]init_params

A pointer to initialization parameters.

Configures the I2C peripheral with the specified initialization parameters and prepares it for operation.

Returns

    • SL_STATUS_OK on success.

    • SL_STATUS_NULL_POINTER if arguments are NULL.

    • SL_STATUS_ALREADY_INITIALIZED if already initialized.

    • SL_STATUS_INVALID_PARAMETER for invalid config.

    • SL_STATUS_NOT_SUPPORTED if peripheral is not valid.

    • SL_STATUS_ALLOCATION_FAILED if DMA allocation fails.


sl_i2c_deinit#

sl_status_t sl_i2c_deinit (sl_i2c_handle_t * i2c_handle)

Deinitializes and resets the I2C instance.

Parameters
TypeDirectionArgument NameDescription
sl_i2c_handle_t *[in]i2c_handle

Pointer to the I2C instance handle.

Disables interrupts, DMA, clocks, and resets hardware and GPIOs.

Returns

    • SL_STATUS_OK on success.

    • SL_STATUS_NULL_POINTER if handle is NULL.


sl_i2c_set_frequency#

sl_status_t sl_i2c_set_frequency (sl_i2c_handle_t * i2c_handle, sl_i2c_freq_mode_t frequency_mode)

Sets the frequency of the I2C bus.

Parameters
TypeDirectionArgument NameDescription
sl_i2c_handle_t *[in]i2c_handle

A pointer to the I2C instance handle.

sl_i2c_freq_mode_t[in]frequency_mode

Operating speed mode (e.g., Standard, Fast, Fast-Plus).

Returns

    • SL_STATUS_OK on success.

    • SL_STATUS_NULL_POINTER if handle is NULL.

    • SL_STATUS_INVALID_PARAMETER if mode is invalid.


sl_i2c_get_frequency#

sl_status_t sl_i2c_get_frequency (sl_i2c_handle_t * i2c_handle, sl_i2c_freq_mode_t * frequency_mode)

Get the current configured frequency of the I2C module.

Parameters
TypeDirectionArgument NameDescription
sl_i2c_handle_t *[in]i2c_handle

Pointer to the I2C instance handle.

sl_i2c_freq_mode_t *[out]frequency_mode

Pointer to store the current mode.

Returns

    • SL_STATUS_OK on success.

    • SL_STATUS_NULL_POINTER if arguments are NULL.

    • SL_STATUS_INVALID_CONFIGURATION if frequency is out of range.

Get the current configured frequency of the I2C module.


sl_i2c_set_follower_address#

sl_status_t sl_i2c_set_follower_address (sl_i2c_handle_t * i2c_handle, uint16_t address, bool is_10bit_addr)

Set the follower device address for I2C communication.

Parameters
TypeDirectionArgument NameDescription
sl_i2c_handle_t *[in]i2c_handle

Pointer to the I2C instance handle.

uint16_t[in]address

Follower device address (7-bit or 10-bit).

bool[in]is_10bit_addr

true for 10-bit address, false for 7-bit address.

Sets the address of the follower device that the I2C leader will communicate with during transactions. Validates address ranges and checks for reserved addresses.

Returns

    • SL_STATUS_OK on success.

    • SL_STATUS_NULL_POINTER if handle is NULL.

    • SL_STATUS_INVALID_MODE if not in follower mode.

    • SL_STATUS_INVALID_PARAMETER if address is invalid.


sl_i2c_configure_dma#

sl_status_t sl_i2c_configure_dma (sl_i2c_handle_t * i2c_handle, sl_i2c_dma_channel_info_t * dma_channel)

Configures the DMA channels for the I2C instance.

Parameters
TypeDirectionArgument NameDescription
sl_i2c_handle_t *[in]i2c_handle

Pointer to the I2C instance handle.

sl_i2c_dma_channel_info_t *[in]dma_channel

Pointer to the DMA channel info structure.

Note

  • This is an optional API that allows the user to assign custom DMA channels, overriding the default channels allocated by the driver.

Returns

    • SL_STATUS_OK on success.

    • SL_STATUS_NULL_POINTER if arguments are NULL.

    • SL_STATUS_INVALID_PARAMETER if channel info is invalid.


sl_i2c_leader_send_blocking#

sl_status_t sl_i2c_leader_send_blocking (sl_i2c_handle_t * i2c_handle, uint16_t address, const uint8_t * tx_buffer, uint32_t tx_len, uint32_t timeout)

Leader Mode: Send data to the specified follower device (blocking).

Parameters
TypeDirectionArgument NameDescription
sl_i2c_handle_t *[in]i2c_handle

Pointer to the I2C instance handle.

uint16_t[in]address

Address of the follower device.

const uint8_t *[in]tx_buffer

Pointer to the transmit data buffer.

uint32_t[in]tx_len

Length of the data to transmit.

uint32_t[in]timeout

Timeout duration in milliseconds (0 = no timeout).

Transmits data to the follower device. Blocks until the transfer completes successfully or an error occurs.

Returns

    • SL_STATUS_OK on success.

    • SL_STATUS_NULL_POINTER if arguments are NULL.

    • SL_STATUS_INVALID_MODE if not in leader mode.

    • SL_STATUS_INVALID_PARAMETER if length/address invalid.

    • SL_STATUS_TIMEOUT if operation timed out.

    • SL_STATUS_NOT_FOUND if address NACK received.

    • SL_STATUS_ABORT if data NACK received.

    • SL_STATUS_TRANSMIT or SL_STATUS_IO for bus errors.


sl_i2c_leader_receive_blocking#

sl_status_t sl_i2c_leader_receive_blocking (sl_i2c_handle_t * i2c_handle, uint16_t address, uint8_t * rx_buffer, uint32_t rx_len, uint32_t timeout)

Leader Mode: Receive data from the specified follower device (blocking).

Parameters
TypeDirectionArgument NameDescription
sl_i2c_handle_t *[in]i2c_handle

Pointer to the I2C instance handle.

uint16_t[in]address

Address of the follower device.

uint8_t *[out]rx_buffer

Pointer to the receive data buffer.

uint32_t[in]rx_len

Length of the data to receive.

uint32_t[in]timeout

Timeout duration in milliseconds (0 = no timeout).

Receives data from the follower device. Blocks until the transfer completes successfully or an error occurs.

Returns

    • SL_STATUS_OK on success.

    • SL_STATUS_NULL_POINTER if arguments are NULL.

    • SL_STATUS_INVALID_MODE if not in leader mode.

    • SL_STATUS_INVALID_PARAMETER if length/address invalid.

    • SL_STATUS_TIMEOUT if operation timed out.

    • SL_STATUS_NOT_FOUND if address NACK received.

    • SL_STATUS_ABORT if data NACK received.

    • SL_STATUS_TRANSMIT or SL_STATUS_IO for bus errors.


sl_i2c_leader_transfer_blocking#

sl_status_t sl_i2c_leader_transfer_blocking (sl_i2c_handle_t * i2c_handle, uint16_t address, const uint8_t * tx_buffer, uint32_t tx_len, uint8_t * rx_buffer, uint32_t rx_len, uint32_t timeout)

Leader Mode: Send then receive data from the specified follower device (blocking).

Parameters
TypeDirectionArgument NameDescription
sl_i2c_handle_t *[in]i2c_handle

Pointer to the I2C instance handle.

uint16_t[in]address

Address of the follower device.

const uint8_t *[in]tx_buffer

Pointer to the transmit data buffer.

uint32_t[in]tx_len

Length of the data to transmit.

uint8_t *[out]rx_buffer

Pointer to the receive data buffer.

uint32_t[in]rx_len

Length of the data to receive.

uint32_t[in]timeout

Timeout duration in milliseconds (0 = no timeout).

Performs a combined write-read operation using a repeated start condition. Blocks until both operations complete or an error occurs.

Returns

    • SL_STATUS_OK on success.

    • SL_STATUS_NULL_POINTER if arguments are NULL.

    • SL_STATUS_INVALID_MODE if not in leader mode.

    • SL_STATUS_INVALID_PARAMETER if lengths/address invalid.

    • SL_STATUS_TIMEOUT if operation timed out.

    • SL_STATUS_NOT_FOUND if address NACK received.

    • SL_STATUS_ABORT if data NACK received.

    • SL_STATUS_TRANSMIT or SL_STATUS_IO for bus errors.


sl_i2c_leader_send_non_blocking#

sl_status_t sl_i2c_leader_send_non_blocking (sl_i2c_handle_t * i2c_handle, uint16_t address, const uint8_t * tx_buffer, uint32_t tx_len, void * user_data)

Leader Mode: Send data to the specified follower device (non-blocking).

Parameters
TypeDirectionArgument NameDescription
sl_i2c_handle_t *[in]i2c_handle

Pointer to the I2C instance handle.

uint16_t[in]address

Address of the follower device.

const uint8_t *[in]tx_buffer

Pointer to the transmit data buffer.

uint32_t[in]tx_len

Length of the data to transmit.

void *[in]user_data

User-defined data passed to callbacks.

Initiates a data transmission using DMA and interrupts. Returns immediately; completion is signaled via registered callbacks.

Returns

    • SL_STATUS_OK if transfer initiated successfully.

    • SL_STATUS_NULL_POINTER if arguments are NULL.

    • SL_STATUS_INVALID_MODE if not in leader mode.

    • SL_STATUS_INVALID_PARAMETER if length/address invalid.

    • Other error codes for DMA/IRQ setup failures.


sl_i2c_leader_receive_non_blocking#

sl_status_t sl_i2c_leader_receive_non_blocking (sl_i2c_handle_t * i2c_handle, uint16_t address, uint8_t * rx_buffer, uint32_t rx_len, void * user_data)

Leader Mode: Receive data from the specified follower device (non-blocking).

Parameters
TypeDirectionArgument NameDescription
sl_i2c_handle_t *[in]i2c_handle

Pointer to the I2C instance handle.

uint16_t[in]address

Address of the follower device.

uint8_t *[out]rx_buffer

Pointer to the receive data buffer.

uint32_t[in]rx_len

Length of the data to receive.

void *[in]user_data

User-defined data passed to callbacks.

Initiates a data reception using DMA and interrupts. Returns immediately; completion is signaled via registered callbacks.

Returns

    • SL_STATUS_OK if transfer initiated successfully.

    • SL_STATUS_NULL_POINTER if arguments are NULL.

    • SL_STATUS_INVALID_MODE if not in leader mode.

    • SL_STATUS_INVALID_PARAMETER if length/address invalid.

    • Other error codes for DMA/IRQ setup failures.


sl_i2c_leader_transfer_non_blocking#

sl_status_t sl_i2c_leader_transfer_non_blocking (sl_i2c_handle_t * i2c_handle, uint16_t address, const uint8_t * tx_buffer, uint32_t tx_len, uint8_t * rx_buffer, uint32_t rx_len, void * user_data)

Leader Mode: Send then receive data from the specified follower device (non-blocking).

Parameters
TypeDirectionArgument NameDescription
sl_i2c_handle_t *[in]i2c_handle

Pointer to the I2C instance handle.

uint16_t[in]address

Address of the follower device.

const uint8_t *[in]tx_buffer

Pointer to the transmit data buffer.

uint32_t[in]tx_len

Length of the data to transmit.

uint8_t *[out]rx_buffer

Pointer to the receive data buffer.

uint32_t[in]rx_len

Length of the data to receive.

void *[in]user_data

User-defined data passed to callbacks.

Initiates a combined write-read operation using a repeated start condition. Uses DMA and interrupts. Returns immediately; completion is signaled via registered callbacks.

Returns

    • SL_STATUS_OK if transfer initiated successfully.

    • SL_STATUS_NULL_POINTER if arguments are NULL.

    • SL_STATUS_INVALID_MODE if not in leader mode.

    • SL_STATUS_INVALID_PARAMETER if lengths/address invalid.

    • Other error codes for DMA/IRQ setup failures.


sl_i2c_follower_send_blocking#

sl_status_t sl_i2c_follower_send_blocking (sl_i2c_handle_t * i2c_handle, const uint8_t * tx_buffer, uint32_t tx_len, uint32_t timeout)

Follower Mode: Send data to the I2C leader (blocking).

Parameters
TypeDirectionArgument NameDescription
sl_i2c_handle_t *[in]i2c_handle

Pointer to the I2C instance handle.

const uint8_t *[in]tx_buffer

Pointer to the transmit data buffer.

uint32_t[in]tx_len

Number of bytes to transmit.

uint32_t[in]timeout

Timeout duration in milliseconds (0 = no timeout).

Transmits data when addressed by the leader. Blocks until the transfer completes or an error occurs.

Returns

    • SL_STATUS_OK on success.

    • SL_STATUS_NULL_POINTER if arguments are NULL.

    • SL_STATUS_INVALID_MODE if not in follower mode.

    • SL_STATUS_INVALID_PARAMETER if length invalid.

    • SL_STATUS_TIMEOUT if operation timed out.

    • SL_STATUS_FULL if buffer full.

    • SL_STATUS_TRANSMIT or SL_STATUS_IO for bus errors.


sl_i2c_follower_receive_blocking#

sl_status_t sl_i2c_follower_receive_blocking (sl_i2c_handle_t * i2c_handle, uint8_t * rx_buffer, uint32_t rx_len, uint32_t timeout)

Follower Mode: Receive data from the I2C leader (blocking).

Parameters
TypeDirectionArgument NameDescription
sl_i2c_handle_t *[in]i2c_handle

Pointer to the I2C instance handle.

uint8_t *[out]rx_buffer

Pointer to the receive data buffer.

uint32_t[in]rx_len

Number of bytes to receive.

uint32_t[in]timeout

Timeout duration in milliseconds (0 = no timeout).

Receives data when addressed by the leader. Blocks until the transfer completes or an error occurs.

Returns

    • SL_STATUS_OK on success.

    • SL_STATUS_NULL_POINTER if arguments are NULL.

    • SL_STATUS_INVALID_MODE if not in follower mode.

    • SL_STATUS_INVALID_PARAMETER if length invalid.

    • SL_STATUS_TIMEOUT if operation timed out.

    • SL_STATUS_FULL if buffer full.

    • SL_STATUS_TRANSMIT or SL_STATUS_IO for bus errors.


sl_i2c_follower_send_non_blocking#

sl_status_t sl_i2c_follower_send_non_blocking (sl_i2c_handle_t * i2c_handle, const uint8_t * tx_buffer, uint32_t tx_len, void * user_data)

Follower Mode: Send data to the I2C leader (non-blocking).

Parameters
TypeDirectionArgument NameDescription
sl_i2c_handle_t *[in]i2c_handle

Pointer to the I2C instance handle.

const uint8_t *[in]tx_buffer

Pointer to the transmit data buffer.

uint32_t[in]tx_len

Number of bytes to transmit.

void *[in]user_data

User-defined data passed to callbacks.

Initiates data transmission when addressed by the leader using DMA and interrupts. Returns immediately; completion is signaled via registered callbacks.

Returns

    • SL_STATUS_OK if transfer initiated successfully.

    • SL_STATUS_NULL_POINTER if arguments are NULL.

    • SL_STATUS_INVALID_MODE if not in follower mode.

    • SL_STATUS_INVALID_PARAMETER if length invalid.

    • Other error codes for DMA/IRQ setup failures.


sl_i2c_follower_receive_non_blocking#

sl_status_t sl_i2c_follower_receive_non_blocking (sl_i2c_handle_t * i2c_handle, uint8_t * rx_buffer, uint32_t rx_len, void * user_data)

Follower Mode: Receive data from the I2C leader (non-blocking).

Parameters
TypeDirectionArgument NameDescription
sl_i2c_handle_t *[in]i2c_handle

Pointer to the I2C instance handle.

uint8_t *[out]rx_buffer

Pointer to the receive data buffer.

uint32_t[in]rx_len

Number of bytes to receive.

void *[in]user_data

User-defined data passed to callbacks.

Initiates data reception when addressed by the leader using DMA and interrupts. Returns immediately; completion is signaled via registered callbacks.

Returns

    • SL_STATUS_OK if transfer initiated successfully.

    • SL_STATUS_NULL_POINTER if arguments are NULL.

    • SL_STATUS_INVALID_MODE if not in follower mode.

    • SL_STATUS_INVALID_PARAMETER if length invalid.

    • Other error codes for DMA/IRQ setup failures.


sl_i2c_set_transfer_complete_callback#

sl_status_t sl_i2c_set_transfer_complete_callback (sl_i2c_handle_t * i2c_handle, sl_i2c_transfer_complete_callback_t callback)

Register a transfer complete callback for non-blocking APIs.

Parameters
TypeDirectionArgument NameDescription
sl_i2c_handle_t *[in]i2c_handle

Pointer to the I2C driver handle.

sl_i2c_transfer_complete_callback_t[in]callback

Transfer complete callback function.

The callback is called once on successful completion of a non-blocking transfer.

Note

  • Passing NULL as the callback parameter will unset/disable the callback.

Returns

    • SL_STATUS_OK on success.

    • SL_STATUS_NULL_POINTER if handle is NULL.


sl_i2c_set_event_callback#

sl_status_t sl_i2c_set_event_callback (sl_i2c_handle_t * i2c_handle, sl_i2c_event_callback_t callback)

Register an event callback for non-blocking APIs.

Parameters
TypeDirectionArgument NameDescription
sl_i2c_handle_t *[in]i2c_handle

Pointer to the I2C driver handle.

sl_i2c_event_callback_t[in]callback

Event callback function.

The callback is called on I2C events other than transfer completion.

Note

  • Passing NULL as the callback parameter will unset/disable the callback.

Returns

    • SL_STATUS_OK on success.

    • SL_STATUS_NULL_POINTER if handle is NULL.