I’m trying to implement own I2C driver for TF mini lidar, so firstly I’ve played with the lidar connected to Arduino board.
I have Arduino code working fine, but I have troubles with understanding what are the corresponding functions in Ardupilot’s I2CDevice.h
Example, a request for a single measurement in Arduino code looks like:
Wire.beginTransmission(TFmini_Addr); // Begin a transmission to the I2C slave device
Wire.write(1);
Wire.write(0);
Wire.write(1);
Wire.endTransmission(0); // will send a restart, keeping the connection active.Wire.beginTransmission(TFmini_Addr); // Begin a transmission to the I2C slave device
Wire.write(1);
Wire.endTransmission(1); // will send a stop message, releasing the bus after transmission
Am I right the code above shall be implemented by using two Device.transfer() calls:
dev->transfer( { 1, 0, 1 }, 3, nullptr, 0);
dev->transfer( { 1 }, 1, nullptr, 0);
But how to define that after the second transfer() call the STOP message should be sent? (like it does the Wire.endTransmission(1) call)