Merged in jussi_kivilinna/nuttx/sensirion_drivers (pull request #809)

Drivers for Sensirion SCD30, SGP30 and SPS30 sensors

* drivers/sensors: add driver for Sensirion SCD30 CO2 sensor

* drivers/sensors: add driver for Sensirion SGP30 gas sensor

* drivers/sensors: add driver for Sensirion SPS30 particulate matter sensor

Approved-by: GregoryN <gnutt@nuttx.org>
This commit is contained in:
Jussi Kivilinna
2019-01-09 13:35:44 +00:00
committed by GregoryN
parent d7f1dc56cf
commit d4a38a8974
9 changed files with 3667 additions and 0 deletions
+84
View File
@@ -513,6 +513,59 @@ config LM92_I2C_FREQUENCY
range 1 400000
depends on LM92
config SENSORS_SCD30
bool "Sensirion SCD30 CO2, humidity and temperature sensor"
default n
---help---
Enable driver support for the Sensirion SCD30 CO₂, humidity and
temperature sensor.
if SENSORS_SCD30
config SCD30_I2C
bool "Sensirion SCD30 I2C mode"
default y
select I2C
config SCD30_I2C_FREQUENCY
int "SCD30 I2C frequency"
default 100000
range 1 100000
depends on SCD30_I2C
---help---
I2C frequency for SCD30. Note, maximum supported frequency for
this sensor is 100kHz.
config SCD30_DEBUG
bool "Debug support for the SCD30"
default n
---help---
Enables debug features for the SCD30
endif # SENSORS_SCD30
config SENSORS_SGP30
bool "Sensirion SGP30 Gas Platform sensor"
default n
select I2C
---help---
Enable driver support for the Sensirion SCD30 CO₂ and TVOC gas sensor.
if SENSORS_SGP30
config SGP30_I2C_FREQUENCY
int "SGP30 I2C frequency"
default 400000
range 1 400000
config SGP30_DEBUG
bool "Debug support for the SGP30"
default n
---help---
Enables debug features for the SGP30
endif # SENSORS_SGP30
config SENSORS_SHT21
bool "Sensirion SHT21 temperature and humidity sensor"
default n
@@ -537,6 +590,37 @@ config SHT21_DEBUG
endif # SENSORS_SHT21
config SENSORS_SPS30
bool "Sensirion SPS30 particulate matter sensor"
default n
---help---
Enable driver support for the Sensirion SPS30 particulate matter sensor
sensor.
if SENSORS_SPS30
config SPS30_I2C
bool "Sensirion SPS30 I2C mode"
default y
select I2C
config SPS30_I2C_FREQUENCY
int "SPS30 I2C frequency"
default 100000
range 1 100000
depends on SPS30_I2C
---help---
I2C frequency for SPS30. Note, maximum supported frequency for
this sensor is 100kHz.
config SPS30_DEBUG
bool "Debug support for the SPS30"
default n
---help---
Enables debug features for the SPS30
endif # SENSORS_SPS30
config SENSORS_T67XX
bool "Telair T6713 carbon dioxide sensor"
default n
+12
View File
@@ -157,10 +157,22 @@ ifeq ($(CONFIG_SENSORS_INA3221),y)
CSRCS += ina3221.c
endif
ifeq ($(CONFIG_SENSORS_SCD30),y)
CSRCS += scd30.c
endif
ifeq ($(CONFIG_SENSORS_SGP30),y)
CSRCS += sgp30.c
endif
ifeq ($(CONFIG_SENSORS_SHT21),y)
CSRCS += sht21.c
endif
ifeq ($(CONFIG_SENSORS_SPS30),y)
CSRCS += sps30.c
endif
ifeq ($(CONFIG_SENSORS_T67XX),y)
CSRCS += t67xx.c
endif
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+32
View File
@@ -178,4 +178,36 @@
#define SNIOC_CHANGE_SMBUSADDR _SNIOC(0x0053) /* Arg: uint8_t value */
/* IOCTL commands unique to the SCD30 */
/* SNIOC_RESET */ /* Arg: None */
/* SNIOC_START */ /* Arg: None */
/* SNIOC_STOP */ /* Arg: None */
/* SNIOC_READ_CONVERT_DATA */ /* Arg: struct scd30_conv_data_s* */
#define SNIOC_SET_INTERVAL _SNIOC(0x0054) /* Arg: uint16_t value (seconds) */
#define SNIOC_SET_TEMP_OFFSET _SNIOC(0x0055) /* Arg: uint16_t value (0.01 Kelvin) */
#define SNIOC_SET_PRESSURE_COMP _SNIOC(0x0056) /* Arg: uint16_t value (mbar) */
#define SNIOC_SET_ALTITUDE_COMP _SNIOC(0x0057) /* Arg: uint16_t value (meters) */
#define SNIOC_SET_FRC _SNIOC(0x0058) /* Arg: uint16_t value (CO₂ ppm) */
#define SNIOC_ENABLE_ASC _SNIOC(0x0059) /* Arg: bool value */
/* IOCTL commands unique to the SGP30 */
/* SNIOC_RESET */ /* Arg: None */
/* SNIOC_START_SELFTEST */ /* Arg: None */
/* SNIOC_READ_CONVERT_DATA */ /* Arg: struct sgp30_conv_data_s* */
/* SNIOC_READ_RAW_DATA */ /* Arg: struct sgp30_raw_data_s* */
#define SNIOC_GET_BASELINE _SNIOC(0x005a) /* Arg: struct sgp30_baseline_s* */
#define SNIOC_SET_BASELINE _SNIOC(0x005b) /* Arg: const struct sgp30_baseline_s* */
#define SNIOC_SET_HUMIDITY _SNIOC(0x005c) /* Arg: uint32_t value (mg/m³) */
/* IOCTL commands unique to the SPS30 */
/* SNIOC_RESET */ /* Arg: None */
/* SNIOC_START */ /* Arg: None */
/* SNIOC_STOP */ /* Arg: None */
/* SNIOC_READ_CONVERT_DATA */ /* Arg: struct sps30_conv_data_s* */
#define SNIOC_SET_CLEAN_INTERVAL _SNIOC(0x005d) /* Arg: uint32_t value (seconds) */
#define SNIOC_START_FAN_CLEANING _SNIOC(0x005e) /* Arg: None */
#endif /* __INCLUDE_NUTTX_SENSORS_IOCTL_H */
+90
View File
@@ -0,0 +1,90 @@
/****************************************************************************
* include/nuttx/sensors/scd30.h
*
* Copyright (C) 2019 Haltian Ltd. All rights reserved.
*
* 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 NuttX 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_NUTT_SENSORS_SCD30_H
#define __INCLUDE_NUTT_SENSORS_SCD30_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/sensors/ioctl.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define CONFIG_SCD30_ADDR 0x61
/****************************************************************************
* Public Types
****************************************************************************/
struct i2c_master_s; /* Forward reference */
struct scd30_conv_data_s
{
float temperature; /* Celcius */
float humidity; /* RH-% */
float co2; /* CO₂ PPM */
};
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef CONFIG_SCD30_I2C
/****************************************************************************
* Name: scd30_register_i2c
*
* Description:
* Register the SCD30 character device as 'devpath'
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/co2_0"
* i2c - An instance of the I2C interface to use to communicate with
* the SCD30
* addr - The I2C address of the SCD30. The I2C address of SCD30
* is always 0x61.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int scd30_register_i2c(FAR const char *devpath, FAR struct i2c_master_s *i2c,
uint8_t addr);
#endif
#endif /* __INCLUDE_NUTT_SENSORS_SHT21_H */
+99
View File
@@ -0,0 +1,99 @@
/****************************************************************************
* include/nuttx/sensors/sgp30.h
*
* Copyright (C) 2019 Haltian Ltd. All rights reserved.
*
* 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 NuttX 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_NUTT_SENSORS_SGP30_H
#define __INCLUDE_NUTT_SENSORS_SGP30_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/sensors/ioctl.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define CONFIG_SGP30_ADDR 0x58
/****************************************************************************
* Public Types
****************************************************************************/
struct i2c_master_s; /* Forward reference */
struct sgp30_conv_data_s
{
uint16_t co2eq_ppm;
uint16_t tvoc_ppb;
};
struct sgp30_raw_data_s
{
uint16_t h2_signal;
uint16_t ethanol_signal;
};
struct sgp30_baseline_s
{
uint16_t co2eq_baseline;
uint16_t tvoc_baseline;
};
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: sgp30_register
*
* Description:
* Register the SGP30 character device as 'devpath'
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/gas0"
* i2c - An instance of the I2C interface to use to communicate with
* the SGP30
* addr - The I2C address of the SGP30. The I2C address of SGP30
* is always 0x58.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int sgp30_register(FAR const char *devpath, FAR struct i2c_master_s *i2c,
uint8_t addr);
#endif /* __INCLUDE_NUTT_SENSORS_SHT21_H */
+107
View File
@@ -0,0 +1,107 @@
/****************************************************************************
* include/nuttx/sensors/sps30.h
*
* Copyright (C) 2019 Haltian Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the followirng 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 NuttX 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_NUTT_SENSORS_SPS30_H
#define __INCLUDE_NUTT_SENSORS_SPS30_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/sensors/ioctl.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define CONFIG_SPS30_ADDR 0x69
/****************************************************************************
* Public Types
****************************************************************************/
struct i2c_master_s; /* Forward reference */
struct sps30_conv_data_s
{
/* Mass Concentrations for particle ranges PM1.0, PM2.5, PM4.0, PM10.
* Unit is [µg/m³] (microgram per cubicmeter).
*/
float mass_concenration_pm1_0;
float mass_concenration_pm2_5;
float mass_concenration_pm4_0;
float mass_concenration_pm10;
/* Number Concentrations for particle ranges PM1.0, PM2.5, PM4.0, PM10.
* Unit is [#/cm³] (number per cubic-centimeter).
*/
float number_concenration_pm0_5;
float number_concenration_pm1_0;
float number_concenration_pm2_5;
float number_concenration_pm4_0;
float number_concenration_pm10;
/* Typical particle size. Unit is [µm] (micrometer). */
float typical_particle_size;
};
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef CONFIG_SPS30_I2C
/****************************************************************************
* Name: sps30_register_i2c
*
* Description:
* Register the SPS30 character device as 'devpath'
*
* Input Parameters:
* devpath - The full path to the driver to register. E.g., "/dev/particle0"
* i2c - An instance of the I2C interface to use to communicate with
* the SPS30
* addr - The I2C address of the SPS30. The I2C address of SPS30
* is always 0x69.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int sps30_register_i2c(FAR const char *devpath, FAR struct i2c_master_s *i2c,
uint8_t addr);
#endif
#endif /* __INCLUDE_NUTT_SENSORS_SHT21_H */