LibDriver BH1750FVI  1.0.0
BH1750FVI full-featured driver
driver_bh1750fvi.h
Go to the documentation of this file.
1 
37 #ifndef DRIVER_BH1750FVI_H
38 #define DRIVER_BH1750FVI_H
39 
40 #include <stdio.h>
41 #include <stdint.h>
42 #include <string.h>
43 
44 #ifdef __cplusplus
45 extern "C"{
46 #endif
47 
62 typedef enum
63 {
67 
71 typedef enum
72 {
77 
81 typedef struct bh1750fvi_handle_s
82 {
83  uint8_t iic_addr;
84  uint8_t (*iic_init)(void);
85  uint8_t (*iic_deinit)(void);
86  uint8_t (*iic_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len);
87  uint8_t (*iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len);
88  void (*delay_ms)(uint32_t ms);
89  void (*debug_print)(const char *const fmt, ...);
90  uint8_t mode;
91  uint8_t t;
92  uint8_t inited;
94 
98 typedef struct bh1750fvi_info_s
99 {
100  char chip_name[32];
101  char manufacturer_name[32];
102  char interface[8];
108  uint32_t driver_version;
110 
128 #define DRIVER_BH1750FVI_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
129 
136 #define DRIVER_BH1750FVI_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
137 
144 #define DRIVER_BH1750FVI_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
145 
152 #define DRIVER_BH1750FVI_LINK_IIC_READ_CMD(HANDLE, FUC) (HANDLE)->iic_read_cmd = FUC
153 
160 #define DRIVER_BH1750FVI_LINK_IIC_WRITE_CMD(HANDLE, FUC) (HANDLE)->iic_write_cmd = FUC
161 
168 #define DRIVER_BH1750FVI_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
169 
176 #define DRIVER_BH1750FVI_LINK_DEBUG_PEINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
177 
197 uint8_t bh1750fvi_info(bh1750fvi_info_t *info);
198 
209 
220 
232 
244 
257 uint8_t bh1750fvi_init(bh1750fvi_handle_t *handle);
258 
270 uint8_t bh1750fvi_deinit(bh1750fvi_handle_t *handle);
271 
285 uint8_t bh1750fvi_single_read(bh1750fvi_handle_t *handle, uint16_t *raw, float *lux);
286 
300 uint8_t bh1750fvi_continuous_read(bh1750fvi_handle_t *handle, uint16_t *raw, float *lux);
301 
314 
327 
339 
350 uint8_t bh1750fvi_power_on(bh1750fvi_handle_t *handle);
351 
362 uint8_t bh1750fvi_reset(bh1750fvi_handle_t *handle);
363 
376 uint8_t bh1750fvi_set_measurement_time(bh1750fvi_handle_t *handle, uint8_t t);
377 
401 uint8_t bh1750fvi_set_reg(bh1750fvi_handle_t *handle, uint8_t *buf, uint16_t len);
402 
415 uint8_t bh1750fvi_get_reg(bh1750fvi_handle_t *handle, uint8_t *buf, uint16_t len);
416 
425 #ifdef __cplusplus
426 }
427 #endif
428 
429 #endif
uint8_t bh1750fvi_stop_continuous_read(bh1750fvi_handle_t *handle)
stop chip reading
uint8_t bh1750fvi_reset(bh1750fvi_handle_t *handle)
reset
uint8_t bh1750fvi_single_read(bh1750fvi_handle_t *handle, uint16_t *raw, float *lux)
read data from the chip once
uint8_t bh1750fvi_get_addr_pin(bh1750fvi_handle_t *handle, bh1750fvi_address_t *addr_pin)
get the address pin
uint8_t bh1750fvi_deinit(bh1750fvi_handle_t *handle)
close the chip
uint8_t bh1750fvi_start_continuous_read(bh1750fvi_handle_t *handle)
start chip reading
struct bh1750fvi_info_s bh1750fvi_info_t
bh1750fvi information structure definition
struct bh1750fvi_handle_s bh1750fvi_handle_t
bh1750fvi handle structure definition
uint8_t bh1750fvi_set_measurement_time(bh1750fvi_handle_t *handle, uint8_t t)
set the measurement time
uint8_t bh1750fvi_continuous_read(bh1750fvi_handle_t *handle, uint16_t *raw, float *lux)
read data from the chip continuously
uint8_t bh1750fvi_set_addr_pin(bh1750fvi_handle_t *handle, bh1750fvi_address_t addr_pin)
set the address pin
uint8_t bh1750fvi_info(bh1750fvi_info_t *info)
get chip's information
uint8_t bh1750fvi_power_down(bh1750fvi_handle_t *handle)
power down
bh1750fvi_mode_t
bh1750fvi mode enumeration definition
uint8_t bh1750fvi_power_on(bh1750fvi_handle_t *handle)
power on
uint8_t bh1750fvi_init(bh1750fvi_handle_t *handle)
initialize the chip
bh1750fvi_address_t
bh1750fvi address enumeration definition
uint8_t bh1750fvi_get_mode(bh1750fvi_handle_t *handle, bh1750fvi_mode_t *mode)
get the mode
uint8_t bh1750fvi_set_mode(bh1750fvi_handle_t *handle, bh1750fvi_mode_t mode)
set the mode
@ BH1750FVI_MODE_HIGH_RESOLUTION_MODE
@ BH1750FVI_MODE_LOW_RESOLUTION_MODE
@ BH1750FVI_MODE_HIGH_RESOLUTION_MODE2
@ BH1750FVI_ADDRESS_LOW
@ BH1750FVI_ADDRESS_HIGH
uint8_t bh1750fvi_get_reg(bh1750fvi_handle_t *handle, uint8_t *buf, uint16_t len)
get the chip register
uint8_t bh1750fvi_set_reg(bh1750fvi_handle_t *handle, uint8_t *buf, uint16_t len)
set the chip register
bh1750fvi handle structure definition
void(* delay_ms)(uint32_t ms)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* iic_read_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
uint8_t(* iic_write_cmd)(uint8_t addr, uint8_t *buf, uint16_t len)
bh1750fvi information structure definition
char manufacturer_name[32]