2025-12-28 4:45 PM
I have seen the question asked many times, references made but the question never gets answered with precision. So, once again...
I want to use HAL_I2C_Master_Seq_Transmit_IT along with receive to read an I2C device register.
1. START SLAVEADDRESSWR (N-Byte RegAddress)
2. REPEATEDSART SLAVEADDRESSRD (N-Byte returned data) STOP
Step 1 would us HAL_I2C_Master_Seq_Transmit_IT
Step 2 would use HAL_I2C_Master_Seq_Receive_IT
What are the "Option" parameters such as I2C_FIRST_FRAME, etc. for each of these calls to avoid a STOP between the sequences and make the REPEATEDSTART occur, and of course finish up with a STOP?
And using the memory read/write calls does not work because the register memory address cannot be of arbitrary length. Don't have a scope handy to see the protocol generated, so I won't know things are working until my device actually returns correct default register values.
2025-12-28 5:18 PM - edited 2025-12-28 5:21 PM
Option for the transmit: I2C_OTHER_FRAME. For receive: I2C_OTHER_AND_LAST_FRAME.
2025-12-28 5:50 PM
Here is a working example of these functions for both the master side and the slave side:
The syntax is the same regardless of chip family.
HAL_I2C_Master_Seq_Transmit_IT(..., I2C_FIRST_FRAME);
...
HAL_I2C_Master_Seq_Receive_IT(..., I2C_LAST_FRAME);