cancel
Showing results for 
Search instead for 
Did you mean: 

I2C read operation modification in driver

MSGokul
Associate II

I have been working on interfacing a Realtek switch and the Realtek configuration was done by i2c bit banging. I am currently trying to change to HAL I2C and am in need of performing a read operation as shown.
image.png

Here the read operation is performed such that the read address write is done as the part of read operation. In STM32H5 Hal I2C driver, I tried making modifications to mimic this sequence, but in all the cases, the address write is only done as part of a write operation only. Is there any way to modify the driver such that the exact same signal generation sequence occurs.

1 REPLY 1
TDK
Guru

What you have shown is a standard read operation of 4 bytes from address 0x5C. This is doable without modifying the driver.

 

uint8_t buffer[4] = {0};
HAL_I2C_Master_Receive(&hi2c, 0x5C << 1, &buffer, 4, HAL_MAX_DELAY);

 

 

Or perhaps you meant to show a different transaction where you write the memory address, then read it, which can be done with HAL_I2C_Mem_Read.

If you feel a post has answered your question, please click "Accept as Solution".