class PortI2C
The PortI2C class is a special version of class Port implementing the I2C / Two-Wire Interface (TWI) protocol. It allows using any port as I2C bus master. When used for I2C, DIO is used as SDA and AIO as SCL.
Unlike the Wire library for the Arduino, which is a more advanced solution for the hardware I2C lines of an ATmega, the PortI2C class is implemented entirely in software using "bit-banging". Another difference is that PortI2C does not use interrupts and will keep the microcontroller occupied while it is performing I/O transfers.
See also the class DeviceI2C documentation for an example of use.
#include <Ports.h>
#include <RF12.h> // needed to avoid a linker error :(
class PortI2C;
Public API
- PortI2C PortI2C() - constructor, creates an instance of class PortI2C
- PortI2C start() - start a new I2C transfer
- PortI2C stop() - end an I2C transfer
- PortI2C write() - write a data byte to the I2C bus
- PortI2C read() - read a data byte from the I2C bus