Contiki-NG
|
Due to the time required for the sensor to startup, this driver is meant to be used in an asynchronous fashion. More...
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. More... | |
static void | start (void) |
Start measurement. | |
static bool | read_data () |
Take readings from the sensor. More... | |
static void | convert (float *temp, float *hum) |
Convert raw data to temperature and humidity. More... | |
static int | value (int type) |
Returns a reading from the sensor. More... | |
static int | configure (int type, int enable) |
Configuration function for the HDC1000 sensor. More... | |
static int | status (int type) |
Returns the status of the sensor. More... | |
HDC1000 driver states | |
#define | HDC_1000_SENSOR_STATUS_DISABLED 0 |
Not initialised. | |
#define | HDC_1000_SENSOR_STATUS_INITIALISED 1 |
Initialised but idle. | |
#define | HDC_1000_SENSOR_STATUS_TAKING_READINGS 2 |
Readings in progress. | |
#define | HDC_1000_SENSOR_STATUS_READINGS_READY 3 |
Both readings ready. | |
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 |
Definition at line 252 of file hdc-1000-sensor.c.
|
static |
Convert raw data to temperature and humidity.
temp | - converted temperature |
hum | - converted humidity |
Definition at line 186 of file hdc-1000-sensor.c.
|
static |
Take readings from the sensor.
Definition at line 157 of file hdc-1000-sensor.c.
|
static |
Initialise the humidity sensor driver.
Definition at line 123 of file hdc-1000-sensor.c.
|
static |
Returns the status of the sensor.
type | SENSORS_ACTIVE or SENSORS_READY |
Definition at line 289 of file hdc-1000-sensor.c.
|
static |
Returns a reading from the sensor.
type | HDC_1000_SENSOR_TYPE_TEMP or HDC_1000_SENSOR_TYPE_HUMID |
Definition at line 212 of file hdc-1000-sensor.c.