I2C_device_Arduino 1.0.5
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 its access in register access level.
On addition to the device abstraction, it provides method ping()
and scan()
as class methods.
See test_LM75B.cpp
and test_LM75B.h
as a sample for how the sub-class can be derived to make actual device supporting class.
Details of the library is provided in this document.
An example code is available using test_LM75B class which is included in this library distribution.
It performs
I2C_device::scan()
)For normal usage of I²C device which is delived from I2C_device class, it will be like sample blelow. This intended to use Wire
instance of Arduino SDK to access I2C, implicitly.
(Using test_LM75B class included in this library package.)
If user need to use other instance of TwoWire class (a class for Wire), it could be done like below.
In this sample, the I²C device is connected Wire1 (It's SDA1&SCL1 pins on Arduino DUE). Wire1 should be used explisitly.
For 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 type of target board and use 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) | — |