Class Ina226
A Texas Instruments INA226 current, voltage, and power monitor. Every call goes straight to the pamoja C ABI, which decodes exactly what the manufacturer's datasheet specifies.
public static class Ina226
- Inheritance
-
Ina226
- Inherited Members
Methods
ActiveAlertFunction(PamojaIna226MaskEnable)
Returns the alert function an INA226 pin actually responds to.
public static PamojaIna226AlertFunction? ActiveAlertFunction(PamojaIna226MaskEnable mask)
Parameters
maskPamojaIna226MaskEnableThe mask.
Returns
- PamojaIna226AlertFunction?
The value, or null where the part defines none.
Address(byte, byte)
Returns the I2C address an INA226's A1 and A0 pin codes select.
public static byte Address(byte a1, byte a0)
Parameters
Returns
- byte
The decoded value.
Exceptions
- PamojaException
The device data is not valid.
AveragingSamples(byte)
Returns how many samples an INA226 averaging code folds into one result.
public static ushort AveragingSamples(byte code)
Parameters
codebyteThe code.
Returns
- ushort
The value the C ABI computes.
BusMicrovolts(ushort)
Converts a raw INA226 bus-voltage register to microvolts.
public static uint BusMicrovolts(ushort raw)
Parameters
rawushortThe raw.
Returns
- uint
The value the C ABI computes.
BusRegister(uint)
Builds the INA226 bus-voltage register a monitor reports for a bus voltage.
public static ushort BusRegister(uint microvolts)
Parameters
microvoltsuintThe microvolts.
Returns
- ushort
The value the C ABI computes.
BusVolts(ushort)
Converts a raw INA226 bus-voltage register to volts.
public static float BusVolts(ushort raw)
Parameters
rawushortThe raw.
Returns
- float
The value the C ABI computes.
Calibration(uint, uint)
Computes the INA226 calibration register for a shunt and current resolution.
public static ushort Calibration(uint currentLsbMicroamps, uint shuntMilliohms)
Parameters
Returns
- ushort
The value the C ABI computes.
ConfigFromRegister(ushort)
Parses an INA226 configuration register value.
public static PamojaIna226Config ConfigFromRegister(ushort raw)
Parameters
rawushortThe raw.
Returns
- PamojaIna226Config
The decoded value.
Exceptions
- PamojaException
The device data is not valid.
ConfigToRegister(PamojaIna226Config)
Assembles an INA226 configuration register value.
public static ushort ConfigToRegister(PamojaIna226Config config)
Parameters
configPamojaIna226ConfigThe config.
Returns
- ushort
The value the C ABI computes.
ConversionMicros(byte)
Returns the conversion time an INA226 code selects.
public static uint ConversionMicros(byte code)
Parameters
codebyteThe code.
Returns
- uint
The value the C ABI computes.
CurrentAmps(short, uint)
Converts a raw INA226 current register to amps.
public static float CurrentAmps(short raw, uint currentLsbMicroamps)
Parameters
Returns
- float
The value the C ABI computes.
CurrentMicroamps(short, uint)
Converts a raw INA226 current register to microamps.
public static int CurrentMicroamps(short raw, uint currentLsbMicroamps)
Parameters
Returns
- int
The value the C ABI computes.
CurrentRegister(int, uint)
Builds the INA226 current register a monitor reports for a current.
public static short CurrentRegister(int microamps, uint currentLsbMicroamps)
Parameters
Returns
- short
The value the C ABI computes.
CurrentRegisterFromShunt(short, ushort)
Computes the INA226 current register the chip derives from a shunt reading.
public static short CurrentRegisterFromShunt(short shunt, ushort calibration)
Parameters
Returns
- short
The value the C ABI computes.
DieId(ushort)
Splits an INA226 die-ID register into its device and revision fields.
public static PamojaIna226DieId DieId(ushort raw)
Parameters
rawushortThe raw.
Returns
- PamojaIna226DieId
The decoded value.
Exceptions
- PamojaException
The device data is not valid.
Identify(ushort, ushort)
Checks that a pair of identification registers belongs to an INA226.
public static PamojaIna226DieId Identify(ushort manufacturerId, ushort dieId)
Parameters
Returns
- PamojaIna226DieId
The decoded value.
Exceptions
- PamojaException
The device data is not valid.
IsContinuous(byte)
Reports whether an INA226 mode code keeps converting after the first result.
public static bool IsContinuous(byte code)
Parameters
codebyteThe code.
Returns
- bool
The value the C ABI computes.
MaskEnableFromRegister(ushort)
Parses an INA226 Mask/Enable register value.
public static PamojaIna226MaskEnable MaskEnableFromRegister(ushort raw)
Parameters
rawushortThe raw.
Returns
- PamojaIna226MaskEnable
The decoded value.
Exceptions
- PamojaException
The device data is not valid.
MaskEnableToRegister(PamojaIna226MaskEnable)
Assembles an INA226 Mask/Enable register value.
public static ushort MaskEnableToRegister(PamojaIna226MaskEnable mask)
Parameters
maskPamojaIna226MaskEnableThe mask.
Returns
- ushort
The value the C ABI computes.
MeasuresBus(byte)
Reports whether an INA226 mode code converts the bus voltage.
public static bool MeasuresBus(byte code)
Parameters
codebyteThe code.
Returns
- bool
The value the C ABI computes.
MeasuresShunt(byte)
Reports whether an INA226 mode code converts the shunt voltage.
public static bool MeasuresShunt(byte code)
Parameters
codebyteThe code.
Returns
- bool
The value the C ABI computes.
MinimumCurrentLsbMicroamps(uint)
Returns the smallest current resolution that still covers an expected maximum.
public static uint MinimumCurrentLsbMicroamps(uint maxExpectedMicroamps)
Parameters
maxExpectedMicroampsuintThe max expected microamps.
Returns
- uint
The value the C ABI computes.
PowerMicrowatts(ushort, uint)
Converts a raw INA226 power register to microwatts.
public static uint PowerMicrowatts(ushort raw, uint currentLsbMicroamps)
Parameters
Returns
- uint
The value the C ABI computes.
PowerRegister(uint, uint)
Builds the INA226 power register a monitor reports for a power.
public static ushort PowerRegister(uint microwatts, uint currentLsbMicroamps)
Parameters
Returns
- ushort
The value the C ABI computes.
PowerRegisterFromCurrent(short, ushort)
Computes the INA226 power register the chip derives from a current reading.
public static ushort PowerRegisterFromCurrent(short current, ushort bus)
Parameters
Returns
- ushort
The value the C ABI computes.
PowerWatts(ushort, uint)
Converts a raw INA226 power register to watts.
public static float PowerWatts(ushort raw, uint currentLsbMicroamps)
Parameters
Returns
- float
The value the C ABI computes.
ShuntMillivolts(short)
Converts a raw INA226 shunt-voltage register to millivolts.
public static float ShuntMillivolts(short raw)
Parameters
rawshortThe raw.
Returns
- float
The value the C ABI computes.
ShuntNanovolts(short)
Converts a raw INA226 shunt-voltage register to nanovolts.
public static int ShuntNanovolts(short raw)
Parameters
rawshortThe raw.
Returns
- int
The value the C ABI computes.
ShuntRegister(int)
Builds the INA226 shunt-voltage register a monitor reports for a shunt voltage.
public static short ShuntRegister(int nanovolts)
Parameters
nanovoltsintThe nanovolts.
Returns
- short
The value the C ABI computes.
UpdateMicros(PamojaIna226Config)
Returns how often an INA226 in a configuration updates its results.
public static uint UpdateMicros(PamojaIna226Config config)
Parameters
configPamojaIna226ConfigThe config.
Returns
- uint
The value the C ABI computes.