Skip to main content

Mainboard

class Mainboard

enum class BatteryType

  • Generic_3V7 Generic Li-ion/LiPo, 3.7 V nominal and 4.2 V max
  • ICR18650_26H Samsung ICR18650-26H
  • UR18650ZY Panasonic UR18650ZY
  • Generic_LFP Generic LiFePO4 (LFP), 3.2 V nominal and 3.6 V max. V2 only; uses the MAX17260 EZ LFP profile with an LFP-tuned empty threshold.

Result init()

Brief

Initialize the board power management and monitoring features with no battery expected.

Description

Initializes the board with battery monitoring disabled. Use this when no battery is connected. See Mainboard::init(uint16_t, BatteryType) for the full default list.

Return

Returns Result::Ok if the board was initialized successfully; returns a value other than Result::Ok if not.

Result init(uint16_t capacity, BatteryType type = BatteryType::Generic_3V7)

Brief

Initialize the board power management and monitoring features.

Description

Initializes the battery charger, battery fuel gauge, and other hardware related to power management and monitoring.

Sets the following defaults:

  • EN: high
  • 3V3: enabled
  • VSQT: enabled
  • Charging: disabled
  • Maximum battery charging current request: 50 mA (programs 40 mA after BQ step quantization)
  • Maintain supply voltage: 4.6 V
  • Fuel gauge: enabled (use Mainboard::init() to disable)
  • Battery temperature sense: disabled
  • Battery alarms (low charge, high/low voltage): disabled

On RTC-retaining warm boots, charger settings changed through public setters are retained only when the battery or profile configuration still matches. If the configuration changes, initialization re-applies safe defaults.

This function should be called once, before calling all other Mainboard functions.

Parameters

  • capacity [in] The capacity of the connected Li-ion/LiPo battery in milliamp-hours (mAh). Valid range depends on board revision: V1 supports 50-6000 mAh, V2 supports 1-16383 mAh. On V2, capacities below 50 mAh are supported for monitoring only: battery charging remains disabled and charge-current configuration is rejected. Must be non-zero; use Mainboard::init() when no battery is expected. If using multiple batteries connected in parallel, specify only the capacity for one cell. Ignored when type is BatteryType::ICR18650_26H or BatteryType::UR18650ZY.
  • type [in] Type of Li-ion/LiPo battery. When set to BatteryType::ICR18650_26H or BatteryType::UR18650ZY, the supplied capacity is ignored and 2600 mAh is used. BatteryType::Generic_LFP is available only on V2 boards; on V1, selecting it returns Result::InvalidArg. Use Mainboard::init(const MAX17260::Model &) for MAX17260 profiles.

Return

Returns Result::Ok if the board was initialized successfully; returns a value other than Result::Ok if not.

Result init(const MAX17260::Model &profile)

Brief

Initialize the board using a MAX17260 model profile.

Description

The battery capacity is inferred from the profile. On V2, inferred capacities below 50 mAh are supported for monitoring only: battery charging remains disabled and charge-current configuration is rejected.

The profile must provide a valid charger constant-voltage target in chargeVoltage. This value is applied directly to the charger VREG/CV limit. Accepted range is 3.5-4.8 V. The SDK does not infer a safe charge voltage from the custom model data; ensure this value matches the connected cell chemistry because an incorrect value can overcharge the cell. The profile's ichgTerm is also applied to the charger termination-current setting after conversion from MAX17260 register units; it must correspond to 5-310 mA.

Parameters

  • profile [in] MAX17260 model profile.

Return

Returns Result::Ok if the board was initialized successfully; returns a value other than Result::Ok if not.

Result setEN(bool high)

Brief

Set EN pin high or low.

Description

This is useful for enabling or disabling connected FeatherWings to reduce power consumption.

Parameters

  • high [in] If true, EN is set high; if false, EN is set low.

Return

Returns Result::Ok if EN was set high or low successfully; returns a value other than Result::Ok if not.

Result enable3V3(bool enable)

Brief

Enable or disable 3V3.

Description

