AceWire
0.4.1
Unified interface for selecting different I2C implementations on Arduino platforms
|
A thin wrapper around the SoftwareWire
class provided by the https://github.com/Testato/SoftwareWire project so that it becomes compatible with the AceWire interface.
More...
#include <TestatoWireInterface.h>
Public Member Functions | |
TestatoWireInterface (T_WIRE &wire) | |
Constructor. More... | |
void | begin () const |
Initial 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 to the I2C bus. More... | |
uint8_t | endTransmission (bool sendStop=true) const |
Send a STOP condition if sendStop is true, or a REPEATED_START condition if sendStop is false. More... | |
uint8_t | requestFrom (uint8_t addr, uint8_t quantity, bool sendStop=true) const |
Prepare to read bytes from the device at the given address, and send a STOP condition if sendStop is true. More... | |
uint8_t | read () const |
Read byte from buffer. | |
TestatoWireInterface (const TestatoWireInterface &)=default | |
TestatoWireInterface & | operator= (const TestatoWireInterface &)=default |
A thin wrapper around the SoftwareWire
class provided by the https://github.com/Testato/SoftwareWire project so that it becomes compatible with the AceWire interface.
T_WIRE | the template parameter for the I2C class which will always be SoftwareWire |
Definition at line 41 of file TestatoWireInterface.h.
|
inlineexplicit |
Constructor.
wire | instance of SoftwareWire |
Definition at line 47 of file TestatoWireInterface.h.
|
inline |
Initial the interface.
Currently does nothing.
Definition at line 50 of file TestatoWireInterface.h.
|
inline |
Prepare the write buffer to accept a sequence of data, and save the addr for transmission when endTransmission()
is called.
SoftwareWire uses no TX buffer, so this method should return the ACK/NACK response from the device, but it actually returns void, so the only thing we can do is always return a 0 to indicate success.
Definition at line 65 of file TestatoWireInterface.h.
|
inline |
|
inline |
Send a STOP condition if sendStop
is true, or a REPEATED_START condition if sendStop
is false.
Returns a status value to indicate the success or failure of the previous write() statements.
Definition at line 95 of file TestatoWireInterface.h.
|
inline |
Prepare to read bytes from the device at the given address, and send a STOP condition if sendStop
is true.
The underlying SoftwareWire does not use a TX buffer, so the addr is immediately placed on the I2C bus.
quantity
if the device responded with an ACK, or 0 if the device responded with a NACK. Definition at line 108 of file TestatoWireInterface.h.
|
inline |
Write data to the I2C bus.
SoftwareWire uses no TX buffer, so this is written directly to the bus. SoftwareWire::write() returns a size_t
, which is converted to a uint8_t
for compatibility with AceWire.
Definition at line 78 of file TestatoWireInterface.h.