Help with adding an I2C recovery pulse

Hello,

I'd like to add the transmission of an I2C recovery pulse (where you toggle SCK 10 times) to my startup routine for an offboard device whose state I'm uncertain of.

I've been looking through the drivers in i2c_nrfx_twim.c and i2c_nrfx_twi.c to see if it's supported and I found i2c_nrfx_twim_recover_bus() in i2c_nrfx_twim.c, but that function calls nrfx_twim_bus_recover(), and I haven't been able to find that function defined anywhere.

I started trying to write my own version of i2c_nrfx_twim_recover_bus() hoping to use direct GPIO access to the port pins if such a thing is still possible and clock out the pulse train with a k_sleep() kind of delay between edges. But I'm getting confused on how to get from the device pointer structure that I have in my third party device driver to the one I need.
Here are some images that show the error:
Thanks for the continued help!
Glen
  • Hi

    I just opened NCS 2.6.1, and I could see that the

    i2c_nrfx_twim_recover_bus() function is defined in i2c_nrfx_twim.c file

  • Yes I found that function as I mentioned, but I had a hard time finding where the function nrfx_twim_bus_recover() that it calls lives. I looked again this morning and I found that it ultimately ends up calling nrfx_twi_twim_bus_recover in nrfx_twi_twim.c.

    I did manage to get this to work, so I'll close this topic. A note to future post-finders, the code in nrfx_twi_twim_bus_recover checks to see if the SDA pin is high and it doesn't send the reset pulse if it is. I guess this procedure is only meant to release a stuck SDA line.

       const struct TM065049_config *config = m_dev_copy->config;    
       
       i2c_recover_bus(config->i2c.bus);
Related