LibDriver BH1750FVI
Loading...
Searching...
No Matches
driver_bh1750fvi.h
Go to the documentation of this file.
1
36
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
45extern "C"{
46#endif
47
53
58
67
77
81typedef 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
110
114
121
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_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
177
181
188
197uint8_t bh1750fvi_info(bh1750fvi_info_t *info);
198
209
220
232
244
257uint8_t bh1750fvi_init(bh1750fvi_handle_t *handle);
258
270uint8_t bh1750fvi_deinit(bh1750fvi_handle_t *handle);
271
285uint8_t bh1750fvi_single_read(bh1750fvi_handle_t *handle, uint16_t *raw, float *lux);
286
300uint8_t bh1750fvi_continuous_read(bh1750fvi_handle_t *handle, uint16_t *raw, float *lux);
301
314
327
339
351
362uint8_t bh1750fvi_reset(bh1750fvi_handle_t *handle);
363
376uint8_t bh1750fvi_set_measurement_time(bh1750fvi_handle_t *handle, uint8_t t);
377
381
388
401uint8_t bh1750fvi_set_reg(bh1750fvi_handle_t *handle, uint8_t *buf, uint16_t len);
402
415uint8_t bh1750fvi_get_reg(bh1750fvi_handle_t *handle, uint8_t *buf, uint16_t len);
416
420
424
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