LCOV - code coverage report
Current view: top level - zephyr/drivers/sensor - veml7700.h Hit Total Coverage
Test: new.info Lines: 6 10 60.0 %
Date: 2024-12-22 00:14:23

          Line data    Source code
       1           0 : /*
       2             :  * Copyright (c) 2023 Andreas Kilian
       3             :  * Copyright (c) 2024 Jeff Welder (Ellenby Technologies, Inc.)
       4             :  *
       5             :  * SPDX-License-Identifier: Apache-2.0
       6             :  */
       7             : 
       8             : #ifndef ZEPHYR_INCLUDE_DRIVERS_SENSOR_VEML7700_H_
       9             : #define ZEPHYR_INCLUDE_DRIVERS_SENSOR_VEML7700_H_
      10             : 
      11             : #ifdef __cplusplus
      12             : extern "C" {
      13             : #endif
      14             : 
      15             : /**
      16             :  * @brief Number of enumerators in enum veml7700_als_gain.
      17             :  */
      18           1 : #define VEML7700_ALS_GAIN_ELEM_COUNT 4
      19             : /**
      20             :  * @brief Number of enumerators in enum veml7700_als_it.
      21             :  */
      22           1 : #define VEML7700_ALS_IT_ELEM_COUNT 6
      23             : 
      24             : /**
      25             :  * @brief Bit mask to check for the low threshold interrupt flag.
      26             :  *
      27             :  * See <tt>SENSOR_ATTR_VEML7700_INT_MODE</tt>
      28             :  * and <tt>SENSOR_CHAN_VEML7700_INTERRUPT</tt>
      29             :  */
      30           1 : #define VEML7700_ALS_INT_LOW_MASK BIT(15)
      31             : /**
      32             :  * @brief Bit mask to check for the high threshold interrupt flag.
      33             :  *
      34             :  * See <tt>SENSOR_ATTR_VEML7700_INT_MODE</tt>
      35             :  * and <tt>SENSOR_CHAN_VEML7700_INTERRUPT</tt>
      36             :  */
      37           1 : #define VEML7700_ALS_INT_HIGH_MASK BIT(14)
      38             : 
      39             : /**
      40             :  * @brief VEML7700 gain options for ambient light measurements.
      41             :  */
      42           0 : enum veml7700_als_gain {
      43             :         VEML7700_ALS_GAIN_1   = 0x00, /* 0b00 */
      44             :         VEML7700_ALS_GAIN_2   = 0x01, /* 0b01 */
      45             :         VEML7700_ALS_GAIN_1_8 = 0x02, /* 0b10 */
      46             :         VEML7700_ALS_GAIN_1_4 = 0x03, /* 0b11 */
      47             : };
      48             : 
      49             : /**
      50             :  * @brief VEML7700 integration time options for ambient light measurements.
      51             :  */
      52           0 : enum veml7700_als_it {
      53             :         VEML7700_ALS_IT_25,
      54             :         VEML7700_ALS_IT_50,
      55             :         VEML7700_ALS_IT_100,
      56             :         VEML7700_ALS_IT_200,
      57             :         VEML7700_ALS_IT_400,
      58             :         VEML7700_ALS_IT_800
      59             : };
      60             : 
      61             : /**
      62             :  * @brief VEML7700 ALS interrupt persistence protect number options.
      63             :  */
      64           0 : enum veml7700_int_mode {
      65             :         VEML7700_INT_DISABLED = 0xFF,
      66             :         VEML7700_ALS_PERS_1   = 0x00, /* 0b00 */
      67             :         VEML7700_ALS_PERS_2   = 0x01, /* 0b01 */
      68             :         VEML7700_ALS_PERS_4   = 0x02, /* 0b10 */
      69             :         VEML7700_ALS_PERS_8   = 0x03, /* 0b11 */
      70             : };
      71             : 
      72             : /**
      73             :  * @brief VEML7700 specific sensor attributes.
      74             :  *
      75             :  * For high and low threshold window settings (ALS_WH and ALS_WL)
      76             :  * use the generic attributes <tt>SENSOR_ATTR_UPPER_THRESH</tt> and
      77             :  * <tt>SENSOR_ATTR_LOWER_THRESH</tt> with 16-bit unsigned integer
      78             :  * values. Both threshold settings are in lux and converted by the
      79             :  * driver to a value compatible with the sensor. This conversion
      80             :  * depends on the current gain and integration time settings. So a
      81             :  * change in gain or integration time usually requires an update of
      82             :  * threshold window settings. To get the correct threshold values
      83             :  * into the sensor update the thresholds -after- a change of gain
      84             :  * or integration time.
      85             :  *
      86             :  * All attributes must be set for the <tt>SENSOR_CHAN_LIGHT</tt> channel.
      87             :  */
      88           1 : enum sensor_attribute_veml7700 {
      89             :         /**
      90             :          * @brief Gain setting for ALS measurements (ALS_GAIN).
      91             :          *
      92             :          * Use enum veml7700_als_gain for attribute values.
      93             :          */
      94             :         SENSOR_ATTR_VEML7700_GAIN = SENSOR_ATTR_PRIV_START,
      95             :         /**
      96             :          * @brief Integration time setting for ALS measurements (ALS_IT).
      97             :          *
      98             :          * Use enum veml7700_als_it for attribute values.
      99             :          */
     100             :         SENSOR_ATTR_VEML7700_ITIME,
     101             :         /**
     102             :          * @brief Enable or disable use of ALS interrupt
     103             :          * (ALS_INT_EN and ALS_PERS).
     104             :          *
     105             :          * Please mind that the VEML7700 does not have an interrupt pin.
     106             :          * That's why this driver does not implement any asynchronous
     107             :          * notification mechanism. Such notifications would require to
     108             :          * periodically query the sensor for it's interrupt state and then
     109             :          * trigger an event based on that state. It's up to the user to
     110             :          * query the interrupt state manually using
     111             :          * <tt>sensor_channel_fetch_chan()</tt> on the
     112             :          * <tt>SENSOR_CHAN_VEML7700_INTERRUPT</tt> channel or using
     113             :          * <tt>sensor_channel_fetch()</tt>.
     114             :          *
     115             :          * Use enum veml7700_int_mode for attribute values.
     116             :          */
     117             :         SENSOR_ATTR_VEML7700_INT_MODE,
     118             : };
     119             : 
     120             : /**
     121             :  * @brief VEML7700 specific sensor channels.
     122             :  */
     123           1 : enum sensor_channel_veml7700 {
     124             :         /**
     125             :          * @brief Channel for raw ALS sensor values.
     126             :          *
     127             :          * This channel represents the raw measurement counts provided by the
     128             :          * sensors ALS register. It is useful for estimating the high/low
     129             :          * threshold window attributes for the sensors interrupt handling.
     130             :          *
     131             :          * You cannot fetch this channel explicitly. Instead, this channel's
     132             :          * value is fetched implicitly using <tt>SENSOR_CHAN_LIGHT</tt>.
     133             :          * Trying to call <tt>sensor_channel_fetch_chan()</tt> with this
     134             :          * enumerator as an argument will result in a <tt>-ENOTSUP</tt>.
     135             :          */
     136             :         SENSOR_CHAN_VEML7700_RAW_COUNTS = SENSOR_CHAN_PRIV_START,
     137             : 
     138             :         /**
     139             :          * @brief Channel for white light sensor values.
     140             :          *
     141             :          * This channel is the White Channel count output of the sensor.
     142             :          * The white channel can be used to correct for light sources with
     143             :          * strong infrared content in the 750-800nm spectrum.
     144             :          */
     145             :         SENSOR_CHAN_VEML7700_WHITE_RAW_COUNTS,
     146             : 
     147             :         /**
     148             :          * @brief This channel is used to query the ALS interrupt state (ALS_INT).
     149             :          *
     150             :          * In order for this channel to provide any meaningful data you need
     151             :          * to enable the ALS interrupt mode using the
     152             :          * <tt>SENSOR_ATTR_VEML7700_INT_MODE</tt> custom sensor attribute.
     153             :          *
     154             :          * It's important to note that the sensor resets it's interrupt state
     155             :          * after retrieving it.
     156             :          */
     157             :         SENSOR_CHAN_VEML7700_INTERRUPT,
     158             : };
     159             : 
     160             : #ifdef __cplusplus
     161             : }
     162             : #endif
     163             : 
     164             : #endif /* ZEPHYR_INCLUDE_DRIVERS_SENSOR_VEML7700_H_ */

Generated by: LCOV version 1.14