class DeviceI2C
Since I2C is a bus, there are actually two classes involved. A PortI2C object manages a port as I2C master for one or more objects of class DeviceI2C, each representing a separate device. You can have multiple ports as I2C bus (running at a different speed perhaps), each talking to multiple I2C devices. Devices sharing the same bus must each have a unique ID in the range 0 .. 127.
Example definition:
PortI2C myBus (3, PortI2C::KHZ400);
DeviceI2C myDev (myBus, 0x77);
Once a device object has been created, I/O transfers to and from that device can be performed.
#include <Ports.h>
#include <RF12.h> // needed to avoid a linker error :(
class DeviceI2C;
Public API
- DeviceI2C isPresent() - see if a device answers at an I2C address
- DeviceI2C send() - start a send operation
- DeviceI2C receive() - start a receive operation
- DeviceI2C stop() - end the transfer for this device
- DeviceI2C write() - write a byte to this device
- DeviceI2C read() - read a byte from this device