ArduinoLibs
|
Bit-banged implementation of an I2C master. More...
#include <SoftI2C.h>
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... | |
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.
|
virtual |
Returns the number of bytes that are still available for reading.
Implements I2CMaster.
Definition at line 155 of file SoftI2C.cpp.
|
virtual |
Ends the current write operation.
Returns true if the write operation was acknowledged; false otherwise.
Implements I2CMaster.
Definition at line 129 of file SoftI2C.cpp.
|
virtual |
Reads a single byte from the I2C bus.
Implements I2CMaster.
Definition at line 160 of file SoftI2C.cpp.
|
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.
Implements I2CMaster.
Definition at line 135 of file SoftI2C.cpp.
|
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.
Reimplemented from I2CMaster.
Definition at line 104 of file SoftI2C.cpp.
|
virtual |
Writes a single byte value on the I2C bus.
Implements I2CMaster.
Definition at line 118 of file SoftI2C.cpp.