LibDriver OPT300X
Loading...
Searching...
No Matches
driver_opt300x.h File Reference

driver opt300x header file More...

#include <stdio.h>
#include <stdint.h>
#include <string.h>
Include dependency graph for driver_opt300x.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  opt300x_handle_s
 opt300x handle structure definition More...
struct  opt300x_info_s
 opt300x information structure definition More...

Macros

#define DRIVER_OPT300X_LINK_INIT(HANDLE, STRUCTURE)
 initialize opt300x_handle_t structure
#define DRIVER_OPT300X_LINK_IIC_INIT(HANDLE, FUC)
 link iic_init function
#define DRIVER_OPT300X_LINK_IIC_DEINIT(HANDLE, FUC)
 link iic_deinit function
#define DRIVER_OPT300X_LINK_IIC_READ(HANDLE, FUC)
 link iic_read function
#define DRIVER_OPT300X_LINK_IIC_WRITE(HANDLE, FUC)
 link iic_write function
#define DRIVER_OPT300X_LINK_DELAY_MS(HANDLE, FUC)
 link delay_ms function
#define DRIVER_OPT300X_LINK_DEBUG_PRINT(HANDLE, FUC)
 link debug_print function
#define DRIVER_OPT300X_LINK_RECEIVE_CALLBACK(HANDLE, FUC)
 link receive_callback function

Typedefs

typedef struct opt300x_handle_s opt300x_handle_t
 opt300x handle structure definition
typedef struct opt300x_info_s opt300x_info_t
 opt300x information structure definition

Enumerations

enum  opt300x_t {
  OPT3001 = 0x01 , OPT3002 = 0x02 , OPT3004 = 0x04 , OPT3005 = 0x05 ,
  OPT3006 = 0x06 , OPT3007 = 0x07
}
 opt300x type enumeration definition More...
enum  opt300x_address_t { OPT300X_ADDRESS_GND = 0x88 , OPT300X_ADDRESS_VCC = 0x8A , OPT300X_ADDRESS_SDA = 0x8C , OPT300X_ADDRESS_SCL = 0x8E }
 opt300x address enumeration definition More...
enum  opt300x_bool_t { OPT300X_BOOL_FALSE = 0x00 , OPT300X_BOOL_TRUE = 0x01 }
 opt300x bool enumeration definition More...
enum  opt300x_conversion_time_t { OPT300X_CONVERSION_TIME_100_MS = 0x00 , OPT300X_CONVERSION_TIME_800_MS = 0x01 }
 opt300x conversion time enumeration definition More...
enum  opt300x_interrupt_polarity_t { OPT300X_INTERRUPT_POLARITY_LOW = 0x00 , OPT300X_INTERRUPT_POLARITY_HIGH = 0x01 }
 opt300x interrupt polarity enumeration definition More...
enum  opt300x_fault_count_t { OPT300X_FAULT_COUNT_ONE = 0x00 , OPT300X_FAULT_COUNT_TWO = 0x01 , OPT300X_FAULT_COUNT_FOUR = 0x02 , OPT300X_FAULT_COUNT_EIGHT = 0x03 }
 opt300x fault count enumeration definition More...
enum  opt300x_range_t {
  OPT300X_RANGE_40P95_LUX = 0x00 , OPT300X_RANGE_81P90_LUX = 0x01 , OPT300X_RANGE_163P80_LUX = 0x02 , OPT300X_RANGE_327P60_LUX = 0x03 ,
  OPT300X_RANGE_655P20_LUX = 0x04 , OPT300X_RANGE_1310P40_LUX = 0x05 , OPT300X_RANGE_2620P80_LUX = 0x06 , OPT300X_RANGE_5241P60_LUX = 0x07 ,
  OPT300X_RANGE_10483P20_LUX = 0x08 , OPT300X_RANGE_20966P40_LUX = 0x09 , OPT300X_RANGE_41932P80_LUX = 0x0A , OPT300X_RANGE_83865P60_LUX = 0x0B ,
  OPT300X_RANGE_AUTO = 0x0C
}
 opt300x range enumeration definition More...
enum  opt3002_range_t {
  OPT3002_RANGE_4914_NW_CM2 = 0x00 , OPT3002_RANGE_9828_NW_CM2 = 0x00 , OPT3002_RANGE_19656_NW_CM2 = 0x00 , OPT3002_RANGE_39312_NW_CM2 = 0x00 ,
  OPT3002_RANGE_78624_NW_CM2 = 0x00 , OPT3002_RANGE_157248_NW_CM2 = 0x00 , OPT3002_RANGE_314496_NW_CM2 = 0x00 , OPT3002_RANGE_628992_NW_CM2 = 0x00 ,
  OPT3002_RANGE_1257984_NW_CM2 = 0x00 , OPT3002_RANGE_2515968_NW_CM2 = 0x00 , OPT3002_RANGE_5031936_NW_CM2 = 0x00 , OPT3002_RANGE_10063872_NW_CM2 = 0x00 ,
  OPT3002_RANGE_AUTO = 0x0C
}
 opt3002 range enumeration definition More...
