ESP32-P4 OBC Firmware
ESP-IDF firmware for Plant-B CubeSat OBC
 
Loading...
Searching...
No Matches
veml7700_sensor.h
Go to the documentation of this file.
1
31
32#ifndef __VEML7700_SENSOR_H__
33#define __VEML7700_SENSOR_H__
34
35#include <stddef.h>
36#include <stdint.h>
37#include <string.h>
38#include "i2c_bus.h"
39#include "esp_err.h"
40#include "esp_log.h"
41
61
62#define VEML7700_I2C_ADDR (0x10)
63
68#define VEML7700_INTEGRATION_TIME_25MS (0b1100)
69#define VEML7700_INTEGRATION_TIME_50MS (0b1000)
70#define VEML7700_INTEGRATION_TIME_100MS (0b0000)
71#define VEML7700_INTEGRATION_TIME_200MS (0b0001)
72#define VEML7700_INTEGRATION_TIME_400MS (0b0010)
73#define VEML7700_INTEGRATION_TIME_800MS (0b0011)
75
80#define VEML7700_GAIN_1 (0b00)
81#define VEML7700_GAIN_2 (0b01)
82#define VEML7700_GAIN_DIV_8 (0b10)
83#define VEML7700_GAIN_DIV_4 (0b11)
85
90#define VEML7700_POWER_SAVING_MODE_500MS (0b00)
91#define VEML7700_POWER_SAVING_MODE_1000MS (0b01)
92#define VEML7700_POWER_SAVING_MODE_2000MS (0b10)
93#define VEML7700_POWER_SAVING_MODE_4000MS (0b11)
95
100#define VEML7700_PERSISTENCE_PROTECTION_1 (0b00)
101#define VEML7700_PERSISTENCE_PROTECTION_2 (0b01)
102#define VEML7700_PERSISTENCE_PROTECTION_4 (0b10)
103#define VEML7700_PERSISTENCE_PROTECTION_8 (0b11)
105
106#ifdef __cplusplus
107extern "C" {
108#endif
109
114typedef uint8_t i2c_addr_t;
115
120typedef uint32_t ill_lx_t;
121
125typedef struct {
126 uint16_t gain : 2;
127 uint16_t integration_time : 4;
128 uint16_t persistence_protect : 2;
129 uint16_t interrupt_enable : 1;
130 uint16_t shutdown : 1;
131 uint16_t threshold_high;
132 uint16_t threshold_low;
133 uint16_t power_saving_mode : 2;
134 uint16_t power_saving_enable : 1;
136
140typedef struct {
141 i2c_bus_device_handle_t i2c_dev;
145
150typedef void* veml7700_handle_t;
151
166veml7700_handle_t veml7700_i2c_create(i2c_bus_handle_t bus, i2c_addr_t dev_addr);
167
192veml7700_handle_t veml7700_i2c_init(i2c_bus_handle_t bus, i2c_addr_t dev_addr);
193
203
215esp_err_t veml7700_i2c_probe(veml7700_handle_t sensor);
216
230
244
258
272
287 veml7700_handle_t sensor,
288 bool *low,
289 bool *high
290);
291
292#ifdef __cplusplus
293}
294#endif
295 // end of veml7700 group
297
298#endif // __VEML7700_SENSOR_H__
uint8_t i2c_addr_t
Type for I²C addresses.
Definition bme280_sensor.h:54
uint16_t interrupt_enable
Enable/disable threshold interrupt.
Definition veml7700_sensor.h:129
uint16_t threshold_low
Low threshold for interrupt.
Definition veml7700_sensor.h:132
veml7700_config_t cfg
Sensor configuration.
Definition veml7700_sensor.h:143
uint16_t gain
Sensor sensitivity control.
Definition veml7700_sensor.h:126
uint16_t power_saving_enable
Enable/disable power saving mode.
Definition veml7700_sensor.h:134
i2c_bus_device_handle_t i2c_dev
I²C device handle.
Definition veml7700_sensor.h:141
uint16_t power_saving_mode
Power saving mode selection.
Definition veml7700_sensor.h:133
i2c_addr_t dev_addr
I²C address of the sensor.
Definition veml7700_sensor.h:142
uint16_t shutdown
Set to 1 to shutdown, 0 to wakeup.
Definition veml7700_sensor.h:130
uint16_t threshold_high
High threshold for interrupt.
Definition veml7700_sensor.h:131
uint16_t integration_time
Integration time setting.
Definition veml7700_sensor.h:127
uint16_t persistence_protect
Samples before interrupt triggers.
Definition veml7700_sensor.h:128
esp_err_t veml7700_i2c_probe(veml7700_handle_t sensor)
Probe if the sensor exist on the I²C bus.
Definition veml7700_sensor.c:259
uint8_t i2c_addr_t
Type for I²C addresses.
Definition veml7700_sensor.h:114
void veml7700_i2c_delete(veml7700_handle_t sensor)
Deinitialize the VEML7700 sensor and free resources.
Definition veml7700_sensor.c:246
void * veml7700_handle_t
Opaque handle for a VEML7700 sensor.
Definition veml7700_sensor.h:150
veml7700_handle_t veml7700_i2c_init(i2c_bus_handle_t bus, i2c_addr_t dev_addr)
Initialize the VEML7700 sensor over I²C.
Definition veml7700_sensor.c:197
veml7700_handle_t veml7700_i2c_create(i2c_bus_handle_t bus, i2c_addr_t dev_addr)
Create a VEML7700 device handle for I²C communication.
Definition veml7700_sensor.c:181
esp_err_t veml7700_i2c_write_config(veml7700_handle_t sensor, veml7700_config_t *cfg)
Write the configuration to the sensor.
Definition veml7700_sensor.c:273
esp_err_t veml7700_i2c_read_interrupt_status(veml7700_handle_t sensor, bool *low, bool *high)
Read the interrupt status from the sensor.
Definition veml7700_sensor.c:385
esp_err_t veml7700_i2c_read_white_channel(veml7700_handle_t sensor, ill_lx_t *val)
Read white channel value from the sensor.
Definition veml7700_sensor.c:370
esp_err_t veml7700_i2c_read_ambient_light(veml7700_handle_t sensor, ill_lx_t *val)
Read ambiant light value from the sensor.
Definition veml7700_sensor.c:354
uint32_t ill_lx_t
Type for illuminance [lx].
Definition veml7700_sensor.h:120
esp_err_t veml7700_i2c_read_config(veml7700_handle_t sensor, veml7700_config_t *cfg)
Read the sensor configuration.
Definition veml7700_sensor.c:315
Configuration structure for the VEML7700 sensor.
Definition veml7700_sensor.h:125
Device handle structure for the VEML7700 sensor.
Definition veml7700_sensor.h:140