Contiki-NG
|
Files | |
file | hdc-1000-sensor.c |
Driver for the Sensortag HDC sensor. | |
file | hdc-1000-sensor.h |
Header file for the Sensortag TI HDC1000 sensor. | |
Functions | |
static bool | sensor_init (void) |
Initialise the humidity sensor driver. | |
static void | start (void) |
Start measurement. | |
static bool | read_data () |
Take readings from the sensor. | |
static void | convert (float *temp, float *hum) |
Convert raw data to temperature and humidity. | |
static void | notify_ready (void *not_used) |
static int | value (int type) |
Returns a reading from the sensor. | |
static int | configure (int type, int enable) |
Configuration function for the HDC1000 sensor. | |
static int | status (int type) |
Returns the status of the sensor. | |
Variables | |
static int | enabled = 0 |
Not initialised. | |
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 has taken readings, it will automatically go back to low power mode.
Once the sensor is stable, the driver will retrieve readings from the sensor and latch them. It will then generate a sensors_changed event.
The user can then retrieve readings by calling .value() and by passing either HDC_1000_SENSOR_TYPE_TEMP or HDC_1000_SENSOR_TYPE_HUMID as the argument. Multiple calls to value() will not trigger new readings, they will simply return the most recent latched values.
The user can query the sensor's status by calling .status()
To get a fresh reading, the user must trigger a new reading cycle by calling SENSORS_ACTIVATE().
|
static |
Configuration function for the HDC1000 sensor.
type | Activate, enable or disable the sensor. See below |
enable |
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
< Initialised but idle
< Not initialised
< Not initialised
< Readings in progress
< Initialised but idle
Definition at line 251 of file hdc-1000-sensor.c.
References configure(), ctimer_set(), ctimer_stop(), enabled, HDC_1000_SENSOR_STATUS_DISABLED, HDC_1000_SENSOR_STATUS_INITIALISED, HDC_1000_SENSOR_STATUS_TAKING_READINGS, notify_ready(), sensor_init(), and start().
Referenced by configure().
|
static |
Convert raw data to temperature and humidity.
temp | - converted temperature |
hum | - converted humidity |
Definition at line 186 of file hdc-1000-sensor.c.
References value().
Referenced by value().
|
static |
< Both readings ready
Definition at line 196 of file hdc-1000-sensor.c.
References enabled, HDC_1000_SENSOR_STATUS_READINGS_READY, and read_data().
Referenced by configure().
|
static |
Take readings from the sensor.
Definition at line 157 of file hdc-1000-sensor.c.
References board_i2c_read(), and value().
Referenced by notify_ready(), value(), value(), and value().
|
static |
Initialise the humidity sensor driver.
Definition at line 123 of file hdc-1000-sensor.c.
References sensor_common_write_reg(), and value().
Referenced by configure().
|
static |
Returns the status of the sensor.
type | SENSORS_ACTIVE or SENSORS_READY |
< Not initialised
Definition at line 288 of file hdc-1000-sensor.c.
References enabled, and HDC_1000_SENSOR_STATUS_DISABLED.
|
static |
Returns a reading from the sensor.
type | HDC_1000_SENSOR_TYPE_TEMP or HDC_1000_SENSOR_TYPE_HUMID |
< Both readings ready
Definition at line 212 of file hdc-1000-sensor.c.
References convert(), enabled, HDC_1000_SENSOR_STATUS_READINGS_READY, and value().
Referenced by convert(), notify_ready(), read_data(), sensor_init(), start(), and value().