42 #if !defined(LPI2C_DRIVER_H)
43 #define LPI2C_DRIVER_H
67 #define LPI2C_MASTER_CMD_QUEUE_SIZE 5U
77 #if(LPI2C_HAS_FAST_PLUS_MODE)
78 LPI2C_FASTPLUS_MODE = 0x2U,
80 #if(LPI2C_HAS_HIGH_SPEED_MODE)
81 LPI2C_HIGHSPEED_MODE = 0x3U,
83 #if(LPI2C_HAS_ULTRA_FAST_MODE)
84 LPI2C_ULTRAFAST_MODE = 0x4U
161 #if(LPI2C_HAS_HIGH_SPEED_MODE)
205 #if(LPI2C_HAS_HIGH_SPEED_MODE)
214 LPI2C_MASTER_COMMAND_TRANSMIT = 0U,
215 LPI2C_MASTER_COMMAND_RECEIVE = 1U,
216 LPI2C_MASTER_COMMAND_STOP = 2U,
217 LPI2C_MASTER_COMMAND_RECEIVE_DISCARD = 3U,
218 LPI2C_MASTER_COMMAND_START = 4U,
219 LPI2C_MASTER_COMMAND_START_NACK = 5U,
220 LPI2C_MASTER_COMMAND_START_HS = 6U,
221 LPI2C_MASTER_COMMAND_START_NACK_HS = 7U,
222 } lpi2c_master_command_t;
229 lpi2c_master_command_t cmd[LPI2C_MASTER_CMD_QUEUE_SIZE];
230 uint8_t data[LPI2C_MASTER_CMD_QUEUE_SIZE];
233 } lpi2c_master_cmd_queue_t;
247 lpi2c_master_cmd_queue_t cmdQueue;
250 const uint8_t * txBuff;
254 uint16_t slaveAddress;
255 volatile bool i2cIdle;
256 #if(LPI2C_HAS_HIGH_SPEED_MODE)
258 bool highSpeedInProgress;
262 semaphore_t idleSemaphore;
283 volatile bool isTransferInProgress;
286 const uint8_t * txBuff;
290 bool txUnderrunWarning;
291 semaphore_t idleSemaphore;
308 #if defined(__cplusplus)
411 const uint8_t * txBuff,
430 const uint8_t * txBuff,
555 const uint8_t * txBuff,
592 const uint8_t * txBuff,
611 const uint8_t * txBuff,
666 uint32_t *bytesRemaining);
691 #if defined(__cplusplus)
status_t LPI2C_DRV_SlaveGetTransferStatus(uint32_t instance, uint32_t *bytesRemaining)
Return the current status of the I2C slave transfer.
void(* lpi2c_slave_callback_t)(uint32_t instance, lpi2c_slave_event_t slaveEvent, void *userData)
LPI2C slave callback function.
lpi2c_mode_t operatingMode
lpi2c_slave_callback_t slaveCallback
status_t LPI2C_DRV_MasterGetTransferStatus(uint32_t instance, uint32_t *bytesRemaining)
Return the current status of the I2C master transfer.
lpi2c_slave_event_t
LPI2C slave events Implements : lpi2c_slave_event_t_Class.
status_t LPI2C_DRV_MasterAbortTransferData(uint32_t instance)
Abort a non-blocking I2C Master transmission or reception.
lpi2c_transfer_type_t transferType
lpi2c_master_callback_t masterCallback
status_t LPI2C_DRV_SlaveReceiveData(uint32_t instance, uint8_t *rxBuff, uint32_t rxSize)
Perform a non-blocking receive transaction on the I2C bus.
status_t LPI2C_DRV_SlaveSendDataBlocking(uint32_t instance, const uint8_t *txBuff, uint32_t txSize, uint32_t timeout)
Perform a blocking send transaction on the I2C bus.
lpi2c_transfer_type_t transferType
lpi2c_mode_t
I2C operating modes Implements : lpi2c_mode_t_Class.
void LPI2C_DRV_MasterSetSlaveAddr(uint32_t instance, const uint16_t address, const bool is10bitAddr)
Set the slave address for any subsequent I2C communication.
status_t LPI2C_DRV_SlaveSetRxBuffer(uint32_t instance, uint8_t *rxBuff, uint32_t rxSize)
Provide a buffer for receiving data.
void(* lpi2c_master_callback_t)(uint32_t instance, lpi2c_master_event_t masterEvent, void *userData)
Defines the example structure.
void LPI2C_DRV_MasterGetBaudRate(uint32_t instance, lpi2c_baud_rate_params_t *baudRate)
Get the currently configured baud rate.
status_t LPI2C_DRV_MasterReceiveDataBlocking(uint32_t instance, uint8_t *rxBuff, uint32_t rxSize, bool sendStop, uint32_t timeout)
Perform a blocking receive transaction on the I2C bus.
status_t LPI2C_DRV_MasterSendData(uint32_t instance, const uint8_t *txBuff, uint32_t txSize, bool sendStop)
Perform a non-blocking send transaction on the I2C bus.
status_t LPI2C_DRV_SlaveSetTxBuffer(uint32_t instance, const uint8_t *txBuff, uint32_t txSize)
Provide a buffer for transmitting data.
Slave configuration structure.
Slave internal context structure.
lpi2c_transfer_type_t
Type of LPI2C transfer (based on interrupts or DMA). Implements : lpi2c_transfer_type_t_Class.
status_t LPI2C_DRV_SlaveSendData(uint32_t instance, const uint8_t *txBuff, uint32_t txSize)
Perform a non-blocking send transaction on the I2C bus.
status_t LPI2C_DRV_SlaveAbortTransferData(uint32_t instance)
Abort a non-blocking I2C Master transmission or reception.
void LPI2C_DRV_MasterIRQHandler(uint32_t instance)
Handle master operation when I2C interrupt occurs.
status_t
Status return codes. Common error codes will be a unified enumeration (C enum) that will contain all ...
status_t LPI2C_DRV_MasterInit(uint32_t instance, const lpi2c_master_user_config_t *userConfigPtr, lpi2c_master_state_t *master)
Initialize the LPI2C master mode driver.
status_t LPI2C_DRV_MasterDeinit(uint32_t instance)
De-initialize the LPI2C master mode driver.
void LPI2C_DRV_SlaveIRQHandler(uint32_t instance)
Handle slave operation when I2C interrupt occurs.
Master configuration structure.
status_t LPI2C_DRV_SlaveDeinit(uint32_t instance)
De-initialize the I2C slave mode driver.
lpi2c_mode_t operatingMode
void LPI2C_DRV_MasterSetBaudRate(uint32_t instance, const lpi2c_mode_t operatingMode, const lpi2c_baud_rate_params_t baudRate)
Set the baud rate for any subsequent I2C communication.
Master internal context structure.
status_t LPI2C_DRV_MasterReceiveData(uint32_t instance, uint8_t *rxBuff, uint32_t rxSize, bool sendStop)
Perform a non-blocking receive transaction on the I2C bus.
status_t LPI2C_DRV_SlaveReceiveDataBlocking(uint32_t instance, uint8_t *rxBuff, uint32_t rxSize, uint32_t timeout)
Perform a blocking receive transaction on the I2C bus.
status_t LPI2C_DRV_SlaveInit(uint32_t instance, const lpi2c_slave_user_config_t *userConfigPtr, lpi2c_slave_state_t *slave)
Initialize the I2C slave mode driver.
status_t LPI2C_DRV_MasterSendDataBlocking(uint32_t instance, const uint8_t *txBuff, uint32_t txSize, bool sendStop, uint32_t timeout)
Perform a blocking send transaction on the I2C bus.
lpi2c_master_event_t
LPI2C master events Implements : lpi2c_master_event_t_Class.