Adjust AON BatMon usage

This commit is contained in:
George Oikonomou 2015-04-20 08:03:08 +01:00
parent 32840db66b
commit 5f4154a0e3
4 changed files with 7 additions and 18 deletions

View File

@ -61,28 +61,25 @@ static int enabled = SENSOR_STATUS_DISABLED;
* \brief Returns a reading from the sensor
* \param type BATMON_SENSOR_TYPE_TEMP or BATMON_SENSOR_TYPE_VOLT
*
* \return The raw sensor reading, not converted to human-readable form
* \return The value as returned by the respective CC26xxware function
*/
static int
value(int type)
{
uint32_t tmp_value;
if(enabled == SENSOR_STATUS_DISABLED) {
PRINTF("Sensor Disabled\n");
return 0;
}
if(type == BATMON_SENSOR_TYPE_TEMP) {
tmp_value = ti_lib_aon_batmon_temperature_get();
return (int)ti_lib_aon_batmon_temperature_get_deg_c();
} else if(type == BATMON_SENSOR_TYPE_VOLT) {
tmp_value = ti_lib_aon_batmon_battery_voltage_get();
return (int)ti_lib_aon_batmon_battery_voltage_get();
} else {
PRINTF("Invalid type\n");
return 0;
}
return (int)tmp_value;
return 0;
}
/*---------------------------------------------------------------------------*/
/**
@ -101,7 +98,6 @@ configure(int type, int enable)
switch(type) {
case SENSORS_HW_INIT:
ti_lib_aon_batmon_enable();
ti_lib_aon_batmon_measurement_cycle_set(AON_BATMON_CYCLE_32);
enabled = SENSOR_STATUS_ENABLED;
break;
case SENSORS_ACTIVE:

View File

@ -57,12 +57,7 @@
#define ti_lib_aon_batmon_enable(...) AONBatMonEnable(__VA_ARGS__)
#define ti_lib_aon_batmon_disable(...) AONBatMonDisable(__VA_ARGS__)
#define ti_lib_aon_batmon_measurement_cycle_set(...) AONBatMonMeasurementCycleSet(__VA_ARGS__)
#define ti_lib_aon_batmon_measurement_cycle_get(...) AONBatMonMeasurementCycleGet(__VA_ARGS__)
#define ti_lib_aon_batmon_battery_trim_set(...) AONBatMonBatteryTrimSet(__VA_ARGS__)
#define ti_lib_aon_batmon_temperature_trim_set(...) AONBatMonTemperatureTrimSet(__VA_ARGS__)
#define ti_lib_aon_batmon_temperature_get(...) AONBatMonTemperatureGet(__VA_ARGS__)
#define ti_lib_aon_batmon_temp_get_deg(...) AON_BatmonTempGetDegC(__VA_ARGS__)
#define ti_lib_aon_batmon_temperature_get_deg_c(...) AONBatMonTemperatureGetDegC(__VA_ARGS__)
#define ti_lib_aon_batmon_battery_voltage_get(...) AONBatMonBatteryVoltageGet(__VA_ARGS__)
#define ti_lib_aon_batmon_new_battery_measure_ready(...) AONBatMonNewBatteryMeasureReady(__VA_ARGS__)
#define ti_lib_aon_batmon_new_temp_measure_ready(...) AONBatMonNewTempMeasureReady(__VA_ARGS__)

View File

@ -329,8 +329,7 @@ get_sync_sensor_readings(void)
printf("-----------------------------------------\n");
value = batmon_sensor.value(BATMON_SENSOR_TYPE_TEMP);
printf("Bat: Temp=%d.%02d C (%08x)\n", value >> 2,
(value & 0x00000003) * 25, value);
printf("Bat: Temp=%d C\n", value);
value = batmon_sensor.value(BATMON_SENSOR_TYPE_VOLT);
printf("Bat: Volt=%d mV\n", (value * 125) >> 5);

View File

@ -392,8 +392,7 @@ get_batmon_reading(void *data)
buf = batmon_temp_reading.converted;
memset(buf, 0, CC26XX_WEB_DEMO_CONVERTED_LEN);
snprintf(buf, CC26XX_WEB_DEMO_CONVERTED_LEN, "%d.%02d", value >> 2,
(value & 0x00000003) * 25);
snprintf(buf, CC26XX_WEB_DEMO_CONVERTED_LEN, "%d", value);
}
}