This Class provides the methods to read and write bytes from an I2CBus.
More...
#include <i2c_bus.h>
|
| virtual | ~I2CBus ()=default |
| |
| virtual ErrorCode | write_readv (uint8_t address, const uint8_t *write_buffer, size_t write_count, uint8_t *read_buffer, size_t read_count)=0 |
| | This virtual method writes bytes to an I2CBus from an array, then reads bytes into an array of ReadBuffer.
|
| |
| ErrorCode | read (uint8_t address, uint8_t *buffer, size_t len) |
| |
| ErrorCode | write (uint8_t address, const uint8_t *buffer, size_t len, bool stop=true) |
| |
|
| void | i2c_scan_ () |
| | Scans the I2C bus for devices.
|
| |
|
| std::vector< std::pair< uint8_t, bool > > | scan_results_ |
| | array containing scan results
|
| |
| bool | scan_ {false} |
| | Should we scan ? Can be set in the yaml.
|
| |
This Class provides the methods to read and write bytes from an I2CBus.
- Note
- The I2CBus virtual class follows a Factory design pattern that provides all the interfaces methods required by clients while deferring the actual implementation of these methods to a subclasses. I2C-bus specification and user manual can be found here https://www.nxp.com/docs/en/user-guide/UM10204.pdf and an interesting I²C Application note https://www.nxp.com/docs/en/application-note/AN10216.pdf
Definition at line 29 of file i2c_bus.h.
◆ ~I2CBus()
| virtual esphome::i2c::I2CBus::~I2CBus |
( |
| ) |
|
|
virtualdefault |
◆ i2c_scan_()
| void esphome::i2c::I2CBus::i2c_scan_ |
( |
| ) |
|
|
protected |
Scans the I2C bus for devices.
Devices presence is kept in an array of std::pair that contains the address and the corresponding bool presence flag.
Definition at line 12 of file i2c.cpp.
◆ read()
| ErrorCode esphome::i2c::I2CBus::read |
( |
uint8_t | address, |
|
|
uint8_t * | buffer, |
|
|
size_t | len ) |
|
inline |
◆ write()
| ErrorCode esphome::i2c::I2CBus::write |
( |
uint8_t | address, |
|
|
const uint8_t * | buffer, |
|
|
size_t | len, |
|
|
bool | stop = true ) |
|
inline |
◆ write_readv()
| virtual ErrorCode esphome::i2c::I2CBus::write_readv |
( |
uint8_t | address, |
|
|
const uint8_t * | write_buffer, |
|
|
size_t | write_count, |
|
|
uint8_t * | read_buffer, |
|
|
size_t | read_count ) |
|
pure virtual |
◆ scan_
| bool esphome::i2c::I2CBus::scan_ {false} |
|
protected |
Should we scan ? Can be set in the yaml.
Definition at line 61 of file i2c_bus.h.
◆ scan_results_
| std::vector<std::pair<uint8_t, bool> > esphome::i2c::I2CBus::scan_results_ |
|
protected |
array containing scan results
Definition at line 60 of file i2c_bus.h.
The documentation for this class was generated from the following files: