This Class provides the methods to read and write bytes from an I2CBus.
bool scan_
Should we scan ? Can be set in the yaml.
virtual ErrorCode readv(uint8_t address, ReadBuffer *buffers, size_t count)=0
This virtual method reads bytes from an I2CBus into an array of ReadBuffer.
std::vector< std::pair< uint8_t, bool > > scan_results_
array containing scan results
virtual ErrorCode writev(uint8_t address, WriteBuffer *buffers, size_t cnt)
virtual ErrorCode writev(uint8_t address, WriteBuffer *buffers, size_t count, bool stop)=0
This virtual method writes bytes to an I2CBus from an array of WriteBuffer.
virtual ErrorCode read(uint8_t address, uint8_t *buffer, size_t len)
Creates a ReadBuffer and calls the virtual readv() method to read bytes into this buffer.
virtual ErrorCode write(uint8_t address, const uint8_t *buffer, size_t len)
void i2c_scan_()
Scans the I2C bus for devices.
virtual ErrorCode write(uint8_t address, const uint8_t *buffer, size_t len, bool stop)
Creates a WriteBuffer and calls the writev() method to send the bytes from this buffer.
ErrorCode
Error codes returned by I2CBus and I2CDevice methods.
@ ERROR_CRC
bytes received with a CRC error
@ ERROR_OK
No error found during execution of method.
@ ERROR_TOO_LARGE
requested a transfer larger than buffers can hold
@ ERROR_INVALID_ARGUMENT
method called invalid argument(s)
@ NO_ERROR
No error found during execution of method.
@ ERROR_TIMEOUT
timeout while waiting to receive bytes
@ ERROR_NOT_ACKNOWLEDGED
I2C bus acknowledgment not received.
@ ERROR_NOT_INITIALIZED
call method to a not initialized bus
@ ERROR_UNKNOWN
miscellaneous I2C error during execution
Providing packet encoding functions for exchanging data with a remote host.
the ReadBuffer structure stores a pointer to a read buffer and its length
size_t len
length of the buffer
uint8_t * data
pointer to the read buffer
the WriteBuffer structure stores a pointer to a write buffer and its length
size_t len
length of the buffer
const uint8_t * data
pointer to the write buffer