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:
Benoît Thébaudeau 2015-05-14 19:21:56 +02:00
commit d64927397f
13 changed files with 404 additions and 56 deletions

View File

@ -52,7 +52,7 @@ CONTIKI_CPU_SOURCEFILES += nvic.c cpu.c sys-ctrl.c gpio.c ioc.c spi.c adc.c
CONTIKI_CPU_SOURCEFILES += cc2538-rf.c udma.c lpm.c
CONTIKI_CPU_SOURCEFILES += dbg.c ieee-addr.c
CONTIKI_CPU_SOURCEFILES += slip-arch.c slip.c
CONTIKI_CPU_SOURCEFILES += i2c.c
CONTIKI_CPU_SOURCEFILES += i2c.c cc2538-temp-sensor.c vdd3-sensor.c
DEBUG_IO_SOURCEFILES += dbg-printf.c dbg-snprintf.c dbg-sprintf.c strformat.c

View File

@ -0,0 +1,72 @@
/*
* Copyright (c) 2015, Zolertia - http://www.zolertia.com
* Copyright (c) 2015, University of Bristol - http://www.bristol.ac.uk
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup cc2538
* @{
*
* \defgroup cc2538-sensors CC2538 Built-In Sensors
*
* Module controlling sensors on the CC2538 SoC (Tmp and VDD3)
* @{
*
* \file
* Generic header usable by all CC2538 sensor drivers
*/
/*---------------------------------------------------------------------------*/
#ifndef CC2538_SENSORS_H_
#define CC2538_SENSORS_H_
/*---------------------------------------------------------------------------*/
#include "lib/sensors.h"
#include "dev/cc2538-temp-sensor.h"
#include "dev/vdd3-sensor.h"
/*---------------------------------------------------------------------------*/
/**
* \name CC2538 sensor constants
*
* These constants are used by various sensors on the CC2538. They can be used
* to differentiate between raw and converted readings, to configure ADC
* decimation rate (where applicable).
* @{
*/
#define CC2538_SENSORS_VALUE_TYPE_RAW 0 /**< Request the raw reading */
#define CC2538_SENSORS_VALUE_TYPE_CONVERTED 1 /**< Request the converted reading */
#define CC2538_SENSORS_ERROR 0x80000000 /**< Generic Error */
/** @} */
/*---------------------------------------------------------------------------*/
#endif /* CC2538_SENSORS_H_ */
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

View File

@ -0,0 +1,77 @@
/*
* Copyright (c) 2015, Zolertia - http://www.zolertia.com
* Copyright (c) 2015, University of Bristol - http://www.bristol.ac.uk
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup cc2538-temp-sensor
* @{
*
* \file
* Driver for the CC2538 On-Chip temperature sensor
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "lib/sensors.h"
#include "dev/adc.h"
#include "dev/cc2538-sensors.h"
#include <stdint.h>
/*---------------------------------------------------------------------------*/
static int
value(int type)
{
int raw = adc_get(SOC_ADC_ADCCON_CH_TEMP, SOC_ADC_ADCCON_REF_INT,
SOC_ADC_ADCCON_DIV_512);
if(type == CC2538_SENSORS_VALUE_TYPE_RAW) {
return raw;
} else if(type == CC2538_SENSORS_VALUE_TYPE_CONVERTED) {
return 25000 + ((raw >> 4) - 1422) * 10000 / 42;
}
return CC2538_SENSORS_ERROR;
}
/*---------------------------------------------------------------------------*/
static int
configure(int type, int value)
{
return 0;
}
/*---------------------------------------------------------------------------*/
static int
status(int type)
{
return 1;
}
/*---------------------------------------------------------------------------*/
SENSORS_SENSOR(cc2538_temp_sensor, TEMP_SENSOR, value, configure, status);
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -0,0 +1,71 @@
/*
* Copyright (c) 2015, Zolertia - http://www.zolertia.com
* Copyright (c) 2015, University of Bristol - http://www.bristol.ac.uk
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup cc2538-sensors
* @{
*
* \defgroup cc2538-temp-sensor CC2538 on-chip temperature Sensor
*
* Driver for the CC2538 on-chip temperature sensor
*
* This driver can return the raw as well as the converted value of the sensor
* reading. This is controlled by the type argument of the sensor driver's
* value() function. The choices for the type argument are:
* - CC2538_SENSORS_VALUE_TYPE_RAW (value() returns the raw reading)
* - CC2538_SENSORS_VALUE_TYPE_CONVERTED (value() returns degrees mC)
* @{
*
* \file
* Header file for the CC2538 on-chip temperature Sensor Driver
*/
/*---------------------------------------------------------------------------*/
#ifndef CC2538_TEMP_SENSOR_H_
#define CC2538_TEMP_SENSOR_H_
/*---------------------------------------------------------------------------*/
#include "lib/sensors.h"
/*---------------------------------------------------------------------------*/
/**
* \name temperature sensor
* @{
*/
#define TEMP_SENSOR "On-Chip Temperature"
/** @} */
/*---------------------------------------------------------------------------*/
extern const struct sensors_sensor cc2538_temp_sensor;
/*---------------------------------------------------------------------------*/
#endif /* CC2538_TEMP_SENSOR_H_ */
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

