|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 device we are using or if several of the class methods are really broken. We have a Lidar Lite v3 plugged into the kOnBoard I2C port. We have the Logic 4 as a scope/logic analyser. We have a working Pixy that we add to the bus, adding the Pixy doesn't change the behavior. Class functions/members/methods: Code:
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, but requires a two byte write A few specific questions: 1.) Can anyone else confirm that AddressOnly() doesn't work at all? 2.) Has anyone seen issues with "addressed" reads from I2C devices? (Pixy uses ReadOnly()) More generally, does anyone have experience with this type of behavior? Any other thoughts? We were able to successfully read and write to the Lidar with the following code snippet (utilizing only "working" methods): Code:
#define LIDAR_I2C_DEFAULT_ADDR 0x62 I2C* i2c_Lidar; //Declare i2c for Lidar i2c_Lidar = new I2C(I2C::Port::kOnboard, LIDAR_I2C_DEFAULT_ADDR); //(I2C::Port::kOnboard or kMXP, Pixy Address) ... i2c_Lidar->Write(0x00, 0x00); Wait(.025); i2c_Lidar->Write(0x00, 0x04); Wait(.005); djoSendData[0] = 0x01; // Bulk Write Based Read_Only for a single register Read of 0x01 (status) i2c_Lidar->WriteBulk(djoSendData,1); i2c_Lidar->ReadOnly(1,LidarMassData); printf("Mass Data 0 %4X \n", LidarMassData[0]); Wait(0.001); djoSendData[0] = 0x8F; // Bulk Write Based Read_Only for a two register Read of 0x8F (distance) i2c_Lidar->WriteBulk(djoSendData,1); i2c_Lidar->ReadOnly(2,LidarMassData); printf("Mass Data 0 %4X \n", LidarMassData[0]); printf("Mass Data 1 %4X \n", LidarMassData[1]); |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|