8 static const char *
const TAG =
"i2c";
19 ErrorCode const err = this->
write(reinterpret_cast<const uint8_t *>(&a_register), 2, stop);
27 buffers[0].
data = &a_register;
29 buffers[1].
data = data;
37 buffers[0].
data =
reinterpret_cast<const uint8_t *
>(&a_register);
39 buffers[1].
data = data;
47 for (
size_t i = 0; i <
len; i++)
54 std::unique_ptr<uint16_t[]> temp{
new uint16_t[
len]};
55 for (
size_t i = 0; i <
len; i++)
61 this->parent_->write_register(this->register_, &value, 1);
66 this->parent_->write_register(this->register_, &value, 1);
71 this->parent_->write_register(this->register_, &value, 1);
77 this->parent_->read_register(this->register_, &value, 1);
82 this->parent_->write_register16(this->register_, &value, 1);
87 this->parent_->write_register16(this->register_, &value, 1);
92 this->parent_->write_register16(this->register_, &value, 1);
98 this->parent_->read_register16(this->register_, &value, 1);
the WriteBuffer structure stores a pointer to a write buffer and its length
uint16_t i2ctohs(uint16_t i2cshort)
ErrorCode read_register(uint8_t a_register, uint8_t *data, size_t len, bool stop=true)
reads an array of bytes from a specific register in the I²C device
uint8_t get() const
returns the register value
ErrorCode write(const uint8_t *data, size_t len, bool stop=true)
writes an array of bytes to a device using an I2CBus
bool write_bytes_16(uint8_t a_register, const uint16_t *data, uint8_t len)
uint16_t htoi2cs(uint16_t hostshort)
I2CRegister & operator|=(uint8_t value)
overloads the compound |= operator.
virtual ErrorCode writev(uint8_t address, WriteBuffer *buffers, size_t cnt)
No error found during execution of method.
constexpr14 T convert_big_endian(T val)
Convert a value between host byte order and big endian (most significant byte first) order...
size_t len
length of the buffer
ErrorCode write_register16(uint16_t a_register, const uint8_t *data, size_t len, bool stop=true)
write an array of bytes to a specific register in the I²C device
uint8_t address_
store the address of the device on the bus
I2CBus * bus_
pointer to I2CBus instance
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...
This class is used to create I2CRegister objects that act as proxies to read/write internal registers...
I2CRegister16 & operator=(uint8_t value)
overloads the = operator.
I2CRegister16 & operator &=(uint8_t value)
overloads the compound &= operator.
const uint8_t * data
pointer to the write buffer
I2CRegister16 & operator|=(uint8_t value)
overloads the compound |= operator.
Implementation of SPI Controller mode.
This class is used to create I2CRegister16 objects that act as proxies to read/write internal registe...
ErrorCode write_register(uint8_t a_register, const uint8_t *data, size_t len, bool stop=true)
writes an array of bytes to a specific register in the I²C device
I2CRegister & operator &=(uint8_t value)
overloads the compound &= operator.
uint8_t get() const
returns the register value
ErrorCode read_register16(uint16_t a_register, uint8_t *data, size_t len, bool stop=true)
reads an array of bytes from a specific register in the I²C device
I2CRegister & operator=(uint8_t value)
overloads the = operator.
ErrorCode
Error codes returned by I2CBus and I2CDevice methods.
bool read_bytes_16(uint8_t a_register, uint16_t *data, uint8_t len)