Enables or disables 3V3, the 3.3 V header pin power output. When disabled, power to the connected loads on 3V3 is cut, reducing power consumption.

Parameters

  • enable [in] If true, 3V3 is enabled; if false, 3V3 is disabled.

Return

Returns Result::Ok if 3V3 was enabled or disabled successfully; returns a value other than Result::Ok if not.

Result enableVSQT(bool enable)

Brief

Enable or disable VSQT.

Description

Enables or disables VSQT, the 3.3 V STEMMA QT power output. When disabled, power to the connected STEMMA QT modules is cut, reducing power consumption.

On V1, disabling VSQT also disables communications to the battery charger and fuel gauge. This means that some of the other Mainboard functions will return Result::InvalidState while VSQT is disabled. On V2, power-management I2C remains usable even with VSQT disabled.

Parameters

  • enable [in] If true, VSQT is enabled; if false, VSQT is disabled.

Return

Returns Result::Ok if VSQT was enabled or disabled successfully; returns a value other than Result::Ok if not.

Result enableSTAT(bool enable)

Brief

Enable or disable the STAT LED.

Description

Normally, the STAT LED turns on when charging, or blinks when there is an error preventing charging (when battery temperature exceeds the set threshold, for example). This function can enable/disable this LED from turning on in these cases.

One instance where disabling this LED is desirable is during low-sunlight charging conditions, where the current extracted from the solar panel should be used to charge the battery as much as possible.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

Parameters

  • enable [in] If true, STAT LED is enabled; if false, STAT LED is disabled.

Return

Returns Result::Ok if STAT LED was enabled or disabled successfully; returns a value other than Result::Ok if not.

Result getSupplyVoltage(float &voltage)

Brief

Measure the supply voltage.

Description

Measures the VUSB or VDC voltage. VUSB is the power input from the USB-C connector, while VDC is the power input from the header pin. Resolution is approximately 0.004 V.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

This function can block for about 100 ms on a normal charger ADC refresh, plus power-management I2C transfer time. I2C faults can add several 50 ms transaction timeout windows before the function returns failure. Tasks contending for the SDK mutex are bounded by the mutex timeout while this call waits for the ADC conversion.

Parameters

  • voltage [out] The measured voltage in volts (V).

Return

Returns Result::Ok if the supply voltage was measured successfully; returns a value other than Result::Ok if not.

Result getSupplyCurrent(float &current)

Brief

Measure the supply current.

Description

Measures the current drawn from VUSB or VDC. VUSB is the power input from the USB-C connector, while VDC is the power input from the header pin. Resolution is 2 mA.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

This function can block for about 100 ms on a normal charger ADC refresh, plus power-management I2C transfer time. I2C faults can add several 50 ms transaction timeout windows before the function returns failure. Tasks contending for the SDK mutex are bounded by the mutex timeout while this call waits for the ADC conversion.

Parameters

  • current [out] The measured current draw in milliamperes (mA).

Return

Returns Result::Ok if the supply current was measured successfully; returns a value other than Result::Ok if not.

Result checkSupplyGood(bool &good)

Brief

Check if the supply is good.

Description

Checks whether the supply, either VUSB or VDC, is good as determined by the battery charger. A good supply means that it powers the board and connected loads, not the battery.

Parameters

  • good [out] If true, the charger has determined the supply to be good; false if not.

Return

Returns Result::Ok if the supply was checked successfully; returns a value other than Result::Ok if not.

Result setSupplyMaintainVoltage(float voltage)

Brief

Set the supply voltage to maintain.

Description

The battery charger dynamically regulates the current drawn from the supply to prevent it from collapsing below the voltage to maintain. This is useful for specifying the maximum power point (MPP) voltage when using a solar panel, allowing the battery charger to extract power from the panel at near-MPPT effectiveness. This programs the charger's VINDPM request. The charger's effective regulation point can be higher when its battery-tracking behavior applies.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

Parameters

  • voltage [in] The supply voltage to maintain in volts (V), from 4.6 V to 16.8 V.

Return

Returns Result::Ok if the supply voltage to maintain was set successfully; returns a value other than Result::Ok if not.

