Contiki-NG
Files | Functions

Due to the time required for the sensor to startup, this driver is meant to be used in an asynchronous fashion. More...

Files

file  tmp-007-sensor.c
 Driver for the Sensortag TI TMP007 infrared thermophile sensor.
 
file  tmp-007-sensor.h
 Header file for the Sensortag TI TMP007 infrared thermophile sensor.
 

Functions

static bool enable_sensor (bool enable)
 Turn the sensor on/off.
 
static bool read_data (uint16_t *raw_temp, uint16_t *raw_obj_temp)
 Read the sensor value registers. More...
 
static void convert (uint16_t raw_temp, uint16_t raw_obj_temp, float *obj, float *amb)
 Convert raw data to values in degrees C. More...
 
static int value (int type)
 Returns a reading from the sensor. More...
 
static int configure (int type, int enable)
 Configuration function for the TMP007 sensor. More...
 
static int status (int type)
 Returns the status of the sensor. More...
 

Detailed Description

Due to the time required for the sensor to startup, this driver is meant to be used in an asynchronous fashion.

The caller must first activate the sensor by calling SENSORS_ACTIVATE(). This will trigger the sensor's startup sequence, but the call will not wait for it to complete so that the CPU can perform other tasks or drop to a low power mode.

Once the sensor is stable, the driver will generate a sensors_changed event.

The caller should then use value(TMP_007_SENSOR_TYPE_ALL) to read sensor values and latch them. Once completed successfully, individual readings can be retrieved with calls to value(TMP_007_SENSOR_TYPE_OBJECT) or value(TMP_007_SENSOR_TYPE_AMBIENT).

Once required readings have been taken, the caller has two options:

Function Documentation

◆ configure()

static int configure ( int  type,
int  enable 
)
static

Configuration function for the TMP007 sensor.

Parameters
typeActivate, enable or disable the sensor. See below
enableWhen type == SENSORS_HW_INIT we turn on the hardware When type == SENSORS_ACTIVE and enable==1 we enable the sensor When type == SENSORS_ACTIVE and enable==0 we disable the sensor

Definition at line 266 of file tmp-007-sensor.c.

◆ convert()

static void convert ( uint16_t  raw_temp,
uint16_t  raw_obj_temp,
float *  obj,
float *  amb 
)
static

Convert raw data to values in degrees C.

Parameters
raw_tempraw ambient temperature from sensor
raw_obj_tempraw object temperature from sensor
objconverted object temperature
ambconverted ambient temperature

Definition at line 191 of file tmp-007-sensor.c.

◆ read_data()

static bool read_data ( uint16_t *  raw_temp,
uint16_t *  raw_obj_temp 
)
static

Read the sensor value registers.

Parameters
raw_tempTemperature in 16 bit format
raw_obj_tempobject temperature in 16 bit format
Returns
TRUE if valid data could be retrieved

Definition at line 149 of file tmp-007-sensor.c.

◆ status()

static int status ( int  type)
static

Returns the status of the sensor.

Parameters
typeSENSORS_ACTIVE or SENSORS_READY
Returns
1 if the sensor is enabled

Definition at line 304 of file tmp-007-sensor.c.

◆ value()

static int value ( int  type)
static

Returns a reading from the sensor.

Parameters
typeTMP_007_SENSOR_TYPE_OBJECT or TMP_007_SENSOR_TYPE_AMBIENT
Returns
Object or Ambient temperature in milli degrees C

Definition at line 212 of file tmp-007-sensor.c.