Hello, I am having problems to be able to perform the transmission (read / write) of data via I2C on the NanoPC-T2 with android.
I open the I2C port and set the slave with the following commands.
But when transmitting data if I see it with the oscilloscope, the clock does not work continuously and the same data is sent repeatedly ((I only send a data for example "1", but I see that it is sent up to 6 times) .).
I open the I2C port and set the slave with the following commands.
Code: Select all
devFD = HardwareControler.open("/dev/i2c-0", FileCtlEnum.O_RDWR);
if (devFD < 0) {
Toast.makeText(getApplicationContext(), "Fail to open I2C device",
Toast.LENGTH_LONG).show();
} else {
if (HardwareControler.setI2CSlave(devFD, 0x48) < 0) {
Toast.makeText(getApplicationContext(), "Fail to open I2C Slave",
Toast.LENGTH_LONG).show();
} else {
Toast.makeText(getApplicationContext(), "Ready " + String.valueOf(devFD),
Toast.LENGTH_LONG).show();
}
}
But when transmitting data if I see it with the oscilloscope, the clock does not work continuously and the same data is sent repeatedly ((I only send a data for example "1", but I see that it is sent up to 6 times) .).
Code: Select all
private void sendData() {
new Thread() {
@Override
public void run() {
while (true){
try {
sleep(100);
HardwareControler.I2CWriteByte(devFD,(byte) (0x01 << 4) ,0);
Log.d("I2C","SENT");
sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}.start();
}