Class I2c
I2C addressing per the NXP I2C-bus specification (UM10204).
public static class I2c
- Inheritance
-
I2c
- Inherited Members
Remarks
The original 7-bit address shares its byte with the read/write bit, so it lands
on the wire as (address << 1) | r/w. The 10-bit extension spends the
reserved 11110xx prefix and takes two bytes.
Fields
ReservedBelow
The first 7-bit address above the reserved block at the bottom.
public const byte ReservedBelow = 8
Field Value
ReservedFrom
The lowest 7-bit address the specification keeps for itself.
public const byte ReservedFrom = 120
Field Value
Methods
AddressFrame(ushort, bool, bool)
Returns the address bytes a controller puts on the bus for a transfer.
public static byte[] AddressFrame(ushort address, bool read = false, bool tenBit = false)
Parameters
addressushortThe device address.
readboolWhether the transfer reads rather than writes.
tenBitboolWhether this is a 10-bit address.
Returns
- byte[]
One byte for a 7-bit address, two for a 10-bit one.
Exceptions
- PamojaException
The address is outside its width's range.
FrameLen(ushort, bool)
Returns how many bytes an address frame occupies.
public static int FrameLen(ushort address, bool tenBit = false)
Parameters
Returns
- int
1for a 7-bit address,2for a 10-bit one.
Exceptions
- PamojaException
The address is outside its width's range.
IsGeneralCall(ushort, bool)
Reports whether an address is the general call address 0x00.
public static bool IsGeneralCall(ushort address, bool tenBit = false)
Parameters
Returns
- bool
Whether this is the broadcast every device on the bus listens to.
Exceptions
- PamojaException
The address is outside its width's range.
IsReserved(ushort, bool)
Reports whether an address falls in a range the specification reserves.
public static bool IsReserved(ushort address, bool tenBit = false)
Parameters
addressushortThe device address.
tenBitboolWhether this is a 10-bit address, which is never reserved in this sense.
Returns
- bool
Whether the address is reserved.
Remarks
UM10204 reserves 0x00..=0x07 and 0x78..=0x7F, leaving
0x08..=0x77 for ordinary devices.
Exceptions
- PamojaException
The address is outside its width's range.