Sens'it SDK  v2.0.0
ltr329.h
Go to the documentation of this file.
1 /*!******************************************************************
2  * \file ltr329.h
3  * \brief Light sensor
4  * \author Sens'it Team
5  * \copyright Copyright (c) 2018 Sigfox, All Rights Reserved.
6  *
7  * This file provide sample code to use Light sensor (ref: LTR329ALS).<BR>
8  * If you want to use other functionalities of the sensor, please refer
9  * to the datasheet:
10  * http://optoelectronics.liteon.com/upload/download/DS86-2014-0006/LTR-329ALS-01_DS_V1.pdf
11  *******************************************************************/
12 
13 
14 /*!******************************************************************
15  * \defgroup LTR329_REG LTR329 Registers
16  * \brief Address of LTR329 registers
17  *
18  * @{
19  *******************************************************************/
20 #define LTR329_ALS_CONTR 0x80
21 #define LTR329_ALS_MEAS_RATE 0x85
22 #define LTR329_PART_ID 0x86
23 #define LTR329_MANUFAC_ID 0x87
24 #define LTR329_ALS_DATA_CH1_0 0x88
25 #define LTR329_ALS_DATA_CH1_1 0x89
26 #define LTR329_ALS_DATA_CH0_0 0x8A
27 #define LTR329_ALS_DATA_CH0_1 0x8B
28 #define LTR329_ALS_STATUS 0x8C
32 /*!******************************************************************
33  * \defgroup LTR329_ERR_CODES LTR329 Error Codes
34  * \brief Error code definitions for LTR329
35  *
36  * @{
37  *******************************************************************/
38 #define LTR329_ERR_NONE 0x00
40 #define LTR329_ERR_I2C 0x40
41 #define LTR329_ERR_ID 0x41
42 #define LTR329_ERR_GAIN 0x42
43 #define LTR329_ERR_MEASURE_TIMEOUT 0x43
47 /*!******************************************************************
48  * \enum ltr329_gain_e
49  * \brief Setting for light sensor gain.
50  *******************************************************************/
51 typedef enum {
52  LTR329_GAIN_1X = 0b000,
53  LTR329_GAIN_2X = 0b001,
54  LTR329_GAIN_4X = 0b010,
55  LTR329_GAIN_8X = 0b011,
58  LTR329_GAIN_48X = 0b110,
59  LTR329_GAIN_96X = 0b111,
60  LTR329_GAIN_LAST
62 
63 
64 /*!******************************************************************
65  * \defgroup LTR329_API LTR329 APIs
66  * \brief Light sensor sample code functions
67  *
68  * @{
69  *******************************************************************/
70 
71 /*!******************************************************************
72  * \fn error_t LTR329_init(void)
73  * \brief Configure sensor with measurement rate of 2s &
74  * integration time of 50ms.<BR>
75  * Sensor is in stand-by mode.
76  *
77  * \retval LTR329_ERR_NONE: No error
78  * \retval LTR329_ERR_I2C: Error on I2C communication
79  * \retval LTR329_ERR_ID: Bad ID value
80  *******************************************************************/
81 error_t LTR329_init(void);
82 
83 /*!******************************************************************
84  * \fn error_t LTR329_set_standby_mode(void)
85  * \brief Put sensor in stand-by mode.
86  *
87  * \retval LTR329_ERR_NONE: No error
88  * \retval LTR329_ERR_I2C: Error on I2C communication
89  *******************************************************************/
91 
92 /*!******************************************************************
93  * \fn error_t LTR329_set_active_mode(ltr329_gain_e gain)
94  * \brief Put sensor in active mode & configure sensor gain.
95  *
96  * \param[in] gain Light measurement gain
97  *
98  * \retval LTR329_ERR_NONE: No error
99  * \retval LTR329_ERR_I2C: Error on I2C communication
100  * \retval LTR329_ERR_GAIN: Gain has an invalid value
101  *******************************************************************/
103 
104 /*!******************************************************************
105  * \fn error_t LTR329_measure(u16* light_ch0, u16* light_ch1)
106  * \brief Get a light measurement.<BR>
107  * Values must be divided by the configured gain to convert it in lux.
108  *
109  * \param[out] light_ch0 Light level on channel 0 (visible)
110  * \param[out] light_ch1 Light level on channel 1 (infrared)
111  *
112  * \retval LTR329_ERR_NONE: No error
113  * \retval LTR329_ERR_I2C: Error on I2C communication
114  * \retval LTR329_ERR_MEASURE_TIMEOUT: Error, measurement is too long
115  *******************************************************************/
116 error_t LTR329_measure(u16* light_ch0,
117  u16* light_ch1);
118 
Definition: ltr329.h:58
error_t LTR329_init(void)
Configure sensor with measurement rate of 2s & integration time of 50ms. Sensor is in stand-by mode...
error_t LTR329_set_active_mode(ltr329_gain_e gain)
Put sensor in active mode & configure sensor gain.
unsigned short u16
Definition: sensit_types.h:12
Definition: ltr329.h:57
ltr329_gain_e
Setting for light sensor gain.
Definition: ltr329.h:51
Definition: ltr329.h:52
Definition: ltr329.h:56
unsigned char error_t
Definition: sensit_types.h:23
error_t LTR329_measure(u16 *light_ch0, u16 *light_ch1)
Get a light measurement. Values must be divided by the configured gain to convert it in lux...
error_t LTR329_set_standby_mode(void)
Put sensor in stand-by mode.
Definition: ltr329.h:54
Definition: ltr329.h:59
Definition: ltr329.h:55
Definition: ltr329.h:53