I2C Class Issues

Disclaimer: I’m aware that the I2C class states “This class is intended to be used by sensor (and other I2C device) drivers. It probably should not be used directly.”

We have been playing with the I2C class a fair amount lately and I wanted to share those results with others and see if anyone else can confirm some of these odd behaviors. I’m not sure if its just the devices we are using or if several of the class methods are really broken.

We have the Pixy plugged into the kOnBoard I2C port. We have the Logic 4 as a scope/logic analyser.

Class functions/members/methods:
AddressOnly() // Doesn’t appear to work at all
Transaction() // Write portion might work, but it reads back the same value all the time
Read() // reads back the same value all the time

ReadOnly() // works fine
WriteBulk() // Works fine
Write() // Works fine

It appears as if the Read() and Transaction() always return the first value returned by the device. I can confirm this is the pattern on the bus, due to the logic analyser. So the problem has to be either the SDA pin is being driven by the RoboRio or somehow the Start/Stop/ReStart/ACK sequence is not being handled correctly and the bus gets stuck in some way.

Anyone have experience with this type of behavior? Any other thoughts?

We were able to successfully read and write to a Lidar Lite v3 with the following code snippet:

      i2c_Lidar->Write(0x00, 0x00);
      i2c_Lidar->Write(0x00, 0x04);

      djoSendData[0] = 0x01;  // Bulk Write Based Read_Only for a single register Read of 0x01 (status)

      djoSendData[0] = 0x8F;  // Bulk Write Based Read_Only for a two register Read of 0x8F (distance)

Please delete this thread and leave the other one intact.

I concur. It’s broken. It was working last year. But it seems that, as of the latest firmware upgrade, it is no longer working.

Really hoping it can be fixed. But we cannot count on that in time for our first competition. So, we’re going to have rewire and reprogram to use the SPI. (Sure hope that isn’t broken as well.)