boards: cxd56xx: Add board function for scd41 sensor driver
Add board function for SCD41 CO2, temperature and humidity sensor driver.
This commit is contained in:
parent
771bd8ca17
commit
81534df8a3
@ -110,6 +110,10 @@ ifeq ($(CONFIG_SENSORS_RPR0521RS_SCU),y)
|
||||
CSRCS += cxd56_rpr0521rs_scu.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SENSORS_SCD41),y)
|
||||
CSRCS += cxd56_scd41_i2c.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NETDEVICES),y)
|
||||
CSRCS += cxd56_netinit.c
|
||||
endif
|
||||
|
72
boards/arm/cxd56xx/common/src/cxd56_scd41_i2c.c
Normal file
72
boards/arm/cxd56xx/common/src/cxd56_scd41_i2c.c
Normal file
@ -0,0 +1,72 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/cxd56xx/common/src/cxd56_scd41_i2c.c
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <debug.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
|
||||
#include <nuttx/sensors/scd41.h>
|
||||
|
||||
#include "cxd56_i2c.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_SCD41)
|
||||
|
||||
int board_scd41_initialize(FAR const char *devpath, int bus)
|
||||
{
|
||||
int ret;
|
||||
FAR struct i2c_master_s *i2c;
|
||||
|
||||
sninfo("Initializing SCD41...\n");
|
||||
|
||||
/* Initialize i2c device */
|
||||
|
||||
i2c = cxd56_i2cbus_initialize(bus);
|
||||
if (!i2c)
|
||||
{
|
||||
snerr("ERROR: Failed to initialize i2c%d.\n", bus);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
ret = scd41_register_i2c(devpath, i2c);
|
||||
if (ret < 0)
|
||||
{
|
||||
snerr("Error registering SCD41.\n");
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#endif
|
@ -216,6 +216,9 @@ static struct sensor_device_s sensor_device[] =
|
||||
#if defined(CONFIG_SENSORS_BH1745NUC) || defined(CONFIG_SENSORS_BH1745NUC_SCU)
|
||||
_I2C_DEVICE(bh1745nuc, "/dev/color"), /* Color */
|
||||
#endif
|
||||
#if defined(CONFIG_SENSORS_SCD41)
|
||||
_I2C_DEVICE(scd41, "/dev/co2"), /* CO2 */
|
||||
#endif
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -61,6 +61,7 @@
|
||||
#include "cxd56_kx022.h"
|
||||
#include "cxd56_lt1pa01.h"
|
||||
#include "cxd56_rpr0521rs.h"
|
||||
#include "cxd56_scd41.h"
|
||||
#include "cxd56_sensors.h"
|
||||
|
||||
#include "cxd56_isx012.h"
|
||||
|
71
boards/arm/cxd56xx/spresense/include/cxd56_scd41.h
Normal file
71
boards/arm/cxd56xx/spresense/include/cxd56_scd41.h
Normal file
@ -0,0 +1,71 @@
|
||||
/****************************************************************************
|
||||
* boards/arm/cxd56xx/spresense/include/cxd56_scd41.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 __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_SCD41_H
|
||||
#define __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_SCD41_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: board_scd41_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize SCD41 i2c driver and register the SCD41 device.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#if defined (CONFIG_SENSORS_SCD41)
|
||||
int board_scd41_initialize(FAR const char *devpath, int bus);
|
||||
#endif
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* __BOARDS_ARM_CXD56XX_SPRESENSE_INCLUDE_CXD56_SCD41_H */
|
Loading…
Reference in New Issue
Block a user