Result enterShipMode()

Brief

Enter ship mode.

Description

Ship mode is a power state that only consumes around 1.5 μA. Only the battery charger and the battery fuel gauge are powered.

This mode can only be entered if the battery is powering the board and connected loads; that is, if Mainboard::checkSupplyGood output parameter good is false.

Ship mode can be exited by either (1) pulling QON header pin low for around 800 ms or (2) connecting a power supply that the battery charger determines to be good.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

This function can block for 30 ms if it fails to enter ship mode.

Return

Does not return if ship mode was successfully entered; returns a value other than Result::Ok if not.

Result enterShutdownMode()

Brief

Enter shutdown mode.

Description

Shutdown mode is a power state that only consumes around 1.4 μA. Only the battery charger and the battery fuel gauge are powered.

This mode can only be entered if the battery is powering the board and connected loads; that is, if Mainboard::checkSupplyGood output parameter good is false.

Shutdown mode can only be exited by connecting a power supply that the battery charger determines to be good.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

This function can block for 30 ms if it fails to enter shutdown mode.

Return

Does not return if shutdown mode was successfully entered; returns a value other than Result::Ok if not.

Result doPowerCycle()

Brief

Perform a power cycle.

Description

For all components on the board and connected loads except the battery fuel gauge and loads connected to VS (supply output header pin, whichever of VUSB and VDC is present), a power cycle provides a complete reset by removing power and re-applying it after a short delay.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

Return

Does not return if a power cycle was performed successfully; returns a value other than Result::Ok if not.

Result enableBatteryCharging(bool enable)

Brief

Enable or disable battery charging.

Description

This is useful when choosing not to fully charge a battery in order to prolong its lifespan.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

A non-zero capacity or type of BatteryType::ICR18650_26H / BatteryType::UR18650ZY should have been specified when Mainboard::init was called, else Result::InvalidState is returned.

On V2, charging is not available for configured battery capacities below 50 mAh.

Parameters

  • enable [in] If true, battery charging is enabled; if false, battery charging is disabled.

Return

Returns Result::Ok if battery charging was enabled or disabled successfully; returns a value other than Result::Ok if not.

Result setBatteryChargingMaxCurrent(float current)

Brief

Set maximum battery charging current.

Description

Limits battery charging current to no more than the requested maximum. This is useful for batteries with small capacities, since it is not recommended to charge a battery at more than 1 C. For example, when charging a 550 mAh battery, a current of no more than 550 mA is recommended. That current limit of 550 mA can be specified using this function. The charger encodes this limit in 40 mA steps; values between steps are rounded down so the programmed charger limit does not exceed the requested maximum.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

A non-zero capacity or type of BatteryType::ICR18650_26H / BatteryType::UR18650ZY should have been specified when Mainboard::init was called, else Result::InvalidState is returned.

On V2, this function is not available for configured battery capacities below 50 mAh.

Parameters

  • current [in] The maximum charging current in milliamperes (mA), from 40 mA to 2000 mA. Values between 40 mA register steps are rounded down.

Return

Returns Result::Ok if the maximum battery charging current was set successfully; returns a value other than Result::Ok if not.

Result enableBatteryTempSense(bool enable)

Brief

Enable or disable battery temperature measurement.

Description

Enables or disables battery temperature measurement using the thermistor connected to the TS pin. When enabled, the battery charger also performs temperature-based battery charging current reduction or cutoff.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

A non-zero capacity or type of BatteryType::ICR18650_26H / BatteryType::UR18650ZY should have been specified when Mainboard::init was called, else Result::InvalidState is returned.

Parameters

  • enable [in] If true, battery temperature measurement is enabled; if false, battery temperature measurement is disabled.

Return

Returns Result::Ok if the battery temperature measurement was enabled or disabled successfully; returns a value other than Result::Ok if not.

Result enableBatteryFuelGauge(bool enable)

Brief

Enable or disable the battery fuel gauge.

Description

Disabling the battery fuel gauge can save around 0.5 μA. However, once disabled, it cannot keep track of battery information such as voltage, charge, health, cycle count, etc. Nonetheless, this is useful when trying to reduce power as much as possible, such as when going into ship mode or shutdown mode for a long time.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

A non-zero capacity or type of BatteryType::ICR18650_26H / BatteryType::UR18650ZY should have been specified when Mainboard::init was called, else Result::InvalidState is returned.

Parameters

  • enable [in] If true, the battery fuel gauge is enabled; if false, the battery fuel gauge is disabled.

Return

Returns Result::Ok if the battery fuel gauge was enabled or disabled successfully; returns a value other than Result::Ok if not.

Result getBatteryVoltage(float &voltage)

Brief

Measure battery voltage.

Description

Resolution is approximately 0.002 V. If the fuel gauge is enabled and available, it is used; otherwise, the charger VBAT ADC path is used as a fallback.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

A non-zero capacity or type of BatteryType::ICR18650_26H / BatteryType::UR18650ZY should have been specified when Mainboard::init was called, else Result::InvalidState is returned.

This function can block for about 100 ms plus power-management I2C transfer time when the charger ADC fallback path is used. I2C faults can add several 50 ms transaction timeout windows before the function returns failure. Tasks contending for the SDK mutex are bounded by the mutex timeout while this call waits for the ADC conversion.

Parameters

  • voltage [out] Measured battery voltage in volts (V).

Return

Returns Result::Ok if the battery voltage was measured successfully; returns a value other than Result::Ok if not.

Result getBatteryCurrent(float &current)

Brief

Measure battery current.

Description

Measures the current to or from the battery during charging and discharging, respectively.

On V1, this function uses the BQ25628E charger IBAT_ADC register with a 4 mA LSB. BQ25628E Table 8-35 specifies that IBAT_ADC resets to zero when charging is disabled; in that case this function returns Result::NotReady instead of reporting a misleading zero current. On V2, this function uses the MAX17260 Current register with a 0.078125 mA LSB.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

A non-zero capacity or type of BatteryType::ICR18650_26H / BatteryType::UR18650ZY should have been specified when Mainboard::init was called, else Result::InvalidState is returned.

The battery fuel gauge must be enabled on V2 before calling this function, else Result::InvalidState is returned.

This function can block for about 100 ms on a normal V1 charger ADC refresh, plus power-management I2C transfer time. I2C faults can add several 50 ms transaction timeout windows before the function returns failure. Tasks contending for the SDK mutex are bounded by the mutex timeout while this call waits for the ADC conversion.

Parameters

  • current [out] Measured battery current in milliamperes (mA). If the battery is discharging, this value is negative; if the battery is charging, this value is positive. On V1, this signed contract applies only when the charger provides a valid IBAT_ADC reading.

Return

Returns Result::Ok if the battery current was measured successfully; returns a value other than Result::Ok if not.

Result getBatteryCharge(uint8_t &percent)

Brief

Estimate battery charge.

Description

Gives an estimate of battery state-of-charge from 0% to 100%. This is useful for getting a sense of whether the battery still has much charge or is nearly empty.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

A non-zero capacity or type of BatteryType::ICR18650_26H / BatteryType::UR18650ZY should have been specified when Mainboard::init was called, else Result::InvalidState is returned.

The battery fuel gauge must be enabled prior to calling this function, else Result::InvalidState is returned.

Parameters

  • percent [out] Estimated battery charge in percent, from 0% to 100%.

Return

Returns Result::Ok if the battery charge was estimated successfully; returns a value other than Result::Ok if not.

Result getBatteryHealth(uint8_t &percent)

Brief

Estimate battery health.

Description

Gives an estimate of battery state-of-health from 0% to 100%. This is useful to get a sense of how much the battery has degraded over time.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

A non-zero capacity or type of BatteryType::ICR18650_26H / BatteryType::UR18650ZY should have been specified when Mainboard::init was called, else Result::InvalidState is returned.

The battery fuel gauge must be enabled prior to calling this function, else Result::InvalidState is returned.

Parameters

  • percent [out] Estimated battery health in percent, from 0% to 100%.

Return

Returns Result::Ok if the battery health was estimated successfully; returns a value other than Result::Ok if not.

Result getBatteryCycles(uint16_t &cycles)

Brief

Estimate battery cycle count.

Description

Gives an estimate of the battery cycle count. This is useful for comparing against the rated cycle count of the battery.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

A non-zero capacity or type of BatteryType::ICR18650_26H / BatteryType::UR18650ZY should have been specified when Mainboard::init was called, else Result::InvalidState is returned.

The battery fuel gauge must be enabled prior to calling this function, else Result::InvalidState is returned.

Parameters

  • cycles [out] Estimated battery cycle count.

Return

Returns Result::Ok if the battery cycle count was estimated successfully; returns a value other than Result::Ok if not.

Result getBatteryTimeLeft(int &minutes)

Brief

Estimate time left for battery to charge or discharge.

Description

Gives an estimate of the battery time-to-empty or time-to-full in minutes. The battery charge must have previously changed by a certain percentage to estimate time-to-empty or time-to-full. If the gauge has not accumulated enough history yet, this function returns Result::NotReady.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

A non-zero capacity or type of BatteryType::ICR18650_26H / BatteryType::UR18650ZY should have been specified when Mainboard::init was called, else Result::InvalidState is returned.

The battery fuel gauge must be enabled prior to calling this function, else Result::InvalidState is returned.

Parameters

  • minutes [out] Estimated time left for the battery to charge or discharge in minutes. If the battery is discharging, this value is negative; if battery is charging, this value is positive.

Return

Returns Result::Ok if the time left for battery to charge or discharge was estimated successfully; returns a value other than Result::Ok if not.

Result getBatteryTemperature(float &celsius)

Brief

Measure battery temperature.

Description

Requires a Semitec 103AT thermistor to be connected to the TS pin and attached to the battery for the measurement to be accurate.

Returns Result::Failure if the thermistor reading is outside the plausible range, such as when the thermistor is missing, open, or shorted.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

A non-zero capacity or type of BatteryType::ICR18650_26H / BatteryType::UR18650ZY should have been specified when Mainboard::init was called, else Result::InvalidState is returned.

Battery temperature measurement must be enabled prior to calling this function, else Result::InvalidState is returned.

This function can block for about 100 ms on a normal charger ADC refresh, plus power-management I2C transfer time. I2C faults can add several 50 ms transaction timeout windows before the function returns failure. Tasks contending for the SDK mutex are bounded by the mutex timeout while this call waits for the ADC conversion.

Parameters

  • celsius [out] Measured battery temperature in degrees Celsius.

Return

Returns Result::Ok if the battery temperature was measured successfully; returns a value other than Result::Ok if not.

Result setBatteryLowVoltageAlarm(float voltage)

Brief

Set an alarm for battery low voltage.

Description

If the battery voltage is less than the set voltage, the ALARM pin is pulled low.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

A non-zero capacity or type of BatteryType::ICR18650_26H / BatteryType::UR18650ZY should have been specified when Mainboard::init was called, else Result::InvalidState is returned.

The battery fuel gauge must be enabled prior to calling this function, else Result::InvalidState is returned.

Parameters

  • voltage [in] The voltage at which the low voltage alarm will trigger in volts (V). Valid non-zero range depends on board revision (2.5-5.0 V for V1, 0.02-5.1 V for V2). If zero, triggering of the alarm is disabled and any existing low voltage alarm is cleared.

Alarm handling differs by board revision:

  • V1 (LC709204F): low-voltage status naturally clears once voltage returns above threshold.
  • V2 (MAX17260): low-voltage status is latched until explicitly cleared. Use setBatteryLowVoltageAlarm(0.0f) to clear, then set a non-zero threshold to re-arm.

Return

Returns Result::Ok if the battery low voltage alarm was set successfully; returns a value other than Result::Ok if not.

Result setBatteryHighVoltageAlarm(float voltage)

Brief

Set an alarm for battery high voltage.

Description

If the battery voltage is greater than the set voltage, the ALARM pin is pulled low.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

