![]() |
SparkFun INA2XX Arduino Library
v1.0.0-3-gc9007d6
Arduino Library for the SparkFun Qwiic Power Monitor (INA228 / INA237)
|
Platform-independent base driver for the INA228/INA237 power monitor ICs. More...
#include <sfDevINA2XX.h>
Public Member Functions | |
| sfDevINA2XX () | |
| sfTkError_t | begin (sfTkIBus *theBus=nullptr) |
| Initialize the device driver with the given bus. More... | |
| void | setCommunicationBus (sfTkIBus *theBus) |
| Set the communication bus pointer. More... | |
| sfTkError_t | getManufacturerID (uint16_t &id) |
| Read the Manufacturer ID register (0x3E). More... | |
| sfTkError_t | getDeviceID (uint16_t &id) |
| Read the Device ID register (0x3F). More... | |
| sfTkError_t | reset (void) |
| Perform a full system reset via the RST bit in CONFIG. More... | |
| sfTkError_t | resetAccumulators (void) |
| Reset the energy and charge accumulators (INA228 RSTACC bit). More... | |
| sfTkError_t | setADCRange (bool reducedRange) |
| Set the ADC full-scale shunt range. More... | |
| sfTkError_t | getADCRange (bool &reducedRange) |
| Get the current ADC range setting. More... | |
| sfTkError_t | setConversionDelay (uint8_t delay2ms) |
| Set the initial conversion delay in 2ms steps. More... | |
| sfTkError_t | getConversionDelay (uint8_t &delay2ms) |
| Get the current conversion delay setting. More... | |
| sfTkError_t | enableTempCompensation (bool enable) |
| Enable or disable shunt temperature compensation. More... | |
| sfTkError_t | getTempCompensation (bool &enabled) |
| Get the temperature compensation enable state. More... | |
| sfTkError_t | setADCMode (sfe_ina2xx_mode_t mode) |
| Set the ADC operating mode. More... | |
| sfTkError_t | getADCMode (sfe_ina2xx_mode_t &mode) |
| Get the current ADC operating mode. More... | |
| sfTkError_t | setBusVoltageConvTime (sfe_ina2xx_conv_time_t time) |
| Set the bus voltage conversion time. More... | |
| sfTkError_t | getBusVoltageConvTime (sfe_ina2xx_conv_time_t &time) |
| Get the bus voltage conversion time. More... | |
| sfTkError_t | setShuntVoltageConvTime (sfe_ina2xx_conv_time_t time) |
| Set the shunt voltage conversion time. More... | |
| sfTkError_t | getShuntVoltageConvTime (sfe_ina2xx_conv_time_t &time) |
| Get the shunt voltage conversion time. More... | |
| sfTkError_t | setTempConvTime (sfe_ina2xx_conv_time_t time) |
| Set the temperature conversion time. More... | |
| sfTkError_t | getTempConvTime (sfe_ina2xx_conv_time_t &time) |
| Get the temperature conversion time. More... | |
| sfTkError_t | setAveragingCount (sfe_ina2xx_avg_count_t count) |
| Set the ADC averaging count. More... | |
| sfTkError_t | getAveragingCount (sfe_ina2xx_avg_count_t &count) |
| Get the current ADC averaging count. More... | |
| sfTkError_t | setShuntCal (uint16_t calValue) |
| Write a raw value to the SHUNT_CAL register. More... | |
| sfTkError_t | getShuntCal (uint16_t &calValue) |
| Read the current SHUNT_CAL register value. More... | |
| sfTkError_t | setShuntTempCoefficient (uint16_t ppmPerDegC) |
| Set the shunt temperature coefficient for temperature compensation. More... | |
| sfTkError_t | getShuntTempCoefficient (uint16_t &ppmPerDegC) |
| Get the shunt temperature coefficient. More... | |
| sfTkError_t | getDiagnosticFlags (sfe_ina2xx_diag_alrt_reg_t &flags) |
| Read the full DIAG_ALRT register. More... | |
| sfTkError_t | setAlertLatch (bool latched) |
| Enable or disable alert latching. More... | |
| sfTkError_t | getAlertLatch (bool &latched) |
| Get the alert latch setting. More... | |
| sfTkError_t | setConversionReadyAlert (bool enable) |
| Enable conversion ready flag on the ALERT pin. More... | |
| sfTkError_t | getConversionReadyAlert (bool &enabled) |
| Get the conversion ready alert enable state. More... | |
| sfTkError_t | setSlowAlert (bool enable) |
| Enable alert comparison on averaged (vs. More... | |
| sfTkError_t | getSlowAlert (bool &enabled) |
| Get the slow alert enable state. More... | |
| sfTkError_t | setAlertPolarity (bool activeHigh) |
| Set the ALERT pin polarity. More... | |
| sfTkError_t | getAlertPolarity (bool &activeHigh) |
| Get the ALERT pin polarity setting. More... | |
| sfTkError_t | isEnergyOverflow (bool &overflow) |
| Check if the energy register has overflowed (INA228 only). More... | |
| sfTkError_t | isChargeOverflow (bool &overflow) |
| Check if the charge register has overflowed (INA228 only). More... | |
| sfTkError_t | isMathOverflow (bool &overflow) |
| Check if a math overflow has occurred in current/power calculations. More... | |
| sfTkError_t | isTempOverLimit (bool &overLimit) |
| Check if the temperature over-limit flag is set. More... | |
| sfTkError_t | isShuntOverVoltage (bool &overVoltage) |
| Check if the shunt overvoltage flag is set. More... | |
| sfTkError_t | isShuntUnderVoltage (bool &underVoltage) |
| Check if the shunt undervoltage flag is set. More... | |
| sfTkError_t | isBusOverVoltage (bool &overVoltage) |
| Check if the bus overvoltage flag is set. More... | |
| sfTkError_t | isBusUnderVoltage (bool &underVoltage) |
| Check if the bus undervoltage flag is set. More... | |
| sfTkError_t | isPowerOverLimit (bool &overLimit) |
| Check if the power over-limit flag is set. More... | |
| sfTkError_t | isConversionReady (bool &ready) |
| Check if a conversion has completed. More... | |
| sfTkError_t | isMemoryValid (bool &valid) |
| Check the memory checksum status. More... | |
| sfTkError_t | setShuntOverVoltageThreshold (int16_t threshold) |
| Set the shunt overvoltage threshold. More... | |
| sfTkError_t | getShuntOverVoltageThreshold (int16_t &threshold) |
| Get the shunt overvoltage threshold. More... | |
| sfTkError_t | setShuntUnderVoltageThreshold (int16_t threshold) |
| Set the shunt undervoltage threshold. More... | |
| sfTkError_t | getShuntUnderVoltageThreshold (int16_t &threshold) |
| Get the shunt undervoltage threshold. More... | |
| sfTkError_t | setBusOverVoltageThreshold (uint16_t threshold) |
| Set the bus overvoltage threshold. More... | |
| sfTkError_t | getBusOverVoltageThreshold (uint16_t &threshold) |
| Get the bus overvoltage threshold. More... | |
| sfTkError_t | setBusUnderVoltageThreshold (uint16_t threshold) |
| Set the bus undervoltage threshold. More... | |
| sfTkError_t | getBusUnderVoltageThreshold (uint16_t &threshold) |
| Get the bus undervoltage threshold. More... | |
| sfTkError_t | setTempLimitThreshold (int16_t threshold) |
| Set the temperature over-limit threshold. More... | |
| sfTkError_t | getTempLimitThreshold (int16_t &threshold) |
| Get the temperature over-limit threshold. More... | |
| sfTkError_t | setPowerLimitThreshold (uint16_t threshold) |
| Set the power over-limit threshold. More... | |
| sfTkError_t | getPowerLimitThreshold (uint16_t &threshold) |
| Get the power over-limit threshold. More... | |
Protected Member Functions | |
| sfTkError_t | readRegister24 (uint8_t reg, uint32_t &value) |
| Read 3 bytes (24-bit) from a register into a uint32_t. More... | |
| sfTkError_t | readRegister40 (uint8_t reg, uint64_t &value) |
| Read 5 bytes (40-bit) from a register into a uint64_t. More... | |
| sfTkError_t | calibrateImpl (float shuntResOhms, float maxCurrentA, float calScale, float currentFullScale) |
| Shared calibration math; only the two scale constants differ per device. More... | |
| sfTkError_t | powerToWatts (float &watts, float powerLSBScale) |
Shared POWER -> watts conversion. powerLSBScale is 3.2 (INA228) or 0.2 (INA237). More... | |
| sfTkError_t | dieTemperatureToCelsius (float &celsius, uint8_t shift, float tempLSB) |
| Shared DIETEMP -> Celsius conversion. More... | |
| sfTkError_t | readPowerRaw (uint32_t &value) |
| Shared raw POWER read (24-bit, unsigned) — identical on both devices. More... | |
| template<typename T , bool Wide> | |
| sfTkError_t | readSignedMeasurementRaw (uint8_t reg, T &value) |
| Shared raw read for a signed measurement register (shunt voltage, current). More... | |
| template<typename T , bool Wide> | |
| sfTkError_t | readUnsignedMeasurementRaw (uint8_t reg, T &value) |
| Shared raw read for an unsigned measurement register (bus voltage). More... | |
| template<typename T , bool Wide> | |
| sfTkError_t | shuntVoltageToMilliVolts (float &milliVolts, float lsbDefault, float lsbReduced) |
| Shared VSHUNT -> millivolts conversion (reads raw, then scales by the range LSB). More... | |
| template<typename T , bool Wide> | |
| sfTkError_t | busVoltageToVolts (float &volts, float busLSB) |
| Shared VBUS -> volts conversion. More... | |
| template<typename T , bool Wide> | |
| sfTkError_t | currentToAmps (float &s) |
| Shared CURRENT -> amps conversion (scales by the calibrated CURRENT_LSB). More... | |
Protected Attributes | |
| sfTkIBus * | _theBus |
| Pointer to the communication bus device. More... | |
| float | _currentLSB |
| Current measurement LSB in Amps, set during calibration. More... | |
| bool | _adcRange |
| Cached ADC range: false = +/-163.84mV, true = +/-40.96mV. More... | |
| float | _shuntRes |
| Shunt resistance in Ohms, stored during calibration. More... | |
Static Protected Attributes | |
| static const uint8_t | kI2CAddress = 0x40 |
| Default 7-bit I2C address for the SparkFun Qwiic Power Monitor board. More... | |
| static const uint8_t | kRegConfig = 0x00 |
| Configuration register (16-bit, R/W) More... | |
| static const uint8_t | kRegAdcConfig = 0x01 |
| ADC Configuration register (16-bit, R/W) More... | |
| static const uint8_t | kRegShuntCal = 0x02 |
| Shunt Calibration register (16-bit, R/W) More... | |
| static const uint8_t | kRegShuntTempCo = 0x03 |
| Shunt Temperature Coefficient (16-bit, R/W) More... | |
| static const uint8_t | kRegVShunt = 0x04 |
| Shunt Voltage Measurement (24/16-bit, R) More... | |
| static const uint8_t | kRegVBus = 0x05 |
| Bus Voltage Measurement (24/16-bit, R) More... | |
| static const uint8_t | kRegDieTemp = 0x06 |
| Die Temperature Measurement (16-bit, R) More... | |
| static const uint8_t | kRegCurrent = 0x07 |
| Current Result (24/16-bit, R) More... | |
| static const uint8_t | kRegPower = 0x08 |
| Power Result (24-bit, R) More... | |
| static const uint8_t | kRegEnergy = 0x09 |
| Energy Result (40-bit, R) – INA228 only. More... | |
| static const uint8_t | kRegCharge = 0x0A |
| Charge Result (40-bit, R) – INA228 only. More... | |
| static const uint8_t | kRegDiagAlrt = 0x0B |
| Diagnostic Flags and Alert (16-bit, R/W) More... | |
| static const uint8_t | kRegSOVL = 0x0C |
| Shunt Overvoltage Threshold (16-bit, R/W) More... | |
| static const uint8_t | kRegSUVL = 0x0D |
| Shunt Undervoltage Threshold (16-bit, R/W) More... | |
| static const uint8_t | kRegBOVL = 0x0E |
| Bus Overvoltage Threshold (16-bit, R/W) More... | |
| static const uint8_t | kRegBUVL = 0x0F |
| Bus Undervoltage Threshold (16-bit, R/W) More... | |
| static const uint8_t | kRegTempLimit = 0x10 |
| Temperature Over-Limit Threshold (16-bit, R/W) More... | |
| static const uint8_t | kRegPowerLimit = 0x11 |
| Power Over-Limit Threshold (16-bit, R/W) More... | |
| static const uint8_t | kRegManufacturerID = 0x3E |
| Manufacturer ID (16-bit, R) – reads 0x5449 ("TI") More... | |
| static const uint8_t | kRegDeviceID = 0x3F |
| Device ID (16-bit, R) More... | |
| static const uint16_t | kShuntCalMask = 0x7FFF |
| SHUNT_CAL valid bits [14:0] (bit 15 reserved) More... | |
| static const uint16_t | kBusThresholdMask = 0x7FFF |
| BOVL/BUVL valid bits [14:0] (bit 15 reserved) More... | |
| static const uint16_t | kShuntTempCoMask = 0x3FFF |
| TEMPCO field mask, bits [13:0]. More... | |
| static const uint16_t | kINA228DeviceIDValue = 0x2280 |
| INA228 device ID (upper 12 bits) More... | |
| static const uint16_t | kINA237DeviceIDValue = 0x2370 |
| INA237 device ID (upper 12 bits) More... | |
| static const uint16_t | kINA238DeviceIDValue = 0x2380 |
| INA238 device ID (register-compatible with INA237) More... | |
| static const uint16_t | kDeviceIDMask = 0xFFF0 |
| Mask for device ID (ignore revision) More... | |
| static const uint16_t | kManufacturerIDValue = 0x5449 |
| "TI" in ASCII More... | |
Platform-independent base driver for the INA228/INA237 power monitor ICs.
This class implements register-level access for all configuration and diagnostic registers shared between the INA228 and INA237. Measurement registers (VSHUNT, VBUS, CURRENT, POWER, ENERGY, CHARGE) are implemented in the derived sfDevINA228 and sfDevINA237 classes because they differ in register width and scaling.
Most methods return a SparkFun Toolkit error code (::ksfTkErrOk on success, a negative value on error); values read from the device are returned through reference (output) parameters.
This class does not depend on Arduino. The Arduino-specific wrappers (SfeINA228ArdI2C, SfeINA237ArdI2C) provide begin() and isConnected() methods.
|
inline |
| sfTkError_t sfDevINA2XX::begin | ( | sfTkIBus * | theBus = nullptr | ) |
Initialize the device driver with the given bus.
Sets the communication bus and configures byte order for big-endian.
| theBus | Pointer to the initialized bus object. If null, a bus set by a prior call is used. |
|
inlineprotected |
Shared VBUS -> volts conversion.
|
protected |
Shared calibration math; only the two scale constants differ per device.
| calScale | Device calibration scale (13107.2e6 for INA228, 819.2e6 for INA237). |
| currentFullScale | Positive half of the ADC range (2^19 for INA228, 2^15 for INA237). |
|
inlineprotected |
Shared CURRENT -> amps conversion (scales by the calibrated CURRENT_LSB).
|
protected |
Shared DIETEMP -> Celsius conversion.
| shift | Right-shift before sign interpretation: 0 (INA228, 16-bit) or 4 (INA237, 12-bit). |
| sfTkError_t sfDevINA2XX::enableTempCompensation | ( | bool | enable | ) |
Enable or disable shunt temperature compensation.
| enable | True to enable, false to disable. |
| sfTkError_t sfDevINA2XX::getADCMode | ( | sfe_ina2xx_mode_t & | mode | ) |
Get the current ADC operating mode.
| mode | Output reference that receives the operating mode. |
| sfTkError_t sfDevINA2XX::getADCRange | ( | bool & | reducedRange | ) |
Get the current ADC range setting.
| reducedRange | Output reference set true if reduced range (+/-40.96mV), false if default. |
| sfTkError_t sfDevINA2XX::getAlertLatch | ( | bool & | latched | ) |
Get the alert latch setting.
| latched | Output reference set true if latched, false if transparent. |
| sfTkError_t sfDevINA2XX::getAlertPolarity | ( | bool & | activeHigh | ) |
Get the ALERT pin polarity setting.
| activeHigh | Output reference set true if active-high, false if active-low. |
| sfTkError_t sfDevINA2XX::getAveragingCount | ( | sfe_ina2xx_avg_count_t & | count | ) |
Get the current ADC averaging count.
| count | Output reference that receives the averaging count setting. |
| sfTkError_t sfDevINA2XX::getBusOverVoltageThreshold | ( | uint16_t & | threshold | ) |
Get the bus overvoltage threshold.
| threshold | Output reference that receives the threshold value. |
| sfTkError_t sfDevINA2XX::getBusUnderVoltageThreshold | ( | uint16_t & | threshold | ) |
Get the bus undervoltage threshold.
| threshold | Output reference that receives the threshold value. |
| sfTkError_t sfDevINA2XX::getBusVoltageConvTime | ( | sfe_ina2xx_conv_time_t & | time | ) |
Get the bus voltage conversion time.
| time | Output reference that receives the conversion time setting. |
| sfTkError_t sfDevINA2XX::getConversionDelay | ( | uint8_t & | delay2ms | ) |
Get the current conversion delay setting.
| delay2ms | Output reference that receives the delay value 0-255. |
| sfTkError_t sfDevINA2XX::getConversionReadyAlert | ( | bool & | enabled | ) |
Get the conversion ready alert enable state.
| enabled | Output reference set true if enabled. |
| sfTkError_t sfDevINA2XX::getDeviceID | ( | uint16_t & | id | ) |
Read the Device ID register (0x3F).
| id | Output reference that receives the full 16-bit device ID (including revision nibble). |
| sfTkError_t sfDevINA2XX::getDiagnosticFlags | ( | sfe_ina2xx_diag_alrt_reg_t & | flags | ) |
Read the full DIAG_ALRT register.
Reading this register clears latched alert flags when ALATCH = 1.
| flags | Output reference that receives the diagnostic flags bitfield. |
| sfTkError_t sfDevINA2XX::getManufacturerID | ( | uint16_t & | id | ) |
Read the Manufacturer ID register (0x3E).
| id | Output reference that receives the manufacturer ID (0x5449 = "TI"). |
| sfTkError_t sfDevINA2XX::getPowerLimitThreshold | ( | uint16_t & | threshold | ) |
Get the power over-limit threshold.
| threshold | Output reference that receives the threshold value. |
| sfTkError_t sfDevINA2XX::getShuntCal | ( | uint16_t & | calValue | ) |
Read the current SHUNT_CAL register value.
| calValue | Output reference that receives the calibration value. |
| sfTkError_t sfDevINA2XX::getShuntOverVoltageThreshold | ( | int16_t & | threshold | ) |
Get the shunt overvoltage threshold.
| threshold | Output reference that receives the threshold value. |
| sfTkError_t sfDevINA2XX::getShuntTempCoefficient | ( | uint16_t & | ppmPerDegC | ) |
Get the shunt temperature coefficient.
| ppmPerDegC | Output reference that receives the temperature coefficient in ppm/deg-C. |
| sfTkError_t sfDevINA2XX::getShuntUnderVoltageThreshold | ( | int16_t & | threshold | ) |
Get the shunt undervoltage threshold.
| threshold | Output reference that receives the threshold value. |
| sfTkError_t sfDevINA2XX::getShuntVoltageConvTime | ( | sfe_ina2xx_conv_time_t & | time | ) |
Get the shunt voltage conversion time.
| time | Output reference that receives the conversion time setting. |
| sfTkError_t sfDevINA2XX::getSlowAlert | ( | bool & | enabled | ) |
Get the slow alert enable state.
| enabled | Output reference set true if alert compares on averaged value. |
| sfTkError_t sfDevINA2XX::getTempCompensation | ( | bool & | enabled | ) |
Get the temperature compensation enable state.
| enabled | Output reference set true if enabled. |
| sfTkError_t sfDevINA2XX::getTempConvTime | ( | sfe_ina2xx_conv_time_t & | time | ) |
Get the temperature conversion time.
| time | Output reference that receives the conversion time setting. |
| sfTkError_t sfDevINA2XX::getTempLimitThreshold | ( | int16_t & | threshold | ) |
Get the temperature over-limit threshold.
| threshold | Output reference that receives the threshold value. |
| sfTkError_t sfDevINA2XX::isBusOverVoltage | ( | bool & | overVoltage | ) |
Check if the bus overvoltage flag is set.
| overVoltage | Output reference set true if bus voltage exceeds BOVL threshold. |
| sfTkError_t sfDevINA2XX::isBusUnderVoltage | ( | bool & | underVoltage | ) |
Check if the bus undervoltage flag is set.
| underVoltage | Output reference set true if bus voltage is below BUVL threshold. |
| sfTkError_t sfDevINA2XX::isChargeOverflow | ( | bool & | overflow | ) |
Check if the charge register has overflowed (INA228 only).
| overflow | Output reference set true if overflow detected. |
| sfTkError_t sfDevINA2XX::isConversionReady | ( | bool & | ready | ) |
Check if a conversion has completed.
| ready | Output reference set true if conversion ready. |
| sfTkError_t sfDevINA2XX::isEnergyOverflow | ( | bool & | overflow | ) |
Check if the energy register has overflowed (INA228 only).
| overflow | Output reference set true if overflow detected. |
| sfTkError_t sfDevINA2XX::isMathOverflow | ( | bool & | overflow | ) |
Check if a math overflow has occurred in current/power calculations.
| overflow | Output reference set true if overflow detected. |
| sfTkError_t sfDevINA2XX::isMemoryValid | ( | bool & | valid | ) |
Check the memory checksum status.
| valid | Output reference set true if the internal memory checksum is valid. |
| sfTkError_t sfDevINA2XX::isPowerOverLimit | ( | bool & | overLimit | ) |
Check if the power over-limit flag is set.
| overLimit | Output reference set true if power exceeds PWR_LIMIT threshold. |
| sfTkError_t sfDevINA2XX::isShuntOverVoltage | ( | bool & | overVoltage | ) |
Check if the shunt overvoltage flag is set.
| overVoltage | Output reference set true if shunt voltage exceeds SOVL threshold. |
| sfTkError_t sfDevINA2XX::isShuntUnderVoltage | ( | bool & | underVoltage | ) |
Check if the shunt undervoltage flag is set.
| underVoltage | Output reference set true if shunt voltage is below SUVL threshold. |
| sfTkError_t sfDevINA2XX::isTempOverLimit | ( | bool & | overLimit | ) |
Check if the temperature over-limit flag is set.
| overLimit | Output reference set true if temperature exceeds TEMP_LIMIT threshold. |
|
protected |
Shared POWER -> watts conversion. powerLSBScale is 3.2 (INA228) or 0.2 (INA237).
|
protected |
Shared raw POWER read (24-bit, unsigned) — identical on both devices.
|
protected |
Read 3 bytes (24-bit) from a register into a uint32_t.
| reg | Register address. |
| value | Output value (MSB-first assembly). |
|
protected |
Read 5 bytes (40-bit) from a register into a uint64_t.
| reg | Register address. |
| value | Output value (MSB-first assembly). |
|
inlineprotected |
Shared raw read for a signed measurement register (shunt voltage, current).
| T | Output integer type (int32_t for the 24-bit INA228, int16_t for INA237). |
| Wide | true = 24-bit register, data in bits [23:4], 20-bit sign extension (INA228); false = 16-bit two's complement read directly (INA237). |
|
inlineprotected |
Shared raw read for an unsigned measurement register (bus voltage).
| T | Output integer type (uint32_t for INA228, uint16_t for INA237). |
| Wide | true = 24-bit register, data in bits [23:4] (INA228); false = 16-bit read (INA237). |
| sfTkError_t sfDevINA2XX::reset | ( | void | ) |
Perform a full system reset via the RST bit in CONFIG.
| sfTkError_t sfDevINA2XX::resetAccumulators | ( | void | ) |
Reset the energy and charge accumulators (INA228 RSTACC bit).
| sfTkError_t sfDevINA2XX::setADCMode | ( | sfe_ina2xx_mode_t | mode | ) |
Set the ADC operating mode.
| mode | Operating mode (see sfe_ina2xx_mode_t). |
| sfTkError_t sfDevINA2XX::setADCRange | ( | bool | reducedRange | ) |
Set the ADC full-scale shunt range.
| reducedRange | False = +/-163.84mV (default), true = +/-40.96mV. |
| sfTkError_t sfDevINA2XX::setAlertLatch | ( | bool | latched | ) |
Enable or disable alert latching.
| latched | True = latched mode, false = transparent mode. |
| sfTkError_t sfDevINA2XX::setAlertPolarity | ( | bool | activeHigh | ) |
Set the ALERT pin polarity.
| activeHigh | True = active-high, false = active-low (default, open-drain). |
| sfTkError_t sfDevINA2XX::setAveragingCount | ( | sfe_ina2xx_avg_count_t | count | ) |
Set the ADC averaging count.
| count | Averaging count (see sfe_ina2xx_avg_count_t). |
| sfTkError_t sfDevINA2XX::setBusOverVoltageThreshold | ( | uint16_t | threshold | ) |
Set the bus overvoltage threshold.
| threshold | Unsigned 15-bit value. LSB = 3.125mV. |
| sfTkError_t sfDevINA2XX::setBusUnderVoltageThreshold | ( | uint16_t | threshold | ) |
Set the bus undervoltage threshold.
| threshold | Unsigned 15-bit value. LSB = 3.125mV. |
| sfTkError_t sfDevINA2XX::setBusVoltageConvTime | ( | sfe_ina2xx_conv_time_t | time | ) |
Set the bus voltage conversion time.
| time | Conversion time setting (see sfe_ina2xx_conv_time_t). |
| void sfDevINA2XX::setCommunicationBus | ( | sfTkIBus * | theBus | ) |
Set the communication bus pointer.
| theBus | Bus to use for all register I/O. |
| sfTkError_t sfDevINA2XX::setConversionDelay | ( | uint8_t | delay2ms | ) |
Set the initial conversion delay in 2ms steps.
| delay2ms | Delay value 0-255 (0 = 0ms, 255 = 510ms). |
| sfTkError_t sfDevINA2XX::setConversionReadyAlert | ( | bool | enable | ) |
Enable conversion ready flag on the ALERT pin.
| enable | True to assert ALERT on conversion complete. |
| sfTkError_t sfDevINA2XX::setPowerLimitThreshold | ( | uint16_t | threshold | ) |
Set the power over-limit threshold.
| threshold | Unsigned value. LSB = 256 x Power LSB. |
| sfTkError_t sfDevINA2XX::setShuntCal | ( | uint16_t | calValue | ) |
Write a raw value to the SHUNT_CAL register.
| calValue | 15-bit calibration value (bit 15 is reserved). |
| sfTkError_t sfDevINA2XX::setShuntOverVoltageThreshold | ( | int16_t | threshold | ) |
Set the shunt overvoltage threshold.
| threshold | Two's complement value. LSB = 5uV (ADCRANGE=0) or 1.25uV (ADCRANGE=1). |
| sfTkError_t sfDevINA2XX::setShuntTempCoefficient | ( | uint16_t | ppmPerDegC | ) |
Set the shunt temperature coefficient for temperature compensation.
| ppmPerDegC | Temperature coefficient, 0-16383 ppm/deg-C. |
| sfTkError_t sfDevINA2XX::setShuntUnderVoltageThreshold | ( | int16_t | threshold | ) |
Set the shunt undervoltage threshold.
| threshold | Two's complement value. Same LSB as shunt overvoltage. |
| sfTkError_t sfDevINA2XX::setShuntVoltageConvTime | ( | sfe_ina2xx_conv_time_t | time | ) |
Set the shunt voltage conversion time.
| time | Conversion time setting (see sfe_ina2xx_conv_time_t). |
| sfTkError_t sfDevINA2XX::setSlowAlert | ( | bool | enable | ) |
Enable alert comparison on averaged (vs.
instantaneous) values.
| enable | True = alert on averaged value, false = alert on ADC value. |
| sfTkError_t sfDevINA2XX::setTempConvTime | ( | sfe_ina2xx_conv_time_t | time | ) |
Set the temperature conversion time.
| time | Conversion time setting (see sfe_ina2xx_conv_time_t). |
| sfTkError_t sfDevINA2XX::setTempLimitThreshold | ( | int16_t | threshold | ) |
Set the temperature over-limit threshold.
| threshold | Two's complement value. LSB = 7.8125 m-deg-C. |
|
inlineprotected |
Shared VSHUNT -> millivolts conversion (reads raw, then scales by the range LSB).
|
protected |
Cached ADC range: false = +/-163.84mV, true = +/-40.96mV.
|
protected |
Current measurement LSB in Amps, set during calibration.
|
protected |
Shunt resistance in Ohms, stored during calibration.
|
protected |
Pointer to the communication bus device.
|
staticprotected |
BOVL/BUVL valid bits [14:0] (bit 15 reserved)
|
staticprotected |
Mask for device ID (ignore revision)
|
staticprotected |
Default 7-bit I2C address for the SparkFun Qwiic Power Monitor board.
A0 = GND, A1 = GND gives 0x40. Both INA228 and INA237 support 0x40-0x4F.
|
staticprotected |
INA228 device ID (upper 12 bits)
|
staticprotected |
INA237 device ID (upper 12 bits)
|
staticprotected |
INA238 device ID (register-compatible with INA237)
|
staticprotected |
"TI" in ASCII
|
staticprotected |
ADC Configuration register (16-bit, R/W)
|
staticprotected |
Bus Overvoltage Threshold (16-bit, R/W)
|
staticprotected |
Bus Undervoltage Threshold (16-bit, R/W)
|
staticprotected |
Charge Result (40-bit, R) – INA228 only.
|
staticprotected |
Configuration register (16-bit, R/W)
|
staticprotected |
Current Result (24/16-bit, R)
|
staticprotected |
Device ID (16-bit, R)
|
staticprotected |
Diagnostic Flags and Alert (16-bit, R/W)
|
staticprotected |
Die Temperature Measurement (16-bit, R)
|
staticprotected |
Energy Result (40-bit, R) – INA228 only.
|
staticprotected |
Manufacturer ID (16-bit, R) – reads 0x5449 ("TI")
|
staticprotected |
Power Result (24-bit, R)
|
staticprotected |
Power Over-Limit Threshold (16-bit, R/W)
|
staticprotected |
Shunt Calibration register (16-bit, R/W)
|
staticprotected |
Shunt Temperature Coefficient (16-bit, R/W)
|
staticprotected |
Shunt Overvoltage Threshold (16-bit, R/W)
|
staticprotected |
Shunt Undervoltage Threshold (16-bit, R/W)
|
staticprotected |
Temperature Over-Limit Threshold (16-bit, R/W)
|
staticprotected |
Bus Voltage Measurement (24/16-bit, R)
|
staticprotected |
Shunt Voltage Measurement (24/16-bit, R)
|
staticprotected |
SHUNT_CAL valid bits [14:0] (bit 15 reserved)
|
staticprotected |
TEMPCO field mask, bits [13:0].