8static 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++)
virtual ErrorCode writev(uint8_t address, WriteBuffer *buffers, size_t cnt)
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.
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
bool write_bytes_16(uint8_t a_register, const uint16_t *data, uint8_t len)
ErrorCode write(const uint8_t *data, size_t len, bool stop=true)
writes an array of bytes to a device using an I2CBus
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
I2CBus * bus_
pointer to I2CBus instance
uint8_t address_
store the address of the device on the bus
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
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
bool read_bytes_16(uint8_t a_register, uint16_t *data, uint8_t len)
This class is used to create I2CRegister16 objects that act as proxies to read/write internal registe...
uint16_t register_
the internal 16 bits address of the register
I2CRegister16 & operator&=(uint8_t value)
overloads the compound &= operator.
I2CRegister16 & operator|=(uint8_t value)
overloads the compound |= operator.
I2CDevice * parent_
I2CDevice object pointer.
uint8_t get() const
returns the register value
I2CRegister16 & operator=(uint8_t value)
overloads the = operator.
This class is used to create I2CRegister objects that act as proxies to read/write internal registers...
I2CRegister & operator|=(uint8_t value)
overloads the compound |= operator.
uint8_t get() const
returns the register value
I2CRegister & operator&=(uint8_t value)
overloads the compound &= operator.
I2CDevice * parent_
I2CDevice object pointer.
uint8_t register_
the internal address of the register
I2CRegister & operator=(uint8_t value)
overloads the = operator.
uint16_t i2ctohs(uint16_t i2cshort)
ErrorCode
Error codes returned by I2CBus and I2CDevice methods.
@ ERROR_OK
No error found during execution of method.
uint16_t htoi2cs(uint16_t hostshort)
Providing packet encoding functions for exchanging data with a remote host.
constexpr14 T convert_big_endian(T val)
Convert a value between host byte order and big endian (most significant byte first) order.
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