Merge pull request #968 from g-oikonomou/cc2538-contrib-on-chip-sensors
Move CC2538 VDD/3 and On-Chip Temp sensors to the CPU dir
This commit is contained in:
commit
d64927397f
13 changed files with 404 additions and 56 deletions
|
@ -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,
|
||||
|
|
|
@ -53,7 +53,7 @@
|
|||
#include "lib/sensors.h"
|
||||
#include "dev/button-sensor.h"
|
||||
#include "dev/leds.h"
|
||||
#include "dev/adc-sensor.h"
|
||||
#include "dev/cc2538-sensors.h"
|
||||
|
||||
#include <string.h>
|
||||
/*---------------------------------------------------------------------------*/
|
||||
|
@ -450,7 +450,6 @@ publish(void)
|
|||
/* Publish MQTT topic in IBM quickstart format */
|
||||
int len;
|
||||
int remaining = APP_BUFFER_SIZE;
|
||||
int16_t value;
|
||||
|
||||
seq_nr_value++;
|
||||
|
||||
|
@ -487,9 +486,8 @@ publish(void)
|
|||
remaining -= len;
|
||||
buf_ptr += len;
|
||||
|
||||
value = adc_sensor.value(ADC_SENSOR_TEMP);
|
||||
len = snprintf(buf_ptr, remaining, ",\"On-Chip Temp (mC)\":%d",
|
||||
25000 + ((value >> 4) - 1422) * 10000 / 42);
|
||||
cc2538_temp_sensor.value(CC2538_SENSORS_VALUE_TYPE_CONVERTED));
|
||||
|
||||
if(len < 0 || len >= remaining) {
|
||||
printf("Buffer too short. Have %d, need %d + \\0\n", remaining, len);
|
||||
|
@ -498,9 +496,8 @@ publish(void)
|
|||
remaining -= len;
|
||||
buf_ptr += len;
|
||||
|
||||
value = adc_sensor.value(ADC_SENSOR_VDD_3);
|
||||
len = snprintf(buf_ptr, remaining, ",\"VDD3 (mV)\":%d",
|
||||
value * (3 * 1190) / (2047 << 4));
|
||||
vdd3_sensor.value(CC2538_SENSORS_VALUE_TYPE_CONVERTED));
|
||||
|
||||
if(len < 0 || len >= remaining) {
|
||||
printf("Buffer too short. Have %d, need %d + \\0\n", remaining, len);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue