AceWire
0.2.0
Unified interface for selecting different I2C implementations on Arduino platforms
|
A thin wrapper around an I2C TwoWire
class and its Wire
object.
More...
#include <TwoWireInterface.h>
Public Member Functions | |
TwoWireInterface (T_WIRE &wire) | |
Constructor. More... | |
void | begin () |
Initial the interface. More... | |
void | end () |
End the interface. More... | |
void | beginTransmission (uint8_t addr) |
Start transmission at specified I2C addr. | |
void | write (uint8_t data) |
Write data into the write buffer. | |
void | endTransmission () |
End building of the buffer, and actually transmit the data. | |
uint8_t | requestFrom (uint8_t addr, uint8_t quantity, bool stop=true) |
Read bytes from the slave and store in buffer owned by T_WIRE. | |
uint8_t | read () |
Read byte from buffer. | |
void | endRequest () |
End requestFrom(). More... | |
TwoWireInterface (const TwoWireInterface &)=default | |
TwoWireInterface & | operator= (const TwoWireInterface &)=default |
A thin wrapper around an I2C TwoWire
class and its Wire
object.
This is a template class to avoid including the <Wire.h> header file, which increases flash memory on AVR by about 1000 byte even if the Wire object is never used.
This wrapper can also be used with alternative implementations of I2C (software or hardware) so long as they implement some basic API of the TwoWire
class: specifically the beginTransmission()
, write()
and endTransmission() methods. Since
TwoWireInterface` is a template, the alternative implementation classes do not need to inherit from the TwoWire
class.
Definition at line 45 of file TwoWireInterface.h.
|
inlineexplicit |
Constructor.
wire | instance of T_WIRE . If the pre-installed Wire.h is used, then T_WIRE is TwoWire and wire is the precreated Wire object |
Definition at line 53 of file TwoWireInterface.h.
|
inline |
|
inline |
|
inline |
End requestFrom().
Clients should always call this. This implementation does nothing, but other implementations will perform additional actions.
Definition at line 90 of file TwoWireInterface.h.