Osram SFH5712 light sensor driver.
This file contains functions for initializing and reading data from a Osram SFH5712 light sensor.
Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.
#include "sfh5712.h"
Functions | |
static bool | sfh5712_device_id (sensor_hal_t *hal, sensor_data_t *data) |
Read SFH5712 device ID and revision numbers. More... | |
static bool | sfh5712_get_light (sensor_hal_t *hal, sensor_data_t *data) |
Read SFH5712 light level data. More... | |
bool | sfh5712_init (sensor_t *sensor, int resvd) |
Osram SFH5712 light sensor driver initialization. More... | |
static bool | sfh5712_ioctl (sensor_t *sensor, sensor_command_t cmd, void *arg) |
SFH5712 ioctl control entry point. More... | |
static bool | sfh5712_read (sensor_t *sensor, sensor_read_t type, sensor_data_t *data) |
Read sensor data. More... | |
static bool | sfh5712_set_state (sensor_hal_t *hal, sensor_state_t state) |
Set the SFH5712 execution mode. More... | |
|
static |
Read SFH5712 device ID and revision numbers.
This function reads the sensor hardware identification registers and returns these values in the specified data structure.
hal | Address of an initialized sensor hardware descriptor. |
data | Address of sensor_data_t structure to return values. |
References sensor_data_t::device, PART_ID_MASK, PART_ID_SHIFT, PART_REV_MASK, sensor_bus_get, and SFH5712_PART_ID.
Referenced by sfh5712_read().
|
static |
Read SFH5712 light level data.
This function reads the ambient light level data from the sensor and places it in the user-provided sensor_data_t structure.
sensor | Address of an initialized sensor device descriptor. |
data | The address of a vector storing sensor measurement data. |
References sensor_data_t::light, light_data, sensor_bus_read, and SFH5712_ALS_DATA_LSB.
Referenced by sfh5712_read().
Osram SFH5712 light sensor driver initialization.
This is the main initialization function for the SFH5712 device.
sensor | Address of a sensor device descriptor. |
resvd | Reserved value. |
References ALS_MODE_ACTIVE, sensor_desc::drv, sensor_device_t::func, sensor_desc::hal, sensor_funcs_t::read, sensor_hal::resolution, sensor_bus_get, sensor_bus_put, SENSOR_SCALE_one, SENSOR_UNITS_lux, SENSOR_VENDOR_OSRAM, SFH5712_ALS_CONTROL, SFH5712_DATA_RESOLUTION, sfh5712_ioctl(), SFH5712_PART_ID, SFH5712_PART_ID_VAL, SFH5712_PART_REV_VAL, sfh5712_read(), and status.
|
static |
SFH5712 ioctl control entry point.
hal | Address of an initialized sensor hardware descriptor. |
cmd | Command to execute |
arg | Argument for command (varies) |
References sensor_desc::err, sensor_desc::hal, SENSOR_ERR_UNSUPPORTED, SENSOR_SET_STATE, sfh5712_set_state(), and status.
Referenced by sfh5712_init().
|
static |
Read sensor data.
This routine calls the appropriate internal data function to obtain the specified type of data from the sensor device.
sensor | Address of an initialized sensor device descriptor. |
type | Type of sensor data to read. |
data | The address where data values are returned. |
References sensor_desc::err, sensor_desc::hal, SENSOR_ERR_FUNCTION, SENSOR_READ_ID, SENSOR_READ_LIGHT, sfh5712_device_id(), and sfh5712_get_light().
Referenced by sfh5712_init().
|
static |
Set the SFH5712 execution mode.
This routine sets a specified SFH5712 execution state to one of the following:
SENSOR_STATE_SLEEP: Setting the sleep mode puts the sensor in standby mode, in which no measurements are made.
SENSOR_STATE_NORMAL: Setting the sleep mode puts sensor in continuous measurement mode.
hal | Address of an initialized sensor hardware descriptor. |
state | A specified sensor operational state. |
References ALS_MODE_ACTIVE, ALS_MODE_STANDBY, sensor_bus_put, SENSOR_STATE_NORMAL, SENSOR_STATE_SLEEP, and SFH5712_ALS_CONTROL.
Referenced by sfh5712_ioctl().