Re-work the CC2538 demo to use the 3 separate ADC sensors

This commit is contained in:
George Oikonomou 2015-02-11 18:14:01 +01:00 committed by George Oikonomou
parent 4de471478a
commit ac459df128

View file

@ -69,8 +69,9 @@
#include "sys/rtimer.h"
#include "dev/leds.h"
#include "dev/uart.h"
#include "dev/cc2538-sensors.h"
#include "dev/button-sensor.h"
#include "dev/adc-sensor.h"
#include "dev/als-sensor.h"
#include "dev/watchdog.h"
#include "dev/serial-line.h"
#include "dev/sys-ctrl.h"
@ -114,8 +115,6 @@ rt_callback(struct rtimer *t, void *ptr)
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(cc2538_demo_process, ev, data)
{
int16_t value;
PROCESS_EXITHANDLER(broadcast_close(&bc))
PROCESS_BEGIN();
@ -134,15 +133,13 @@ PROCESS_THREAD(cc2538_demo_process, ev, data)
printf("-----------------------------------------\n"
"Counter = 0x%08x\n", counter);
value = adc_sensor.value(ADC_SENSOR_VDD_3);
printf("VDD = %d mV\n", value * (3 * 1190) / (2047 << 4));
printf("VDD = %d mV\n",
vdd3_sensor.value(CC2538_SENSORS_VALUE_TYPE_CONVERTED));
value = adc_sensor.value(ADC_SENSOR_TEMP);
printf("Temperature = %d mC\n",
25000 + ((value >> 4) - 1422) * 10000 / 42);
cc2538_temp_sensor.value(CC2538_SENSORS_VALUE_TYPE_CONVERTED));
value = adc_sensor.value(ADC_SENSOR_ALS);
printf("Ambient light sensor = %d raw\n", value);
printf("Ambient light sensor = %d raw\n", als_sensor.value(0));
etimer_set(&et, CLOCK_SECOND);
rtimer_set(&rt, RTIMER_NOW() + LEDS_OFF_HYSTERISIS, 1,