ArduinoLibs
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | List of all members
SoftI2C Class Reference

Bit-banged implementation of an I2C master. More...

#include <SoftI2C.h>

Inheritance diagram for SoftI2C:
I2CMaster

Public Member Functions

 SoftI2C (uint8_t dataPin, uint8_t clockPin)
 Constructs a new software I2C master on dataPin and clockPin.
 
unsigned int maxTransferSize () const
 Returns the maximum number of bytes that can be read or written in a single request by this bus master.
 
void startWrite (unsigned int address)
 Starts a write operation by sending a start condition and the I2C control byte. More...
 
void write (uint8_t value)
 Writes a single byte value on the I2C bus. More...
 
bool endWrite ()
 Ends the current write operation. More...
 
bool startRead (unsigned int address, unsigned int count)
 Starts a read operation for count bytes by sending the start condition and the I2C control byte. More...
 
unsigned int available ()
 Returns the number of bytes that are still available for reading. More...
 
uint8_t read ()
 Reads a single byte from the I2C bus. More...
 

Detailed Description

Bit-banged implementation of an I2C master.

This class implements the I2C master protocol on any arbitrary pair of data and clock pins. It is not restricted to pre-defined pins as is the case for the standard Arduino two-wire interface.

This implementation only implements the master side of the protocol. It assumes that there is a single bus master, no arbitration, and no clock stretching.

See Also
I2CMaster

Definition at line 28 of file SoftI2C.h.

Member Function Documentation

unsigned int SoftI2C::available ( )
virtual

Returns the number of bytes that are still available for reading.

See Also
startRead(), read()

Implements I2CMaster.

Definition at line 155 of file SoftI2C.cpp.

bool SoftI2C::endWrite ( )
virtual

Ends the current write operation.

Returns true if the write operation was acknowledged; false otherwise.

See Also
startWrite(), write()

Implements I2CMaster.

Definition at line 129 of file SoftI2C.cpp.

uint8_t SoftI2C::read ( )
virtual

Reads a single byte from the I2C bus.

See Also
startRead(), available()

Implements I2CMaster.

Definition at line 160 of file SoftI2C.cpp.

bool SoftI2C::startRead ( unsigned int  address,
unsigned int  count 
)
virtual

Starts a read operation for count bytes by sending the start condition and the I2C control byte.

The address must be the 7-bit or 10-bit address of the I2C slave on the bus.

Returns true if the read request was acknowledged by the I2C slave or false otherwise. If true, this function should be followed by count calls to read() to fetch the bytes.

See Also
available(), read(), startWrite()

Implements I2CMaster.

Definition at line 135 of file SoftI2C.cpp.

void SoftI2C::startWrite ( unsigned int  address)
virtual

Starts a write operation by sending a start condition and the I2C control byte.

The address must be the 7-bit or 10-bit address of the I2C slave on the bus.

See Also
write(), endWrite(), startRead()

Reimplemented from I2CMaster.

Definition at line 104 of file SoftI2C.cpp.

void SoftI2C::write ( uint8_t  value)
virtual

Writes a single byte value on the I2C bus.

See Also
startWrite(), endWrite()

Implements I2CMaster.

Definition at line 118 of file SoftI2C.cpp.


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