55 #ifndef FOXBMS__I2C_H_
56 #define FOXBMS__I2C_H_
69 #define I2C_TIMEOUT_us (1000u)
72 #define I2C_TXDMAEN (0x2u)
74 #define I2C_RXDMAEN (0x1u)
77 #define I2C_DDR_REGISTER_DATA_MASK (0xFFu)
80 #define I2C_TASK_HANDLE (ftsk_taskHandleI2c)
83 #define I2C_NOTIFICATION_TX_INDEX (1u)
85 #define I2C_NOTIFICATION_RX_INDEX (2u)
87 #define I2C_NO_NOTIFIED_VALUE (0x0u)
89 #define I2C_TX_NOTIFIED_VALUE (0x51u)
91 #define I2C_RX_NOTIFIED_VALUE (0x61u)
93 #define I2C_RX_NOTCOME_VALUE (0x62u)
98 #define I2C_NOTIFICATION_TIMEOUT_ms (2u)
100 #define I2C_PRESCALER_MASK (0xFFu)
102 #define I2C_FACTOR_MHZ_TO_HZ (1000000u)
104 #define I2C_FACTOR_S_TO_US (1000000u)
106 #define I2C_FACTOR_WORD_TO_BITS (9u)
112 #define I2C_DFACTOR_VALUE_PRESCALER_0 (7u)
113 #define I2C_DFACTOR_VALUE_PRESCALER_1 (6u)
114 #define I2C_DFACTOR_VALUE_PRESCALER_OTHER (5u)
117 #define I2C_TX_TIME_MARGIN_us (5u)
150 i2cBASE_t *pI2cInterface,
151 uint32_t slaveAddress,
166 i2cBASE_t *pI2cInterface,
167 uint32_t slaveAddress,
168 uint32_t nrBytesWrite,
170 uint32_t nrBytesRead,
182 i2cBASE_t *pI2cInterface,
183 uint32_t slaveAddress,
196 i2cBASE_t *pI2cInterface,
197 uint32_t slaveAddress,
212 i2cBASE_t *pI2cInterface,
213 uint32_t slaveAddress,
214 uint32_t nrBytesWrite,
216 uint32_t nrBytesRead,
239 extern bool I2C_WaitReceive(i2cBASE_t *pI2cInterface, uint32_t timeout_us);
242 #ifdef UNITY_UNIT_TEST
Definition of foxBMS standard types.
STD_RETURN_TYPE_e I2C_WriteRead(i2cBASE_t *pI2cInterface, uint32_t slaveAddress, uint32_t nrBytesWrite, uint8_t *writeData, uint32_t nrBytesRead, uint8_t *readData)
reads from an I2C slave, blocking.
bool I2C_WaitReceive(i2cBASE_t *pI2cInterface, uint32_t timeout_us)
Waits for the I2C Rx buffer to be full.
uint8_t i2c_rxLastByteInterface2
uint8_t i2c_rxLastByteInterface1
uint8_t I2C_ReadLastRxByte(i2cBASE_t *pI2cInterface)
Used to read last byte received per I2C.
STD_RETURN_TYPE_e I2C_ReadDma(i2cBASE_t *pI2cInterface, uint32_t slaveAddress, uint32_t nrBytes, uint8_t *readData)
reads from an I2C slave, no register address written first, using DMA.
STD_RETURN_TYPE_e I2C_Read(i2cBASE_t *pI2cInterface, uint32_t slaveAddress, uint32_t nrBytes, uint8_t *readData)
reads from an I2C slave, no register address written first, blocking.
STD_RETURN_TYPE_e I2C_WriteReadDma(i2cBASE_t *pI2cInterface, uint32_t slaveAddress, uint32_t nrBytesWrite, uint8_t *writeData, uint32_t nrBytesRead, uint8_t *readData)
reads from an I2C slave, using DMA.
STD_RETURN_TYPE_e I2C_Write(i2cBASE_t *pI2cInterface, uint32_t slaveAddress, uint32_t nrBytes, uint8_t *writeData)
writes to an I2C slave, no register address written first, blocking.
STD_RETURN_TYPE_e I2C_WriteDma(i2cBASE_t *pI2cInterface, uint32_t slaveAddress, uint32_t nrBytes, uint8_t *writeData)
writes to an I2C slave, no register address written first, using DMA.
void I2C_Initialize(void)
Initialize the I2C hardware with dedicated HAL functions. Has to be called before any call to the res...