mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
L61: Sensor: Add driver for OPT3006 light sensor.
N/A Add light sensor. Signed-off-by: yangjiukui <yangjiukui@xiaomi.com> Change-Id: If0695aaec21476e68d739c420db732b184c178bb
This commit is contained in:
@@ -96,6 +96,21 @@ config SENSORS_BMG160
|
||||
---help---
|
||||
Enable driver support for the Bosch BMG160 gyroscope sensor.
|
||||
|
||||
config SENSORS_OPT3006
|
||||
bool "TI OPT3006 Ambient Light Sensor support"
|
||||
default n
|
||||
select I2C
|
||||
select IOEXPANDER
|
||||
---help---
|
||||
Enable driver support for the TI OPT3006 Ambient light sensor.
|
||||
|
||||
config SENSORS_OPT3006_BUFFER_NUMBER
|
||||
int "The number of circular buffer for sensor OPT3006"
|
||||
default 1
|
||||
depends on SENSORS_OPT3006
|
||||
---help---
|
||||
The number of the circular buffer used. If the value equal to zero,
|
||||
indicates that the circular buffer is disabled.
|
||||
|
||||
config SENSORS_BMI160
|
||||
bool "Bosch BMI160 Inertial Measurement Sensor support"
|
||||
|
||||
@@ -112,6 +112,10 @@ ifeq ($(CONFIG_SENSORS_BH1750FVI),y)
|
||||
CSRCS += bh1750fvi.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_OPT3006),y)
|
||||
CSRCS += opt3006.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_BMG160),y)
|
||||
CSRCS += bmg160.c
|
||||
endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,101 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/sensors/opt3006.h
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership. The
|
||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_SENSORS_OPT3006_H
|
||||
#define __INCLUDE_NUTTX_SENSORS_OPT3006_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/i2c/i2c_master.h>
|
||||
#include <nuttx/ioexpander/ioexpander.h>
|
||||
|
||||
#if defined CONFIG_SENSORS_OPT3006
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
struct opt3006_config_s
|
||||
{
|
||||
uint8_t addr; /* I2C address */
|
||||
int freq; /* I2C frequency */
|
||||
int pin; /* Interrupt pin */
|
||||
FAR struct i2c_master_s *i2c; /* I2C interface */
|
||||
FAR struct ioexpander_dev_s *ioedev; /* Ioexpander device */
|
||||
uint32_t pinset; /* Interrupt pin set */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: opt3006_register
|
||||
*
|
||||
* Description:
|
||||
* Register the OPT3006 character device as 'devno'
|
||||
*
|
||||
* Input Parameters:
|
||||
* devno - The user specifies device number, from 0.
|
||||
* i2c - An instance of the I2C interface to use to communicate with
|
||||
* OPT3006
|
||||
* config - The board config function for the device.
|
||||
*
|
||||
* Returned Value:
|
||||
* Return 0 if the driver was successfully initialize; A negated errno
|
||||
* value is returned on any failure.
|
||||
*
|
||||
* Assumptions/Limitations:
|
||||
* none
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int opt3006_register(int devno, FAR const struct opt3006_config_s *config);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_SENSORS_OPT3006 */
|
||||
#endif /* __INCLUDE_NUTTX_SENSORS_OPT3006_H */
|
||||
Reference in New Issue
Block a user