sensors: Add support to MS5611 Barometer

This commit is contained in:
Alan C. Assis
2022-01-24 10:23:45 +08:00
committed by Xiang Xiao
parent d664385784
commit d8163803d1
5 changed files with 865 additions and 1 deletions
+40
View File
@@ -561,6 +561,46 @@ config MCP9844_I2C_FREQUENCY
range 1 400000
depends on SENSORS_MCP9844
config SENSORS_MS5611
bool "MS5611 Barometric Pressure Sensor support"
default n
---help---
Enable driver support for MEAS MS5511 barometer.
if SENSORS_MS5611
choice
prompt "MS5611 Interface"
default MS5611_I2C
config MS5611_I2C
bool "MS5611 I2C Interface"
select I2C
---help---
Enables support for the I2C interface
config MS5611_SPI
bool "MS5611 SPI Interface"
select SPI
---help---
Enables support for the SPI interface.
config MS5611_THREAD_STACKSIZE
int "Worker thread stack size"
default 1024
---help---
The stack size for the worker thread
endchoice
config MS5611_I2C_FREQUENCY
int "MS5611 I2C frequency"
default 400000
range 1 400000
depends on MS5611_I2C
endif # SENSORS_MS5611
config SENSORS_MS58XX
bool "MEAS MS58XX Altimeter support"
default n
+4
View File
@@ -164,6 +164,10 @@ ifeq ($(CONFIG_SENSORS_MLX90614),y)
CSRCS += mlx90614.c
endif
ifeq ($(CONFIG_SENSORS_MS5611),y)
CSRCS += ms5611.c
endif
ifeq ($(CONFIG_SENSORS_MS58XX),y)
CSRCS += ms58xx.c
endif
File diff suppressed because it is too large Load Diff
+99
View File
@@ -0,0 +1,99 @@
/****************************************************************************
* include/nuttx/sensors/ms5611.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_MS5611_H
#define __INCLUDE_NUTTX_SENSORS_MS5611_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/sensors/ioctl.h>
#if defined(CONFIG_I2C) && defined(CONFIG_SENSORS_MS5611)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************
* Prerequisites:
*
* CONFIG_I2C
* Enables support for I2C drivers
* CONFIG_SENSORS_MS5611
* Enables support for the MS5611 driver
*/
/* I2C Address **************************************************************/
#define MS5611_ADDR0 0x77
#define MS5611_ADDR1 0x76
/****************************************************************************
* Public Types
****************************************************************************/
struct ms5611_measure_s
{
int32_t temperature; /* in Degree x100 */
int32_t pressure; /* in mBar x10 */
};
struct i2c_master_s;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Name: ms5611_register
*
* Description:
* Register the MS5611 character device as 'devpath'.
*
* Input Parameters:
* i2c - An I2C driver instance.
* devno - Number of device (i.e. baro0, baro1, ...)
* addr - The I2C address of the MS5611.
*
* Returned Value:
* Zero (OK) on success; a negated errno value on failure.
*
****************************************************************************/
int ms5611_register(FAR struct i2c_master_s *i2c, int devno, uint8_t addr);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* CONFIG_I2C && CONFIG_SENSORS_MS5611 */
#endif /* __INCLUDE_NUTTX_SENSORS_MS5611_H */
+17 -1
View File
@@ -1,5 +1,21 @@
/****************************************************************************
* drivers/sensors/msxxxx_crc4.c
* include/nuttx/sensors/msxxxx_crc4.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.
*
****************************************************************************/
/****************************************************************************