mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 16:50:55 +08:00
L61: Sensor: Add driver for OPT3007 light sensor.
N/A Add light sensor. Signed-off-by: yangjiukui <yangjiukui@xiaomi.com> Change-Id: I91654ffff94a7faff17b765524b595cd92049b33
This commit is contained in:
@@ -142,6 +142,22 @@ config SENSORS_OPT3006_BUFFER_NUMBER
|
||||
The number of the circular buffer used. If the value equal to zero,
|
||||
indicates that the circular buffer is disabled.
|
||||
|
||||
config SENSORS_OPT3007
|
||||
bool "TI OPT3007 Ambient Light Sensor support"
|
||||
default n
|
||||
select I2C
|
||||
select IOEXPANDER
|
||||
---help---
|
||||
Enable driver support for the TI OPT3007 Ambient light sensor.
|
||||
|
||||
config SENSORS_OPT3007_BUFFER_NUMBER
|
||||
int "The number of circular buffer for sensor OPT3007"
|
||||
default 1
|
||||
depends on SENSORS_OPT3007
|
||||
---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"
|
||||
default n
|
||||
|
||||
@@ -120,6 +120,10 @@ ifeq ($(CONFIG_SENSORS_OPT3006),y)
|
||||
CSRCS += opt3006.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_OPT3007),y)
|
||||
CSRCS += opt3007.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_BMG160),y)
|
||||
CSRCS += bmg160.c
|
||||
endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,99 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/sensors/opt3007.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_OPT3007_H
|
||||
#define __INCLUDE_NUTTX_SENSORS_OPT3007_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
#include <nuttx/i2c/i2c_master.h>
|
||||
#include <nuttx/ioexpander/ioexpander.h>
|
||||
|
||||
#if defined CONFIG_SENSORS_OPT3007
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
struct opt3007_config_s
|
||||
{
|
||||
uint8_t addr; /* I2C address */
|
||||
int freq; /* I2C frequency */
|
||||
FAR struct i2c_master_s *i2c; /* I2C interface */
|
||||
FAR struct ioexpander_dev_s *ioedev; /* Ioexpander device */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Inline Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: opt3007_register
|
||||
*
|
||||
* Description:
|
||||
* Register the OPT3007 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
|
||||
* OPT3007
|
||||
* 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 opt3007_register(int devno, FAR const struct opt3007_config_s *config);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_SENSORS_OPT3007 */
|
||||
#endif /* __INCLUDE_NUTTX_SENSORS_OPT3007_H */
|
||||
Reference in New Issue
Block a user