mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 13:13:08 +08:00
Merged in alinjerpelea/nuttx (pull request #944)
drivers: sensors: add I2C Bosch BMP280 and I2C Asahi AK09911/AK09912 Compass Sensor
* drivers: sensors: add Bosch BMP280 Barometic Pressure Sensor
add driver for the Bosch BMP280 barometic pressure sensor
This sensor is connected over I2C bus
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
* drivers: sensors: add Asahi AK09911/AK09912 Compass Sensor
add driver for AK09911/AK09912 Compass sensor over I2C bus
Signed-off-by: Alin Jerpelea <alin.jerpelea@sony.com>
Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
committed by
Gregory Nutt
parent
fb720cb817
commit
ffb4f00da9
@@ -15,6 +15,13 @@ config APDS9960_I2C_FREQUENCY
|
||||
default 400000
|
||||
depends on SENSORS_APDS9960
|
||||
|
||||
config SENSORS_AK09912
|
||||
bool "Asahi AK09911/AK09912 Compass Sensor"
|
||||
default n
|
||||
select I2C
|
||||
---help---
|
||||
Enable driver for AK09911/AK09912 Compass sensor.
|
||||
|
||||
config SENSORS_AS5048B
|
||||
bool "AMS AS5048B Magnetic Rotary Encoder support"
|
||||
default n
|
||||
@@ -86,6 +93,13 @@ config SENSORS_BMP180
|
||||
---help---
|
||||
Enable driver support for the Bosch BMP180 barometer sensor.
|
||||
|
||||
config SENSORS_BMP280
|
||||
bool "Bosch BMP280 Barometic Pressure Sensor"
|
||||
default n
|
||||
select I2C
|
||||
---help---
|
||||
Enable driver for the Bosch BMP280 barometic pressure sensor.
|
||||
|
||||
config SENSORS_DHTXX
|
||||
bool "DHTxx humidity/temperature Sensor support"
|
||||
default n
|
||||
|
||||
@@ -57,6 +57,10 @@ ifeq ($(CONFIG_SENSORS_APDS9960),y)
|
||||
CSRCS += apds9960.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_AK09912),y)
|
||||
CSRCS += ak09912.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_AS5048B),y)
|
||||
CSRCS += as5048b.c
|
||||
endif
|
||||
@@ -113,6 +117,11 @@ ifeq ($(CONFIG_SENSORS_BMP180),y)
|
||||
CSRCS += bmp180.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_BMP280),y)
|
||||
CSRCS += bmp280.c
|
||||
endif
|
||||
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_HTS221),y)
|
||||
CSRCS += hts221.c
|
||||
endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,122 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/sensors/ak09912.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_SENSORS_AK09912_H
|
||||
#define __INCLUDE_NUTTX_SENSORS_AK09912_H
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_AK09912)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
/* Prerequisites:
|
||||
*
|
||||
* CONFIG_AK09912
|
||||
* Enables support for the AK09912 driver
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
struct i2c_master_s;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* IOCTL Commands ***********************************************************/
|
||||
|
||||
/* Arg: 0: Disable compensated
|
||||
* 1: Enable compensated
|
||||
*/
|
||||
|
||||
#define ENABLE_COMPENSATED (1)
|
||||
#define DISABLE_COMPENSATED (0)
|
||||
#define SNIOC_ENABLE_COMPENSATED _SNIOC(0x0001)
|
||||
|
||||
#define SNIOC_GETADJ _SNIOC(0x0002)
|
||||
|
||||
struct mag_data_s
|
||||
{
|
||||
int16_t x; /* X raw data */
|
||||
int16_t y; /* Y raw data */
|
||||
int16_t z; /* Z raw data */
|
||||
};
|
||||
|
||||
struct ak09912_sensadj_s
|
||||
{
|
||||
uint8_t x;
|
||||
uint8_t y;
|
||||
uint8_t z;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ak09912_register
|
||||
*
|
||||
* Description:
|
||||
* Register the AK09912 character device as 'devpath'
|
||||
*
|
||||
* Input Parameters:
|
||||
* devpath - The full path to the driver to register. E.g., "/dev/mag0"
|
||||
* i2c - An instance of the I2C interface to use to communicate with
|
||||
* AK09912
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
int ak09912_register(FAR const char *devpath, FAR struct i2c_master_s *i2c);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_I2C && CONFIG_AK09912 */
|
||||
#endif /* __DRIVERS_AK09912_H */
|
||||
@@ -0,0 +1,165 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/sensors/bmp280.h
|
||||
*
|
||||
* Copyright 2018 Sony Semiconductor Solutions Corporation
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name of Sony Semiconductor Solutions Corporation nor
|
||||
* the names of its contributors may be used to endorse or promote
|
||||
* products derived from this software without specific prior written
|
||||
* permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_SENSORS_BMP280_H
|
||||
#define __INCLUDE_NUTTX_SENSORS_BMP280_H
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_BMP280)
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
/* Prerequisites:
|
||||
*
|
||||
* CONFIG_BMP280
|
||||
* Enables support for the BMP280 driver
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
struct i2c_master_s;
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* IOCTL Commands ***********************************************************/
|
||||
|
||||
/* Arg: 0: Disable compensated
|
||||
* 1: Enable compensated
|
||||
*/
|
||||
|
||||
#define ENABLE_COMPENSATED (1)
|
||||
#define DISABLE_COMPENSATED (0)
|
||||
|
||||
/* Standby duration */
|
||||
|
||||
#define BMP280_STANDBY_1_MS (0x00) /* 0.5 ms */
|
||||
#define BMP280_STANDBY_63_MS (0x01) /* 62.5 ms */
|
||||
#define BMP280_STANDBY_125_MS (0x02) /* 125 ms */
|
||||
#define BMP280_STANDBY_250_MS (0x03) /* 250 ms */
|
||||
#define BMP280_STANDBY_500_MS (0x04) /* 500 ms */
|
||||
#define BMP280_STANDBY_1000_MS (0x05) /* 1000 ms */
|
||||
#define BMP280_STANDBY_2000_MS (0x06) /* 2000 ms */
|
||||
#define BMP280_STANDBY_4000_MS (0x07) /* 4000 ms */
|
||||
|
||||
/* Enable compensate of sensing values (no SCU bus only)
|
||||
*
|
||||
* Arg: ENABLE_COMPENSATED or DISABLE_COMPENSATED
|
||||
*/
|
||||
|
||||
#define SNIOC_ENABLE_COMPENSATED _SNIOC(0x0001)
|
||||
|
||||
/* Get sensor predefined adjustment values (SCU bus only)
|
||||
*
|
||||
* Arg: Pointer of struct bmp280_press_adj_s (pressure)
|
||||
* Pointer of struct bmp280_temp_adj_s (temperature)
|
||||
*/
|
||||
|
||||
#define SNIOC_GETADJ _SNIOC(0x0002)
|
||||
|
||||
/* Set sensor standby duration
|
||||
*
|
||||
* Arg: BMP280_STANDBY_*_MS
|
||||
*/
|
||||
|
||||
#define SNIOC_SETSTB _SNIOC(0x0003)
|
||||
|
||||
struct bmp280_press_adj_s
|
||||
{
|
||||
uint16_t dig_p1; /** calibration P1 data */
|
||||
int16_t dig_p2; /** calibration P2 data */
|
||||
int16_t dig_p3; /** calibration P3 data */
|
||||
int16_t dig_p4; /** calibration P4 data */
|
||||
int16_t dig_p5; /** calibration P5 data */
|
||||
int16_t dig_p6; /** calibration P6 data */
|
||||
int16_t dig_p7; /** calibration P7 data */
|
||||
int16_t dig_p8; /** calibration P8 data */
|
||||
int16_t dig_p9; /** calibration P9 data */
|
||||
};
|
||||
|
||||
struct bmp280_temp_adj_s
|
||||
{
|
||||
uint16_t dig_t1; /** calibration T1 data */
|
||||
int16_t dig_t2; /** calibration T2 data */
|
||||
int16_t dig_t3; /** calibration T3 data */
|
||||
};
|
||||
|
||||
struct bmp280_meas_s
|
||||
{
|
||||
uint8_t msb; /** meas value MSB */
|
||||
uint8_t lsb; /** meas value LSB */
|
||||
uint8_t xlsb; /** meas value XLSB */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Name: bmp280_register
|
||||
*
|
||||
* Description:
|
||||
* Register the BMP280 character device as 'devpath'
|
||||
*
|
||||
* Input Parameters:
|
||||
* devpath - The full path to the driver to register. E.g., "/dev/press"
|
||||
* i2c - An instance of the I2C interface to use to communicate with
|
||||
* BMP280
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno value on failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
int bmp280_register(FAR const char *devpath, FAR struct i2c_master_s *i2c);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_I2C && CONFIG_SENSORS_BMP280 */
|
||||
#endif /* __INCLUDE_NUTTX_BMP280_H */
|
||||
Reference in New Issue
Block a user