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

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
 
TestatoWireInterfaceoperator= (const TestatoWireInterface &)=default
 

Detailed Description

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

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.

Template Parameters
T_WIREthe template parameter for the I2C class which will always be SoftwareWire

Definition at line 41 of file TestatoWireInterface.h.

Constructor & Destructor Documentation

◆ TestatoWireInterface()

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

Constructor.

Parameters
wireinstance of SoftwareWire

Definition at line 47 of file TestatoWireInterface.h.

Member Function Documentation

◆ begin()

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

Initial the interface.

Currently does nothing.

Definition at line 50 of file TestatoWireInterface.h.

◆ beginTransmission()

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

Returns
always returns 0 to indicate success because SoftwareWire does not have a TX buffer

Definition at line 65 of file TestatoWireInterface.h.

◆ end()

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

End the interface.

Currently does nothing.

Definition at line 53 of file TestatoWireInterface.h.

◆ endTransmission()

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

  • 0: success
  • 1: length too long for buffer
  • 2: address send, NACK received
  • 3: data send, NACK received
  • 4: other twi error (lost bus arbitration, bus error, ..)

Definition at line 95 of file TestatoWireInterface.h.

◆ requestFrom()

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

Returns
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.

◆ write()

template<typename T_WIRE >
uint8_t ace_wire::TestatoWireInterface< T_WIRE >::write ( uint8_t  data) const
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.

Returns
1 always to indicate success, since SoftwareWire::write() always returns 1

Definition at line 78 of file TestatoWireInterface.h.


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