/* Probes the connected supply and determines its type. The results are stored in global variables.  */
void UTIL_supplyProbe(void)
/* Probes the connected supply and determines its type. The results are stored in global variables.  */
void UTIL_supplyProbe(void)
{
   SI7021_init();
   uint8_t type;
   float r, v;
   type = UTIL_SUPPLY_TYPE_UNKNOWN;
   v = measureSupplyVoltage( 16 );
   r = measureSupplyIR( 0x00 );
   if( r > 5.0 ) {
      type = UTIL_SUPPLY_TYPE_CR2032;
   }
   else if( ( v < 3.20 ) || ( r > 0.5 ) ) {
      type = UTIL_SUPPLY_TYPE_AAA;
   }
   else {
      type = UTIL_SUPPLY_TYPE_USB;
   }
   UTIL_supplyVoltage = v;
   UTIL_supplyIR = r;
   UTIL_supplyType = type;
   SI7021_deInit();
   return;
}