|
SatCat5
|
Conversion function for I2C device addresses.
Natively, conventional I2C device addresses are 7-bits followed by the read/write flag. Two bytes are required for 10-bit address mode.
There are conflicting conventions for representing this in software. This wrapper allows unambiguous use of all common conventions:
#include <cfg_i2c.h>
Public Member Functions | |
| I2cAddr (const I2cAddr &t)=default | |
| I2cAddr & | operator= (const I2cAddr &t)=default |
| bool | is_10b () const |
| Is this a 10-bit address? | |
| bool | operator== (const I2cAddr &other) const |
| Comparison operators: | |
| bool | operator!= (const I2cAddr &other) const |
| Comparison operators: | |
Static Public Member Functions | |
| static constexpr I2cAddr | addr7 (u8 addr) |
Create I2C address from a 7-bit input (right-justified) Example: I2cAddr my_addr = I2cAddr::addr7(0x77); | |
| static constexpr I2cAddr | addr8 (u8 addr) |
Create I2C address from an 8-bit input (left-justified) Example: I2cAddr my_addr = I2cAddr::addr8(0xEE); | |
| static constexpr I2cAddr | addr10 (u16 addr) |
Create I2C address from a 10-bit input (right-justified) Example: I2cAddr my_addr = I2cAddr::addr10(0x377); | |
| static constexpr I2cAddr | native (u16 addr) |
| Create I2C address from its native internal representation. | |
Public Attributes | |
| const u16 | m_addr |
| Native internal address representation. | |
Private Member Functions | |
| constexpr | I2cAddr (u16 addr) |