-
Notifications
You must be signed in to change notification settings - Fork 0
/
veml3235.h
197 lines (166 loc) · 6.27 KB
/
veml3235.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
/**
******************************************************************************
* @file veml3235.h
* @author MCD Application Team
* @brief VEML3235 header driver file
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef VEML3235_H
#define VEML3235_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "veml3235_reg.h"
#include <string.h>
/** @addtogroup BSP
* @{
*/
/** @addtogroup Components
* @{
*/
/** @addtogroup VEML3235
* @{
*/
/** @defgroup VEML3235_Exported_Types
* @{
*/
typedef int32_t (*VEML3235_Init_Func)(void);
typedef int32_t (*VEML3235_DeInit_Func)(void);
typedef int32_t (*VEML3235_GetTick_Func)(void);
typedef int32_t (*VEML3235_WriteReg_Func)(uint16_t, uint16_t, uint8_t *, uint16_t);
typedef int32_t (*VEML3235_ReadReg_Func)(uint16_t, uint16_t, uint8_t *, uint16_t);
typedef int32_t (*VEML3235_IsReady_Func)(uint16_t, uint32_t);
typedef struct
{
VEML3235_Init_Func Init;
VEML3235_DeInit_Func DeInit;
uint16_t ReadAddress;
uint16_t WriteAddress;
VEML3235_IsReady_Func IsReady;
VEML3235_WriteReg_Func WriteReg;
VEML3235_ReadReg_Func ReadReg;
VEML3235_GetTick_Func GetTick;
} VEML3235_IO_t;
typedef struct
{
VEML3235_IO_t IO;
veml3235_ctx_t Ctx;
uint8_t IsInitialized;
uint8_t IsContinuous;
uint8_t IsStarted;
} VEML3235_Object_t;
typedef struct
{
uint8_t NumberOfChannels; /*!< Max: LIGHT_SENSOR_MAX_CHANNELS */
uint8_t FlickerDetection; /*!< Not available: 0, Available: 1 */
uint8_t Autogain; /*!< Not available: 0, Available: 1 */
} VEML3235_Capabilities_t;
typedef struct
{
int32_t (*Init)(VEML3235_Object_t *);
int32_t (*DeInit)(VEML3235_Object_t *);
int32_t (*ReadID)(VEML3235_Object_t *, uint32_t *);
int32_t (*GetCapabilities)(VEML3235_Object_t *, VEML3235_Capabilities_t *);
int32_t (*SetExposureTime)(VEML3235_Object_t *, uint32_t);
int32_t (*GetExposureTime)(VEML3235_Object_t *, uint32_t *);
int32_t (*SetGain)(VEML3235_Object_t *, uint8_t, uint32_t);
int32_t (*GetGain)(VEML3235_Object_t *, uint8_t, uint32_t *);
int32_t (*SetInterMeasurementTime)(VEML3235_Object_t *, uint32_t);
int32_t (*GetInterMeasurementTime)(VEML3235_Object_t *, uint32_t *);
int32_t (*Start)(VEML3235_Object_t *, uint32_t);
int32_t (*Stop)(VEML3235_Object_t *);
int32_t (*StartFlicker)(VEML3235_Object_t *, uint8_t, uint8_t);
int32_t (*StopFlicker)(VEML3235_Object_t *);
int32_t (*GetValues)(VEML3235_Object_t *, uint32_t *);
int32_t (*SetControlMode)(VEML3235_Object_t *, uint32_t, uint32_t);
} VEML3235_Drv_t;
/**
* @}
*/
/** @defgroup VEML3235_Exported_Constants
* @{
*/
/* VEML3235 error codes */
#define VEML3235_OK (0)
#define VEML3235_ERROR (-1)
#define VEML3235_INVALID_PARAM (-2)
/* softowre ID */
#define VEML3235_ID (0x3235U)
/**
* @brief VEML3235 Features Parameters
*/
/* VEML3235 Channel */
#define VEML3235_ALS_CHANNEL (0U)
#define VEML3235_WHITE_CHANNEL (1U)
#define VEML3235_MAX_CHANNELS (2U) /*!< Number of channels of the device */
/* VEML3235 capture modes */
#define VEML3235_MODE_CONTINUOUS (1U)
/* VEML3235 I2C ADDRESS */
#define VEML3235_I2C_READ_ADD 0x21
#define VEML3235_I2C_WRITE_ADD 0x20
/* driver structure */
extern VEML3235_Drv_t VEML3235_Driver;
/**
* @}
*/
/** @addtogroup VEML3235_Exported_Functions VEML3235 Exported Functions
* @{
*/
int32_t VEML3235_RegisterBusIO(VEML3235_Object_t *pObj, VEML3235_IO_t *pIO);
int32_t VEML3235_Init(VEML3235_Object_t *pObj);
int32_t VEML3235_DeInit(VEML3235_Object_t *pObj);
int32_t VEML3235_ReadID(VEML3235_Object_t *pObj, uint32_t *pId);
int32_t VEML3235_SetExposureTime(VEML3235_Object_t *pObj, uint32_t ExposureTime);
int32_t VEML3235_GetExposureTime(VEML3235_Object_t *pObj, uint32_t *pExposureTime);
int32_t VEML3235_GetCapabilities(VEML3235_Object_t *pObj, VEML3235_Capabilities_t *pCapabilities);
int32_t VEML3235_SetGain(VEML3235_Object_t *pObj, uint8_t Channel, uint32_t Gain);
int32_t VEML3235_GetGain(VEML3235_Object_t *pObj, uint8_t Channel, uint32_t *pGain);
int32_t VEML3235_SetInterMeasurementTime(VEML3235_Object_t *pObj, uint32_t InterMeasurementTime);
int32_t VEML3235_GetInterMeasurementTime(VEML3235_Object_t *pObj, uint32_t *pInterMeasurementTime);
int32_t VEML3235_Start(VEML3235_Object_t *pObj, uint32_t Mode);
int32_t VEML3235_Stop(VEML3235_Object_t *pObj);
int32_t VEML3235_GetValues(VEML3235_Object_t *pObj, uint32_t *pValues);
int32_t VEML3235_StartFlicker(VEML3235_Object_t *pObj, uint8_t Channel, uint8_t OutputMode);
int32_t VEML3235_StopFlicker(VEML3235_Object_t *pObj);
int32_t VEML3235_SetControlMode(VEML3235_Object_t *pObj, uint32_t ControlMode, uint32_t Value);
int32_t VEML3235_SetPowerSavingMode(VEML3235_Object_t *pObj, uint32_t PowerMode);
int32_t VEML3235_GetPowerSavingMode(VEML3235_Object_t *pObj, uint32_t *pPowerMode);
int32_t VEML3235_SetPersistence(VEML3235_Object_t *pObj, uint32_t Persistence);
int32_t VEML3235_GetPersistence(VEML3235_Object_t *pObj, uint32_t *pPersistence);
int32_t VEML3235_GetWhiteValues(VEML3235_Object_t *pObj, uint32_t *pValues);
/* interrupt Mangement Functions */
int32_t VEML3235_SetHighThreshold(VEML3235_Object_t *pObj, uint16_t Threshold);
int32_t VEML3235_GetHighThreshold(VEML3235_Object_t *pObj, uint32_t *pThreshold);
int32_t VEML3235_SetLowThreshold(VEML3235_Object_t *pObj, uint16_t Threshold);
int32_t VEML3235_GetLowThreshold(VEML3235_Object_t *pObj, uint32_t *pThreshold);
int32_t VEML3235_GetIntStatus(VEML3235_Object_t *pObj, uint32_t *pStatus);
int32_t VEML3235_Disable_IT(VEML3235_Object_t *pObj);
int32_t VEML3235_Enable_IT(VEML3235_Object_t *pObj);
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif /* VEML3235_H */