PMSIS API
|
Data Structures | |
struct | pi_i2c_conf_t |
I2C master configuration structure. More... | |
Enumerations | |
enum | pi_i2c_xfer_flags_e |
Properties for I2C transfers. More... | |
enum | pi_i2c_ioctl_e |
Commands for pi_i2c_control. More... | |
Functions | |
void | pi_i2c_conf_init (pi_i2c_conf_t *conf) |
Initialize an I2C configuration with default values. More... | |
void | pi_i2c_conf_set_slave_addr (struct pi_i2c_conf *conf, uint16_t slave_addr, int8_t is_10_bits) |
set slave addr in conf. More... | |
void | pi_i2c_conf_set_wait_cycles (struct pi_i2c_conf *conf, uint16_t wait_cycles) |
set wait_cycles in conf. More... | |
int | pi_i2c_open (struct pi_device *device) |
Open an I2C device. More... | |
void | pi_i2c_close (struct pi_device *device) |
Close an opened I2C device. More... | |
void | pi_i2c_ioctl (struct pi_device *device, uint32_t cmd, void *arg) |
Dynamically change the device configuration. More... | |
int | pi_i2c_read (struct pi_device *device, uint8_t *rx_buff, int length, pi_i2c_xfer_flags_e flags) |
Enqueue a burst read copy from the I2C (from I2C device to chip). More... | |
int | pi_i2c_write (struct pi_device *device, uint8_t *tx_data, int length, pi_i2c_xfer_flags_e flags) |
Enqueue a burst write copy to the I2C (from chip to I2C device). More... | |
void | pi_i2c_write_read (struct pi_device *device, void *tx_buffer, void *rx_buffer, uint32_t tx_size, uint32_t rx_size) |
void | pi_i2c_write_dual (struct pi_device *device, void *tx_buffer0, void *tx_buffer1, uint32_t tx_size0, uint32_t tx_size1) |
void | pi_i2c_read_async (struct pi_device *device, uint8_t *rx_buff, int length, pi_i2c_xfer_flags_e flags, pi_task_t *task) |
Enqueue an asynchronous burst read copy from the I2C (from I2C device to chip). More... | |
void | pi_i2c_write_async (struct pi_device *device, uint8_t *tx_data, int length, pi_i2c_xfer_flags_e flags, pi_task_t *task) |
Enqueue a burst write copy to the I2C (from chip to I2C device). More... | |
void | pi_i2c_write_read_async (struct pi_device *device, void *tx_buffer, void *rx_buffer, uint32_t tx_size, uint32_t rx_size, pi_task_t *callback) |
void | pi_i2c_write_dual_async (struct pi_device *device, void *tx_buffer0, void *tx_buffer1, uint32_t tx_size0, uint32_t tx_size1, pi_task_t *callback) |
int | pi_i2c_read_timeout (struct pi_device *device, uint8_t *rx_buff, int length, pi_i2c_xfer_flags_e flags, uint32_t timeout_us) |
Enqueue an asynchronous burst read copy from the I2C (from I2C device to chip), with timeout. More... | |
int | pi_i2c_write_timeout (struct pi_device *device, uint8_t *tx_data, int length, pi_i2c_xfer_flags_e flags, uint32_t timeout_us) |
Enqueue a burst write copy to the I2C (from chip to I2C device), with timeout. More... | |
int | pi_i2c_get_request_status (pi_task_t *task) |
get the request status from a task More... | |
int | pi_i2c_detect (struct pi_device *device, struct pi_i2c_conf *conf, uint8_t *rx_data) |
Scan i2c bus to detect a dev. More... | |
The I2C driver provides support for transferring data between an external I2C device and the chip running this driver.
enum pi_i2c_ioctl_e |
This is used to tell which command to execute through pi_i2c_control.
enum pi_i2c_xfer_flags_e |
This is used to specify additional behaviors when transfering data through I2C.
Enumerator | |
---|---|
PI_I2C_XFER_STOP |
Generate a STOP bit at the end of the transfer. |
PI_I2C_XFER_NO_STOP |
Don't generate a STOP bit at the end of the transfer. |
PI_I2C_XFER_START |
Generate a START bit at the beginning of the transfer. |
PI_I2C_XFER_NO_START |
Don't generate a START bit at the beginning of the transfer. |
PI_I2C_XFER_RESTART |
Generate a RESTART bit at the beginning of the transfer. |
PI_I2C_XFER_NO_RESTART |
Don't generate a RESTART bit at the beginning of the transfer. |
void pi_i2c_close | ( | struct pi_device * | device | ) |
This function can be called to close an opened I2C 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.
device | The device structure of the device to close. |
void pi_i2c_conf_init | ( | pi_i2c_conf_t * | conf | ) |
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 I2C device is opened.
conf | A pointer to the I2C configuration. |
void pi_i2c_conf_set_slave_addr | ( | struct pi_i2c_conf * | conf, |
uint16_t | slave_addr, | ||
int8_t | is_10_bits | ||
) |
conf | A pointer to the I2C configuration. |
slave_addr | Address of the slave device. |
is_10_bits | Indicate if slave address is 7 bits or 10 bits. |
void pi_i2c_conf_set_wait_cycles | ( | struct pi_i2c_conf * | conf, |
uint16_t | wait_cycles | ||
) |
conf | A pointer to the I2C configuration. |
wait_cycles | Number of wait cycles applied at the end of transfer |
int pi_i2c_detect | ( | struct pi_device * | device, |
struct pi_i2c_conf * | conf, | ||
uint8_t * | rx_data | ||
) |
This function can be used to detect if a device is connected to the i2c bus. The pi_i2c_conf_t structure is used to pass the address of the device to look for, with different baudrate if needed.
device | Pointer to device structure. |
conf | Conf struct holding address and baudrate. |
rx_data | Pointer to 1 Byte buffer to store data. |
0x00 | If a device has been detected at given address. |
0xFF | Otherwise. |
int pi_i2c_get_request_status | ( | pi_task_t * | task | ) |
This function can be used to retrieve the request status from a task.
task | the task to retrieve the status from |
void pi_i2c_ioctl | ( | struct pi_device * | device, |
uint32_t | cmd, | ||
void * | arg | ||
) |
This function can be called to change part of the device configuration after it has been opened.
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_i2c_ioctl_e. |
arg | An additional value which is required for some parameters when they are set. |
int pi_i2c_open | ( | struct pi_device * | 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.
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. |
int pi_i2c_read | ( | struct pi_device * | device, |
uint8_t * | rx_buff, | ||
int | length, | ||
pi_i2c_xfer_flags_e | flags | ||
) |
This function can be used to read at least 1 byte of data from the I2C device. The copy will make a synchronous transfer between the I2C 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.
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. |
flags | Specify additional transfer behaviors like start and stop bits management. |
void pi_i2c_read_async | ( | struct pi_device * | device, |
uint8_t * | rx_buff, | ||
int | length, | ||
pi_i2c_xfer_flags_e | flags, | ||
pi_task_t * | task | ||
) |
This function can be used to read at least 1 byte of data from the I2C device. The copy will make an asynchronous transfer between the I2C and one of the chip memory. A task must be specified in order to specify how the caller should be notified when the transfer is finished. The task will contain the request status (success or error). It should be retrieved using the pi_i2c_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.
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. |
flags | Specify additional transfer behaviors like start and stop bits management. |
task | The task used to notify the end of transfer. See the documentation of pi_task_t for more details. |
int pi_i2c_read_timeout | ( | struct pi_device * | device, |
uint8_t * | rx_buff, | ||
int | length, | ||
pi_i2c_xfer_flags_e | flags, | ||
uint32_t | timeout_us | ||
) |
This function has the same behaviour as pi_i2c_read(), with timeout. This timeout value is used to abort/cancel a transfer when timeout is reached.
device | Pointer to the structure describing the device. |
rx_buff | Address in the chip where the received data must be written. |
length | Size in bytes of the copy. |
flags | Specify additional transfer behaviors like start and stop bits management. |
timeout_us | Timeout value in us. |
int pi_i2c_write | ( | struct pi_device * | device, |
uint8_t * | tx_data, | ||
int | length, | ||
pi_i2c_xfer_flags_e | flags | ||
) |
This function can be used to write at least 1 byte of data to the I2C device. The copy will make a synchronous transfer between the I2C 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.
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. |
flags | Specify additional transfer behaviors like start and stop bits management. |
void pi_i2c_write_async | ( | struct pi_device * | device, |
uint8_t * | tx_data, | ||
int | length, | ||
pi_i2c_xfer_flags_e | flags, | ||
pi_task_t * | task | ||
) |
This function can be used to write at least 1 byte of data to the I2C device. The copy will make an asynchronous transfer between the I2C and one of the chip memory. A task must be specified in order to specify how the caller should be notified when the transfer is finished. The task will contain the request status (success or error). It should be retrieved using the pi_i2c_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.
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 |
flags | Specify additional transfer behaviors like start and stop bits management. |
task | The task used to notify the end of transfer. See the documentation of pi_task_t for more details. |
void pi_i2c_write_dual | ( | struct pi_device * | device, |
void * | tx_buffer0, | ||
void * | tx_buffer1, | ||
uint32_t | tx_size0, | ||
uint32_t | tx_size1 | ||
) |
void pi_i2c_write_dual_async | ( | struct pi_device * | device, |
void * | tx_buffer0, | ||
void * | tx_buffer1, | ||
uint32_t | tx_size0, | ||
uint32_t | tx_size1, | ||
pi_task_t * | callback | ||
) |
void pi_i2c_write_read | ( | struct pi_device * | device, |
void * | tx_buffer, | ||
void * | rx_buffer, | ||
uint32_t | tx_size, | ||
uint32_t | rx_size | ||
) |
void pi_i2c_write_read_async | ( | struct pi_device * | device, |
void * | tx_buffer, | ||
void * | rx_buffer, | ||
uint32_t | tx_size, | ||
uint32_t | rx_size, | ||
pi_task_t * | callback | ||
) |
int pi_i2c_write_timeout | ( | struct pi_device * | device, |
uint8_t * | tx_data, | ||
int | length, | ||
pi_i2c_xfer_flags_e | flags, | ||
uint32_t | timeout_us | ||
) |
This function has the same behaviour as pi_i2c_write(), with timeout. This timeout value is used to abort/cancel a transfer when timeout is reached.
device | Pointer to the structure describing the device. |
tx_data | Address in the chip where the data to be sent is read. |
length | Size in bytes of the copy |
flags | Specify additional transfer behaviors like start and stop bits management. |
timeout_us | Timeout value in us. |