C/C++ API Reference
Loading...
Searching...
No Matches
pw::i2c::Address Class Reference

Overview

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.

#include "pw_i2c/address.h"
constexpr pw::i2c::Address kAddress1 = pw::i2c::Address::SevenBit<0x42>();
uint8_t raw_address_1 = kAddress1.GetSevenBit();
const pw::i2c::Address kAddress2<0x200>(); // 10-bit
uint16_t raw_address_2 = kAddress2.GetAddress();
// Note: kAddress2.GetSevenBit() would fail an assertion here.
Definition: address.h:42
uint8_t GetSevenBit() const

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)
 

The documentation for this class was generated from the following file: