mirror of
https://github.com/apache/nuttx.git
synced 2026-05-31 23:40:19 +08:00
esp32-devkitc: Add support to MS5611
This commit is contained in:
committed by
Xiang Xiao
parent
d8163803d1
commit
eb39b3a189
@@ -0,0 +1,68 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/xtensa/esp32/common/include/esp32_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 __BOARDS_XTENSA_ESP32_COMMON_INCLUDE_ESP32_MS5611_H
|
||||||
|
#define __BOARDS_XTENSA_ESP32_COMMON_INCLUDE_ESP32_MS5611_H
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Included Files
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Data
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
#define EXTERN extern "C"
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#else
|
||||||
|
#define EXTERN extern
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Function Prototypes
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_ms5611_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize and register the MS5611 Pressure Sensor driver.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* devno - The device number, used to build the device path as /dev/pressN
|
||||||
|
* busno - The I2C bus number
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int board_ms5611_initialize(int devno, int busno);
|
||||||
|
|
||||||
|
#undef EXTERN
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* __BOARDS_XTENSA_ESP32_COMMON_INCLUDE_ESP32_MS5611_H */
|
||||||
@@ -54,6 +54,10 @@ ifeq ($(CONFIG_SENSORS_SHT3X),y)
|
|||||||
CSRCS += esp32_sht3x.c
|
CSRCS += esp32_sht3x.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_SENSORS_MS5611),y)
|
||||||
|
CSRCS += esp32_ms5611.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_LCD_HT16K33),y)
|
ifeq ($(CONFIG_LCD_HT16K33),y)
|
||||||
CSRCS += esp32_ht16k33.c
|
CSRCS += esp32_ht16k33.c
|
||||||
endif
|
endif
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* boards/xtensa/esp32/common/src/esp32_ms5611.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 <nuttx/arch.h>
|
||||||
|
#include <nuttx/sensors/ms5611.h>
|
||||||
|
#include <nuttx/i2c/i2c_master.h>
|
||||||
|
|
||||||
|
#include "esp32_board_i2c.h"
|
||||||
|
#include "esp32_i2c.h"
|
||||||
|
#include "esp32_ms5611.h"
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Public Functions
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: board_ms5611_initialize
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* Initialize and register the MS5611 Pressure Sensor driver.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* devno - The device number, used to build the device path as /dev/pressN
|
||||||
|
* busno - The I2C bus number
|
||||||
|
*
|
||||||
|
* Returned Value:
|
||||||
|
* Zero (OK) on success; a negated errno value on failure.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
int board_ms5611_initialize(int devno, int busno)
|
||||||
|
{
|
||||||
|
struct i2c_master_s *i2c;
|
||||||
|
char devpath[12];
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
sninfo("Initializing MS5611!\n");
|
||||||
|
|
||||||
|
/* Initialize MS5611 */
|
||||||
|
|
||||||
|
i2c = esp32_i2cbus_initialize(busno);
|
||||||
|
if (i2c != NULL)
|
||||||
|
{
|
||||||
|
/* Then try to register the barometer sensor in I2C0 */
|
||||||
|
|
||||||
|
snprintf(devpath, sizeof(devpath), "/dev/press%d", devno);
|
||||||
|
|
||||||
|
ret = ms5611_register(i2c, devno, MS5611_ADDR0);
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
snerr("ERROR: Error registering MS5611 in I2C%d\n", busno);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ret = -ENODEV;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,64 @@
|
|||||||
|
#
|
||||||
|
# This file is autogenerated: PLEASE DO NOT EDIT IT.
|
||||||
|
#
|
||||||
|
# You can use "make menuconfig" to make any modifications to the installed .config file.
|
||||||
|
# You can then do "make savedefconfig" to generate a new defconfig file that includes your
|
||||||
|
# modifications.
|
||||||
|
#
|
||||||
|
# CONFIG_ARCH_LEDS is not set
|
||||||
|
# CONFIG_NSH_ARGCAT is not set
|
||||||
|
# CONFIG_NSH_CMDOPT_HEXDUMP is not set
|
||||||
|
# CONFIG_NSH_CMDPARMS is not set
|
||||||
|
CONFIG_ARCH="xtensa"
|
||||||
|
CONFIG_ARCH_BOARD="esp32-devkitc"
|
||||||
|
CONFIG_ARCH_BOARD_ESP32_DEVKITC=y
|
||||||
|
CONFIG_ARCH_CHIP="esp32"
|
||||||
|
CONFIG_ARCH_CHIP_ESP32=y
|
||||||
|
CONFIG_ARCH_CHIP_ESP32WROVER=y
|
||||||
|
CONFIG_ARCH_STACKDUMP=y
|
||||||
|
CONFIG_ARCH_XTENSA=y
|
||||||
|
CONFIG_BOARD_LOOPSPERMSEC=16717
|
||||||
|
CONFIG_BUILTIN=y
|
||||||
|
CONFIG_DEBUG_ERROR=y
|
||||||
|
CONFIG_DEBUG_FEATURES=y
|
||||||
|
CONFIG_DEBUG_INFO=y
|
||||||
|
CONFIG_DEBUG_SENSORS=y
|
||||||
|
CONFIG_DEBUG_SENSORS_ERROR=y
|
||||||
|
CONFIG_DEBUG_SENSORS_WARN=y
|
||||||
|
CONFIG_DEBUG_WARN=y
|
||||||
|
CONFIG_ESP32_GPIO_IRQ=y
|
||||||
|
CONFIG_ESP32_I2C0=y
|
||||||
|
CONFIG_ESP32_I2C0_SDAPIN=21
|
||||||
|
CONFIG_ESP32_UART0=y
|
||||||
|
CONFIG_FS_PROCFS=y
|
||||||
|
CONFIG_HAVE_CXX=y
|
||||||
|
CONFIG_HAVE_CXXINITIALIZE=y
|
||||||
|
CONFIG_I2CTOOL_DEFFREQ=100000
|
||||||
|
CONFIG_IDLETHREAD_STACKSIZE=3072
|
||||||
|
CONFIG_INIT_ENTRYPOINT="nsh_main"
|
||||||
|
CONFIG_INTELHEX_BINARY=y
|
||||||
|
CONFIG_LIBC_FLOATINGPOINT=y
|
||||||
|
CONFIG_MM_REGIONS=3
|
||||||
|
CONFIG_MS5611_I2C_FREQUENCY=100000
|
||||||
|
CONFIG_NSH_ARCHINIT=y
|
||||||
|
CONFIG_NSH_BUILTIN_APPS=y
|
||||||
|
CONFIG_NSH_FILEIOSIZE=512
|
||||||
|
CONFIG_NSH_LINELEN=64
|
||||||
|
CONFIG_NSH_READLINE=y
|
||||||
|
CONFIG_PREALLOC_TIMERS=4
|
||||||
|
CONFIG_RAM_SIZE=114688
|
||||||
|
CONFIG_RAM_START=0x20000000
|
||||||
|
CONFIG_RAW_BINARY=y
|
||||||
|
CONFIG_RR_INTERVAL=200
|
||||||
|
CONFIG_SCHED_WAITPID=y
|
||||||
|
CONFIG_SDCLONE_DISABLE=y
|
||||||
|
CONFIG_SENSORS=y
|
||||||
|
CONFIG_SENSORS_MS5611=y
|
||||||
|
CONFIG_START_DAY=6
|
||||||
|
CONFIG_START_MONTH=12
|
||||||
|
CONFIG_START_YEAR=2011
|
||||||
|
CONFIG_SYSTEM_I2CTOOL=y
|
||||||
|
CONFIG_SYSTEM_NSH=y
|
||||||
|
CONFIG_TESTING_SENSORTEST=y
|
||||||
|
CONFIG_TESTING_SENSORTEST_PROGNAME="sensor"
|
||||||
|
CONFIG_UART0_SERIAL_CONSOLE=y
|
||||||
@@ -89,6 +89,10 @@
|
|||||||
# include "esp32_sht3x.h"
|
# include "esp32_sht3x.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_SENSORS_MS5611
|
||||||
|
# include "esp32_ms5611.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_LCD_HT16K33
|
#ifdef CONFIG_LCD_HT16K33
|
||||||
# include "esp32_ht16k33.h"
|
# include "esp32_ht16k33.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -409,6 +413,18 @@ int esp32_bringup(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_SENSORS_MS5611
|
||||||
|
/* Try to register MS5611 device in I2C0 as device 0: I2C addr 0x77 */
|
||||||
|
|
||||||
|
ret = board_ms5611_initialize(0, 0);
|
||||||
|
|
||||||
|
if (ret < 0)
|
||||||
|
{
|
||||||
|
syslog(LOG_ERR, "Failed to initialize MS5611 driver: %d\n", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_LCD_HT16K33
|
#ifdef CONFIG_LCD_HT16K33
|
||||||
/* Try to register HT16K33 in the I2C0 */
|
/* Try to register HT16K33 in the I2C0 */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user