View File

@ -0,0 +1,78 @@
/*
* Copyright (c) 2015, Zolertia - http://www.zolertia.com
* Copyright (c) 2015, University of Bristol - http://www.bristol.ac.uk
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup cc2538-vdd3-sensor
* @{
*
* \file
* Driver for the CC2538 VDD3 sensor
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "lib/sensors.h"
#include "dev/vdd3-sensor.h"
#include "dev/adc.h"
#include "dev/cc2538-sensors.h"
#include <stdint.h>
/*---------------------------------------------------------------------------*/
static int
value(int type)
{
int raw = adc_get(SOC_ADC_ADCCON_CH_VDD_3, SOC_ADC_ADCCON_REF_INT,
SOC_ADC_ADCCON_DIV_512);
if(type == CC2538_SENSORS_VALUE_TYPE_RAW) {
return raw;
} else if(type == CC2538_SENSORS_VALUE_TYPE_CONVERTED) {
return raw * (3 * 1190) / (2047 << 4);
}
return CC2538_SENSORS_ERROR;
}
/*---------------------------------------------------------------------------*/
static int
configure(int type, int value)
{
return 0;
}
/*---------------------------------------------------------------------------*/
static int
status(int type)
{
return 1;
}
/*---------------------------------------------------------------------------*/
SENSORS_SENSOR(vdd3_sensor, VDD3_SENSOR, value, configure, status);
/*---------------------------------------------------------------------------*/
/** @} */

View File

@ -0,0 +1,71 @@
/*
* Copyright (c) 2015, Zolertia - http://www.zolertia.com
* Copyright (c) 2015, University of Bristol - http://www.bristol.ac.uk
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*---------------------------------------------------------------------------*/
/**
* \addtogroup cc2538-sensors
* @{
*
* \defgroup cc2538-vdd3-sensor CC2538 VDD3 Sensor
*
* Driver for the CC2538 VDD3 sensor
*
* This driver can return the raw as well as the converted value of the sensor
* reading. This is controlled by the type argument of the sensor driver's
* value() function. The choices for the type argument are:
* - REMOTE_SENSORS_VALUE_TYPE_RAW (value() returns the raw reading)
* - REMOTE_SENSORS_VALUE_TYPE_CONVERTED (value() returns mV)
* @{
*
* \file
* Header file for the CC2538 VDD3 Sensor Driver
*/
/*---------------------------------------------------------------------------*/
#ifndef VDD3_SENSOR_H_
#define VDD3_SENSOR_H_
/*---------------------------------------------------------------------------*/
#include "lib/sensors.h"
/*---------------------------------------------------------------------------*/
/**
* \name VDD3 sensors
* @{
*/
#define VDD3_SENSOR "VDD3"
/** @} */
/*---------------------------------------------------------------------------*/
extern const struct sensors_sensor vdd3_sensor;
/*---------------------------------------------------------------------------*/
#endif /* VDD3_SENSOR_H_ */
/*---------------------------------------------------------------------------*/
/**
* @}
* @}
*/

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,

View File

@ -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);

View File

@ -9,7 +9,7 @@ CONTIKI_TARGET_DIRS = . dev
CONTIKI_TARGET_SOURCEFILES += leds.c leds-arch.c
CONTIKI_TARGET_SOURCEFILES += contiki-main.c
CONTIKI_TARGET_SOURCEFILES += sensors.c smartrf-sensors.c
CONTIKI_TARGET_SOURCEFILES += button-sensor.c adc-sensor.c
CONTIKI_TARGET_SOURCEFILES += button-sensor.c als-sensor.c
CONTIKI_SOURCEFILES += $(CONTIKI_TARGET_SOURCEFILES)

View File

@ -43,6 +43,7 @@
*/
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "dev/adc.h"
#include "dev/leds.h"
#include "dev/sys-ctrl.h"
#include "dev/scb.h"
@ -208,6 +209,8 @@ main(void)
process_start(&tcpip_process, NULL);
#endif /* NETSTACK_CONF_WITH_IPV6 */
adc_init();
process_start(&sensors_process, NULL);
energest_init();

View File

