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

A thin wrapper around the SlowSoftWire class provided by the https://github.com/felias-fogg/SlowSoftWire project so that it becomes compatible with the AceWire API. More...

#include <FeliasFoggWireInterface.h>

Public Member Functions

 FeliasFoggWireInterface (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 into the write buffer. More...
 
uint8_t endTransmission (bool sendStop=true) const
 Send the data in the buffer, and return the following status code: 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 SoftWire. More...
 
uint8_t read () const
 Read byte from buffer.
 
 FeliasFoggWireInterface (const FeliasFoggWireInterface &)=default
 
FeliasFoggWireInterfaceoperator= (const FeliasFoggWireInterface &)=default
 

Detailed Description

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

A thin wrapper around the SlowSoftWire class provided by the https://github.com/felias-fogg/SlowSoftWire project so that it becomes compatible with the AceWire API.

The SlowSoftWire class uses a 32-byte RX buffer and a 32-byte TX buffer.

Template Parameters
T_WIREunderlying I2C class which will always be SlowSoftWire

Definition at line 41 of file FeliasFoggWireInterface.h.

Constructor & Destructor Documentation

◆ FeliasFoggWireInterface()

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

Constructor.

Parameters
wireinstance of SlowSoftWire

Definition at line 47 of file FeliasFoggWireInterface.h.

Member Function Documentation

◆ begin()

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

Initial the interface.

Currently does nothing.

Definition at line 50 of file FeliasFoggWireInterface.h.

◆ beginTransmission()

template<typename T_WIRE >
uint8_t ace_wire::FeliasFoggWireInterface< 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.

Returns
always returns 0 to indicate success because the addr is simply written into a buffer

Definition at line 62 of file FeliasFoggWireInterface.h.

◆ end()

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

End the interface.

Currently does nothing.

Definition at line 53 of file FeliasFoggWireInterface.h.

◆ endTransmission()

template<typename T_WIRE >
uint8_t ace_wire::FeliasFoggWireInterface< T_WIRE >::endTransmission ( bool  sendStop = true) const
inline

Send the data in the buffer, and return the following status code:

  • 0: success
  • 1: length too long for buffer (not used by SlowSoftWire)
  • 2: address send, NACK received
  • 3: data send, NACK received
  • 4: other twi error (lost bus arbitration, bus error, ..) (not used by SlowSoftWire)
Parameters
sendStopcontrols whether or not a STOP condition is sent at the end of the buffer

Definition at line 89 of file FeliasFoggWireInterface.h.

◆ requestFrom()

template<typename T_WIRE >
uint8_t ace_wire::FeliasFoggWireInterface< T_WIRE >::requestFrom ( uint8_t  addr,
uint8_t  quantity,
bool  sendStop = true 
) const
inline

Read bytes from the slave and store in buffer owned by SoftWire.

Parameters
addrI2C address
quantitynumber of bytes to read from I2C bus
sendStopcontrols whether the STOP condition should be sent
Returns
the value returned by the underlying SoftWire::requestFrom() method, which will normally be 'quantity'.

Definition at line 103 of file FeliasFoggWireInterface.h.

◆ write()

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

Write data into the write buffer.

Returns
the number of bytes written into buffer, which will always be 1

Definition at line 72 of file FeliasFoggWireInterface.h.


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