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

driver opt300x source file More...

#include "driver_opt300x.h"
#include <math.h>
Include dependency graph for driver_opt300x.c:

Go to the source code of this file.

Macros

#define CHIP_NAME   "Texas Instruments OPT300X"
 chip information definition
#define MANUFACTURER_NAME   "Texas Instruments"
#define SUPPLY_VOLTAGE_MIN   1.6f
#define SUPPLY_VOLTAGE_MAX   3.6f
#define MAX_CURRENT   0.01f
#define TEMPERATURE_MIN   -40.0f
#define TEMPERATURE_MAX   85.0f
#define DRIVER_VERSION   1000
#define OPT300X_REG_RESULT   0x00
 chip register definition
#define OPT300X_REG_CONFIGURATION   0x01
#define OPT300X_REG_LOW_LIMIT   0x02
#define OPT300X_REG_HIGH_LIMIT   0x03
#define OPT300X_REG_MANUFACTURER_ID   0x7E
#define OPT300X_REG_DEVICE_ID   0x7F

Functions

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_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_irq_handler (opt300x_handle_t *handle)
 irq handler
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
uint8_t opt300x_info (opt300x_info_t *info)
 get chip's information

Detailed Description

driver opt300x source 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.c.

Macro Definition Documentation

◆ CHIP_NAME

#define CHIP_NAME   "Texas Instruments OPT300X"

chip information definition

chip name

Definition at line 43 of file driver_opt300x.c.

◆ DRIVER_VERSION

#define DRIVER_VERSION   1000

driver version

Definition at line 50 of file driver_opt300x.c.

◆ MANUFACTURER_NAME

#define MANUFACTURER_NAME   "Texas Instruments"

manufacturer name

Definition at line 44 of file driver_opt300x.c.

◆ MAX_CURRENT

#define MAX_CURRENT   0.01f

chip max current

Definition at line 47 of file driver_opt300x.c.

◆ OPT300X_REG_CONFIGURATION

#define OPT300X_REG_CONFIGURATION   0x01

configuration register

Definition at line 56 of file driver_opt300x.c.

◆ OPT300X_REG_DEVICE_ID

#define OPT300X_REG_DEVICE_ID   0x7F

device id register

Definition at line 60 of file driver_opt300x.c.

◆ OPT300X_REG_HIGH_LIMIT

#define OPT300X_REG_HIGH_LIMIT   0x03

high limit register

Definition at line 58 of file driver_opt300x.c.

◆ OPT300X_REG_LOW_LIMIT

#define OPT300X_REG_LOW_LIMIT   0x02

low limit register

Definition at line 57 of file driver_opt300x.c.

◆ OPT300X_REG_MANUFACTURER_ID

#define OPT300X_REG_MANUFACTURER_ID   0x7E

manufacturer id register

Definition at line 59 of file driver_opt300x.c.

◆ OPT300X_REG_RESULT

#define OPT300X_REG_RESULT   0x00

chip register definition

result register

Definition at line 55 of file driver_opt300x.c.

◆ SUPPLY_VOLTAGE_MAX

#define SUPPLY_VOLTAGE_MAX   3.6f

chip max supply voltage

Definition at line 46 of file driver_opt300x.c.

◆ SUPPLY_VOLTAGE_MIN

#define SUPPLY_VOLTAGE_MIN   1.6f

chip min supply voltage

Definition at line 45 of file driver_opt300x.c.

◆ TEMPERATURE_MAX

#define TEMPERATURE_MAX   85.0f

chip max operating temperature

Definition at line 49 of file driver_opt300x.c.

◆ TEMPERATURE_MIN

#define TEMPERATURE_MIN   -40.0f

chip min operating temperature

Definition at line 48 of file driver_opt300x.c.