#include <address.h>
Public Member Functions | |
Address (uint16_t address) | |
uint8_t | GetSevenBit () const |
uint16_t | GetTenBit () const |
uint16_t | GetAddress () const |
constexpr bool | IsTenBit () const |
Static Public Member Functions | |
template<uint16_t kAddress> | |
static constexpr Address | TenBit () |
static Address | TenBit (uint16_t address) |
template<uint8_t kAddress> | |
static constexpr Address | SevenBit () |
static Address | SevenBit (uint16_t address) |
Static Public Attributes | |
static constexpr uint8_t | kMaxSevenBitAddress = (1 << 7) - 1 |
static constexpr uint16_t | kMaxTenBitAddress = (1 << 10) - 1 |
Friends | |
bool | operator== (const Address &a1, const Address &a2) |
A helper class that represents I2C addresses.
An address instance remembers whether it was constructed as a seven-bit or ten-bit address. This attribute can be used by Initiators to determine the i2c addressing style to transmit.
Note: Per the above, a ten-bit constructed instance may still have an an address of seven or fewer bits.
|
explicit |
Creates a pw::i2c::Address
instance from a 7 or 10 bit address.
If the address argument is 7-bits or less, a 7-bit address is constructed equivalent to Address::SevenBit(address);
If the address argument is 8, 9 or 10 bits, a ten-bit address is constructed equivalent to Address::TenBit(address);
The type of address construced will affect how the i2c address is transmitted on the bus. You should always use 7-bit addresses unless you are certain you have a host and device that support 10-bit addresses.
[in] | address | An address no larger than 10-bits as an unsigned integer. This method does a runtime assertion to ensure that address is 10 bits or less. |
pw::i2c::Address
instance.
|
inline |
Gets the raw address that was provided when this Address was created.
Use IsTenBit() to know whether the address should be interpreted as a 7-bit or 10-bit address.
uint8_t pw::i2c::Address::GetSevenBit | ( | ) | const |
Gets the 7-bit address that was provided when this instance was created.
This method does a runtime assertion to ensure that the address was constructed in 7-bit mode.
|
inline |
Gets the 10-bit address that was provided when this instance was created.
|
inlineconstexpr |
Getter for whether this object represents a Ten bit address. Note: The address itself may still be fewer than 10 bits.
|
inlinestaticconstexpr |
Creates a pw::i2c::Address
instance for an address that's 7 bits or less.
This constant expression does a compile-time assertion to ensure that the provided address is 7 bits or less.
pw::i2c::Address
instance.
|
inlinestatic |
Creates a pw::i2c::Address
instance for an address that's 7 bits or less.
This constructor does a run-time check to ensure that the provided address is 7 bits or less.
pw::i2c::Address
instance.
|
inlinestaticconstexpr |
Creates a pw::i2c::Address
instance for an address that's 10 bits or less.
This constant expression does a compile-time assertion to ensure that the provided address is 10 bits or less.
pw::i2c::Address
instance.
|
inlinestatic |
Creates a pw::i2c::Address
instance for an address that's 10 bits or less.
This constructor does a run-time check to ensure that the provided address is 10 bits or less.
pw::i2c::Address
instance.