AceWire
0.4.0
Unified interface for selecting different I2C implementations on Arduino platforms
|
A thin wrapper around the default TwoWire
class and its Wire
object provided by most Arduino platforms.
More...
#include <TwoWireInterface.h>
Public Member Functions | |
TwoWireInterface (T_WIRE &wire) | |
Constructor. More... | |
void | begin () const |
Initialize the interface. More... | |
void | end () const |
End the interface. More... | |
uint8_t | beginTransmission (uint8_t addr) const |
Prepare the write buffer to accept a sequence of data, and save the addr for transmission when endTransmission() is called. More... | |
uint8_t | write (uint8_t data) const |
Write data into the write buffer. More... | |
uint8_t | endTransmission (bool sendStop=true) const |
Send the data in the buffer, with a STOP condition if sendStop is true. More... | |
uint8_t | requestFrom (uint8_t addr, uint8_t quantity, bool sendStop=true) const |
Read bytes from the slave and store in buffer owned by TwoWire and send a STOP condition if sendStop is true. More... | |
uint8_t | read () const |
Read byte from the TwoWire receive buffer. | |
TwoWireInterface (const TwoWireInterface &)=default | |
TwoWireInterface & | operator= (const TwoWireInterface &)=default |
A thin wrapper around the default TwoWire
class and its Wire
object provided by most Arduino platforms.
All TwoWire
instances use a TX and RX buffer of varying sizes. For example:
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.
T_WIRE | underlying class that implements the I2C protocol which will always be TwoWire |
Definition at line 50 of file TwoWireInterface.h.
|
inlineexplicit |
Constructor.
wire | instance of TwoWire which will always be the Wire object |
Definition at line 56 of file TwoWireInterface.h.
|
inline |
|
inline |
Prepare the write buffer to accept a sequence of data, and save the addr for transmission when endTransmission()
is called.
addr
is simply written into a buffer Definition at line 71 of file TwoWireInterface.h.
|
inline |
|
inline |
Send the data in the buffer, with a STOP condition if sendStop
is true.
Returns the value returned by the underlying TwoWire::endTransmission() method, which returns the values documented in the twi_writeTo() function:
Definition at line 98 of file TwoWireInterface.h.
|
inline |
Read bytes from the slave and store in buffer owned by TwoWire and send a STOP condition if sendStop
is true.
addr | I2C address |
quantity | number of bytes to read |
sendStop | whether the STOP condition should be sent at end |
Definition at line 113 of file TwoWireInterface.h.
|
inline |
Write data into the write buffer.
Definition at line 81 of file TwoWireInterface.h.