Due to the time required for the sensor to startup, this driver is
meant to be used in an asynchronous fashion.
More...
|
#define | CFG_RN 0x00F0 |
| [15..12] Range Number
|
|
#define | CFG_CT 0x0008 |
| [11] Conversion Time
|
|
#define | CFG_M 0x0006 |
| [10..9] Mode of Conversion
|
|
#define | CFG_OVF 0x0001 |
| [8] Overflow
|
|
#define | CFG_CRF 0x8000 |
| [7] Conversion Ready Field
|
|
#define | CFG_FH 0x4000 |
| [6] Flag High
|
|
#define | CFG_FL 0x2000 |
| [5] Flag Low
|
|
#define | CFG_L 0x1000 |
| [4] Latch
|
|
#define | CFG_POL 0x0800 |
| [3] Polarity
|
|
#define | CFG_ME 0x0400 |
| [2] Mask Exponent
|
|
#define | CFG_FC 0x0300 |
| [1..0] Fault Count
|
|
|
static bool | sensor_enable (bool enable) |
| Turn the sensor on/off. More...
|
|
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. 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.
◆ configure()
static int configure |
( |
int |
type, |
|
|
int |
enable |
|
) |
| |
|
static |
Configuration function for the OPT3001 sensor.
- Parameters
-
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.
◆ sensor_enable()
static bool sensor_enable |
( |
bool |
enable | ) |
|
|
static |
Turn the sensor on/off.
- Parameters
-
enable | Enable sensor if true; else, disable sensor. |
Definition at line 156 of file opt-3001-sensor.c.
◆ status()
static int status |
( |
int |
type | ) |
|
|
static |
Returns the status of the sensor.
- Parameters
-
- Returns
- The state of the sensor SENSOR_STATE_xyz.
Definition at line 331 of file opt-3001-sensor.c.
◆ value()
static int value |
( |
int |
type | ) |
|
|
static |
Returns a reading from the sensor.
- Parameters
-
- Returns
- Illuminance in centilux.
Definition at line 232 of file opt-3001-sensor.c.