ESPHome
2024.11.0
|
This class is used to create I2CRegister objects that act as proxies to read/write internal registers on an I2C device. More...
#include <i2c.h>
Public Member Functions | |
I2CRegister & | operator= (uint8_t value) |
overloads the = operator. More... | |
I2CRegister & | operator &= (uint8_t value) |
overloads the compound &= operator. More... | |
I2CRegister & | operator|= (uint8_t value) |
overloads the compound |= operator. More... | |
operator uint8_t () const | |
overloads the uint8_t() cast operator to return the I²C register value More... | |
uint8_t | get () const |
returns the register value More... | |
Protected Member Functions | |
I2CRegister (I2CDevice *parent, uint8_t a_register) | |
protected constructor that stores the owning object and the register address. More... | |
Protected Attributes | |
I2CDevice * | parent_ |
I2CDevice object pointer. More... | |
uint8_t | register_ |
the internal address of the register More... | |
This class is used to create I2CRegister objects that act as proxies to read/write internal registers on an I2C device.
typical usage:
The I²C protocol specifies how to read/write in sets of 8-bits followed by an Acknowledgement (ACK/NACK) from the device receiving the data. How the device interprets the bits read/written can vary greatly from device to device. However most of the devices follow the same protocol for reading/writing 8 bit registers using as implemented in the I2CRegister: after sending the device address, the controller sends one byte with the internal register address and then read or write the specified register content.
|
inlineprotected |
protected constructor that stores the owning object and the register address.
Note as only friends can create an I2CRegister
parent | our parent |
a_register | address of the i2c register |
uint8_t esphome::i2c::I2CRegister::get | ( | ) | const |
I2CRegister& esphome::i2c::I2CRegister::operator&= | ( | uint8_t | value | ) |
overloads the compound &= operator.
This allows to reset specific bits of an I²C register
value | used for the & operation |
|
inlineexplicit |
I2CRegister & esphome::i2c::I2CRegister::operator= | ( | uint8_t | value | ) |
I2CRegister & esphome::i2c::I2CRegister::operator|= | ( | uint8_t | value | ) |
|
protected |
|
protected |