AceWire
0.4.0
Unified interface for selecting different I2C implementations on Arduino platforms
|
A thin wrapper for the SoftwareI2C class from the https://github.com/Seeed-Studio/Arduino_Software_I2C project so that it becomes compatible with the AceWire API. More...
#include <SeeedWireInterface.h>
Public Member Functions | |
SeeedWireInterface (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 |
Send the I2C address on the bus immediately since the underlying SoftwareI2C class does not use a TX buffer. More... | |
uint8_t | write (uint8_t data) const |
Write data immediately into the I2C bus with the Write bit set, since the SoftwareI2C library does not use a TX buffer. More... | |
uint8_t | endTransmission (bool sendStop=true) const |
Send the data in the buffer. More... | |
uint8_t | requestFrom (uint8_t addr, uint8_t quantity, bool sendStop=true) const |
Prepare to send quantity bytes to the device at addr. More... | |
uint8_t | read () const |
Read byte from the I2C bus. More... | |
SeeedWireInterface (const SeeedWireInterface &)=default | |
SeeedWireInterface & | operator= (const SeeedWireInterface &)=default |
A thin wrapper for the SoftwareI2C class from the https://github.com/Seeed-Studio/Arduino_Software_I2C project so that it becomes compatible with the AceWire API.
The Arduino_Software_I2C library uses no RX or TX buffer.
T_WIRE | underlying class which will be SoftwareI2C |
Definition at line 41 of file SeeedWireInterface.h.
|
inlineexplicit |
Constructor.
wire | instance of SoftwareI2C |
Definition at line 47 of file SeeedWireInterface.h.
|
inline |
|
inline |
Send the I2C address on the bus immediately since the underlying SoftwareI2C class does not use a TX buffer.
The underlying SoftwareI2C::beginTransmission() method returns a 0 if the device responded with a NACK, and a 1 if ACK. This is opposite of the convention used by the endTransmission() function. The AceWire library defines the return value of beginTransmission() to use the same return value convention as endTransmission(). So we have to flip the return status from the Seeed library.
Definition at line 68 of file SeeedWireInterface.h.
|
inline |
|
inline |
Send the data in the buffer.
The sendStop parameter is ignored by the SoftwareI2C implementation and the underlying implementation always sends the STOP condition.
Returns the value returned by the underlying SoftwareI2C::endTransmission() method, which always returns 0 to indicate success.
Definition at line 92 of file SeeedWireInterface.h.
|
inline |
Read byte from the I2C bus.
Automatically sends a STOP condition after reading quantity bytes as specified by requestFrom(). The sendStop
parameter is ignored.
Definition at line 122 of file SeeedWireInterface.h.
|
inline |
Prepare to send quantity bytes to the device at addr.
SoftwareI2C does not implement at TX buffer, so the addr is sent immediately on the bus.
addr | I2C address |
quantity | number of bytes to read |
sendStop | whether to send a STOP condition after reading. This parameter is ignored by the SoftwareI2C class which always sends a STOP condition. |
Definition at line 111 of file SeeedWireInterface.h.
|
inline |
Write data immediately into the I2C bus with the Write bit set, since the SoftwareI2C library does not use a TX buffer.
Definition at line 79 of file SeeedWireInterface.h.