|
I2C_device_Arduino 1.2.0
An I²C utility class for Arduino
|
An I²C utility class for Arduino
An Arduino library for I²C device operations.
This is an abstraction class which can be used for all I²C devices to manage access at the register level.
In addition to the device abstraction, it provides ping() and scan() as class methods.
See test_LM75B.cpp and test_LM75B.h as a sample for how a sub-class can be derived to make an actual device-supporting class.
Details of the library are provided in this document.
An example code is available using test_LM75B class which is included in this library distribution.
It performs:
For normal usage of an I²C device which is derived from I2C_device class, it will be like the sample below. This is intended to use the Wire instance of Arduino SDK to access I2C, implicitly.
(Using test_LM75B class included in this library package.)
If a user needs to use other instances of TwoWire class (a class for Wire), it could be done like below.
In this sample, the I²C device is connected to Wire1 (It's SDA1&SCL1 pins on Arduino DUE). Wire1 should be used explicitly.
For a more generic way to define the hardware, you can do it by compile option to detect the board and switch compile option.
In this sample, the compiler detects the type of target board and uses the right instance for the target.
| Library | Feature | Target devices | Required library |
|---|---|---|---|
| GPIO_NXP_Arduino | GPIO libraries | PCAL6408A, PCAL6416A, PCAL6524, PCAL6534, PCA9555, PCA9554 | I2C_device_Arduino |
| LCDDriver_NXP_Arduino | LCD driver libraries | PCA8561 | I2C_device_Arduino |
| LEDDriver_NXP_Arduino | LED driver libraries | PCA9955B, PCA9956B, PCA9957 | I2C_device_Arduino |
| MUX_SW_NXP_Arduino | I²C mux/switch libraries | PCA9846 | I2C_device_Arduino |
| RTC_NXP_Arduino | RTC libraries | PCF2131, PCF85063A | I2C_device_Arduino |
| TempSensor_NXP_Arduino | Temperature sensor libraries | LM75B, PCT2075, P3T1085 | I2C_device_Arduino |
| I2C_device_Arduino | Base library for I²C operations | none (can be applied as base class for all I²C targets) | — |