static uint8_t battMeasure(void)
{
uint32_t percent;
// Call measurement setup callback
if (battServiceSetupCB != NULL)
{
battServiceSetupCB();
}
// Read the battery voltage (V), only the first 12 bits
percent = AONBatMonBatteryVoltageGet();
// Convert to from V to mV to avoid fractions.
// Fractional part is in the lower 8 bits thus converting is done as follows:
// (1/256)/(1/1000) = 1000/256 = 125/32
// This is done most effectively by multiplying by 125 and then shifting
// 5 bits to the right.
percent = (percent * 125) >> 5;
// Convert to percentage of maximum voltage.
percent = ((percent* 100) / battMaxLevel);
// Call measurement teardown callback
if (battServiceTeardownCB != NULL)
{
battServiceTeardownCB();
}
return percent;
}
代码如上,
AONBatMonBatteryVoltageGet 这个函数接口是怎样获取到电池电压的?