CC26xx Driver Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
[aonbatmon] AON Battery Monitor

Functions

__STATIC_INLINE void AONBatMonEnable (void)
 Enable the temperatur and battery monitoring. More...
 
__STATIC_INLINE void AONBatMonDisable (void)
 Disable the temperatur and battery monitoring. More...
 
__STATIC_INLINE void AONBatMonMeasurementCycleSet (uint32_t ui32Cycle)
 Adjust the measurement cycle for the temperature and the battery voltage. More...
 
__STATIC_INLINE uint32_t AONBatMonMeasurementCycleGet (void)
 Get the measurement cycle for the temperature and the battery voltage. More...
 
__STATIC_INLINE void AONBatMonBatteryTrimSet (uint32_t ui32TrimP0, uint32_t ui32TrimP1)
 Set the trim values for the battery voltage calculation. More...
 
__STATIC_INLINE void AONBatMonTemperatureTrimSet (uint32_t ui32TrimP0, uint32_t ui32TrimP1, uint32_t ui32TrimP2)
 Set the trim values for the temperature calculation. More...
 
__STATIC_INLINE uint32_t AONBatMonTemperatureGet (void)
 Get the current temperature measurement. More...
 
int32_t AON_BatmonTempGetDegC (void)
 Get the current temperature measurement as a signed value in Deg Celsius. More...
 
__STATIC_INLINE uint32_t AONBatMonBatteryVoltageGet (void)
 Get the battery monitor measurement. More...
 
__STATIC_INLINE bool AONBatMonNewBatteryMeasureReady (void)
 Check if battery monitor measurement has changed. More...
 
__STATIC_INLINE bool AONBatMonNewTempMeasureReady (void)
 Check if temperature monitor measurement has changed. More...
 

Detailed Description

Function Documentation

int32_t AON_BatmonTempGetDegC ( void  )

Get the current temperature measurement as a signed value in Deg Celsius.

This function returns an calibrated and rounded value in degree Celsius. The temperature measurements are updated every cycle as defined using AONBatMonMeasurementCycleSet().

Note
The temperature drifts slightly depending on the battery voltage. This function compensates for this drift and returns a calibrated temperature.
Use the function AONBatMonNewTempMeasureReady() to test for a new measurement.
Returns
Returns signed integer part of temperature in Deg C (-256 .. +255)
See also
AONBatMonNewTempMeasureReady(), AONBatMonMeasurementCycleSet(), AONBatMonTemperatureGet()

Definition at line 55 of file aon_batmon.c.

Referenced by OSCHF_GetStartupTime(), OSCHF_SwitchToRcOscTurnOffXosc(), SysCtrlAdjustRechargeAfterPowerDown(), and SysCtrlSetRechargeBeforePowerDown().

__STATIC_INLINE void AONBatMonBatteryTrimSet ( uint32_t  ui32TrimP0,
uint32_t  ui32TrimP1 
)

Set the trim values for the battery voltage calculation.

The trim value must be setup correctly before enabling the battery voltage measurement, to ensure correct calculation and system behaviour. The output from the battery monitor measurement is a 10 bit vector with a 2 bit integer part and an 8 bit fractional part in the range 0 to 3,9961 volt.

          (352 + ui32TrimP1)    (128 + ui32TrimP0) x Vbmon
  Vout = ------------------- + -----------------------------
                2^8                      2^12
Parameters
ui32TrimP0is a 6 bit trim value.
ui32TrimP1is a 6 bit trim value.
Returns
None
See also
AONBatMonTemperatureTrimSet()

Definition at line 230 of file aon_batmon.h.

__STATIC_INLINE uint32_t AONBatMonBatteryVoltageGet ( void  )

Get the battery monitor measurement.

This function will return the current battery monitor measurement. The battery voltage measurements are updated every cycle as defined using AONBatMonMeasurementCycleSet().

Note
The returned value is NOT sign-extended!
Use the function AONBatMonNewBatteryMeasureReady() to test for a change in measurement.
Returns
Returns the current battery monitor value of the battery voltage measurement in a <int.frac> format size <3.8> in units of volt.
See also
AONBatMonMeasurementCycleSet(), AONBatMonNewBatteryMeasureReady()

Definition at line 367 of file aon_batmon.h.

__STATIC_INLINE void AONBatMonDisable ( void  )

Disable the temperatur and battery monitoring.

This function will disable the measurements of the temperature and the battery voltage.

Returns
None

Definition at line 138 of file aon_batmon.h.

__STATIC_INLINE void AONBatMonEnable ( void  )

Enable the temperatur and battery monitoring.

This function will enable the measurements of the temperature and the battery voltage.

To speed up the measurement of the levels the measurement can be enabled before configuring the battery and temperatur settings. When all of the AON_BATMON registers are configured, the calculation of the voltage and temperature values can be enabled (the measurement will now take effect/propagate to other blocks).

It is possible to enable both at the same time, after the AON_BATMON registers are configured, but then the first values will be ready at a later point compared to the scenario above.

Note
Temperature and battery voltage measurements are not done in parallel. The measurement cycle is controlled by a hardware Finite State Machine. First the temperature and then the battery voltage each taking one cycle to complete. However, if the comparator measuring the battery voltage detects a change on the reference value, a new measurement of the battery voltage only is performed immediately after. This has no impact on the cycle count.
Returns
None

Definition at line 117 of file aon_batmon.h.

__STATIC_INLINE uint32_t AONBatMonMeasurementCycleGet ( void  )

Get the measurement cycle for the temperature and the battery voltage.

This function returns the value of the register AON_BATMON_O_MEASCFG which contains the settings for the measurement interval.

Returns
Returns the current setting of the measurement period configuration.
See also
AONBatMonMeasurementCycleSet()

Definition at line 196 of file aon_batmon.h.

__STATIC_INLINE void AONBatMonMeasurementCycleSet ( uint32_t  ui32Cycle)

Adjust the measurement cycle for the temperature and the battery voltage.

The AON battery and temperature monitor can measure continously or wait a predefined number of BATMON clock cycles between each measurement. This function is used to adjust the length of the measurement cycle in number of BATMON clock cycles.

Parameters
ui32Cycledefines the number of clock cycles between each measurement.
Returns
None
See also
AONBatMonMeasurementCycleGet()

Definition at line 167 of file aon_batmon.h.

__STATIC_INLINE bool AONBatMonNewBatteryMeasureReady ( void  )

Check if battery monitor measurement has changed.

This function checks if a new battery monitor value is available. If the measurement value has changed since last clear the function returns true.

If the measurement has changed the function will automatically clear the status bit.

Note
It is always possible to read out the current value of the battery level using AONBatMonBatteryVoltageGet() but this function can be used to check if the measurement has changed.
Returns
Returns true if the measurement value has changed and false otherwise.
See also
AONBatMonNewTempMeasureReady(), AONBatMonBatteryVoltageGet()

Definition at line 400 of file aon_batmon.h.

__STATIC_INLINE bool AONBatMonNewTempMeasureReady ( void  )

Check if temperature monitor measurement has changed.

This function checks if a new temperature value is available. If the measurement value has changed since last clear the function returns true.

If the measurement has changed the function will automatically clear the status bit.

Note
It is always possible to read out the current value of the temperature using AONBatMonTemperatureGet() or AON_BatmonTempGetDegC() but this function can be used to check if the measurement has changed.
Returns
Returns true if the measurement value has changed and false otherwise.
See also
AONBatMonNewBatteryMeasureReady(), AONBatMonTemperatureGet(), AON_BatmonTempGetDegC()

Definition at line 445 of file aon_batmon.h.

__STATIC_INLINE uint32_t AONBatMonTemperatureGet ( void  )

Get the current temperature measurement.

This function will return the current temperature measurement. The temperature measurements are updated every cycle as defined using AONBatMonMeasurementCycleSet().

Note
The returned value is NOT sign-extended!
The temperature drifts slightly depending on the battery voltage. This function is a raw read and does not compensate for this drift. Use function AON_BatmonTempGetDegC() to get a calibrated value.
Use the function AONBatMonNewTempMeasureReady() to test for a change in measurement.
Returns
Returns the current value of the temperature measurement in a <int.frac> format size <9.2>.
See also
AONBatMonNewTempMeasureReady(), AONBatMonMeasurementCycleSet(), AON_BatmonTempGetDegC()

Definition at line 315 of file aon_batmon.h.

__STATIC_INLINE void AONBatMonTemperatureTrimSet ( uint32_t  ui32TrimP0,
uint32_t  ui32TrimP1,
uint32_t  ui32TrimP2 
)

Set the trim values for the temperature calculation.

The trim value must be setup correctly before enabling the temperature measurement, to ensure correct calculation and system behaviour.The output from the temperature monitor measurement is a signed 10 bit vector with an 8 bit integer part and a 2 bit fractional part in the range -128 C to +127,75 C with a resolution of 0,25 C.

          (-384 + ui32TrimP2)    (256 + ui32TrimP1) x Temp     (64 + ui32TrimP0) x Temp^2
  Vout = ------------------- + ---------------------------- + ----------------------------
                2^2                       2^8                            2^12
Parameters
ui32TrimP0is an 8 bit trim value.
ui32TrimP1is a 6 bit trim value.
ui32TrimP2is a 5 bit trim value.
Returns
None
See also
AONBatMonBatteryTrimSet()

Definition at line 273 of file aon_batmon.h.

Macro Definition Documentation

#define AON_BATMON_CYCLE_16   AON_BATMON_MEASCFG_PER_16CYC

Definition at line 76 of file aon_batmon.h.

Referenced by AONBatMonMeasurementCycleSet().

#define AON_BATMON_CYCLE_32   AON_BATMON_MEASCFG_PER_32CYC

Definition at line 74 of file aon_batmon.h.

Referenced by AONBatMonMeasurementCycleSet().

#define AON_BATMON_CYCLE_8   AON_BATMON_MEASCFG_PER_8CYC

Definition at line 78 of file aon_batmon.h.

Referenced by AONBatMonMeasurementCycleSet().

#define AON_BATMON_CYCLE_CONT   AON_BATMON_MEASCFG_PER_CONT

Definition at line 80 of file aon_batmon.h.

Referenced by AONBatMonMeasurementCycleSet().