Skip to main content

address

Function address 

Source
pub fn address(a1: AddressPin, a0: AddressPin) -> u8
Expand description

Returns the 7-bit I2C address the A1 and A0 pins select.

This is Table 1 of the datasheet: the address is 1 0 0 A1 A0, each pin contributing two bits in the order GND, VS+, SDA, SCL, which gives the sixteen addresses 0x40 through 0x4F. Several monitors share a bus by tying their pins differently.

§Arguments

  • a1 - what the A1 pin is tied to.
  • a0 - what the A0 pin is tied to.

§Returns

The 7-bit target address, before the read/write bit is appended.

§Examples

use pamoja_sensors::ina219::{address, AddressPin};

// A1 to ground and A0 to VS+: the first address above the base.
assert_eq!(address(AddressPin::Ground, AddressPin::Supply), 0x41);