A non-zero capacity or type of BatteryType::ICR18650_26H / BatteryType::UR18650ZY should have been specified when Mainboard::init was called, else Result::InvalidState is returned.

The battery fuel gauge must be enabled prior to calling this function, else Result::InvalidState is returned.

Parameters

  • voltage [in] The voltage at which the high voltage alarm will trigger in volts (V). Valid non-zero range depends on board revision (2.5-5.0 V for V1, 0.02-5.1 V for V2). If zero, triggering of the alarm is disabled and any existing high voltage alarm is cleared.

Alarm handling differs by board revision:

  • V1 (LC709204F): high-voltage status naturally clears once voltage returns below threshold.
  • V2 (MAX17260): high-voltage status is latched until explicitly cleared. Use setBatteryHighVoltageAlarm(0.0f) to clear, then set a non-zero threshold to re-arm.

Return

Returns Result::Ok if the battery high voltage alarm was set successfully; returns a value other than Result::Ok if not.

Result setBatteryLowChargeAlarm(uint8_t percent)

Brief

Set an alarm for battery low charge.

Description

If the battery charge is less than the set percentage, the ALARM pin is pulled low.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

A non-zero capacity or type of BatteryType::ICR18650_26H / BatteryType::UR18650ZY should have been specified when Mainboard::init was called, else Result::InvalidState is returned.

The battery fuel gauge must be enabled prior to calling this function, else Result::InvalidState is returned.

Parameters

  • percent [in] The percentage at which the low charge alarm will trigger in percent, from 1% to 100%. If zero, triggering of the alarm is disabled and any existing low charge alarm is cleared.

Alarm handling differs by board revision:

  • V1 (LC709204F): low-charge status follows gauge behavior.
  • V2 (MAX17260): low-charge status is latched until explicitly cleared. Use setBatteryLowChargeAlarm(0) to clear, then set a non-zero threshold to re-arm.

Return

Returns Result::Ok if the battery low charge alarm was set successfully; returns a value other than Result::Ok if not.

Result updateBatteryFuelGaugeTemp(float temperature)

Brief

Update fuel gauge with measured battery temperature.

Description

To improve fuel gauge accuracy, you can update the fuel gauge with the battery temperature obtained from getBatteryTemperature() or other sources.

Temperature mode behavior depends on board revision:

  • V1: after initialization, fuel gauge temperature is host-updated (this API writes the value used for gauging).
  • V2: after initialization, fuel gauge temperature defaults to on-IC measurement until the first call to this API or its no-arg overload, after which host-updated temperature is used.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

A non-zero capacity or type of BatteryType::ICR18650_26H / BatteryType::UR18650ZY should have been specified when Mainboard::init was called, else Result::InvalidState is returned.

The battery fuel gauge must be enabled prior to calling this function, else Result::InvalidState is returned.

Parameters

  • temperature [in] The temperature of the battery cell in degrees Celsius.

Return

Returns Result::Ok if the fuel gauge's battery temperature has been updated successfully; returns a value other than Result::Ok if not.

Result updateBatteryFuelGaugeTemp()

Brief

Update fuel gauge temperature using the current battery thermistor measurement.

Description

Equivalent to calling getBatteryTemperature() then updateBatteryFuelGaugeTemp(float). See updateBatteryFuelGaugeTemp(float) for V1/V2 temperature mode behavior details.

On V1, VSQT must be enabled prior to calling this function, else Result::InvalidState is returned. On V2, power-management I2C remains usable with VSQT disabled.

A non-zero capacity or type of BatteryType::ICR18650_26H / BatteryType::UR18650ZY should have been specified when Mainboard::init was called, else Result::InvalidState is returned.

Battery temperature measurement must be enabled prior to calling this function, else Result::InvalidState is returned.

The battery fuel gauge must be enabled prior to calling this function, else Result::InvalidState is returned.

Return

Returns Result::Ok if the fuel gauge's battery temperature has been updated successfully; returns a value other than Result::Ok if not.

extern Mainboard &Board

Singleton instance of Mainboard.