TinyGPU
Loading...
Searching...
No Matches
Public Member Functions | List of all members
TwoWire Class Reference

#include <EmulationIDF.h>

Public Member Functions

 TwoWire ()=default
 
 TwoWire (i2c_port_t port)
 
bool begin (int sdaPin, int sclPin, uint32_t freqHz=100000)
 
void beginTransmission (uint8_t address)
 
void write (uint8_t value)
 
uint8_t endTransmission (bool sendStop=true)
 
size_t requestFrom (int address, int length)
 
int available () const
 
int read ()
 

Detailed Description

Legacy driver/i2c.h-backed stand-in for Arduino's TwoWire, covering exactly what this library's I2C touch drivers call: beginTransmission/ write/endTransmission/requestFrom/available/read. endTransmission(false) defers the actual bus write so a following requestFrom() can chain it into one repeated-start transaction (write register address, repeated start, read data) instead of two separate stop/start transactions - several of this library's touch controllers document that this matters for reliable register reads.

Constructor & Destructor Documentation

◆ TwoWire() [1/2]

TwoWire ( )
default

◆ TwoWire() [2/2]

TwoWire ( i2c_port_t  port)
inlineexplicit

Member Function Documentation

◆ available()

int available ( ) const
inline

Bytes still unread from the last requestFrom() - matches TwoWire::available().

◆ begin()

bool begin ( int  sdaPin,
int  sclPin,
uint32_t  freqHz = 100000 
)
inline

Initializes the I2C bus pins/speed. Matches arduino-esp32's TwoWire::begin(sda, scl, freq). Safe to call more than once.

◆ beginTransmission()

void beginTransmission ( uint8_t  address)
inline

Starts buffering a write to address - matches TwoWire::beginTransmission().

◆ endTransmission()

uint8_t endTransmission ( bool  sendStop = true)
inline

Sends the buffered write. sendStop = false defers the actual I2C transaction to the following requestFrom() call, so it becomes a single repeated-start write-then-read - see class comment. Returns 0 on success, matching Arduino's TwoWire::endTransmission() (which also uses 0 for success).

◆ read()

int read ( )
inline

Reads one byte from the last requestFrom(), or -1 if none remain - matches TwoWire::read().

◆ requestFrom()

size_t requestFrom ( int  address,
int  length 
)
inline

Reads up to length bytes from address into the internal receive buffer - matches TwoWire::requestFrom(). If a prior endTransmission(false) is pending, folds it into this call as one repeated-start write-then-read transaction; otherwise this is a plain read. Returns the number of bytes actually read (0 on error).

◆ write()

void write ( uint8_t  value)
inline

Buffers one byte for the next endTransmission() - matches TwoWire::write(uint8_t). Silently drops bytes past the small fixed buffer (this library's own drivers write at most a few register- address bytes per transaction).


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