This class provides an API to access the I2C bus. It uses JNA to call operating system functions of the Android Linux kernel.
The class has been tested with a Hardkernel ODROID-C2 with Android 6.
Example of how to use the I2C driver class to scan the bus:
I2cBusDriver i2c = new I2cBusDriver("2"); int foundDevices = 0; for (int slaveAddr = 3; slaveAddr <= 0x77; slaveAddr++) { if (i2c.probeSlaveAddress(slaveAddr)) { Log.v("I2C Test", "Found: 0x" + Integer.toHexString(slaveAddr)); foundDevices++; } } Log.v("I2C Test", foundDevices + " devices found.");
Source code: I2cBusDriver.java
Peripheral driver for PCF8563 RTC (real-time clock) chip: PCF8563Driver.java
Author: Christian d'Heureuse (www.source-code.biz, www.inventec.ch/chdh)
Index