LibDriver VEML7700
Loading...
Searching...
No Matches
driver_veml7700.h
Go to the documentation of this file.
1
36
37#ifndef DRIVER_VEML7700_H
38#define DRIVER_VEML7700_H
39
40#include <stdio.h>
41#include <stdint.h>
42#include <string.h>
43
44#ifdef __cplusplus
45extern "C"{
46#endif
47
53
58
62#ifndef VEML7700_AUTO_RANGE_HIGH_THRESHOLD
63 #define VEML7700_AUTO_RANGE_HIGH_THRESHOLD 0xFF00U
64#endif
65
69#ifndef VEML7700_AUTO_RANGE_LOW_THRESHOLD
70 #define VEML7700_AUTO_RANGE_LOW_THRESHOLD 0x00FFU
71#endif
72
81
92
105
116
125
143
147typedef struct veml7700_handle_s
148{
149 uint8_t (*iic_init)(void);
150 uint8_t (*iic_deinit)(void);
151 uint8_t (*iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
152 uint8_t (*iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
153 void (*delay_ms)(uint32_t ms);
154 void (*debug_print)(const char *const fmt, ...);
155 uint8_t inited;
156 uint8_t auto_mode;
158
174
178
185
192#define DRIVER_VEML7700_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
193
200#define DRIVER_VEML7700_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
201
208#define DRIVER_VEML7700_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
209
216#define DRIVER_VEML7700_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
217
224#define DRIVER_VEML7700_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
225
232#define DRIVER_VEML7700_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
233
240#define DRIVER_VEML7700_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
241
245
252
261uint8_t veml7700_info(veml7700_info_t *info);
262
274uint8_t veml7700_init(veml7700_handle_t *handle);
275
287uint8_t veml7700_deinit(veml7700_handle_t *handle);
288
303uint8_t veml7700_read_als(veml7700_handle_t *handle, uint16_t *raw, double *lux);
304
316uint8_t veml7700_read_white(veml7700_handle_t *handle, uint16_t *raw);
317
329
341
354
367
380
393
406
419
432
445
458
471
483uint8_t veml7700_set_als_high_threshold(veml7700_handle_t *handle, uint16_t threshold);
484
496uint8_t veml7700_get_als_high_threshold(veml7700_handle_t *handle, uint16_t *threshold);
497
509uint8_t veml7700_set_als_low_threshold(veml7700_handle_t *handle, uint16_t threshold);
510
522uint8_t veml7700_get_als_low_threshold(veml7700_handle_t *handle, uint16_t *threshold);
523
536
549
562
575
588uint8_t veml7700_get_interrupt_status(veml7700_handle_t *handle, veml7700_bool_t *low_threshold, veml7700_bool_t *high_threshold);
589
593
600
613uint8_t veml7700_set_reg(veml7700_handle_t *handle, uint8_t reg, uint16_t data);
614
627uint8_t veml7700_get_reg(veml7700_handle_t *handle, uint8_t reg, uint16_t *data);
628
632
636
637#ifdef __cplusplus
638}
639#endif
640
641#endif
uint8_t veml7700_get_interrupt_status(veml7700_handle_t *handle, veml7700_bool_t *low_threshold, veml7700_bool_t *high_threshold)
get interrupt status
uint8_t veml7700_set_als_integration_time(veml7700_handle_t *handle, veml7700_als_integration_time_t t)
set als integration time
veml7700_bool_t
veml7700 bool enumeration definition
uint8_t veml7700_deinit(veml7700_handle_t *handle)
close the chip
uint8_t veml7700_set_als_interrupt(veml7700_handle_t *handle, veml7700_bool_t enable)
enable or disable als interrupt
uint8_t veml7700_get_als_persistence(veml7700_handle_t *handle, veml7700_als_persistence_t *persistence)
get als persistence
uint8_t veml7700_read_white(veml7700_handle_t *handle, uint16_t *raw)
read white channel
uint8_t veml7700_get_power_saving_mode(veml7700_handle_t *handle, veml7700_power_saving_mode_t *mode)
get power saving mode
uint8_t veml7700_info(veml7700_info_t *info)
get chip's information
uint8_t veml7700_get_als_low_threshold(veml7700_handle_t *handle, uint16_t *threshold)
get als low threshold
struct veml7700_info_s veml7700_info_t
veml7700 information structure definition
uint8_t veml7700_init(veml7700_handle_t *handle)
initialize the chip
uint8_t veml7700_read_als(veml7700_handle_t *handle, uint16_t *raw, double *lux)
read als channel
uint8_t veml7700_set_als_mode(veml7700_handle_t *handle, veml7700_als_mode_t mode)
set als mode
uint8_t veml7700_set_als_gain(veml7700_handle_t *handle, veml7700_als_gain_t gain)
set als gain
veml7700_power_saving_mode_t
veml7700 power saving mode enumeration definition
uint8_t veml7700_get_als_gain(veml7700_handle_t *handle, veml7700_als_gain_t *gain)
get als gain
uint8_t veml7700_get_als_high_threshold(veml7700_handle_t *handle, uint16_t *threshold)
get als high threshold
struct veml7700_handle_s veml7700_handle_t
veml7700 handle structure definition
uint8_t veml7700_get_als_interrupt(veml7700_handle_t *handle, veml7700_bool_t *enable)
get als interrupt status
veml7700_als_integration_time_t
veml7700 als integration time enumeration definition
uint8_t veml7700_set_als_persistence(veml7700_handle_t *handle, veml7700_als_persistence_t persistence)
set als persistence
veml7700_als_gain_t
veml7700 als gain enumeration definition
uint8_t veml7700_set_als_low_threshold(veml7700_handle_t *handle, uint16_t threshold)
set als low threshold
uint8_t veml7700_get_als_integration_time(veml7700_handle_t *handle, veml7700_als_integration_time_t *t)
get als integration time
uint8_t veml7700_set_als_high_threshold(veml7700_handle_t *handle, uint16_t threshold)
set als high threshold
uint8_t veml7700_get_auto_range(veml7700_handle_t *handle, veml7700_bool_t *enable)
get auto range
uint8_t veml7700_get_power_saving(veml7700_handle_t *handle, veml7700_bool_t *enable)
get power saving status
uint8_t veml7700_set_auto_range(veml7700_handle_t *handle, veml7700_bool_t enable)
set auto range
veml7700_als_persistence_t
veml7700 als persistence enumeration definition
veml7700_als_mode_t
veml7700 als mode enumeration definition
uint8_t veml7700_set_power_saving(veml7700_handle_t *handle, veml7700_bool_t enable)
enable or disable power saving
uint8_t veml7700_set_power_saving_mode(veml7700_handle_t *handle, veml7700_power_saving_mode_t mode)
set power saving mode
uint8_t veml7700_get_als_mode(veml7700_handle_t *handle, veml7700_als_mode_t *mode)
get als mode
@ VEML7700_BOOL_DISABLE
@ VEML7700_BOOL_ENABLE
@ VEML7700_POWER_SAVING_MODE3
@ VEML7700_POWER_SAVING_MODE2
@ VEML7700_POWER_SAVING_MODE4
@ VEML7700_POWER_SAVING_MODE1
@ VEML7700_ALS_INTEGRATION_TIME_400MS
@ VEML7700_ALS_INTEGRATION_TIME_50MS
@ VEML7700_ALS_INTEGRATION_TIME_25MS
@ VEML7700_ALS_INTEGRATION_TIME_200MS
@ VEML7700_ALS_INTEGRATION_TIME_800MS
@ VEML7700_ALS_INTEGRATION_TIME_100MS
@ VEML7700_ALS_GAIN_1
@ VEML7700_ALS_GAIN_1_DIV_4
@ VEML7700_ALS_GAIN_2
@ VEML7700_ALS_GAIN_1_DIV_8
@ VEML7700_ALS_PERSISTENCE_1
@ VEML7700_ALS_PERSISTENCE_2
@ VEML7700_ALS_PERSISTENCE_8
@ VEML7700_ALS_PERSISTENCE_4
@ VEML7700_ALS_MODE_SHUT_DOWN
@ VEML7700_ALS_MODE_POWER_ON
uint8_t veml7700_set_reg(veml7700_handle_t *handle, uint8_t reg, uint16_t data)
set the chip register
uint8_t veml7700_get_reg(veml7700_handle_t *handle, uint8_t reg, uint16_t *data)
get the chip register
veml7700 handle structure definition
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
veml7700 information structure definition
char manufacturer_name[32]