enum  opt3005_range_t {
  OPT3005_RANGE_81P90_LUX = 0x00 , OPT3005_RANGE_163P80_LUX = 0x01 , OPT3005_RANGE_327P60_LUX = 0x02 , OPT3005_RANGE_655P20_LUX = 0x03 ,
  OPT3005_RANGE_1310P40_LUX = 0x04 , OPT3005_RANGE_2620P80_LUX = 0x05 , OPT3005_RANGE_5241P60_LUX = 0x06 , OPT3005_RANGE_10483P20_LUX = 0x07 ,
  OPT3005_RANGE_20966P40_LUX = 0x08 , OPT3005_RANGE_41932P80_LUX = 0x09 , OPT3005_RANGE_83865P60_LUX = 0x0A , OPT3005_RANGE_167731P20_LUX = 0x0B ,
  OPT3005_RANGE_AUTO = 0x0C
}
 opt3005 range enumeration definition More...
enum  opt300x_interrupt_t { OPT300X_INTERRUPT_HIGH_LIMIT = 0x00 , OPT300X_INTERRUPT_LOW_LIMIT = 0x01 }
 opt300x interrupt enumeration definition More...

Functions

uint8_t opt300x_info (opt300x_info_t *info)
 get chip's information
uint8_t opt300x_set_type (opt300x_handle_t *handle, opt300x_t type)
 set the chip type
uint8_t opt300x_get_type (opt300x_handle_t *handle, opt300x_t *type)
 get the iic chip type
uint8_t opt300x_set_addr_pin (opt300x_handle_t *handle, opt300x_address_t addr_pin)
 set the iic address pin
uint8_t opt300x_get_addr_pin (opt300x_handle_t *handle, opt300x_address_t *addr_pin)
 get the iic address pin
uint8_t opt300x_irq_handler (opt300x_handle_t *handle)
 irq handler
uint8_t opt300x_init (opt300x_handle_t *handle)
 initialize the chip
uint8_t opt300x_deinit (opt300x_handle_t *handle)
 close the chip
uint8_t opt300x_start_continuous_read (opt300x_handle_t *handle)
 start the chip reading
uint8_t opt300x_stop_continuous_read (opt300x_handle_t *handle)
 stop the chip reading
uint8_t opt300x_continuous_read (opt300x_handle_t *handle, uint16_t *raw, float *lux)
 read data from the chip continuously
uint8_t opt3002_continuous_read (opt300x_handle_t *handle, uint16_t *raw, float *nw_cm2)
 read data from the chip continuously
uint8_t opt300x_single_read (opt300x_handle_t *handle, uint16_t *raw, float *lux)
 read data from the chip
uint8_t opt3002_single_read (opt300x_handle_t *handle, uint16_t *raw, float *nw_cm2)
 read data from the chip
uint8_t opt300x_set_low_limit (opt300x_handle_t *handle, uint16_t limit)
 set low limit
uint8_t opt300x_get_low_limit (opt300x_handle_t *handle, uint16_t *limit)
 get low limit
uint8_t opt300x_set_high_limit (opt300x_handle_t *handle, uint16_t limit)
 set high limit
uint8_t opt300x_get_high_limit (opt300x_handle_t *handle, uint16_t *limit)
 get high limit
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 opt300x_limit_convert_to_data (opt300x_handle_t *handle, uint16_t reg, float *lux)
 convert the register raw data to the limit threshold
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 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_range (opt300x_handle_t *handle, opt300x_range_t range)
 set range
uint8_t opt300x_get_range (opt300x_handle_t *handle, opt300x_range_t *range)
 get range
uint8_t opt3002_set_range (opt300x_handle_t *handle, opt3002_range_t range)
 set range
uint8_t opt3002_get_range (opt300x_handle_t *handle, opt3002_range_t *range)
 get range
uint8_t opt3005_set_range (opt300x_handle_t *handle, opt3005_range_t range)
 set range
uint8_t opt3005_get_range (opt300x_handle_t *handle, opt3005_range_t *range)
 get range
uint8_t opt300x_set_conversion_time (opt300x_handle_t *handle, opt300x_conversion_time_t t)
 set conversion time
uint8_t opt300x_get_conversion_time (opt300x_handle_t *handle, opt300x_conversion_time_t *t)
 get conversion time
uint8_t opt300x_set_interrupt_latch (opt300x_handle_t *handle, opt300x_bool_t enable)
 enable or disable interrupt latch
uint8_t opt300x_get_interrupt_latch (opt300x_handle_t *handle, opt300x_bool_t *enable)
 get interrupt latch status
uint8_t opt300x_set_interrupt_pin_polarity (opt300x_handle_t *handle, opt300x_interrupt_polarity_t polarity)
 set interrupt pin polarity
uint8_t opt300x_get_interrupt_pin_polarity (opt300x_handle_t *handle, opt300x_interrupt_polarity_t *polarity)
 get interrupt pin polarity
uint8_t opt300x_set_mask_exponent (opt300x_handle_t *handle, opt300x_bool_t enable)
 enable or disable mask exponent
uint8_t opt300x_get_mask_exponent (opt300x_handle_t *handle, opt300x_bool_t *enable)
 get mask exponent status
uint8_t opt300x_set_fault_count (opt300x_handle_t *handle, opt300x_fault_count_t count)
 set fault count
uint8_t opt300x_get_fault_count (opt300x_handle_t *handle, opt300x_fault_count_t *count)
 get fault count
uint8_t opt300x_set_reg (opt300x_handle_t *handle, uint8_t reg, uint16_t data)
 set the chip register
uint8_t opt300x_get_reg (opt300x_handle_t *handle, uint8_t reg, uint16_t *data)
 get the chip register

Detailed Description

driver opt300x header file

Copyright (c) 2015 - present LibDriver All rights reserved

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version
1.0.0
Author
Shifeng Li
Date
2025-08-30

history

Date Version Author Description
2025/08/30 1.0 Shifeng Li first upload

Definition in file driver_opt300x.h.