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 | opt-3001-sensor.c |
Driver for the Sensortag Opt3001 light sensor. | |
file | opt-3001-sensor.h |
Header file for the Sensortag Opt3001 light sensor. | |
Functions | |
static void | select_on_bus (void) |
Select the sensor on the I2C bus. | |
static void | enable_sensor (bool enable) |
Turn the sensor on/off. More... | |
static bool | read_data (uint16_t *raw_data) |
Read the result register. More... | |
static float | convert (uint16_t raw_data) |
Convert raw data to a value in lux. More... | |
static int | value (int type) |
Returns a reading from the sensor. More... | |
static int | configure (int type, int enable) |
Configuration function for the OPT3001 sensor. More... | |
static int | status (int type) |
Returns the status of the sensor. More... | |
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 reading and conversion are complete, the driver will generate a sensors_changed event.
We use single-shot readings. In this mode, the hardware automatically goes back to its shutdown mode after the conversion is finished. However, it will still respond to I2C operations, so the last conversion can still be read out.
In order to take a new reading, the caller has to use SENSORS_ACTIVATE again.
|
static |
Configuration function for the OPT3001 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 278 of file opt-3001-sensor.c.
|
static |
Convert raw data to a value in lux.
raw_data | data Pointer to a buffer with a raw sensor reading |
Definition at line 230 of file opt-3001-sensor.c.
|
static |
Turn the sensor on/off.
enable | TRUE: on, FALSE: off |
Definition at line 168 of file opt-3001-sensor.c.
|
static |
Read the result register.
raw_data | Pointer to a buffer to store the reading |
Definition at line 196 of file opt-3001-sensor.c.
Referenced by value().
|
static |
Returns the status of the sensor.
type | ignored |
Definition at line 314 of file opt-3001-sensor.c.
|
static |
Returns a reading from the sensor.
type | Ignored |
Definition at line 246 of file opt-3001-sensor.c.
References read_data().