Zephyr API Documentation 4.5.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches

Extended public API for the ams OSRAM TSL2522 ambient light sensor. More...

Go to the source code of this file.

Enumerations

enum  sensor_attribute_tsl2522 { SENSOR_ATTR_MEASUREMENT_TIME_STEPS = SENSOR_ATTR_PRIV_START + 1 , SENSOR_ATTR_NUMBER_OF_SAMPLES }
 Custom sensor attribute for TSL2522. More...
enum  sensor_gain_tsl2522 {
  TSL2522_GAIN_MOD_HALF = 0U , TSL2522_GAIN_MOD_1X , TSL2522_GAIN_MOD_2X , TSL2522_GAIN_MOD_4X ,
  TSL2522_GAIN_MOD_8X , TSL2522_GAIN_MOD_16X , TSL2522_GAIN_MOD_32X , TSL2522_GAIN_MOD_64X ,
  TSL2522_GAIN_MOD_128X , TSL2522_GAIN_MOD_256X , TSL2522_GAIN_MOD_512X , TSL2522_GAIN_MOD_1024X ,
  TSL2522_GAIN_MOD_2048X , TSL2522_GAIN_MOD_4096X
}
 Modulator gain settings used in both channels. More...

Detailed Description

Extended public API for the ams OSRAM TSL2522 ambient light sensor.

Channels
SENSOR_CHAN_LIGHT and SENSOR_CHAN_AMBIENT_LIGHT return the illuminance in lux. SENSOR_CHAN_IR returns a normalized count rate in counts per ms at 1x gain (not a photometric unit). Both take the glass attenuation from the devicetree into account. If the sensor was saturated, sensor_channel_get() still fills the value but returns -EOVERFLOW.
Attributes
Attributes are written with sensor_attr_set() and read with sensor_attr_get(). Any of SENSOR_CHAN_ALL, SENSOR_CHAN_AMBIENT_LIGHT, SENSOR_CHAN_LIGHT and SENSOR_CHAN_IR is accepted as channel, the setting always applies to the whole device (both channels). val2 is unused.
  • SENSOR_ATTR_GAIN: val1 is an enumerator of sensor_gain_tsl2522, not the numeric gain factor.
  • SENSOR_ATTR_MEASUREMENT_TIME_STEPS: val1 is the number of 1.388889 us steps (1 ... 2048).
  • SENSOR_ATTR_NUMBER_OF_SAMPLES: val1 is the number of samples per conversion (1 ... 2048).
Note
Changing an attribute restarts the measurement. sensor_sample_fetch() returns -EAGAIN until the first conversion with the new settings has finished.