37#ifndef DRIVER_OPT300X_H
38#define DRIVER_OPT300X_H
198 uint8_t (*
iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
199 uint8_t (*
iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len);
240#define DRIVER_OPT300X_LINK_INIT(HANDLE, STRUCTURE) memset(HANDLE, 0, sizeof(STRUCTURE))
248#define DRIVER_OPT300X_LINK_IIC_INIT(HANDLE, FUC) (HANDLE)->iic_init = FUC
256#define DRIVER_OPT300X_LINK_IIC_DEINIT(HANDLE, FUC) (HANDLE)->iic_deinit = FUC
264#define DRIVER_OPT300X_LINK_IIC_READ(HANDLE, FUC) (HANDLE)->iic_read = FUC
272#define DRIVER_OPT300X_LINK_IIC_WRITE(HANDLE, FUC) (HANDLE)->iic_write = FUC
280#define DRIVER_OPT300X_LINK_DELAY_MS(HANDLE, FUC) (HANDLE)->delay_ms = FUC
288#define DRIVER_OPT300X_LINK_DEBUG_PRINT(HANDLE, FUC) (HANDLE)->debug_print = FUC
296#define DRIVER_OPT300X_LINK_RECEIVE_CALLBACK(HANDLE, FUC) (HANDLE)->receive_callback = FUC
uint8_t opt300x_get_range(opt300x_handle_t *handle, opt300x_range_t *range)
get range
uint8_t opt300x_set_fault_count(opt300x_handle_t *handle, opt300x_fault_count_t count)
set fault count
uint8_t opt300x_info(opt300x_info_t *info)
get chip's information
uint8_t opt300x_get_low_limit(opt300x_handle_t *handle, uint16_t *limit)
get low limit
uint8_t opt300x_get_high_limit(opt300x_handle_t *handle, uint16_t *limit)
get high limit
uint8_t opt3002_continuous_read(opt300x_handle_t *handle, uint16_t *raw, float *nw_cm2)
read data from the chip continuously
uint8_t opt3005_set_range(opt300x_handle_t *handle, opt3005_range_t range)
set range
uint8_t opt3002_single_read(opt300x_handle_t *handle, uint16_t *raw, float *nw_cm2)
read data from the chip
uint8_t opt300x_set_type(opt300x_handle_t *handle, opt300x_t type)
set the chip type
uint8_t opt300x_set_mask_exponent(opt300x_handle_t *handle, opt300x_bool_t enable)
enable or disable mask exponent
opt300x_address_t
opt300x address enumeration definition
uint8_t opt300x_set_high_limit(opt300x_handle_t *handle, uint16_t limit)
set high limit
opt300x_bool_t
opt300x bool enumeration definition
uint8_t opt300x_get_interrupt_pin_polarity(opt300x_handle_t *handle, opt300x_interrupt_polarity_t *polarity)
get interrupt pin polarity
opt3005_range_t
opt3005 range enumeration definition
uint8_t opt300x_get_conversion_time(opt300x_handle_t *handle, opt300x_conversion_time_t *t)
get conversion time
uint8_t opt300x_start_continuous_read(opt300x_handle_t *handle)
start the chip reading
opt300x_range_t
opt300x range enumeration definition
uint8_t opt300x_continuous_read(opt300x_handle_t *handle, uint16_t *raw, float *lux)
read data from the chip continuously
uint8_t opt300x_set_low_limit(opt300x_handle_t *handle, uint16_t limit)
set low limit
struct opt300x_info_s opt300x_info_t
opt300x information structure definition
uint8_t opt300x_limit_convert_to_register(opt300x_handle_t *handle, float lux, uint16_t *reg)
convert the limit threshold to the register raw data
uint8_t opt3005_get_range(opt300x_handle_t *handle, opt3005_range_t *range)
get range
opt300x_t
opt300x type enumeration definition
uint8_t opt3002_get_range(opt300x_handle_t *handle, opt3002_range_t *range)
get range
uint8_t opt300x_set_interrupt_pin_polarity(opt300x_handle_t *handle, opt300x_interrupt_polarity_t polarity)
set interrupt pin polarity
uint8_t opt300x_get_type(opt300x_handle_t *handle, opt300x_t *type)
get the iic chip type
uint8_t opt3002_limit_convert_to_register(opt300x_handle_t *handle, float nw_cm2, uint16_t *reg)
convert the limit threshold to the register raw data
uint8_t opt300x_set_conversion_time(opt300x_handle_t *handle, opt300x_conversion_time_t t)
set conversion time
uint8_t opt300x_get_addr_pin(opt300x_handle_t *handle, opt300x_address_t *addr_pin)
get the iic address pin
uint8_t opt300x_get_interrupt_latch(opt300x_handle_t *handle, opt300x_bool_t *enable)
get interrupt latch status
uint8_t opt3002_limit_convert_to_data(opt300x_handle_t *handle, uint16_t reg, float *nw_cm2)
convert the register raw data to the limit threshold
uint8_t opt300x_set_interrupt_latch(opt300x_handle_t *handle, opt300x_bool_t enable)
enable or disable interrupt latch
uint8_t opt300x_set_range(opt300x_handle_t *handle, opt300x_range_t range)
set range
uint8_t opt300x_deinit(opt300x_handle_t *handle)
close the chip
opt300x_conversion_time_t
opt300x conversion time enumeration definition
uint8_t opt300x_get_fault_count(opt300x_handle_t *handle, opt300x_fault_count_t *count)
get fault count
uint8_t opt300x_stop_continuous_read(opt300x_handle_t *handle)
stop the chip reading
uint8_t opt300x_limit_convert_to_data(opt300x_handle_t *handle, uint16_t reg, float *lux)
convert the register raw data to the limit threshold
opt3002_range_t
opt3002 range enumeration definition
opt300x_interrupt_t
opt300x interrupt enumeration definition
uint8_t opt300x_set_addr_pin(opt300x_handle_t *handle, opt300x_address_t addr_pin)
set the iic address pin
uint8_t opt300x_init(opt300x_handle_t *handle)
initialize the chip
uint8_t opt300x_irq_handler(opt300x_handle_t *handle)
irq handler
opt300x_interrupt_polarity_t
opt300x interrupt polarity enumeration definition
uint8_t opt3002_set_range(opt300x_handle_t *handle, opt3002_range_t range)
set range
uint8_t opt300x_single_read(opt300x_handle_t *handle, uint16_t *raw, float *lux)
read data from the chip
opt300x_fault_count_t
opt300x fault count enumeration definition
struct opt300x_handle_s opt300x_handle_t
opt300x handle structure definition
uint8_t opt300x_get_mask_exponent(opt300x_handle_t *handle, opt300x_bool_t *enable)
get mask exponent status
@ OPT3005_RANGE_5241P60_LUX
@ OPT3005_RANGE_167731P20_LUX
@ OPT3005_RANGE_2620P80_LUX
@ OPT3005_RANGE_81P90_LUX
@ OPT3005_RANGE_655P20_LUX
@ OPT3005_RANGE_41932P80_LUX
@ OPT3005_RANGE_327P60_LUX
@ OPT3005_RANGE_20966P40_LUX
@ OPT3005_RANGE_163P80_LUX
@ OPT3005_RANGE_83865P60_LUX
@ OPT3005_RANGE_10483P20_LUX
@ OPT3005_RANGE_1310P40_LUX
@ OPT300X_RANGE_1310P40_LUX
@ OPT300X_RANGE_10483P20_LUX
@ OPT300X_RANGE_83865P60_LUX
@ OPT300X_RANGE_5241P60_LUX
@ OPT300X_RANGE_81P90_LUX
@ OPT300X_RANGE_40P95_LUX
@ OPT300X_RANGE_20966P40_LUX
@ OPT300X_RANGE_41932P80_LUX
@ OPT300X_RANGE_163P80_LUX
@ OPT300X_RANGE_327P60_LUX
@ OPT300X_RANGE_655P20_LUX
@ OPT300X_RANGE_2620P80_LUX
@ OPT300X_CONVERSION_TIME_800_MS
@ OPT300X_CONVERSION_TIME_100_MS
@ OPT3002_RANGE_19656_NW_CM2
@ OPT3002_RANGE_9828_NW_CM2
@ OPT3002_RANGE_78624_NW_CM2
@ OPT3002_RANGE_39312_NW_CM2
@ OPT3002_RANGE_1257984_NW_CM2
@ OPT3002_RANGE_157248_NW_CM2
@ OPT3002_RANGE_10063872_NW_CM2
@ OPT3002_RANGE_2515968_NW_CM2
@ OPT3002_RANGE_314496_NW_CM2
@ OPT3002_RANGE_4914_NW_CM2
@ OPT3002_RANGE_5031936_NW_CM2
@ OPT3002_RANGE_628992_NW_CM2
@ OPT300X_INTERRUPT_HIGH_LIMIT
@ OPT300X_INTERRUPT_LOW_LIMIT
@ OPT300X_INTERRUPT_POLARITY_LOW
@ OPT300X_INTERRUPT_POLARITY_HIGH
@ OPT300X_FAULT_COUNT_EIGHT
@ OPT300X_FAULT_COUNT_ONE
@ OPT300X_FAULT_COUNT_TWO
@ OPT300X_FAULT_COUNT_FOUR
uint8_t opt300x_get_reg(opt300x_handle_t *handle, uint8_t reg, uint16_t *data)
get the chip register
uint8_t opt300x_set_reg(opt300x_handle_t *handle, uint8_t reg, uint16_t data)
set the chip register
opt300x handle structure definition
void(* delay_ms)(uint32_t ms)
void(* receive_callback)(uint8_t type)
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)
opt300x information structure definition
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v