@ -30,18 +30,18 @@
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/**
* \addtogroup cc2538dk-adc-sensor
* \addtogroup cc2538dk-als-sensor
* @{
*
* \file
* Driver for the SmartRF06EB ADC
* Driver for the SmartRF06EB ALS
*/
#include "contiki.h"
#include "sys/clock.h"
#include "dev/ioc.h"
#include "dev/gpio.h"
#include "dev/adc.h"
#include "dev/adc-sensor.h"
#include "dev/als-sensor.h"
#include <stdint.h>
@ -52,30 +52,15 @@
static int
value(int type)
{
uint8_t channel;
uint8_t channel = SOC_ADC_ADCCON_CH_AIN0 + ADC_ALS_OUT_PIN;
int16_t res;
switch(type) {
case ADC_SENSOR_VDD_3:
channel = SOC_ADC_ADCCON_CH_VDD_3;
break;
case ADC_SENSOR_TEMP:
channel = SOC_ADC_ADCCON_CH_TEMP;
break;
case ADC_SENSOR_ALS:
channel = SOC_ADC_ADCCON_CH_AIN0 + ADC_ALS_OUT_PIN;
GPIO_SET_PIN(ADC_ALS_PWR_PORT_BASE, ADC_ALS_PWR_PIN_MASK);
clock_delay_usec(2000);
break;
default:
return 0;
}
GPIO_SET_PIN(ADC_ALS_PWR_PORT_BASE, ADC_ALS_PWR_PIN_MASK);
clock_delay_usec(2000);
res = adc_get(channel, SOC_ADC_ADCCON_REF_INT, SOC_ADC_ADCCON_DIV_512);
if(type == ADC_SENSOR_ALS) {
GPIO_CLR_PIN(ADC_ALS_PWR_PORT_BASE, ADC_ALS_PWR_PIN_MASK);
}
GPIO_CLR_PIN(ADC_ALS_PWR_PORT_BASE, ADC_ALS_PWR_PIN_MASK);
return res;
}
@ -94,7 +79,6 @@ configure(int type, int value)
GPIO_SET_INPUT(GPIO_A_BASE, ADC_ALS_OUT_PIN_MASK);
ioc_set_over(GPIO_A_NUM, ADC_ALS_OUT_PIN, IOC_OVERRIDE_ANA);
adc_init();
break;
}
return 0;
@ -106,6 +90,6 @@ status(int type)
return 1;
}
/*---------------------------------------------------------------------------*/
SENSORS_SENSOR(adc_sensor, ADC_SENSOR, value, configure, status);
SENSORS_SENSOR(als_sensor, ALS_SENSOR, value, configure, status);
/** @} */

View File

@ -33,33 +33,29 @@
* \addtogroup cc2538-smartrf-sensors
* @{
*
* \defgroup cc2538dk-adc-sensor cc2538dk ADC Driver
* \defgroup cc2538dk-als-sensor cc2538dk ALS Driver
*
* Driver for the SmartRF06EB ADC sensors
* Driver for the SmartRF06EB ALS sensor
* @{
*
* \file
* Header file for the cc2538dk ADC Driver
* Header file for the cc2538dk ALS Driver
*/
#ifndef ADC_SENSOR_H_
#define ADC_SENSOR_H_
#ifndef ALS_SENSOR_H_
#define ALS_SENSOR_H_
#include "lib/sensors.h"
/*---------------------------------------------------------------------------*/
/** \name ADC sensors
/** \name ALS sensor
* @{
*/
#define ADC_SENSOR "ADC"
#define ADC_SENSOR_VDD_3 0 /**< On-chip VDD / 3 */
#define ADC_SENSOR_TEMP 1 /**< On-chip temperature */
#define ADC_SENSOR_ALS 2 /**< Ambient light sensor */
#define ALS_SENSOR "ALS"
/** @} */
extern const struct sensors_sensor adc_sensor;
extern const struct sensors_sensor als_sensor;
#endif /* ADC_SENSOR_H_ */
#endif /* ALS_SENSOR_H_ */
/**
* @}

View File

@ -42,13 +42,15 @@
*/
#include "contiki.h"
#include "dev/button-sensor.h"
#include "dev/adc-sensor.h"
#include "dev/als-sensor.h"
#include "dev/cc2538-sensors.h"
#include <string.h>
/** \brief Exports a global symbol to be used by the sensor API */
SENSORS(&button_select_sensor, &button_left_sensor, &button_right_sensor,
&button_up_sensor, &button_down_sensor, &adc_sensor);
&button_up_sensor, &button_down_sensor, &als_sensor,
&cc2538_temp_sensor, &vdd3_sensor);
/**
* @}