Skip to main content
Visitor II
August 26, 2024
Question

I2C read operation modification in driver

  • August 26, 2024
  • 1 reply
  • 695 views

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.

    This topic has been closed for replies.

    1 reply

    Super User
    August 26, 2024

    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.