I3C

group I3C

The I3C driver provides support for transferring data between an external I3C device and the chip running this driver.

Typedefs

typedef struct pi_i3c_conf pi_i3c_conf_t

Enums

enum pi_i3c_ioctl_e

Commands for pi_i3c_control.

This is used to tell which command to execute through pi_i3c_control.

Values:

enumerator PI_I3C_CTRL_SET_MAX_BAUDRATE = 1 << __PI_I3C_CTRL_SET_MAX_BAUDRATE_BIT

Change maximum baudrate.

Param baudrate:

Max baudrate.

Functions

void pi_i3c_conf_init(pi_i3c_conf_t *conf)

Initialize an I3C configuration with default values.

This function can be called to get default values for all parameters before setting some of them. The structure containing the configuration must be kept alive until the I3C device is opened.

Parameters:
  • conf – A pointer to the I3C configuration.

void pi_i3c_conf_set_slave_addr(struct pi_i3c_conf *conf, uint16_t slave_addr)

Set slave address in conf.

Parameters:
  • conf – A pointer to the I3C configuration.

  • slave_addr – Address of the slave device.

int32_t pi_i3c_open(struct pi_device *device)

Open an I3C device.

This function must be called before the Hyperbus device can be used. It will do all the needed configuration to make it usable and initialize the handle used to refer to this opened device when calling other functions.

Parameters:
  • device – A pointer to the device structure of the device to open. This structure is allocated by the called and must be kept alive until the device is closed.

Return values:
  • 0 – if the operation is successfull.

  • -1 – if there was an error.

Returns:

Operation return code.

void pi_i3c_close(struct pi_device *device)

Close an opened I3C device.

This function can be called to close an opened I3C device once it is not needed anymore, in order to free all allocated resources. Once this function is called, the device is not accessible anymore and must be opened again before being used.

Parameters:
  • device – The device structure of the device to close.

void pi_i3c_ioctl(struct pi_device *device, uint32_t cmd, void *arg)

Dynamically change the device configuration.

This function can be called to change part of the device configuration after it has been opened.

Parameters:
  • device – A pointer to the structure describing the device.

  • cmd – The command which specifies which parameters of the driver to modify and for some of them also their values. The command must be one of those defined in pi_i3c_ioctl_e.

  • arg – An additional value which is required for some parameters when they are set.

int32_t pi_i3c_read(struct pi_device *device, uint8_t *rx_buff, int32_t length)

Enqueue a burst read copy from the I3C (from I3C device to chip).

This function can be used to read at least 1 byte of data from the I3C device. The copy will make a synchronous transfer between the I3C and one of the chip memory. The caller is blocked until the transfer is finished. Depending on the chip, there may be some restrictions on the memory which can be used. Check the chip-specific documentation for more details.

Parameters:
  • device – A pointer to the structure describing the device.

  • rx_buff – The address in the chip where the received data must be written.

  • length – The size in bytes of the buffer to read.

Returns:

PI_OK if request is successful PI_ERR_I3C_NACK if a NACK was received during the request

int32_t pi_i3c_write(struct pi_device *device, uint8_t *tx_data, int32_t length)

Enqueue a burst write copy to the I3C (from chip to I3C device).

This function can be used to write at least 1 byte of data to the I3C device. The copy will make a synchronous transfer between the I3C and one of the chip memory. The caller is blocked until the transfer is finished. Depending on the chip, there may be some restrictions on the memory which can be used. Check the chip-specific documentation for more details.

Parameters:
  • device – A pointer to the structure describing the device.

  • tx_data – The address in the chip where the data to be sent is read.

  • length – The size in bytes of the buffer to write.

Returns:

PI_OK if request is successful PI_ERR_I3C_NACK if a NACK was received during the request

void pi_i3c_read_async(struct pi_device *device, uint8_t *rx_buff, int32_t length, pi_evt_t *event)

Enqueue an asynchronous burst read copy from the I3C (from I3C device to chip).

This function can be used to read at least 1 byte of data from the I3C device. The copy will make an asynchronous transfer between the I3C and one of the chip memory. An event must be specified in order to specify how the caller should be notified when the transfer is finished. The event will contain the request status (success or error). It should be retrieved using the pi_i3c_get_request_status function. Depending on the chip, there may be some restrictions on the memory which can be used. Check the chip-specific documentation for more details.

Parameters:
  • device – A pointer to the structure describing the device.

  • rx_buff – The address in the chip where the received data must be written.

  • length – The size in bytes of the copy.

  • event – The event used to notify the end of transfer. See the documentation of pi_evt_t for more details.

void pi_i3c_write_async(struct pi_device *device, uint8_t *tx_data, int32_t length, pi_evt_t *event)

Enqueue a burst write copy to the I3C (from chip to I3C device).

This function can be used to write at least 1 byte of data to the I3C device. The copy will make an asynchronous transfer between the I3C and one of the chip memory. An event must be specified in order to specify how the caller should be notified when the transfer is finished. The event will contain the request status (success or error). It should be retrieved using the pi_i3c_get_request_status function. Depending on the chip, there may be some restrictions on the memory which can be used. Check the chip-specific documentation for more details.

Parameters:
  • device – A pointer to the structure describing the device.

  • tx_data – The address in the chip where the data to be sent is read.

  • length – The size in bytes of the copy

  • event – The event used to notify the end of transfer. See the documentation of pi_evt_t for more details.

int32_t pi_i3c_get_request_status(pi_evt_t *event)

Give information on the transfer status of the given event.

Returns:

Code for success if transfer went well, or error if an error occurred.

struct pi_i3c_conf
#include <i3c.h>

I3C master configuration structure.

This structure is used to pass the desired I3C configuration to the runtime when opening a device.

Public Members

uint8_t itf

Specifies on which I3C interface the device is connected. For now, we have only one interface (0).

uint16_t cs

i3c slave address (7 bits), the runtime will take care of the LSB of read and write.

uint32_t max_baudrate

Maximum baudrate for the I3C bitstream which can be used with the opened device.