forked from apache/nuttx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
esp32[c3|c6|h2]: Add BMP180 sensor support
- Loading branch information
1 parent
3917857
commit b07842a
Showing
21 changed files
with
790 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
/**************************************************************************** | ||
* boards/risc-v/esp32c3/common/include/esp_board_bmp180.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_RISCV_ESP32C3_COMMON_INCLUDE_ESP_BOARD_BMP180_H | ||
#define __BOARDS_RISCV_ESP32C3_COMMON_INCLUDE_ESP_BOARD_BMP180_H | ||
|
||
/**************************************************************************** | ||
* Included Files | ||
****************************************************************************/ | ||
|
||
#include <nuttx/config.h> | ||
|
||
/**************************************************************************** | ||
* Pre-processor Definitions | ||
****************************************************************************/ | ||
|
||
#ifndef __ASSEMBLY__ | ||
|
||
#undef EXTERN | ||
#if defined(__cplusplus) | ||
#define EXTERN extern "C" | ||
extern "C" | ||
{ | ||
#else | ||
#define EXTERN extern | ||
#endif | ||
|
||
/**************************************************************************** | ||
* Public Function Prototypes | ||
****************************************************************************/ | ||
|
||
/**************************************************************************** | ||
* Name: board_bmp180_initialize | ||
* | ||
* Description: | ||
* Initialize and register the BMP180 Pressure Sensor driver. | ||
* | ||
* Input Parameters: | ||
* devno - The device number, used to build the device path as /dev/pressN | ||
* | ||
* | ||
* Returned Value: | ||
* Zero (OK) on success; a negated errno value on failure. | ||
* | ||
****************************************************************************/ | ||
|
||
#ifdef CONFIG_SENSORS_BMP180 | ||
int board_bmp180_initialize(int devno); | ||
#endif | ||
|
||
#undef EXTERN | ||
#if defined(__cplusplus) | ||
} | ||
#endif | ||
|
||
#endif /* __ASSEMBLY__ */ | ||
#endif /* __BOARDS_RISCV_ESP32C3_COMMON_INCLUDE_ESP_BOARD_BMP180_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/**************************************************************************** | ||
* boards/risc-v/esp32c3/common/src/esp_board_bmp180.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/bmp180.h> | ||
#include <nuttx/i2c/i2c_master.h> | ||
|
||
#include "espressif/esp_i2c.h" | ||
|
||
#include "esp_board_bmp180.h" | ||
|
||
/**************************************************************************** | ||
* Public Functions | ||
****************************************************************************/ | ||
|
||
/**************************************************************************** | ||
* Name: board_bmp180_initialize | ||
* | ||
* Description: | ||
* Initialize and register the BMP180 Pressure Sensor driver. | ||
* | ||
* Input Parameters: | ||
* devno - The device number, used to build the device path as /dev/pressN | ||
* | ||
* | ||
* Returned Value: | ||
* Zero (OK) on success; a negated errno value on failure. | ||
* | ||
****************************************************************************/ | ||
|
||
int board_bmp180_initialize(int devno) | ||
{ | ||
struct i2c_master_s *i2c; | ||
char devpath[12]; | ||
int ret; | ||
|
||
sninfo("Initializing BMP180!\n"); | ||
|
||
/* Initialize BMP180 */ | ||
|
||
i2c = esp_i2cbus_initialize(ESPRESSIF_I2C0); | ||
|
||
if (i2c) | ||
{ | ||
/* Then try to register the barometer sensor in I2C0 */ | ||
|
||
snprintf(devpath, 12, "/dev/press%d", devno); | ||
ret = bmp180_register(devpath, i2c); | ||
if (ret < 0) | ||
{ | ||
snerr("ERROR: Error registering BMP180 in I2C0\n"); | ||
} | ||
} | ||
else | ||
{ | ||
ret = -ENODEV; | ||
} | ||
|
||
return ret; | ||
} |
50 changes: 50 additions & 0 deletions
50
boards/risc-v/esp32c3/esp32c3-generic/configs/bmp180/defconfig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# | ||
# 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_NSH_ARGCAT is not set | ||
# CONFIG_NSH_CMDOPT_HEXDUMP is not set | ||
CONFIG_ARCH="risc-v" | ||
CONFIG_ARCH_BOARD="esp32c3-generic" | ||
CONFIG_ARCH_BOARD_COMMON=y | ||
CONFIG_ARCH_BOARD_ESP32C3_GENERIC=y | ||
CONFIG_ARCH_CHIP="esp32c3" | ||
CONFIG_ARCH_CHIP_ESP32C3_GENERIC=y | ||
CONFIG_ARCH_INTERRUPTSTACK=1536 | ||
CONFIG_ARCH_RISCV=y | ||
CONFIG_ARCH_STACKDUMP=y | ||
CONFIG_BOARDCTL_RESET=y | ||
CONFIG_BOARD_LOOPSPERMSEC=15000 | ||
CONFIG_BUILTIN=y | ||
CONFIG_DEV_ZERO=y | ||
CONFIG_ESPRESSIF_I2C0=y | ||
CONFIG_EXAMPLES_BMP180=y | ||
CONFIG_FS_PROCFS=y | ||
CONFIG_IDLETHREAD_STACKSIZE=2048 | ||
CONFIG_INIT_ENTRYPOINT="nsh_main" | ||
CONFIG_INTELHEX_BINARY=y | ||
CONFIG_LIBC_PERROR_STDOUT=y | ||
CONFIG_LIBC_STRERROR=y | ||
CONFIG_NFILE_DESCRIPTORS_PER_BLOCK=6 | ||
CONFIG_NSH_ARCHINIT=y | ||
CONFIG_NSH_BUILTIN_APPS=y | ||
CONFIG_NSH_FILEIOSIZE=512 | ||
CONFIG_NSH_READLINE=y | ||
CONFIG_NSH_STRERROR=y | ||
CONFIG_PREALLOC_TIMERS=0 | ||
CONFIG_RR_INTERVAL=200 | ||
CONFIG_SCHED_BACKTRACE=y | ||
CONFIG_SCHED_WAITPID=y | ||
CONFIG_SENSORS=y | ||
CONFIG_SENSORS_BMP180=y | ||
CONFIG_START_DAY=29 | ||
CONFIG_START_MONTH=11 | ||
CONFIG_START_YEAR=2019 | ||
CONFIG_SYSTEM_DUMPSTACK=y | ||
CONFIG_SYSTEM_NSH=y | ||
CONFIG_TESTING_GETPRIME=y | ||
CONFIG_TESTING_OSTEST=y | ||
CONFIG_UART0_SERIAL_CONSOLE=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/**************************************************************************** | ||
* boards/risc-v/esp32c6/common/include/esp_board_bmp180.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_RISCV_ESP32C6_COMMON_INCLUDE_ESP_BOARD_BMP180_H | ||
#define __BOARDS_RISCV_ESP32C6_COMMON_INCLUDE_ESP_BOARD_BMP180_H | ||
|
||
/**************************************************************************** | ||
* Included Files | ||
****************************************************************************/ | ||
|
||
#include <nuttx/config.h> | ||
|
||
/**************************************************************************** | ||
* Pre-processor Definitions | ||
****************************************************************************/ | ||
|
||
#ifndef __ASSEMBLY__ | ||
|
||
#undef EXTERN | ||
#if defined(__cplusplus) | ||
#define EXTERN extern "C" | ||
extern "C" | ||
{ | ||
#else | ||
#define EXTERN extern | ||
#endif | ||
|
||
/**************************************************************************** | ||
* Public Function Prototypes | ||
****************************************************************************/ | ||
|
||
/**************************************************************************** | ||
* Name: board_bmp180_initialize | ||
* | ||
* Description: | ||
* Initialize and register the BMP180 Pressure Sensor driver. | ||
* | ||
* Input Parameters: | ||
* devno - The device number, used to build the device path as /dev/pressN | ||
* | ||
* Returned Value: | ||
* Zero (OK) on success; a negated errno value on failure. | ||
* | ||
****************************************************************************/ | ||
|
||
#ifdef CONFIG_SENSORS_BMP180 | ||
int board_bmp180_initialize(int devno); | ||
#endif | ||
|
||
#undef EXTERN | ||
#if defined(__cplusplus) | ||
} | ||
#endif | ||
|
||
#endif /* __ASSEMBLY__ */ | ||
#endif /* __BOARDS_RISCV_ESP32C6_COMMON_INCLUDE_ESP_BOARD_BMP180_H */ |
Oops, something went wrong.