2025-10-23 7:42 AM
Hi,
I am trying to create the I2C communication using the format used from the company seller of the device.
I have to follow these steps:
I2CReadFunciton ( uint8_t slAddr,
uint8_t* wrData, int wrLen,
uint8_t* rdData, int rdLen
Initiate the bus by issuing a START condition.
If there are bytes to write (wrLen > 0):
Begin the read phase:
Terminate the transaction with a STOP condition.
Key constraints:
My problem is how to not have the stop condition in the write function using the HAL functions.
Solved! Go to Solution.
2025-10-23 7:59 AM
Please include your full chip part number in your posts.
What device are you interfacing with?
HAL_I2C_Mem_Read will issue a write then a read with a repeated-start condition. Perhaps use that or look there to see how it is done.
2025-10-23 7:59 AM
Please include your full chip part number in your posts.
What device are you interfacing with?
HAL_I2C_Mem_Read will issue a write then a read with a repeated-start condition. Perhaps use that or look there to see how it is done.
2025-10-23 11:47 PM
Thanks for the answer!
It's a gas sensor, but it's form the coompetition of ST, so I prefer not to say which is.
I have already used it, but it didn't work because it can happen that in the write part the wrLen cab be bigger than 1 byte, so the HAL_I2C_Mem_Read doesn't work.
In principle, it can happen I need to write 3 bytes and read 5 bytes.
I found the HAL_I2C_Master_Seq_Transmit_IT, but I am not pretty sure how to use it.
Thans in advance for the help