Contiki-NG
|
Files | |
file | tmp-007-sensor.c |
Driver for the Sensortag TI TMP-007 IR Thermophile sensor. | |
file | tmp-007-sensor.h |
Header file for the Sensortag TMP-007 IR Thermophile sensor. | |
Macros | |
#define | VAL_CONFIG_ON 0x1000 |
Sensor on state. | |
#define | VAL_CONFIG_OFF 0x0000 |
Sensor off state. | |
#define | VAL_PROD_ID 0x0078 |
Product ID. | |
Functions | |
static bool | sensor_init (void) |
Initialize the TMP-007 sensor driver. | |
static void | notify_ready_cb (void *not_used) |
Callback when sensor is ready to read data from. | |
static bool | enable_sensor (bool enable) |
Turn the sensor on or off. | |
static bool | read_data (uint16_t *local_tmp, uint16_t *obj_tmp) |
Read the sensor value registers. | |
static void | convert (uint16_t *local_tmp, uint16_t *obj_tmp) |
Convert raw data to values in degrees Celsius. | |
static int | value (int type) |
Returns a reading from the sensor. | |
static int | configure (int type, int enable) |
Configuration function for the TMP-007 sensor. | |
static int | status (int type) |
Returns the status of the sensor. | |
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: - Turn the sensor off by calling SENSORS_DEACTIVATE, but in order to take subsequent readings SENSORS_ACTIVATE must be called again. - Leave the sensor on. In this scenario, the caller can simply keep calling value(TMP_007_SENSOR_TYPE_ALL) to read and latch new values. However keeping the sensor on will consume more energy.
|
static |
Configuration function for the TMP-007 sensor.
type | Activate, enable or disable the sensor. See below. |
enable | Enable or disable sensor. When 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 336 of file tmp-007-sensor.c.
References configure(), ctimer_set(), ctimer_stop(), enable_sensor(), notify_ready_cb(), and sensor_init().
Referenced by configure().
|
static |
Convert raw data to values in degrees Celsius.
local_tmp | Output variable holding the raw ambient temperature from sensor. |
obj_tmp | Output variable holding the raw object temperature from sensor. |
Definition at line 270 of file tmp-007-sensor.c.
References value().
|
static |
Turn the sensor on or off.
< Sensor on state
< Sensor off state
Definition at line 174 of file tmp-007-sensor.c.
References i2c_arch_acquire(), i2c_arch_release(), i2c_arch_write(), VAL_CONFIG_OFF, VAL_CONFIG_ON, and value().
|
static |
Read the sensor value registers.
local_tmp | Output variable holding the Temperature in 16-bit format. |
obj_tmp | Output variable holding the Object temperature in 16-bit format. |
Definition at line 207 of file tmp-007-sensor.c.
References i2c_arch_acquire(), i2c_arch_release(), i2c_arch_write_read(), and value().
|
static |
Initialize the TMP-007 sensor driver.
Definition at line 144 of file tmp-007-sensor.c.
References value().
Referenced by configure().
|
static |
Returns the status of the sensor.
type | Ignored. |
Definition at line 378 of file tmp-007-sensor.c.
References value().
|
static |
Returns a reading from the sensor.
type | TMP_007_SENSOR_TYPE_OBJECT or TMP_007_SENSOR_TYPE_AMBIENT. |
Definition at line 288 of file tmp-007-sensor.c.
References convert(), read_data(), and value().
Referenced by convert(), enable_sensor(), read_data(), sensor_init(), status(), and value().