AceWire  0.4.0
Unified interface for selecting different I2C implementations on Arduino platforms
Public Member Functions | List of all members
ace_wire::SeeedWireInterface< T_WIRE > Class Template Reference

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
 
SeeedWireInterfaceoperator= (const SeeedWireInterface &)=default
 

Detailed Description

template<typename T_WIRE>
class ace_wire::SeeedWireInterface< T_WIRE >

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.

Template Parameters
T_WIREunderlying class which will be SoftwareI2C

Definition at line 41 of file SeeedWireInterface.h.

Constructor & Destructor Documentation

◆ SeeedWireInterface()

template<typename T_WIRE >
ace_wire::SeeedWireInterface< T_WIRE >::SeeedWireInterface ( T_WIRE &  wire)
inlineexplicit

Constructor.

Parameters
wireinstance of SoftwareI2C

Definition at line 47 of file SeeedWireInterface.h.

Member Function Documentation

◆ begin()

template<typename T_WIRE >
void ace_wire::SeeedWireInterface< T_WIRE >::begin ( ) const
inline

Initial the interface.

Currently does nothing.

Definition at line 50 of file SeeedWireInterface.h.

◆ beginTransmission()

template<typename T_WIRE >
uint8_t ace_wire::SeeedWireInterface< T_WIRE >::beginTransmission ( uint8_t  addr) const
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.

Returns
returns 0 upon ACK from the device, 1 upon NACK from the device

Definition at line 68 of file SeeedWireInterface.h.

◆ end()

template<typename T_WIRE >
void ace_wire::SeeedWireInterface< T_WIRE >::end ( ) const
inline

End the interface.

Currently does nothing.

Definition at line 53 of file SeeedWireInterface.h.

◆ endTransmission()

template<typename T_WIRE >
uint8_t ace_wire::SeeedWireInterface< T_WIRE >::endTransmission ( bool  sendStop = true) const
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.

◆ read()

template<typename T_WIRE >
uint8_t ace_wire::SeeedWireInterface< T_WIRE >::read ( ) const
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.

◆ requestFrom()

template<typename T_WIRE >
uint8_t ace_wire::SeeedWireInterface< T_WIRE >::requestFrom ( uint8_t  addr,
uint8_t  quantity,
bool  sendStop = true 
) const
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.

Parameters
addrI2C address
quantitynumber of bytes to read
sendStopwhether to send a STOP condition after reading. This parameter is ignored by the SoftwareI2C class which always sends a STOP condition.
Returns
the value returned by the underlying SoftwareI2C::requestFrom() method, which is 0 for success if the device responded with an ACK, and 1 if the device sent a NACK

Definition at line 111 of file SeeedWireInterface.h.

◆ write()

template<typename T_WIRE >
uint8_t ace_wire::SeeedWireInterface< T_WIRE >::write ( uint8_t  data) const
inline

Write data immediately into the I2C bus with the Write bit set, since the SoftwareI2C library does not use a TX buffer.

Returns
the number of bytes written into buffer if the device responded with an ACK (will always be 1), or 0 if the device responded with a NACK

Definition at line 79 of file SeeedWireInterface.h.


The documentation for this class was generated from the following file: