Header file of I3C Interface. More...
Go to the source code of this file.
Classes | |
union | no_os_i3c_ccc_info |
struct | no_os_i3c_daa_lut |
Stores the PID + DA information to look-up during the DAA. Should be used only for device initialization, since it may go outdated. More... | |
struct | no_os_i3c_msg |
Item describing an I3C transfer. More... | |
struct | no_os_i3c_bus_desc |
Structure holding I3C bus descriptor. More... | |
struct | no_os_i3c_bus_init_param |
Structure holding the parameters for I3C initialization. More... | |
struct | no_os_i3c_init_param |
Structure holding the parameters for I3C initialization. Works like a device tree, the values are copied to no_os_i3c_desc during I3C initialization. Set is_static to 1 if the device provides a Static Address and is desired to use it instead of assigning a Dynamic Address during the DAA. is_i3c has higher precedence than is_static, and therefore is_static does not matter when is_i3c is 0. More... | |
struct | no_os_i3c_desc |
Structure holding I3C device descriptor. More... | |
struct | no_os_i3c_platform_ops |
Structure holding I3C function pointers that point to the platform specific function. More... | |
Enumerations | |
enum | no_os_i3c_slot_status { NO_OS_I3C_ADDR_SLOT_FREE , NO_OS_I3C_ADDR_SLOT_RSVD , NO_OS_I3C_ADDR_SLOT_I2C_DEV , NO_OS_I3C_ADDR_SLOT_I3C_DEV , NO_OS_I3C_ADDR_SLOT_STATUS_MASK = 3 } |
On an I3C bus, addresses are assigned dynamically, and we need to know which addresses are free to use and which ones are already assigned. More... | |
Functions | |
int | no_os_i3c_init (struct no_os_i3c_desc **desc, const struct no_os_i3c_init_param *param) |
Initialize the I3C device. If the bus of the I3C device is not initialized, it will call to init it. | |
int | no_os_i3c_init_bus (struct no_os_i3c_bus_desc **desc, const struct no_os_i3c_bus_init_param *param) |
Initialize the I3C bus. | |
int | no_os_i3c_remove (struct no_os_i3c_desc *desc) |
Free the resources allocated by no_os_i3c_init(). | |
int | no_os_i3c_remove_bus (struct no_os_i3c_bus_desc *desc) |
Free the resources allocated by no_os_i3c_init_bus. Must remove all devices first, if not, -EBUSY is returned. | |
int | no_os_i3c_do_daa (struct no_os_i3c_bus_desc *desc, bool rstdaa) |
Do DAA to assign the dynamic addresses. | |
int | no_os_i3c_send_ccc (struct no_os_i3c_bus_desc *desc, uint8_t addr, uint32_t ccc, uint8_t *data) |
Send CCC, either to a device device or broadcast to all. | |
int | no_os_i3c_send_direct_ccc (struct no_os_i3c_desc *desc, uint32_t ccc, uint8_t *data) |
Send CCC to device device. | |
int | no_os_i3c_write (struct no_os_i3c_desc *desc, uint8_t *data, uint8_t size) |
Write data to device device. | |
int | no_os_i3c_read (struct no_os_i3c_desc *desc, uint8_t *data, uint8_t size) |
Read data from device device. | |
int | no_os_i3c_write_and_read (struct no_os_i3c_desc *desc, uint8_t *tx_data, uint8_t tx_data_len, uint8_t *rx_data, uint8_t rx_data_len) |
Read and write the device. | |
int | no_os_i3c_conf_irq (struct no_os_i3c_bus_desc *desc, uint8_t irq, bool en) |
Configure I3C interrupts. | |
int | no_os_i3c_wait_irq (struct no_os_i3c_bus_desc *desc, uint8_t irq) |
Wait I3C interrupt. Set async_irq on call to false to ensure single entry point. | |
int | no_os_i3c_call_irq (struct no_os_i3c_bus_desc *desc) |
Non-blocking I3C interrupt. Since a payload is always retrieved with it, also update the no_os_i3c_ccc_info fields. | |
int | no_os_i3c_async_irq (struct no_os_i3c_bus_desc *desc, bool en) |
Enable I3C non-blocking interrupts. | |
uint8_t | no_os_i3c_addr_get_free (struct no_os_i3c_bus_desc *desc, uint8_t start_addr) |
Get a free address. | |
void | no_os_i3c_addr_set_status (struct no_os_i3c_bus_desc *desc, uint8_t addr, enum no_os_i3c_slot_status status) |
Set status of an address. | |
void | no_os_i3c_attach_callback (struct no_os_i3c_desc *desc, void(*callback)(struct no_os_i3c_desc *, uint32_t, uint32_t)) |
Attach event callback. | |
void | no_os_i3c_detach_callback (struct no_os_i3c_desc *desc) |
Detach event callback. | |
int32_t | no_os_i3c_transfer_dma_async (struct no_os_i3c_desc *desc, struct no_os_i3c_msg *msgs, uint32_t len, void(*callback)(void *), void *ctx) |
Transfer a list of messages using DMA. Non-blocking, invokes a callback after the last message is concluded. | |
int32_t | no_os_i3c_transfer_abort (struct no_os_i3c_desc *desc) |
Abort the ongoing DMA transaction. | |
Header file of I3C Interface.
Copyright 2024(c) Analog Devices, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#define NO_OS_I3C_ADDR_FLAG_SIZE 2 |
#define NO_OS_I3C_ADDR_GET_POS | ( | x | ) |
#define NO_OS_I3C_ADDR_GET_SLOT | ( | x | ) |
#define NO_OS_I3C_ADDR_PER_SLOT ((unsigned int)(sizeof(unsigned int)*8 / NO_OS_I3C_ADDR_FLAG_SIZE)) |
#define NO_OS_I3C_ADDRSLOTS_SIZE (NO_OS_I3C_I2C_MAX_ADDR / NO_OS_I3C_ADDR_PER_SLOT) + !!(NO_OS_I3C_I2C_MAX_ADDR % NO_OS_I3C_ADDR_PER_SLOT) |
#define NO_OS_I3C_BCAST_ADDR 0x7E |
#define NO_OS_I3C_BCR_DEVICE_ROLE | ( | bcr | ) |
#define NO_OS_I3C_BCR_IBI_PAYLOAD | ( | bcr | ) |
#define NO_OS_I3C_BCR_IBI_REQUEST_CAPABLE | ( | bcr | ) |
Extract capabilities from BCR
#define NO_OS_I3C_CCC_ADDR | ( | x | ) |
#define NO_OS_I3C_CCC_BCAST 0 |
#define NO_OS_I3C_CCC_DEFSLVS NO_OS_I3C_CCC_ID(0x8, NO_OS_I3C_CCC_BCAST) |
#define NO_OS_I3C_CCC_DIRECT NO_OS_BIT(7) |
#define NO_OS_I3C_CCC_DISEC_BCAST 0x01 | NO_OS_I3C_CCC_SET_DEF |
#define NO_OS_I3C_CCC_DISEC_DIRECT 0x81 | NO_OS_I3C_CCC_SET_LEN(1) |
#define NO_OS_I3C_CCC_ENEC_BCAST 0x00 | NO_OS_I3C_CCC_SET_DEF |
#define NO_OS_I3C_CCC_ENEC_DIRECT 0x80 | NO_OS_I3C_CCC_SET_LEN(1) |
Commands valid in both broadcast and direct modes type: NO_OS_I3C_CCC_DIRECT, NO_OS_I3C_CCC_BCAST
#define NO_OS_I3C_CCC_ENTAS | ( | as, | |
type ) |
#define NO_OS_I3C_CCC_ENTDAA NO_OS_I3C_CCC_ID(0x7, NO_OS_I3C_CCC_BCAST) |
#define NO_OS_I3C_CCC_ENTHDR | ( | x | ) |
#define NO_OS_I3C_CCC_ENTTM NO_OS_I3C_CCC_ID(0xb, NO_OS_I3C_CCC_BCAST) |
#define NO_OS_I3C_CCC_EVENT_HJ NO_OS_BIT(3) |
#define NO_OS_I3C_CCC_EVENT_MR NO_OS_BIT(1) |
#define NO_OS_I3C_CCC_EVENT_SIR NO_OS_BIT(0) |
#define NO_OS_I3C_CCC_GET_DEF | ( | x | ) |
#define NO_OS_I3C_CCC_GET_LEN | ( | x | ) |
#define NO_OS_I3C_CCC_GET_RNW | ( | x | ) |
#define NO_OS_I3C_CCC_GETACCMST NO_OS_I3C_CCC_ID(0x11, NO_OS_I3C_CCC_DIRECT) |
#define NO_OS_I3C_CCC_GETBCR (NO_OS_I3C_CCC_ID(0xe, NO_OS_I3C_CCC_DIRECT) | NO_OS_I3C_CCC_SET_LEN(1) | NO_OS_I3C_CCC_SET_RNW(1)) |
#define NO_OS_I3C_CCC_GETDCR (NO_OS_I3C_CCC_ID(0xf, NO_OS_I3C_CCC_DIRECT) | NO_OS_I3C_CCC_SET_LEN(1) | NO_OS_I3C_CCC_SET_RNW(1)) |
#define NO_OS_I3C_CCC_GETHDRCAP NO_OS_I3C_CCC_ID(0x15, NO_OS_I3C_CCC_DIRECT) |
#define NO_OS_I3C_CCC_GETMRL NO_OS_I3C_CCC_ID(0xc, NO_OS_I3C_CCC_DIRECT) |
#define NO_OS_I3C_CCC_GETMWL NO_OS_I3C_CCC_ID(0xb, NO_OS_I3C_CCC_DIRECT) |
#define NO_OS_I3C_CCC_GETMXDS NO_OS_I3C_CCC_ID(0x14, NO_OS_I3C_CCC_DIRECT) |
#define NO_OS_I3C_CCC_GETPID (NO_OS_I3C_CCC_ID(0xd, NO_OS_I3C_CCC_DIRECT) | NO_OS_I3C_CCC_SET_LEN(6) | NO_OS_I3C_CCC_SET_RNW(1)) |
#define NO_OS_I3C_CCC_GETSTATUS (NO_OS_I3C_CCC_ID(0x10, NO_OS_I3C_CCC_DIRECT) | NO_OS_I3C_CCC_SET_LEN(2) | NO_OS_I3C_CCC_SET_RNW(1)) |
#define NO_OS_I3C_CCC_GETXTIME NO_OS_I3C_CCC_ID(0x19, NO_OS_I3C_CCC_DIRECT) |
#define NO_OS_I3C_CCC_ID | ( | id, | |
type ) |
#define NO_OS_I3C_CCC_RSTACT_BCAST 0x2a | NO_OS_I3C_CCC_SET_DEF |
#define NO_OS_I3C_CCC_RSTACT_DIRECT 0x9a | NO_OS_I3C_CCC_SET_DEF |
#define NO_OS_I3C_CCC_RSTACT_I3C_ONLY 0x1 |
#define NO_OS_I3C_CCC_RSTACT_WHOLE_TARGET 0x2 |
#define NO_OS_I3C_CCC_RSTDAA | ( | type | ) |
#define NO_OS_I3C_CCC_SET_DEF NO_OS_BIT(17) |
#define NO_OS_I3C_CCC_SET_LEN | ( | x | ) |
#define NO_OS_I3C_CCC_SET_RNW | ( | x | ) |
#define NO_OS_I3C_CCC_SETAASA NO_OS_I3C_CCC_ID(0x29, NO_OS_I3C_CCC_BCAST) |
#define NO_OS_I3C_CCC_SETBRGTGT NO_OS_I3C_CCC_ID(0x13, NO_OS_I3C_CCC_DIRECT) |
#define NO_OS_I3C_CCC_SETDASA NO_OS_I3C_CCC_ID(0x7, NO_OS_I3C_CCC_DIRECT) |
#define NO_OS_I3C_CCC_SETMRL | ( | type | ) |
#define NO_OS_I3C_CCC_SETMWL | ( | type | ) |
#define NO_OS_I3C_CCC_SETNEWDA NO_OS_I3C_CCC_ID(0x8, NO_OS_I3C_CCC_DIRECT) |
#define NO_OS_I3C_CCC_SETXTIME_BCAST 0x28 | NO_OS_I3C_CCC_SET_DEF |
#define NO_OS_I3C_CCC_SETXTIME_DIRECT 0x98 | NO_OS_I3C_CCC_SET_DEF |
#define NO_OS_I3C_I2C_MAX_ADDR 0x7F |
#define NO_OS_I3C_IRQ_CR 0x4 |
#define NO_OS_I3C_IRQ_HJ 0x2 |
#define NO_OS_I3C_IRQ_IBI 0x1 |
List of possible IRQ events.
#define NO_OS_I3C_MAX_ADDR NO_OS_I3C_I2C_MAX_ADDR |
#define NO_OS_I3C_MAX_BUS_NUMBER 3 |
#define NO_OS_I3C_MAX_DEV_NUMBER 15 |
On an I3C bus, addresses are assigned dynamically, and we need to know which addresses are free to use and which ones are already assigned.
Addresses marked as reserved are those reserved by the I3C protocol (broadcast address, ...).
uint8_t no_os_i3c_addr_get_free | ( | struct no_os_i3c_bus_desc * | desc, |
uint8_t | start_addr ) |
Get a free address.
desc | - The I3C bus descriptor. |
start_addr | - Start address to search from. |
void no_os_i3c_addr_set_status | ( | struct no_os_i3c_bus_desc * | desc, |
uint8_t | addr, | ||
enum no_os_i3c_slot_status | status ) |
Set status of an address.
desc | - The I3C bus descriptor. |
addr | - The address to set. |
status | - The value to write. |
int no_os_i3c_async_irq | ( | struct no_os_i3c_bus_desc * | desc, |
bool | en ) |
Enable I3C non-blocking interrupts.
desc | - The I3C descriptor. |
en | - 1 to enable, 0 to disable async callback. |
void no_os_i3c_attach_callback | ( | struct no_os_i3c_desc * | desc, |
void(* | callback )(struct no_os_i3c_desc *, uint32_t, uint32_t) ) |
Attach event callback.
desc | - The I3C device descriptor. |
callback | - Method to call on event. |
int no_os_i3c_call_irq | ( | struct no_os_i3c_bus_desc * | desc | ) |
Non-blocking I3C interrupt. Since a payload is always retrieved with it, also update the no_os_i3c_ccc_info fields.
desc | - The I3C descriptor. |
int no_os_i3c_conf_irq | ( | struct no_os_i3c_bus_desc * | desc, |
uint8_t | irq, | ||
bool | en ) |
Configure I3C interrupts.
desc | - The I3C descriptor. |
irq | - The interrupt type to enable. |
en | - 1 to enable, 0 to disable irq type. |
void no_os_i3c_detach_callback | ( | struct no_os_i3c_desc * | desc | ) |
Detach event callback.
desc | - The I3C device descriptor. |
int no_os_i3c_do_daa | ( | struct no_os_i3c_bus_desc * | desc, |
bool | rstdaa ) |
Do DAA to assign the dynamic addresses.
desc | - The I3C descriptor. |
rstdaa | - Do RSTDAA CCC before the DAA. |
int no_os_i3c_init | ( | struct no_os_i3c_desc ** | desc, |
const struct no_os_i3c_init_param * | param ) |
Initialize the I3C device. If the bus of the I3C device is not initialized, it will call to init it.
desc | - The I3C device descriptor. |
param | - The structure that contains the I3C device parameters, to match PID. |
int no_os_i3c_init_bus | ( | struct no_os_i3c_bus_desc ** | desc, |
const struct no_os_i3c_bus_init_param * | param ) |
Initialize the I3C bus.
desc | - The I3C bus descriptor. |
param | - The structure that contains the I3C bus parameters. |
int no_os_i3c_read | ( | struct no_os_i3c_desc * | desc, |
uint8_t * | data, | ||
uint8_t | size ) |
Read data from device device.
desc | - The I3C descriptor. |
data | - The buffer with the received data. |
size | - Number of bytes to read. |
int no_os_i3c_remove | ( | struct no_os_i3c_desc * | desc | ) |
Free the resources allocated by no_os_i3c_init().
desc | - The I3C device descriptor. |
int no_os_i3c_remove_bus | ( | struct no_os_i3c_bus_desc * | desc | ) |
Free the resources allocated by no_os_i3c_init_bus. Must remove all devices first, if not, -EBUSY is returned.
desc | - The I3C bus descriptor. |
int no_os_i3c_send_ccc | ( | struct no_os_i3c_bus_desc * | desc, |
uint8_t | addr, | ||
uint32_t | ccc, | ||
uint8_t * | data ) |
Send CCC, either to a device device or broadcast to all.
desc | - The I3C descriptor. |
addr | - Device address or broadcast address. |
ccc | - CCC RnW, CCC Length, CCC ID. |
data | - The buffer with the transmitted/received data. |
int no_os_i3c_send_direct_ccc | ( | struct no_os_i3c_desc * | desc, |
uint32_t | ccc, | ||
uint8_t * | data ) |
Send CCC to device device.
desc | - The I3C descriptor. |
ccc | - CCC RnW, CCC length, CCC id. |
data | - The buffer with the transmitted/received data. |
int32_t no_os_i3c_transfer_abort | ( | struct no_os_i3c_desc * | desc | ) |
Abort the ongoing DMA transaction.
desc | - The I3C descriptor. |
int32_t no_os_i3c_transfer_dma_async | ( | struct no_os_i3c_desc * | desc, |
struct no_os_i3c_msg * | msgs, | ||
uint32_t | len, | ||
void(* | callback )(void *), | ||
void * | ctx ) |
Transfer a list of messages using DMA. Non-blocking, invokes a callback after the last message is concluded.
desc | - The I3C descriptor. |
msgs | - The list of messages to transfer. |
len | - The number of messages to transfer. |
callback | - The callback to invoke after the transfer is concluded. |
ctx | - The context to pass to the callback. |
int no_os_i3c_wait_irq | ( | struct no_os_i3c_bus_desc * | desc, |
uint8_t | irq ) |
Wait I3C interrupt. Set async_irq on call to false to ensure single entry point.
desc | - The I3C descriptor. |
irq | - The interrupt to wait for. |
int no_os_i3c_write | ( | struct no_os_i3c_desc * | desc, |
uint8_t * | data, | ||
uint8_t | size ) |
Write data to device device.
desc | - The I3C descriptor. |
data | - The buffer with the transmitted data. |
size | - Number of bytes to write. |
int no_os_i3c_write_and_read | ( | struct no_os_i3c_desc * | desc, |
uint8_t * | tx_data, | ||
uint8_t | tx_data_len, | ||
uint8_t * | rx_data, | ||
uint8_t | rx_data_len ) |
Read and write the device.
desc | - The I3C descriptor. |
tx_data | - The buffer with the transmitted data. |
tx_data_len | - Number of bytes to write. |
rx_data | - The buffer with the received data. |
rx_data_len | - Number of bytes to read. |