Contiki-NG
|
Files | |
file | opt-3001-sensor.c |
Driver for the Sensortag OPT-3001 light sensor. | |
file | opt-3001-sensor.h |
Header file for the Sensortag OPT-3001 light sensor. | |
Functions | |
static bool | sensor_enable (bool enable) |
Turn the sensor on/off. | |
static void | notify_ready_cb (void *unused) |
Callback when sensor is ready to read data from. | |
static int | value (int type) |
Returns a reading from the sensor. | |
static int | configure (int type, int enable) |
Configuration function for the OPT3001 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 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 | 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 298 of file opt-3001-sensor.c.
References configure(), ctimer_set(), ctimer_stop(), notify_ready_cb(), and sensor_enable().
Referenced by configure().
|
static |
Callback when sensor is ready to read data from.
< [7] Conversion Ready Field
Definition at line 185 of file opt-3001-sensor.c.
References CFG_CRF, ctimer_set(), i2c_arch_acquire(), i2c_arch_release(), i2c_arch_write_read(), notify_ready_cb(), and value().
Referenced by configure(), and notify_ready_cb().
|
static |
Turn the sensor on/off.
enable | Enable sensor if true; else, disable sensor. |
Definition at line 156 of file opt-3001-sensor.c.
References i2c_arch_acquire(), i2c_arch_release(), i2c_arch_write(), and value().
Referenced by configure().
|
static |
Returns the status of the sensor.
type | Ignored. |
Definition at line 331 of file opt-3001-sensor.c.
References value().
|
static |
Returns a reading from the sensor.
type | Ignored. |
Definition at line 232 of file opt-3001-sensor.c.
References i2c_arch_acquire(), i2c_arch_release(), i2c_arch_write_read(), and value().
Referenced by notify_ready_cb(), sensor_enable(), status(), and value().