Compare commits
No commits in common. "main" and "gh-pages" have entirely different histories.
17
.claude/settings.local.json
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"permissions": {
|
||||
"allow": [
|
||||
"Bash(cd:*)",
|
||||
"Bash(cd:*)",
|
||||
"Bash(timeout:*)",
|
||||
"Bash(cd:*)",
|
||||
"Bash(~/bin/arduino-cli board:*)",
|
||||
"Bash(~/bin/arduino-cli lib install:*)",
|
||||
"Bash(~/bin/arduino-cli compile:*)",
|
||||
"WebFetch(domain:raw.githubusercontent.com)",
|
||||
"Bash(~/bin/arduino-cli lib:*)",
|
||||
"Bash(git push:*)"
|
||||
],
|
||||
"deny": []
|
||||
}
|
||||
}
|
||||
32
.github/workflows/githubci.yml
vendored
|
|
@ -1,32 +0,0 @@
|
|||
name: Arduino Library CI
|
||||
|
||||
on: [pull_request, push, repository_dispatch]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-python@v1
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v2
|
||||
with:
|
||||
repository: adafruit/ci-arduino
|
||||
path: ci
|
||||
|
||||
- name: pre-install
|
||||
run: bash ci/actions_install.sh
|
||||
|
||||
- name: clang
|
||||
run: python3 ci/run-clang-format.py -e "ci/*" -e "bin/*" -r .
|
||||
|
||||
- name: test platforms
|
||||
run: python3 ci/build_platform.py main_platforms
|
||||
|
||||
- name: doxygen
|
||||
env:
|
||||
GH_REPO_TOKEN: ${{ secrets.GH_REPO_TOKEN }}
|
||||
PRETTYNAME : "Adafruit BMP5xx Library"
|
||||
run: bash ci/doxy_gen_and_deploy.sh
|
||||
17
.gitignore
vendored
|
|
@ -1,17 +0,0 @@
|
|||
# Datasheet files
|
||||
*.pdf
|
||||
*.txt
|
||||
|
||||
# Build artifacts
|
||||
*.o
|
||||
*.hex
|
||||
*.elf
|
||||
|
||||
# IDE files
|
||||
.vscode/
|
||||
*.swp
|
||||
*.swo
|
||||
|
||||
# System files
|
||||
.DS_Store
|
||||
Thumbs.db
|
||||
1
.nojekyll
Normal file
|
|
@ -0,0 +1 @@
|
|||
|
||||
29
LICENSE
|
|
@ -1,29 +0,0 @@
|
|||
BSD 3-Clause License
|
||||
|
||||
Copyright (c) 2024 Adafruit Industries
|
||||
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 of the copyright holder 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 HOLDER 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.
|
||||
36
README.md
|
|
@ -1,36 +0,0 @@
|
|||
# Adafruit BMP5xx Library [](https://github.com/adafruit/Adafruit_BMP5xx/actions)[](http://adafruit.github.io/Adafruit_BMP5xx/html/index.html)
|
||||
|
||||
Arduino library for the BMP5xx (BMP580/BMP581/BMP585) pressure and temperature sensors.
|
||||
|
||||
## About the BMP5xx
|
||||
|
||||
The BMP5xx series (BMP580/BMP581/BMP585) are high-precision barometric pressure sensors from Bosch Sensortec featuring:
|
||||
|
||||
- High-resolution 24-bit pressure and temperature measurements
|
||||
- I2C and SPI interface support
|
||||
- Built-in digital signal processing with IIR filter
|
||||
- Multiple power modes for optimized power consumption
|
||||
- Configurable oversampling and output data rates
|
||||
- Wide operating temperature range: -40°C to +85°C
|
||||
- Pressure range: 300-1250 hPa
|
||||
- Low power consumption
|
||||
- FIFO buffer support
|
||||
|
||||
## Installation
|
||||
|
||||
To install, use the Arduino Library Manager and search for "Adafruit BMP5xx", and install the library.
|
||||
|
||||
### Dependencies
|
||||
|
||||
This library depends on:
|
||||
|
||||
- [Adafruit Unified Sensor](https://github.com/adafruit/Adafruit_Sensor)
|
||||
- [Adafruit BusIO](https://github.com/adafruit/Adafruit_BusIO)
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions are welcome! Please read our [Code of Conduct](https://github.com/adafruit/Adafruit_BMP5xx/blob/main/CODE_OF_CONDUCT.md) before contributing to help this project stay welcoming.
|
||||
|
||||
## License
|
||||
|
||||
BSD license, all text above must be included in any redistribution. See LICENSE file for details.
|
||||
|
|
@ -1,111 +0,0 @@
|
|||
/*!
|
||||
* @file bmp5xx_interrupt_test.ino
|
||||
*
|
||||
* This is a simple test sketch for the BMP5xx interrupt functionality.
|
||||
* It demonstrates data ready interrupts and shows how to monitor the interrupt pin.
|
||||
* Connect the BMP5xx INT pin to the specified Arduino interrupt pin.
|
||||
*
|
||||
* Adafruit invests time and resources providing this open source code,
|
||||
* please support Adafruit and open-source hardware by purchasing
|
||||
* products from Adafruit!
|
||||
*
|
||||
* Written by Limor "ladyada" Fried for Adafruit Industries.
|
||||
* BSD license, all text above must be included in any redistribution
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include "Adafruit_BMP5xx.h"
|
||||
|
||||
#define BMP5XX_IRQ_PIN 2 // Interrupt pin (change this if using a different pin)
|
||||
|
||||
Adafruit_BMP5xx bmp; // Create BMP5xx object
|
||||
|
||||
// Interrupt flag - set by interrupt handler
|
||||
volatile bool dataReady = false;
|
||||
|
||||
// Interrupt service routine
|
||||
void bmp5xxInterruptHandler() {
|
||||
dataReady = true;
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
while (!Serial) delay(10); // Wait for Serial Monitor to open
|
||||
|
||||
Serial.println(F("Adafruit BMP5xx Interrupt Test"));
|
||||
Serial.print(F("Using interrupt pin: "));
|
||||
Serial.println(BMP5XX_IRQ_PIN);
|
||||
Serial.println();
|
||||
|
||||
// Configure interrupt pin as input
|
||||
pinMode(BMP5XX_IRQ_PIN, INPUT);
|
||||
|
||||
// Try to initialize the sensor using I2C
|
||||
if (!bmp.begin(BMP5XX_ALTERNATIVE_ADDRESS, &Wire)) {
|
||||
Serial.println(F("Could not find a valid BMP5xx sensor, check wiring!"));
|
||||
while (1) delay(10);
|
||||
}
|
||||
|
||||
Serial.println(F("BMP5xx found!"));
|
||||
|
||||
// Configure sensor settings for interrupt testing
|
||||
bmp.setTemperatureOversampling(BMP5XX_OVERSAMPLING_1X);
|
||||
bmp.setPressureOversampling(BMP5XX_OVERSAMPLING_1X);
|
||||
bmp.setIIRFilterCoeff(BMP5XX_IIR_FILTER_BYPASS);
|
||||
bmp.setOutputDataRate(BMP5XX_ODR_01_HZ); // 1 Hz for clear interrupt timing
|
||||
bmp.setPowerMode(BMP5XX_POWERMODE_NORMAL);
|
||||
|
||||
// Configure interrupt: pulsed, active high, push-pull, data ready source
|
||||
Serial.println(F("Configuring data ready interrupt..."));
|
||||
if (!bmp.configureInterrupt(BMP5XX_INTERRUPT_PULSED,
|
||||
BMP5XX_INTERRUPT_ACTIVE_HIGH,
|
||||
BMP5XX_INTERRUPT_PUSH_PULL,
|
||||
BMP5XX_INTERRUPT_DATA_READY,
|
||||
true)) {
|
||||
Serial.println(F("Failed to configure interrupt!"));
|
||||
while (1) delay(10);
|
||||
}
|
||||
|
||||
// Attach interrupt handler
|
||||
attachInterrupt(digitalPinToInterrupt(BMP5XX_IRQ_PIN), bmp5xxInterruptHandler, RISING);
|
||||
|
||||
Serial.println(F("Interrupt configured successfully!"));
|
||||
Serial.println(F("Waiting for interrupts..."));
|
||||
Serial.println();
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Check if interrupt occurred
|
||||
if (dataReady) {
|
||||
// Clear the interrupt flag
|
||||
dataReady = false;
|
||||
|
||||
// Check if data is actually ready using library function
|
||||
if (bmp.dataReady()) {
|
||||
// Read the sensor data
|
||||
if (bmp.performReading()) {
|
||||
Serial.print(F(" Temperature: "));
|
||||
Serial.print(bmp.temperature);
|
||||
Serial.println(F(" °C"));
|
||||
|
||||
Serial.print(F(" Pressure: "));
|
||||
Serial.print(bmp.pressure);
|
||||
Serial.println(F(" hPa"));
|
||||
|
||||
Serial.print(F(" Pin state after read: "));
|
||||
Serial.println(digitalRead(BMP5XX_IRQ_PIN) ? F("HIGH") : F("LOW"));
|
||||
} else {
|
||||
Serial.println(F(" Failed to read sensor data"));
|
||||
}
|
||||
} else {
|
||||
Serial.println(F("Data not ready (false interrupt?)"));
|
||||
}
|
||||
|
||||
Serial.println(F("---"));
|
||||
}
|
||||
|
||||
// Small delay to prevent overwhelming the serial output
|
||||
delay(10);
|
||||
}
|
||||
|
|
@ -1,246 +0,0 @@
|
|||
/*!
|
||||
* @file bmp5xx_test.ino
|
||||
*
|
||||
* This is a comprehensive test sketch for the BMP5xx pressure and temperature sensor.
|
||||
* It demonstrates all settings with pretty-printed output and continuous mode operation.
|
||||
*
|
||||
* Adafruit invests time and resources providing this open source code,
|
||||
* please support Adafruit and open-source hardware by purchasing
|
||||
* products from Adafruit!
|
||||
*
|
||||
* Written by Limor "ladyada" Fried for Adafruit Industries.
|
||||
* BSD license, all text above must be included in any redistribution
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <SPI.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include "Adafruit_BMP5xx.h"
|
||||
|
||||
#define SEALEVELPRESSURE_HPA (1013.25)
|
||||
|
||||
// For SPI mode, uncomment the next line and comment out the I2C begin() call in setup()
|
||||
// #define BMP5XX_CS_PIN 10
|
||||
|
||||
Adafruit_BMP5xx bmp; // Create BMP5xx object
|
||||
bmp5xx_powermode_t desiredMode = BMP5XX_POWERMODE_NORMAL; // Cache desired power mode
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
while (!Serial) delay(10); // Wait for Serial Monitor to open
|
||||
|
||||
Serial.println(F("Adafruit BMP5xx Comprehensive Test!"));
|
||||
|
||||
// Try to initialize the sensor
|
||||
// For I2C mode (default):
|
||||
if (!bmp.begin(BMP5XX_ALTERNATIVE_ADDRESS, &Wire)) {
|
||||
// For SPI mode (uncomment the line below and comment out the I2C line above):
|
||||
// if (!bmp.begin(BMP5XX_CS_PIN, &SPI)) {
|
||||
Serial.println(F("Could not find a valid BMP5xx sensor, check wiring!"));
|
||||
while (1) delay(10);
|
||||
}
|
||||
|
||||
Serial.println(F("BMP5xx found!"));
|
||||
Serial.println();
|
||||
|
||||
// Demonstrate all setter functions with range documentation
|
||||
Serial.println(F("=== Setting Up Sensor Configuration ==="));
|
||||
|
||||
/* Temperature Oversampling Settings:
|
||||
* BMP5XX_OVERSAMPLING_1X - 1x oversampling (fastest, least accurate)
|
||||
* BMP5XX_OVERSAMPLING_2X - 2x oversampling
|
||||
* BMP5XX_OVERSAMPLING_4X - 4x oversampling
|
||||
* BMP5XX_OVERSAMPLING_8X - 8x oversampling
|
||||
* BMP5XX_OVERSAMPLING_16X - 16x oversampling
|
||||
* BMP5XX_OVERSAMPLING_32X - 32x oversampling
|
||||
* BMP5XX_OVERSAMPLING_64X - 64x oversampling
|
||||
* BMP5XX_OVERSAMPLING_128X - 128x oversampling (slowest, most accurate)
|
||||
*/
|
||||
Serial.println(F("Setting temperature oversampling to 2X..."));
|
||||
bmp.setTemperatureOversampling(BMP5XX_OVERSAMPLING_2X);
|
||||
|
||||
/* Pressure Oversampling Settings (same options as temperature):
|
||||
* Higher oversampling = better accuracy but slower readings
|
||||
* Recommended: 16X for good balance of speed/accuracy
|
||||
*/
|
||||
Serial.println(F("Setting pressure oversampling to 16X..."));
|
||||
bmp.setPressureOversampling(BMP5XX_OVERSAMPLING_16X);
|
||||
|
||||
/* IIR Filter Coefficient Settings:
|
||||
* BMP5XX_IIR_FILTER_BYPASS - No filtering (fastest response)
|
||||
* BMP5XX_IIR_FILTER_COEFF_1 - Light filtering
|
||||
* BMP5XX_IIR_FILTER_COEFF_3 - Medium filtering
|
||||
* BMP5XX_IIR_FILTER_COEFF_7 - More filtering
|
||||
* BMP5XX_IIR_FILTER_COEFF_15 - Heavy filtering
|
||||
* BMP5XX_IIR_FILTER_COEFF_31 - Very heavy filtering
|
||||
* BMP5XX_IIR_FILTER_COEFF_63 - Maximum filtering
|
||||
* BMP5XX_IIR_FILTER_COEFF_127- Maximum filtering (slowest response)
|
||||
*/
|
||||
Serial.println(F("Setting IIR filter to coefficient 3..."));
|
||||
bmp.setIIRFilterCoeff(BMP5XX_IIR_FILTER_COEFF_3);
|
||||
|
||||
/* Output Data Rate Settings (Hz):
|
||||
* BMP5XX_ODR_240_HZ, BMP5XX_ODR_218_5_HZ, BMP5XX_ODR_199_1_HZ
|
||||
* BMP5XX_ODR_179_2_HZ, BMP5XX_ODR_160_HZ, BMP5XX_ODR_149_3_HZ
|
||||
* BMP5XX_ODR_140_HZ, BMP5XX_ODR_129_8_HZ, BMP5XX_ODR_120_HZ
|
||||
* BMP5XX_ODR_110_1_HZ, BMP5XX_ODR_100_2_HZ, BMP5XX_ODR_89_6_HZ
|
||||
* BMP5XX_ODR_80_HZ, BMP5XX_ODR_70_HZ, BMP5XX_ODR_60_HZ, BMP5XX_ODR_50_HZ
|
||||
* BMP5XX_ODR_45_HZ, BMP5XX_ODR_40_HZ, BMP5XX_ODR_35_HZ, BMP5XX_ODR_30_HZ
|
||||
* BMP5XX_ODR_25_HZ, BMP5XX_ODR_20_HZ, BMP5XX_ODR_15_HZ, BMP5XX_ODR_10_HZ
|
||||
* BMP5XX_ODR_05_HZ, BMP5XX_ODR_04_HZ, BMP5XX_ODR_03_HZ, BMP5XX_ODR_02_HZ
|
||||
* BMP5XX_ODR_01_HZ, BMP5XX_ODR_0_5_HZ, BMP5XX_ODR_0_250_HZ, BMP5XX_ODR_0_125_HZ
|
||||
*/
|
||||
Serial.println(F("Setting output data rate to 50 Hz..."));
|
||||
bmp.setOutputDataRate(BMP5XX_ODR_50_HZ);
|
||||
|
||||
/* Power Mode Settings:
|
||||
* BMP5XX_POWERMODE_STANDBY - Standby mode (no measurements)
|
||||
* BMP5XX_POWERMODE_NORMAL - Normal mode (periodic measurements)
|
||||
* BMP5XX_POWERMODE_FORCED - Forced mode (single measurement then standby)
|
||||
* BMP5XX_POWERMODE_CONTINUOUS - Continuous mode (fastest measurements)
|
||||
* BMP5XX_POWERMODE_DEEP_STANDBY - Deep standby (lowest power)
|
||||
*/
|
||||
Serial.println(F("Setting power mode to normal..."));
|
||||
desiredMode = BMP5XX_POWERMODE_NORMAL;
|
||||
bmp.setPowerMode(desiredMode);
|
||||
|
||||
/* Enable/Disable Pressure Measurement:
|
||||
* true - Enable pressure measurement (default)
|
||||
* false - Disable pressure measurement (temperature only)
|
||||
*/
|
||||
Serial.println(F("Enabling pressure measurement..."));
|
||||
bmp.enablePressure(true);
|
||||
|
||||
/* Interrupt Configuration:
|
||||
* BMP5XX_INTERRUPT_PULSED / BMP5XX_INTERRUPT_LATCHED - Interrupt mode
|
||||
* BMP5XX_INTERRUPT_ACTIVE_LOW / BMP5XX_INTERRUPT_ACTIVE_HIGH - Interrupt polarity
|
||||
* BMP5XX_INTERRUPT_PUSH_PULL / BMP5XX_INTERRUPT_OPEN_DRAIN - Interrupt drive
|
||||
* BMP5XX_INTERRUPT_DATA_READY, BMP5XX_INTERRUPT_FIFO_FULL, etc. - Interrupt sources (can combine with |)
|
||||
*/
|
||||
Serial.println(F("Configuring interrupt pin with data ready source..."));
|
||||
bmp.configureInterrupt(BMP5XX_INTERRUPT_LATCHED, BMP5XX_INTERRUPT_ACTIVE_HIGH, BMP5XX_INTERRUPT_PUSH_PULL, BMP5XX_INTERRUPT_DATA_READY, true);
|
||||
|
||||
Serial.println();
|
||||
Serial.println(F("=== Current Sensor Configuration ==="));
|
||||
|
||||
// Pretty print temperature oversampling inline
|
||||
Serial.print(F("Temperature Oversampling: "));
|
||||
switch(bmp.getTemperatureOversampling()) {
|
||||
case BMP5XX_OVERSAMPLING_1X: Serial.println(F("1X")); break;
|
||||
case BMP5XX_OVERSAMPLING_2X: Serial.println(F("2X")); break;
|
||||
case BMP5XX_OVERSAMPLING_4X: Serial.println(F("4X")); break;
|
||||
case BMP5XX_OVERSAMPLING_8X: Serial.println(F("8X")); break;
|
||||
case BMP5XX_OVERSAMPLING_16X: Serial.println(F("16X")); break;
|
||||
case BMP5XX_OVERSAMPLING_32X: Serial.println(F("32X")); break;
|
||||
case BMP5XX_OVERSAMPLING_64X: Serial.println(F("64X")); break;
|
||||
case BMP5XX_OVERSAMPLING_128X: Serial.println(F("128X")); break;
|
||||
default: Serial.println(F("Unknown")); break;
|
||||
}
|
||||
|
||||
// Pretty print pressure oversampling inline
|
||||
Serial.print(F("Pressure Oversampling: "));
|
||||
switch(bmp.getPressureOversampling()) {
|
||||
case BMP5XX_OVERSAMPLING_1X: Serial.println(F("1X")); break;
|
||||
case BMP5XX_OVERSAMPLING_2X: Serial.println(F("2X")); break;
|
||||
case BMP5XX_OVERSAMPLING_4X: Serial.println(F("4X")); break;
|
||||
case BMP5XX_OVERSAMPLING_8X: Serial.println(F("8X")); break;
|
||||
case BMP5XX_OVERSAMPLING_16X: Serial.println(F("16X")); break;
|
||||
case BMP5XX_OVERSAMPLING_32X: Serial.println(F("32X")); break;
|
||||
case BMP5XX_OVERSAMPLING_64X: Serial.println(F("64X")); break;
|
||||
case BMP5XX_OVERSAMPLING_128X: Serial.println(F("128X")); break;
|
||||
default: Serial.println(F("Unknown")); break;
|
||||
}
|
||||
|
||||
// Pretty print IIR filter coefficient inline
|
||||
Serial.print(F("IIR Filter Coefficient: "));
|
||||
switch(bmp.getIIRFilterCoeff()) {
|
||||
case BMP5XX_IIR_FILTER_BYPASS: Serial.println(F("Bypass (No filtering)")); break;
|
||||
case BMP5XX_IIR_FILTER_COEFF_1: Serial.println(F("1 (Light filtering)")); break;
|
||||
case BMP5XX_IIR_FILTER_COEFF_3: Serial.println(F("3 (Medium filtering)")); break;
|
||||
case BMP5XX_IIR_FILTER_COEFF_7: Serial.println(F("7 (More filtering)")); break;
|
||||
case BMP5XX_IIR_FILTER_COEFF_15: Serial.println(F("15 (Heavy filtering)")); break;
|
||||
case BMP5XX_IIR_FILTER_COEFF_31: Serial.println(F("31 (Very heavy filtering)")); break;
|
||||
case BMP5XX_IIR_FILTER_COEFF_63: Serial.println(F("63 (Maximum filtering)")); break;
|
||||
case BMP5XX_IIR_FILTER_COEFF_127:Serial.println(F("127 (Maximum filtering)")); break;
|
||||
default: Serial.println(F("Unknown")); break;
|
||||
}
|
||||
|
||||
// Pretty print output data rate inline
|
||||
Serial.print(F("Output Data Rate: "));
|
||||
switch(bmp.getOutputDataRate()) {
|
||||
case BMP5XX_ODR_240_HZ: Serial.println(F("240 Hz")); break;
|
||||
case BMP5XX_ODR_218_5_HZ: Serial.println(F("218.5 Hz")); break;
|
||||
case BMP5XX_ODR_199_1_HZ: Serial.println(F("199.1 Hz")); break;
|
||||
case BMP5XX_ODR_179_2_HZ: Serial.println(F("179.2 Hz")); break;
|
||||
case BMP5XX_ODR_160_HZ: Serial.println(F("160 Hz")); break;
|
||||
case BMP5XX_ODR_149_3_HZ: Serial.println(F("149.3 Hz")); break;
|
||||
case BMP5XX_ODR_140_HZ: Serial.println(F("140 Hz")); break;
|
||||
case BMP5XX_ODR_129_8_HZ: Serial.println(F("129.8 Hz")); break;
|
||||
case BMP5XX_ODR_120_HZ: Serial.println(F("120 Hz")); break;
|
||||
case BMP5XX_ODR_110_1_HZ: Serial.println(F("110.1 Hz")); break;
|
||||
case BMP5XX_ODR_100_2_HZ: Serial.println(F("100.2 Hz")); break;
|
||||
case BMP5XX_ODR_89_6_HZ: Serial.println(F("89.6 Hz")); break;
|
||||
case BMP5XX_ODR_80_HZ: Serial.println(F("80 Hz")); break;
|
||||
case BMP5XX_ODR_70_HZ: Serial.println(F("70 Hz")); break;
|
||||
case BMP5XX_ODR_60_HZ: Serial.println(F("60 Hz")); break;
|
||||
case BMP5XX_ODR_50_HZ: Serial.println(F("50 Hz")); break;
|
||||
case BMP5XX_ODR_45_HZ: Serial.println(F("45 Hz")); break;
|
||||
case BMP5XX_ODR_40_HZ: Serial.println(F("40 Hz")); break;
|
||||
case BMP5XX_ODR_35_HZ: Serial.println(F("35 Hz")); break;
|
||||
case BMP5XX_ODR_30_HZ: Serial.println(F("30 Hz")); break;
|
||||
case BMP5XX_ODR_25_HZ: Serial.println(F("25 Hz")); break;
|
||||
case BMP5XX_ODR_20_HZ: Serial.println(F("20 Hz")); break;
|
||||
case BMP5XX_ODR_15_HZ: Serial.println(F("15 Hz")); break;
|
||||
case BMP5XX_ODR_10_HZ: Serial.println(F("10 Hz")); break;
|
||||
case BMP5XX_ODR_05_HZ: Serial.println(F("5 Hz")); break;
|
||||
case BMP5XX_ODR_04_HZ: Serial.println(F("4 Hz")); break;
|
||||
case BMP5XX_ODR_03_HZ: Serial.println(F("3 Hz")); break;
|
||||
case BMP5XX_ODR_02_HZ: Serial.println(F("2 Hz")); break;
|
||||
case BMP5XX_ODR_01_HZ: Serial.println(F("1 Hz")); break;
|
||||
case BMP5XX_ODR_0_5_HZ: Serial.println(F("0.5 Hz")); break;
|
||||
case BMP5XX_ODR_0_250_HZ: Serial.println(F("0.25 Hz")); break;
|
||||
case BMP5XX_ODR_0_125_HZ: Serial.println(F("0.125 Hz")); break;
|
||||
default: Serial.println(F("Unknown")); break;
|
||||
}
|
||||
|
||||
// Pretty print power mode inline
|
||||
Serial.print(F("Power Mode: "));
|
||||
switch(bmp.getPowerMode()) {
|
||||
case BMP5XX_POWERMODE_STANDBY: Serial.println(F("Standby")); break;
|
||||
case BMP5XX_POWERMODE_NORMAL: Serial.println(F("Normal")); break;
|
||||
case BMP5XX_POWERMODE_FORCED: Serial.println(F("Forced")); break;
|
||||
case BMP5XX_POWERMODE_CONTINUOUS: Serial.println(F("Continuous")); break;
|
||||
case BMP5XX_POWERMODE_DEEP_STANDBY:Serial.println(F("Deep Standby")); break;
|
||||
default: Serial.println(F("Unknown")); break;
|
||||
}
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Check if new data is ready before reading
|
||||
if (!bmp.dataReady()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Data is ready, perform reading
|
||||
if (!bmp.performReading()) {
|
||||
return;
|
||||
}
|
||||
|
||||
Serial.print(F("Temperature = "));
|
||||
Serial.print(bmp.temperature);
|
||||
Serial.println(F(" °C"));
|
||||
|
||||
Serial.print(F("Pressure = "));
|
||||
Serial.print(bmp.pressure);
|
||||
Serial.println(F(" hPa"));
|
||||
|
||||
Serial.print(F("Approx. Altitude = "));
|
||||
Serial.print(bmp.readAltitude(SEALEVELPRESSURE_HPA));
|
||||
Serial.println(F(" m"));
|
||||
|
||||
Serial.println(F("---"));
|
||||
|
||||
delay(10); // Short delay since we're checking dataReady()
|
||||
}
|
||||
|
|
@ -1,125 +0,0 @@
|
|||
/*!
|
||||
* @file bmp5xx_unified_sensor.ino
|
||||
*
|
||||
* This is an example for the BMP5xx pressure and temperature sensor using
|
||||
* the Adafruit Unified Sensor API. This approach allows for easy integration
|
||||
* with other Adafruit sensor libraries and provides standardized sensor events.
|
||||
*
|
||||
* Adafruit invests time and resources providing this open source code,
|
||||
* please support Adafruit and open-source hardware by purchasing
|
||||
* products from Adafruit!
|
||||
*
|
||||
* Written by Limor "ladyada" Fried for Adafruit Industries.
|
||||
* BSD license, all text above must be included in any redistribution
|
||||
*/
|
||||
|
||||
#include <Wire.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include "Adafruit_BMP5xx.h"
|
||||
|
||||
Adafruit_BMP5xx bmp; // Create BMP5xx object
|
||||
|
||||
// Get separate sensor objects for temperature and pressure
|
||||
Adafruit_Sensor *bmp_temp = NULL;
|
||||
Adafruit_Sensor *bmp_pressure = NULL;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
while (!Serial) delay(10); // Wait for Serial Monitor to open
|
||||
|
||||
Serial.println(F("Adafruit BMP5xx Unified Sensor API Example"));
|
||||
Serial.println();
|
||||
|
||||
// Try to initialize the sensor using I2C with alternative address
|
||||
if (!bmp.begin(BMP5XX_ALTERNATIVE_ADDRESS, &Wire)) {
|
||||
Serial.println(F("Could not find a valid BMP5xx sensor, check wiring!"));
|
||||
while (1) delay(10);
|
||||
}
|
||||
|
||||
Serial.println(F("BMP5xx found!"));
|
||||
|
||||
// Get the unified sensor objects
|
||||
bmp_temp = bmp.getTemperatureSensor();
|
||||
bmp_pressure = bmp.getPressureSensor();
|
||||
|
||||
// Print sensor details using the unified sensor API
|
||||
Serial.println(F("=== Temperature Sensor Details ==="));
|
||||
sensor_t temp_sensor;
|
||||
bmp_temp->getSensor(&temp_sensor);
|
||||
Serial.print(F("Sensor Name: ")); Serial.println(temp_sensor.name);
|
||||
Serial.print(F("Sensor Type: ")); Serial.println(temp_sensor.type);
|
||||
Serial.print(F("Driver Ver: ")); Serial.println(temp_sensor.version);
|
||||
Serial.print(F("Unique ID: ")); Serial.println(temp_sensor.sensor_id);
|
||||
Serial.print(F("Min Value: ")); Serial.print(temp_sensor.min_value); Serial.println(F(" °C"));
|
||||
Serial.print(F("Max Value: ")); Serial.print(temp_sensor.max_value); Serial.println(F(" °C"));
|
||||
Serial.print(F("Resolution: ")); Serial.print(temp_sensor.resolution); Serial.println(F(" °C"));
|
||||
Serial.println();
|
||||
|
||||
Serial.println(F("=== Pressure Sensor Details ==="));
|
||||
sensor_t pressure_sensor;
|
||||
bmp_pressure->getSensor(&pressure_sensor);
|
||||
Serial.print(F("Sensor Name: ")); Serial.println(pressure_sensor.name);
|
||||
Serial.print(F("Sensor Type: ")); Serial.println(pressure_sensor.type);
|
||||
Serial.print(F("Driver Ver: ")); Serial.println(pressure_sensor.version);
|
||||
Serial.print(F("Unique ID: ")); Serial.println(pressure_sensor.sensor_id);
|
||||
Serial.print(F("Min Value: ")); Serial.print(pressure_sensor.min_value); Serial.println(F(" hPa"));
|
||||
Serial.print(F("Max Value: ")); Serial.print(pressure_sensor.max_value); Serial.println(F(" hPa"));
|
||||
Serial.print(F("Resolution: ")); Serial.print(pressure_sensor.resolution); Serial.println(F(" hPa"));
|
||||
Serial.println();
|
||||
|
||||
// Configure sensor for optimal performance
|
||||
bmp.setTemperatureOversampling(BMP5XX_OVERSAMPLING_2X);
|
||||
bmp.setPressureOversampling(BMP5XX_OVERSAMPLING_16X);
|
||||
bmp.setIIRFilterCoeff(BMP5XX_IIR_FILTER_COEFF_3);
|
||||
bmp.setOutputDataRate(BMP5XX_ODR_50_HZ);
|
||||
bmp.setPowerMode(BMP5XX_POWERMODE_NORMAL);
|
||||
|
||||
Serial.println(F("=== Starting Unified Sensor Readings ==="));
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Create sensor event structures
|
||||
sensors_event_t temp_event, pressure_event;
|
||||
|
||||
// Get temperature event using unified sensor API
|
||||
if (bmp_temp->getEvent(&temp_event)) {
|
||||
Serial.print(F("Temperature: "));
|
||||
Serial.print(temp_event.temperature);
|
||||
Serial.print(F(" °C"));
|
||||
|
||||
// Print additional event details
|
||||
Serial.print(F(" [Timestamp: "));
|
||||
Serial.print(temp_event.timestamp);
|
||||
Serial.print(F(" ms, Sensor ID: "));
|
||||
Serial.print(temp_event.sensor_id);
|
||||
Serial.println(F("]"));
|
||||
} else {
|
||||
Serial.println(F("Failed to get temperature event"));
|
||||
}
|
||||
|
||||
// Get pressure event using unified sensor API
|
||||
if (bmp_pressure->getEvent(&pressure_event)) {
|
||||
Serial.print(F("Pressure: "));
|
||||
Serial.print(pressure_event.pressure);
|
||||
Serial.print(F(" hPa"));
|
||||
|
||||
// Print additional event details
|
||||
Serial.print(F(" [Timestamp: "));
|
||||
Serial.print(pressure_event.timestamp);
|
||||
Serial.print(F(" ms, Sensor ID: "));
|
||||
Serial.print(pressure_event.sensor_id);
|
||||
Serial.println(F("]"));
|
||||
|
||||
// Calculate and display altitude using pressure
|
||||
float altitude = 44330.0 * (1.0 - pow(pressure_event.pressure / 1013.25, 0.1903));
|
||||
Serial.print(F("Altitude: "));
|
||||
Serial.print(altitude);
|
||||
Serial.println(F(" m"));
|
||||
} else {
|
||||
Serial.println(F("Failed to get pressure event"));
|
||||
}
|
||||
|
||||
Serial.println(F("---"));
|
||||
delay(2000); // Read every 2 seconds
|
||||
}
|
||||
BIN
html/bc_s.png
Normal file
|
After Width: | Height: | Size: 676 B |
BIN
html/bdwn.png
Normal file
|
After Width: | Height: | Size: 147 B |
BIN
html/closed.png
Normal file
|
After Width: | Height: | Size: 132 B |
BIN
html/doc.png
Normal file
|
After Width: | Height: | Size: 746 B |
1596
html/doxygen.css
Normal file
BIN
html/doxygen.png
Normal file
|
After Width: | Height: | Size: 3.7 KiB |
97
html/dynsections.js
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
function toggleVisibility(linkObj)
|
||||
{
|
||||
var base = $(linkObj).attr('id');
|
||||
var summary = $('#'+base+'-summary');
|
||||
var content = $('#'+base+'-content');
|
||||
var trigger = $('#'+base+'-trigger');
|
||||
var src=$(trigger).attr('src');
|
||||
if (content.is(':visible')===true) {
|
||||
content.hide();
|
||||
summary.show();
|
||||
$(linkObj).addClass('closed').removeClass('opened');
|
||||
$(trigger).attr('src',src.substring(0,src.length-8)+'closed.png');
|
||||
} else {
|
||||
content.show();
|
||||
summary.hide();
|
||||
$(linkObj).removeClass('closed').addClass('opened');
|
||||
$(trigger).attr('src',src.substring(0,src.length-10)+'open.png');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function updateStripes()
|
||||
{
|
||||
$('table.directory tr').
|
||||
removeClass('even').filter(':visible:even').addClass('even');
|
||||
}
|
||||
|
||||
function toggleLevel(level)
|
||||
{
|
||||
$('table.directory tr').each(function() {
|
||||
var l = this.id.split('_').length-1;
|
||||
var i = $('#img'+this.id.substring(3));
|
||||
var a = $('#arr'+this.id.substring(3));
|
||||
if (l<level+1) {
|
||||
i.removeClass('iconfopen iconfclosed').addClass('iconfopen');
|
||||
a.html('▼');
|
||||
$(this).show();
|
||||
} else if (l==level+1) {
|
||||
i.removeClass('iconfclosed iconfopen').addClass('iconfclosed');
|
||||
a.html('►');
|
||||
$(this).show();
|
||||
} else {
|
||||
$(this).hide();
|
||||
}
|
||||
});
|
||||
updateStripes();
|
||||
}
|
||||
|
||||
function toggleFolder(id)
|
||||
{
|
||||
// the clicked row
|
||||
var currentRow = $('#row_'+id);
|
||||
|
||||
// all rows after the clicked row
|
||||
var rows = currentRow.nextAll("tr");
|
||||
|
||||
var re = new RegExp('^row_'+id+'\\d+_$', "i"); //only one sub
|
||||
|
||||
// only match elements AFTER this one (can't hide elements before)
|
||||
var childRows = rows.filter(function() { return this.id.match(re); });
|
||||
|
||||
// first row is visible we are HIDING
|
||||
if (childRows.filter(':first').is(':visible')===true) {
|
||||
// replace down arrow by right arrow for current row
|
||||
var currentRowSpans = currentRow.find("span");
|
||||
currentRowSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed");
|
||||
currentRowSpans.filter(".arrow").html('►');
|
||||
rows.filter("[id^=row_"+id+"]").hide(); // hide all children
|
||||
} else { // we are SHOWING
|
||||
// replace right arrow by down arrow for current row
|
||||
var currentRowSpans = currentRow.find("span");
|
||||
currentRowSpans.filter(".iconfclosed").removeClass("iconfclosed").addClass("iconfopen");
|
||||
currentRowSpans.filter(".arrow").html('▼');
|
||||
// replace down arrows by right arrows for child rows
|
||||
var childRowsSpans = childRows.find("span");
|
||||
childRowsSpans.filter(".iconfopen").removeClass("iconfopen").addClass("iconfclosed");
|
||||
childRowsSpans.filter(".arrow").html('►');
|
||||
childRows.show(); //show all children
|
||||
}
|
||||
updateStripes();
|
||||
}
|
||||
|
||||
|
||||
function toggleInherit(id)
|
||||
{
|
||||
var rows = $('tr.inherit.'+id);
|
||||
var img = $('tr.inherit_header.'+id+' img');
|
||||
var src = $(img).attr('src');
|
||||
if (rows.filter(':first').is(':visible')===true) {
|
||||
rows.css('display','none');
|
||||
$(img).attr('src',src.substring(0,src.length-8)+'closed.png');
|
||||
} else {
|
||||
rows.css('display','table-row'); // using show() causes jump in firefox
|
||||
$(img).attr('src',src.substring(0,src.length-10)+'open.png');
|
||||
}
|
||||
}
|
||||
|
||||
BIN
html/folderclosed.png
Normal file
|
After Width: | Height: | Size: 616 B |
BIN
html/folderopen.png
Normal file
|
After Width: | Height: | Size: 597 B |
73
html/index.html
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
||||
<meta name="generator" content="Doxygen 1.8.13"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
||||
<title>Adafruit BMP5xx Library: Main Page</title>
|
||||
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="jquery.js"></script>
|
||||
<script type="text/javascript" src="dynsections.js"></script>
|
||||
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
||||
<script type="text/javascript" src="search/searchdata.js"></script>
|
||||
<script type="text/javascript" src="search/search.js"></script>
|
||||
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">Adafruit BMP5xx Library
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!-- end header part -->
|
||||
<!-- Generated by Doxygen 1.8.13 -->
|
||||
<script type="text/javascript">
|
||||
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
||||
</script>
|
||||
<script type="text/javascript" src="menudata.js"></script>
|
||||
<script type="text/javascript" src="menu.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
initMenu('',true,false,'search.php','Search');
|
||||
$(document).ready(function() { init_search(); });
|
||||
});
|
||||
</script>
|
||||
<div id="main-nav"></div>
|
||||
</div><!-- top -->
|
||||
<!-- window showing the filter options -->
|
||||
<div id="MSearchSelectWindow"
|
||||
onmouseover="return searchBox.OnSearchSelectShow()"
|
||||
onmouseout="return searchBox.OnSearchSelectHide()"
|
||||
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
||||
</div>
|
||||
|
||||
<!-- iframe showing the search results (closed by default) -->
|
||||
<div id="MSearchResultsWindow">
|
||||
<iframe src="javascript:void(0)" frameborder="0"
|
||||
name="MSearchResults" id="MSearchResults">
|
||||
</iframe>
|
||||
</div>
|
||||
|
||||
<div class="header">
|
||||
<div class="headertitle">
|
||||
<div class="title">Adafruit BMP5xx Library Documentation</div> </div>
|
||||
</div><!--header-->
|
||||
<div class="contents">
|
||||
</div><!-- contents -->
|
||||
<!-- start footer part -->
|
||||
<hr class="footer"/><address class="footer"><small>
|
||||
Generated by  <a href="http://www.doxygen.org/index.html">
|
||||
<img class="footer" src="doxygen.png" alt="doxygen"/>
|
||||
</a> 1.8.13
|
||||
</small></address>
|
||||
</body>
|
||||
</html>
|
||||
87
html/jquery.js
vendored
Normal file
26
html/menu.js
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
function initMenu(relPath,searchEnabled,serverSide,searchPage,search) {
|
||||
function makeTree(data,relPath) {
|
||||
var result='';
|
||||
if ('children' in data) {
|
||||
result+='<ul>';
|
||||
for (var i in data.children) {
|
||||
result+='<li><a href="'+relPath+data.children[i].url+'">'+
|
||||
data.children[i].text+'</a>'+
|
||||
makeTree(data.children[i],relPath)+'</li>';
|
||||
}
|
||||
result+='</ul>';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
$('#main-nav').append(makeTree(menudata,relPath));
|
||||
$('#main-nav').children(':first').addClass('sm sm-dox').attr('id','main-menu');
|
||||
if (searchEnabled) {
|
||||
if (serverSide) {
|
||||
$('#main-menu').append('<li style="float:right"><div id="MSearchBox" class="MSearchBoxInactive"><div class="left"><form id="FSearchBox" action="'+searchPage+'" method="get"><img id="MSearchSelect" src="'+relPath+'search/mag.png" alt=""/><input type="text" id="MSearchField" name="query" value="'+search+'" size="20" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)"></form></div><div class="right"></div></div></li>');
|
||||
} else {
|
||||
$('#main-menu').append('<li style="float:right"><div id="MSearchBox" class="MSearchBoxInactive"><span class="left"><img id="MSearchSelect" src="'+relPath+'search/mag_sel.png" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" alt=""/><input type="text" id="MSearchField" value="'+search+'" accesskey="S" onfocus="searchBox.OnSearchFieldFocus(true)" onblur="searchBox.OnSearchFieldFocus(false)" onkeyup="searchBox.OnSearchFieldChange(event)"/></span><span class="right"><a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="'+relPath+'search/close.png" alt=""/></a></span></div></li>');
|
||||
}
|
||||
}
|
||||
$('#main-menu').smartmenus();
|
||||
}
|
||||
2
html/menudata.js
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
var menudata={children:[
|
||||
{text:"Main Page",url:"index.html"}]}
|
||||
BIN
html/nav_f.png
Normal file
|
After Width: | Height: | Size: 153 B |
BIN
html/nav_g.png
Normal file
|
After Width: | Height: | Size: 95 B |
BIN
html/nav_h.png
Normal file
|
After Width: | Height: | Size: 98 B |
BIN
html/open.png
Normal file
|
After Width: | Height: | Size: 123 B |
BIN
html/search/close.png
Normal file
|
After Width: | Height: | Size: 273 B |
BIN
html/search/mag_sel.png
Normal file
|
After Width: | Height: | Size: 563 B |
12
html/search/nomatches.html
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html><head><title></title>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
||||
<link rel="stylesheet" type="text/css" href="search.css"/>
|
||||
<script type="text/javascript" src="search.js"></script>
|
||||
</head>
|
||||
<body class="SRPage">
|
||||
<div id="SRIndex">
|
||||
<div class="SRStatus" id="NoMatches">No Matches</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
271
html/search/search.css
Normal file
|
|
@ -0,0 +1,271 @@
|
|||
/*---------------- Search Box */
|
||||
|
||||
#FSearchBox {
|
||||
float: left;
|
||||
}
|
||||
|
||||
#MSearchBox {
|
||||
white-space : nowrap;
|
||||
float: none;
|
||||
margin-top: 8px;
|
||||
right: 0px;
|
||||
width: 170px;
|
||||
height: 24px;
|
||||
z-index: 102;
|
||||
}
|
||||
|
||||
#MSearchBox .left
|
||||
{
|
||||
display:block;
|
||||
position:absolute;
|
||||
left:10px;
|
||||
width:20px;
|
||||
height:19px;
|
||||
background:url('search_l.png') no-repeat;
|
||||
background-position:right;
|
||||
}
|
||||
|
||||
#MSearchSelect {
|
||||
display:block;
|
||||
position:absolute;
|
||||
width:20px;
|
||||
height:19px;
|
||||
}
|
||||
|
||||
.left #MSearchSelect {
|
||||
left:4px;
|
||||
}
|
||||
|
||||
.right #MSearchSelect {
|
||||
right:5px;
|
||||
}
|
||||
|
||||
#MSearchField {
|
||||
display:block;
|
||||
position:absolute;
|
||||
height:19px;
|
||||
background:url('search_m.png') repeat-x;
|
||||
border:none;
|
||||
width:115px;
|
||||
margin-left:20px;
|
||||
padding-left:4px;
|
||||
color: #909090;
|
||||
outline: none;
|
||||
font: 9pt Arial, Verdana, sans-serif;
|
||||
-webkit-border-radius: 0px;
|
||||
}
|
||||
|
||||
#FSearchBox #MSearchField {
|
||||
margin-left:15px;
|
||||
}
|
||||
|
||||
#MSearchBox .right {
|
||||
display:block;
|
||||
position:absolute;
|
||||
right:10px;
|
||||
top:8px;
|
||||
width:20px;
|
||||
height:19px;
|
||||
background:url('search_r.png') no-repeat;
|
||||
background-position:left;
|
||||
}
|
||||
|
||||
#MSearchClose {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: 4px;
|
||||
background : none;
|
||||
border: none;
|
||||
margin: 0px 4px 0px 0px;
|
||||
padding: 0px 0px;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.left #MSearchClose {
|
||||
left: 6px;
|
||||
}
|
||||
|
||||
.right #MSearchClose {
|
||||
right: 2px;
|
||||
}
|
||||
|
||||
.MSearchBoxActive #MSearchField {
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
/*---------------- Search filter selection */
|
||||
|
||||
#MSearchSelectWindow {
|
||||
display: none;
|
||||
position: absolute;
|
||||
left: 0; top: 0;
|
||||
border: 1px solid #90A5CE;
|
||||
background-color: #F9FAFC;
|
||||
z-index: 10001;
|
||||
padding-top: 4px;
|
||||
padding-bottom: 4px;
|
||||
-moz-border-radius: 4px;
|
||||
-webkit-border-top-left-radius: 4px;
|
||||
-webkit-border-top-right-radius: 4px;
|
||||
-webkit-border-bottom-left-radius: 4px;
|
||||
-webkit-border-bottom-right-radius: 4px;
|
||||
-webkit-box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
|
||||
.SelectItem {
|
||||
font: 8pt Arial, Verdana, sans-serif;
|
||||
padding-left: 2px;
|
||||
padding-right: 12px;
|
||||
border: 0px;
|
||||
}
|
||||
|
||||
span.SelectionMark {
|
||||
margin-right: 4px;
|
||||
font-family: monospace;
|
||||
outline-style: none;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.SelectItem {
|
||||
display: block;
|
||||
outline-style: none;
|
||||
color: #000000;
|
||||
text-decoration: none;
|
||||
padding-left: 6px;
|
||||
padding-right: 12px;
|
||||
}
|
||||
|
||||
a.SelectItem:focus,
|
||||
a.SelectItem:active {
|
||||
color: #000000;
|
||||
outline-style: none;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
a.SelectItem:hover {
|
||||
color: #FFFFFF;
|
||||
background-color: #3D578C;
|
||||
outline-style: none;
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
display: block;
|
||||
}
|
||||
|
||||
/*---------------- Search results window */
|
||||
|
||||
iframe#MSearchResults {
|
||||
width: 60ex;
|
||||
height: 15em;
|
||||
}
|
||||
|
||||
#MSearchResultsWindow {
|
||||
display: none;
|
||||
position: absolute;
|
||||
left: 0; top: 0;
|
||||
border: 1px solid #000;
|
||||
background-color: #EEF1F7;
|
||||
z-index:10000;
|
||||
}
|
||||
|
||||
/* ----------------------------------- */
|
||||
|
||||
|
||||
#SRIndex {
|
||||
clear:both;
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
|
||||
.SREntry {
|
||||
font-size: 10pt;
|
||||
padding-left: 1ex;
|
||||
}
|
||||
|
||||
.SRPage .SREntry {
|
||||
font-size: 8pt;
|
||||
padding: 1px 5px;
|
||||
}
|
||||
|
||||
body.SRPage {
|
||||
margin: 5px 2px;
|
||||
}
|
||||
|
||||
.SRChildren {
|
||||
padding-left: 3ex; padding-bottom: .5em
|
||||
}
|
||||
|
||||
.SRPage .SRChildren {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.SRSymbol {
|
||||
font-weight: bold;
|
||||
color: #425E97;
|
||||
font-family: Arial, Verdana, sans-serif;
|
||||
text-decoration: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
a.SRScope {
|
||||
display: block;
|
||||
color: #425E97;
|
||||
font-family: Arial, Verdana, sans-serif;
|
||||
text-decoration: none;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
a.SRSymbol:focus, a.SRSymbol:active,
|
||||
a.SRScope:focus, a.SRScope:active {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
span.SRScope {
|
||||
padding-left: 4px;
|
||||
}
|
||||
|
||||
.SRPage .SRStatus {
|
||||
padding: 2px 5px;
|
||||
font-size: 8pt;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.SRResult {
|
||||
display: none;
|
||||
}
|
||||
|
||||
DIV.searchresults {
|
||||
margin-left: 10px;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
/*---------------- External search page results */
|
||||
|
||||
.searchresult {
|
||||
background-color: #F0F3F8;
|
||||
}
|
||||
|
||||
.pages b {
|
||||
color: white;
|
||||
padding: 5px 5px 3px 5px;
|
||||
background-image: url("../tab_a.png");
|
||||
background-repeat: repeat-x;
|
||||
text-shadow: 0 1px 1px #000000;
|
||||
}
|
||||
|
||||
.pages {
|
||||
line-height: 17px;
|
||||
margin-left: 4px;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.hl {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
#searchresults {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.searchpages {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
791
html/search/search.js
Normal file
|
|
@ -0,0 +1,791 @@
|
|||
function convertToId(search)
|
||||
{
|
||||
var result = '';
|
||||
for (i=0;i<search.length;i++)
|
||||
{
|
||||
var c = search.charAt(i);
|
||||
var cn = c.charCodeAt(0);
|
||||
if (c.match(/[a-z0-9\u0080-\uFFFF]/))
|
||||
{
|
||||
result+=c;
|
||||
}
|
||||
else if (cn<16)
|
||||
{
|
||||
result+="_0"+cn.toString(16);
|
||||
}
|
||||
else
|
||||
{
|
||||
result+="_"+cn.toString(16);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function getXPos(item)
|
||||
{
|
||||
var x = 0;
|
||||
if (item.offsetWidth)
|
||||
{
|
||||
while (item && item!=document.body)
|
||||
{
|
||||
x += item.offsetLeft;
|
||||
item = item.offsetParent;
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
function getYPos(item)
|
||||
{
|
||||
var y = 0;
|
||||
if (item.offsetWidth)
|
||||
{
|
||||
while (item && item!=document.body)
|
||||
{
|
||||
y += item.offsetTop;
|
||||
item = item.offsetParent;
|
||||
}
|
||||
}
|
||||
return y;
|
||||
}
|
||||
|
||||
/* A class handling everything associated with the search panel.
|
||||
|
||||
Parameters:
|
||||
name - The name of the global variable that will be
|
||||
storing this instance. Is needed to be able to set timeouts.
|
||||
resultPath - path to use for external files
|
||||
*/
|
||||
function SearchBox(name, resultsPath, inFrame, label)
|
||||
{
|
||||
if (!name || !resultsPath) { alert("Missing parameters to SearchBox."); }
|
||||
|
||||
// ---------- Instance variables
|
||||
this.name = name;
|
||||
this.resultsPath = resultsPath;
|
||||
this.keyTimeout = 0;
|
||||
this.keyTimeoutLength = 500;
|
||||
this.closeSelectionTimeout = 300;
|
||||
this.lastSearchValue = "";
|
||||
this.lastResultsPage = "";
|
||||
this.hideTimeout = 0;
|
||||
this.searchIndex = 0;
|
||||
this.searchActive = false;
|
||||
this.insideFrame = inFrame;
|
||||
this.searchLabel = label;
|
||||
|
||||
// ----------- DOM Elements
|
||||
|
||||
this.DOMSearchField = function()
|
||||
{ return document.getElementById("MSearchField"); }
|
||||
|
||||
this.DOMSearchSelect = function()
|
||||
{ return document.getElementById("MSearchSelect"); }
|
||||
|
||||
this.DOMSearchSelectWindow = function()
|
||||
{ return document.getElementById("MSearchSelectWindow"); }
|
||||
|
||||
this.DOMPopupSearchResults = function()
|
||||
{ return document.getElementById("MSearchResults"); }
|
||||
|
||||
this.DOMPopupSearchResultsWindow = function()
|
||||
{ return document.getElementById("MSearchResultsWindow"); }
|
||||
|
||||
this.DOMSearchClose = function()
|
||||
{ return document.getElementById("MSearchClose"); }
|
||||
|
||||
this.DOMSearchBox = function()
|
||||
{ return document.getElementById("MSearchBox"); }
|
||||
|
||||
// ------------ Event Handlers
|
||||
|
||||
// Called when focus is added or removed from the search field.
|
||||
this.OnSearchFieldFocus = function(isActive)
|
||||
{
|
||||
this.Activate(isActive);
|
||||
}
|
||||
|
||||
this.OnSearchSelectShow = function()
|
||||
{
|
||||
var searchSelectWindow = this.DOMSearchSelectWindow();
|
||||
var searchField = this.DOMSearchSelect();
|
||||
|
||||
if (this.insideFrame)
|
||||
{
|
||||
var left = getXPos(searchField);
|
||||
var top = getYPos(searchField);
|
||||
left += searchField.offsetWidth + 6;
|
||||
top += searchField.offsetHeight;
|
||||
|
||||
// show search selection popup
|
||||
searchSelectWindow.style.display='block';
|
||||
left -= searchSelectWindow.offsetWidth;
|
||||
searchSelectWindow.style.left = left + 'px';
|
||||
searchSelectWindow.style.top = top + 'px';
|
||||
}
|
||||
else
|
||||
{
|
||||
var left = getXPos(searchField);
|
||||
var top = getYPos(searchField);
|
||||
top += searchField.offsetHeight;
|
||||
|
||||
// show search selection popup
|
||||
searchSelectWindow.style.display='block';
|
||||
searchSelectWindow.style.left = left + 'px';
|
||||
searchSelectWindow.style.top = top + 'px';
|
||||
}
|
||||
|
||||
// stop selection hide timer
|
||||
if (this.hideTimeout)
|
||||
{
|
||||
clearTimeout(this.hideTimeout);
|
||||
this.hideTimeout=0;
|
||||
}
|
||||
return false; // to avoid "image drag" default event
|
||||
}
|
||||
|
||||
this.OnSearchSelectHide = function()
|
||||
{
|
||||
this.hideTimeout = setTimeout(this.name +".CloseSelectionWindow()",
|
||||
this.closeSelectionTimeout);
|
||||
}
|
||||
|
||||
// Called when the content of the search field is changed.
|
||||
this.OnSearchFieldChange = function(evt)
|
||||
{
|
||||
if (this.keyTimeout) // kill running timer
|
||||
{
|
||||
clearTimeout(this.keyTimeout);
|
||||
this.keyTimeout = 0;
|
||||
}
|
||||
|
||||
var e = (evt) ? evt : window.event; // for IE
|
||||
if (e.keyCode==40 || e.keyCode==13)
|
||||
{
|
||||
if (e.shiftKey==1)
|
||||
{
|
||||
this.OnSearchSelectShow();
|
||||
var win=this.DOMSearchSelectWindow();
|
||||
for (i=0;i<win.childNodes.length;i++)
|
||||
{
|
||||
var child = win.childNodes[i]; // get span within a
|
||||
if (child.className=='SelectItem')
|
||||
{
|
||||
child.focus();
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
else if (window.frames.MSearchResults.searchResults)
|
||||
{
|
||||
var elem = window.frames.MSearchResults.searchResults.NavNext(0);
|
||||
if (elem) elem.focus();
|
||||
}
|
||||
}
|
||||
else if (e.keyCode==27) // Escape out of the search field
|
||||
{
|
||||
this.DOMSearchField().blur();
|
||||
this.DOMPopupSearchResultsWindow().style.display = 'none';
|
||||
this.DOMSearchClose().style.display = 'none';
|
||||
this.lastSearchValue = '';
|
||||
this.Activate(false);
|
||||
return;
|
||||
}
|
||||
|
||||
// strip whitespaces
|
||||
var searchValue = this.DOMSearchField().value.replace(/ +/g, "");
|
||||
|
||||
if (searchValue != this.lastSearchValue) // search value has changed
|
||||
{
|
||||
if (searchValue != "") // non-empty search
|
||||
{
|
||||
// set timer for search update
|
||||
this.keyTimeout = setTimeout(this.name + '.Search()',
|
||||
this.keyTimeoutLength);
|
||||
}
|
||||
else // empty search field
|
||||
{
|
||||
this.DOMPopupSearchResultsWindow().style.display = 'none';
|
||||
this.DOMSearchClose().style.display = 'none';
|
||||
this.lastSearchValue = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.SelectItemCount = function(id)
|
||||
{
|
||||
var count=0;
|
||||
var win=this.DOMSearchSelectWindow();
|
||||
for (i=0;i<win.childNodes.length;i++)
|
||||
{
|
||||
var child = win.childNodes[i]; // get span within a
|
||||
if (child.className=='SelectItem')
|
||||
{
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
this.SelectItemSet = function(id)
|
||||
{
|
||||
var i,j=0;
|
||||
var win=this.DOMSearchSelectWindow();
|
||||
for (i=0;i<win.childNodes.length;i++)
|
||||
{
|
||||
var child = win.childNodes[i]; // get span within a
|
||||
if (child.className=='SelectItem')
|
||||
{
|
||||
var node = child.firstChild;
|
||||
if (j==id)
|
||||
{
|
||||
node.innerHTML='•';
|
||||
}
|
||||
else
|
||||
{
|
||||
node.innerHTML=' ';
|
||||
}
|
||||
j++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Called when an search filter selection is made.
|
||||
// set item with index id as the active item
|
||||
this.OnSelectItem = function(id)
|
||||
{
|
||||
this.searchIndex = id;
|
||||
this.SelectItemSet(id);
|
||||
var searchValue = this.DOMSearchField().value.replace(/ +/g, "");
|
||||
if (searchValue!="" && this.searchActive) // something was found -> do a search
|
||||
{
|
||||
this.Search();
|
||||
}
|
||||
}
|
||||
|
||||
this.OnSearchSelectKey = function(evt)
|
||||
{
|
||||
var e = (evt) ? evt : window.event; // for IE
|
||||
if (e.keyCode==40 && this.searchIndex<this.SelectItemCount()) // Down
|
||||
{
|
||||
this.searchIndex++;
|
||||
this.OnSelectItem(this.searchIndex);
|
||||
}
|
||||
else if (e.keyCode==38 && this.searchIndex>0) // Up
|
||||
{
|
||||
this.searchIndex--;
|
||||
this.OnSelectItem(this.searchIndex);
|
||||
}
|
||||
else if (e.keyCode==13 || e.keyCode==27)
|
||||
{
|
||||
this.OnSelectItem(this.searchIndex);
|
||||
this.CloseSelectionWindow();
|
||||
this.DOMSearchField().focus();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// --------- Actions
|
||||
|
||||
// Closes the results window.
|
||||
this.CloseResultsWindow = function()
|
||||
{
|
||||
this.DOMPopupSearchResultsWindow().style.display = 'none';
|
||||
this.DOMSearchClose().style.display = 'none';
|
||||
this.Activate(false);
|
||||
}
|
||||
|
||||
this.CloseSelectionWindow = function()
|
||||
{
|
||||
this.DOMSearchSelectWindow().style.display = 'none';
|
||||
}
|
||||
|
||||
// Performs a search.
|
||||
this.Search = function()
|
||||
{
|
||||
this.keyTimeout = 0;
|
||||
|
||||
// strip leading whitespace
|
||||
var searchValue = this.DOMSearchField().value.replace(/^ +/, "");
|
||||
|
||||
var code = searchValue.toLowerCase().charCodeAt(0);
|
||||
var idxChar = searchValue.substr(0, 1).toLowerCase();
|
||||
if ( 0xD800 <= code && code <= 0xDBFF && searchValue > 1) // surrogate pair
|
||||
{
|
||||
idxChar = searchValue.substr(0, 2);
|
||||
}
|
||||
|
||||
var resultsPage;
|
||||
var resultsPageWithSearch;
|
||||
var hasResultsPage;
|
||||
|
||||
var idx = indexSectionsWithContent[this.searchIndex].indexOf(idxChar);
|
||||
if (idx!=-1)
|
||||
{
|
||||
var hexCode=idx.toString(16);
|
||||
resultsPage = this.resultsPath + '/' + indexSectionNames[this.searchIndex] + '_' + hexCode + '.html';
|
||||
resultsPageWithSearch = resultsPage+'?'+escape(searchValue);
|
||||
hasResultsPage = true;
|
||||
}
|
||||
else // nothing available for this search term
|
||||
{
|
||||
resultsPage = this.resultsPath + '/nomatches.html';
|
||||
resultsPageWithSearch = resultsPage;
|
||||
hasResultsPage = false;
|
||||
}
|
||||
|
||||
window.frames.MSearchResults.location = resultsPageWithSearch;
|
||||
var domPopupSearchResultsWindow = this.DOMPopupSearchResultsWindow();
|
||||
|
||||
if (domPopupSearchResultsWindow.style.display!='block')
|
||||
{
|
||||
var domSearchBox = this.DOMSearchBox();
|
||||
this.DOMSearchClose().style.display = 'inline';
|
||||
if (this.insideFrame)
|
||||
{
|
||||
var domPopupSearchResults = this.DOMPopupSearchResults();
|
||||
domPopupSearchResultsWindow.style.position = 'relative';
|
||||
domPopupSearchResultsWindow.style.display = 'block';
|
||||
var width = document.body.clientWidth - 8; // the -8 is for IE :-(
|
||||
domPopupSearchResultsWindow.style.width = width + 'px';
|
||||
domPopupSearchResults.style.width = width + 'px';
|
||||
}
|
||||
else
|
||||
{
|
||||
var domPopupSearchResults = this.DOMPopupSearchResults();
|
||||
var left = getXPos(domSearchBox) + 150; // domSearchBox.offsetWidth;
|
||||
var top = getYPos(domSearchBox) + 20; // domSearchBox.offsetHeight + 1;
|
||||
domPopupSearchResultsWindow.style.display = 'block';
|
||||
left -= domPopupSearchResults.offsetWidth;
|
||||
domPopupSearchResultsWindow.style.top = top + 'px';
|
||||
domPopupSearchResultsWindow.style.left = left + 'px';
|
||||
}
|
||||
}
|
||||
|
||||
this.lastSearchValue = searchValue;
|
||||
this.lastResultsPage = resultsPage;
|
||||
}
|
||||
|
||||
// -------- Activation Functions
|
||||
|
||||
// Activates or deactivates the search panel, resetting things to
|
||||
// their default values if necessary.
|
||||
this.Activate = function(isActive)
|
||||
{
|
||||
if (isActive || // open it
|
||||
this.DOMPopupSearchResultsWindow().style.display == 'block'
|
||||
)
|
||||
{
|
||||
this.DOMSearchBox().className = 'MSearchBoxActive';
|
||||
|
||||
var searchField = this.DOMSearchField();
|
||||
|
||||
if (searchField.value == this.searchLabel) // clear "Search" term upon entry
|
||||
{
|
||||
searchField.value = '';
|
||||
this.searchActive = true;
|
||||
}
|
||||
}
|
||||
else if (!isActive) // directly remove the panel
|
||||
{
|
||||
this.DOMSearchBox().className = 'MSearchBoxInactive';
|
||||
this.DOMSearchField().value = this.searchLabel;
|
||||
this.searchActive = false;
|
||||
this.lastSearchValue = ''
|
||||
this.lastResultsPage = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------
|
||||
|
||||
// The class that handles everything on the search results page.
|
||||
function SearchResults(name)
|
||||
{
|
||||
// The number of matches from the last run of <Search()>.
|
||||
this.lastMatchCount = 0;
|
||||
this.lastKey = 0;
|
||||
this.repeatOn = false;
|
||||
|
||||
// Toggles the visibility of the passed element ID.
|
||||
this.FindChildElement = function(id)
|
||||
{
|
||||
var parentElement = document.getElementById(id);
|
||||
var element = parentElement.firstChild;
|
||||
|
||||
while (element && element!=parentElement)
|
||||
{
|
||||
if (element.nodeName == 'DIV' && element.className == 'SRChildren')
|
||||
{
|
||||
return element;
|
||||
}
|
||||
|
||||
if (element.nodeName == 'DIV' && element.hasChildNodes())
|
||||
{
|
||||
element = element.firstChild;
|
||||
}
|
||||
else if (element.nextSibling)
|
||||
{
|
||||
element = element.nextSibling;
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
element = element.parentNode;
|
||||
}
|
||||
while (element && element!=parentElement && !element.nextSibling);
|
||||
|
||||
if (element && element!=parentElement)
|
||||
{
|
||||
element = element.nextSibling;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.Toggle = function(id)
|
||||
{
|
||||
var element = this.FindChildElement(id);
|
||||
if (element)
|
||||
{
|
||||
if (element.style.display == 'block')
|
||||
{
|
||||
element.style.display = 'none';
|
||||
}
|
||||
else
|
||||
{
|
||||
element.style.display = 'block';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Searches for the passed string. If there is no parameter,
|
||||
// it takes it from the URL query.
|
||||
//
|
||||
// Always returns true, since other documents may try to call it
|
||||
// and that may or may not be possible.
|
||||
this.Search = function(search)
|
||||
{
|
||||
if (!search) // get search word from URL
|
||||
{
|
||||
search = window.location.search;
|
||||
search = search.substring(1); // Remove the leading '?'
|
||||
search = unescape(search);
|
||||
}
|
||||
|
||||
search = search.replace(/^ +/, ""); // strip leading spaces
|
||||
search = search.replace(/ +$/, ""); // strip trailing spaces
|
||||
search = search.toLowerCase();
|
||||
search = convertToId(search);
|
||||
|
||||
var resultRows = document.getElementsByTagName("div");
|
||||
var matches = 0;
|
||||
|
||||
var i = 0;
|
||||
while (i < resultRows.length)
|
||||
{
|
||||
var row = resultRows.item(i);
|
||||
if (row.className == "SRResult")
|
||||
{
|
||||
var rowMatchName = row.id.toLowerCase();
|
||||
rowMatchName = rowMatchName.replace(/^sr\d*_/, ''); // strip 'sr123_'
|
||||
|
||||
if (search.length<=rowMatchName.length &&
|
||||
rowMatchName.substr(0, search.length)==search)
|
||||
{
|
||||
row.style.display = 'block';
|
||||
matches++;
|
||||
}
|
||||
else
|
||||
{
|
||||
row.style.display = 'none';
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
document.getElementById("Searching").style.display='none';
|
||||
if (matches == 0) // no results
|
||||
{
|
||||
document.getElementById("NoMatches").style.display='block';
|
||||
}
|
||||
else // at least one result
|
||||
{
|
||||
document.getElementById("NoMatches").style.display='none';
|
||||
}
|
||||
this.lastMatchCount = matches;
|
||||
return true;
|
||||
}
|
||||
|
||||
// return the first item with index index or higher that is visible
|
||||
this.NavNext = function(index)
|
||||
{
|
||||
var focusItem;
|
||||
while (1)
|
||||
{
|
||||
var focusName = 'Item'+index;
|
||||
focusItem = document.getElementById(focusName);
|
||||
if (focusItem && focusItem.parentNode.parentNode.style.display=='block')
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (!focusItem) // last element
|
||||
{
|
||||
break;
|
||||
}
|
||||
focusItem=null;
|
||||
index++;
|
||||
}
|
||||
return focusItem;
|
||||
}
|
||||
|
||||
this.NavPrev = function(index)
|
||||
{
|
||||
var focusItem;
|
||||
while (1)
|
||||
{
|
||||
var focusName = 'Item'+index;
|
||||
focusItem = document.getElementById(focusName);
|
||||
if (focusItem && focusItem.parentNode.parentNode.style.display=='block')
|
||||
{
|
||||
break;
|
||||
}
|
||||
else if (!focusItem) // last element
|
||||
{
|
||||
break;
|
||||
}
|
||||
focusItem=null;
|
||||
index--;
|
||||
}
|
||||
return focusItem;
|
||||
}
|
||||
|
||||
this.ProcessKeys = function(e)
|
||||
{
|
||||
if (e.type == "keydown")
|
||||
{
|
||||
this.repeatOn = false;
|
||||
this.lastKey = e.keyCode;
|
||||
}
|
||||
else if (e.type == "keypress")
|
||||
{
|
||||
if (!this.repeatOn)
|
||||
{
|
||||
if (this.lastKey) this.repeatOn = true;
|
||||
return false; // ignore first keypress after keydown
|
||||
}
|
||||
}
|
||||
else if (e.type == "keyup")
|
||||
{
|
||||
this.lastKey = 0;
|
||||
this.repeatOn = false;
|
||||
}
|
||||
return this.lastKey!=0;
|
||||
}
|
||||
|
||||
this.Nav = function(evt,itemIndex)
|
||||
{
|
||||
var e = (evt) ? evt : window.event; // for IE
|
||||
if (e.keyCode==13) return true;
|
||||
if (!this.ProcessKeys(e)) return false;
|
||||
|
||||
if (this.lastKey==38) // Up
|
||||
{
|
||||
var newIndex = itemIndex-1;
|
||||
var focusItem = this.NavPrev(newIndex);
|
||||
if (focusItem)
|
||||
{
|
||||
var child = this.FindChildElement(focusItem.parentNode.parentNode.id);
|
||||
if (child && child.style.display == 'block') // children visible
|
||||
{
|
||||
var n=0;
|
||||
var tmpElem;
|
||||
while (1) // search for last child
|
||||
{
|
||||
tmpElem = document.getElementById('Item'+newIndex+'_c'+n);
|
||||
if (tmpElem)
|
||||
{
|
||||
focusItem = tmpElem;
|
||||
}
|
||||
else // found it!
|
||||
{
|
||||
break;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (focusItem)
|
||||
{
|
||||
focusItem.focus();
|
||||
}
|
||||
else // return focus to search field
|
||||
{
|
||||
parent.document.getElementById("MSearchField").focus();
|
||||
}
|
||||
}
|
||||
else if (this.lastKey==40) // Down
|
||||
{
|
||||
var newIndex = itemIndex+1;
|
||||
var focusItem;
|
||||
var item = document.getElementById('Item'+itemIndex);
|
||||
var elem = this.FindChildElement(item.parentNode.parentNode.id);
|
||||
if (elem && elem.style.display == 'block') // children visible
|
||||
{
|
||||
focusItem = document.getElementById('Item'+itemIndex+'_c0');
|
||||
}
|
||||
if (!focusItem) focusItem = this.NavNext(newIndex);
|
||||
if (focusItem) focusItem.focus();
|
||||
}
|
||||
else if (this.lastKey==39) // Right
|
||||
{
|
||||
var item = document.getElementById('Item'+itemIndex);
|
||||
var elem = this.FindChildElement(item.parentNode.parentNode.id);
|
||||
if (elem) elem.style.display = 'block';
|
||||
}
|
||||
else if (this.lastKey==37) // Left
|
||||
{
|
||||
var item = document.getElementById('Item'+itemIndex);
|
||||
var elem = this.FindChildElement(item.parentNode.parentNode.id);
|
||||
if (elem) elem.style.display = 'none';
|
||||
}
|
||||
else if (this.lastKey==27) // Escape
|
||||
{
|
||||
parent.searchBox.CloseResultsWindow();
|
||||
parent.document.getElementById("MSearchField").focus();
|
||||
}
|
||||
else if (this.lastKey==13) // Enter
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
this.NavChild = function(evt,itemIndex,childIndex)
|
||||
{
|
||||
var e = (evt) ? evt : window.event; // for IE
|
||||
if (e.keyCode==13) return true;
|
||||
if (!this.ProcessKeys(e)) return false;
|
||||
|
||||
if (this.lastKey==38) // Up
|
||||
{
|
||||
if (childIndex>0)
|
||||
{
|
||||
var newIndex = childIndex-1;
|
||||
document.getElementById('Item'+itemIndex+'_c'+newIndex).focus();
|
||||
}
|
||||
else // already at first child, jump to parent
|
||||
{
|
||||
document.getElementById('Item'+itemIndex).focus();
|
||||
}
|
||||
}
|
||||
else if (this.lastKey==40) // Down
|
||||
{
|
||||
var newIndex = childIndex+1;
|
||||
var elem = document.getElementById('Item'+itemIndex+'_c'+newIndex);
|
||||
if (!elem) // last child, jump to parent next parent
|
||||
{
|
||||
elem = this.NavNext(itemIndex+1);
|
||||
}
|
||||
if (elem)
|
||||
{
|
||||
elem.focus();
|
||||
}
|
||||
}
|
||||
else if (this.lastKey==27) // Escape
|
||||
{
|
||||
parent.searchBox.CloseResultsWindow();
|
||||
parent.document.getElementById("MSearchField").focus();
|
||||
}
|
||||
else if (this.lastKey==13) // Enter
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function setKeyActions(elem,action)
|
||||
{
|
||||
elem.setAttribute('onkeydown',action);
|
||||
elem.setAttribute('onkeypress',action);
|
||||
elem.setAttribute('onkeyup',action);
|
||||
}
|
||||
|
||||
function setClassAttr(elem,attr)
|
||||
{
|
||||
elem.setAttribute('class',attr);
|
||||
elem.setAttribute('className',attr);
|
||||
}
|
||||
|
||||
function createResults()
|
||||
{
|
||||
var results = document.getElementById("SRResults");
|
||||
for (var e=0; e<searchData.length; e++)
|
||||
{
|
||||
var id = searchData[e][0];
|
||||
var srResult = document.createElement('div');
|
||||
srResult.setAttribute('id','SR_'+id);
|
||||
setClassAttr(srResult,'SRResult');
|
||||
var srEntry = document.createElement('div');
|
||||
setClassAttr(srEntry,'SREntry');
|
||||
var srLink = document.createElement('a');
|
||||
srLink.setAttribute('id','Item'+e);
|
||||
setKeyActions(srLink,'return searchResults.Nav(event,'+e+')');
|
||||
setClassAttr(srLink,'SRSymbol');
|
||||
srLink.innerHTML = searchData[e][1][0];
|
||||
srEntry.appendChild(srLink);
|
||||
if (searchData[e][1].length==2) // single result
|
||||
{
|
||||
srLink.setAttribute('href',searchData[e][1][1][0]);
|
||||
if (searchData[e][1][1][1])
|
||||
{
|
||||
srLink.setAttribute('target','_parent');
|
||||
}
|
||||
var srScope = document.createElement('span');
|
||||
setClassAttr(srScope,'SRScope');
|
||||
srScope.innerHTML = searchData[e][1][1][2];
|
||||
srEntry.appendChild(srScope);
|
||||
}
|
||||
else // multiple results
|
||||
{
|
||||
srLink.setAttribute('href','javascript:searchResults.Toggle("SR_'+id+'")');
|
||||
var srChildren = document.createElement('div');
|
||||
setClassAttr(srChildren,'SRChildren');
|
||||
for (var c=0; c<searchData[e][1].length-1; c++)
|
||||
{
|
||||
var srChild = document.createElement('a');
|
||||
srChild.setAttribute('id','Item'+e+'_c'+c);
|
||||
setKeyActions(srChild,'return searchResults.NavChild(event,'+e+','+c+')');
|
||||
setClassAttr(srChild,'SRScope');
|
||||
srChild.setAttribute('href',searchData[e][1][c+1][0]);
|
||||
if (searchData[e][1][c+1][1])
|
||||
{
|
||||
srChild.setAttribute('target','_parent');
|
||||
}
|
||||
srChild.innerHTML = searchData[e][1][c+1][2];
|
||||
srChildren.appendChild(srChild);
|
||||
}
|
||||
srEntry.appendChild(srChildren);
|
||||
}
|
||||
srResult.appendChild(srEntry);
|
||||
results.appendChild(srResult);
|
||||
}
|
||||
}
|
||||
|
||||
function init_search()
|
||||
{
|
||||
var results = document.getElementById("MSearchSelectWindow");
|
||||
for (var key in indexSectionLabels)
|
||||
{
|
||||
var link = document.createElement('a');
|
||||
link.setAttribute('class','SelectItem');
|
||||
link.setAttribute('onclick','searchBox.OnSelectItem('+key+')');
|
||||
link.href='javascript:void(0)';
|
||||
link.innerHTML='<span class="SelectionMark"> </span>'+indexSectionLabels[key];
|
||||
results.appendChild(link);
|
||||
}
|
||||
searchBox.OnSelectItem(0);
|
||||
}
|
||||
|
||||
BIN
html/search/search_l.png
Normal file
|
After Width: | Height: | Size: 604 B |
BIN
html/search/search_m.png
Normal file
|
After Width: | Height: | Size: 158 B |
BIN
html/search/search_r.png
Normal file
|
After Width: | Height: | Size: 612 B |
12
html/search/searchdata.js
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
var indexSectionsWithContent =
|
||||
{
|
||||
};
|
||||
|
||||
var indexSectionNames =
|
||||
{
|
||||
};
|
||||
|
||||
var indexSectionLabels =
|
||||
{
|
||||
};
|
||||
|
||||
BIN
html/splitbar.png
Normal file
|
After Width: | Height: | Size: 314 B |
BIN
html/sync_off.png
Normal file
|
After Width: | Height: | Size: 853 B |
BIN
html/sync_on.png
Normal file
|
After Width: | Height: | Size: 845 B |
BIN
html/tab_a.png
Normal file
|
After Width: | Height: | Size: 142 B |
BIN
html/tab_b.png
Normal file
|
After Width: | Height: | Size: 169 B |
BIN
html/tab_h.png
Normal file
|
After Width: | Height: | Size: 177 B |
BIN
html/tab_s.png
Normal file
|
After Width: | Height: | Size: 184 B |
1
html/tabs.css
Normal file
11
index.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="refresh" content="1;url=html/index.html">
|
||||
<title>Page Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
If you are not redirected automatically, follow the <a href="html/index.html">link to the documentation</a>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,10 +0,0 @@
|
|||
name=Adafruit BMP5xx Library
|
||||
version=1.0.1
|
||||
author=Adafruit
|
||||
maintainer=Adafruit <info@adafruit.com>
|
||||
sentence=Arduino library for BMP580, BMP581, and BMP585 pressure and temperature sensors.
|
||||
paragraph=Arduino library for Bosch BMP580, BMP581, and BMP585 pressure and temperature sensors with I2C and SPI support. Uses Bosch Sensortec API for reliable operation.
|
||||
category=Sensors
|
||||
url=https://github.com/adafruit/Adafruit_BMP5xx
|
||||
architectures=*
|
||||
depends=Adafruit Unified Sensor, Adafruit BusIO
|
||||
|
|
@ -1,597 +0,0 @@
|
|||
/*!
|
||||
* @file Adafruit_BMP5xx.cpp
|
||||
*
|
||||
* @mainpage Adafruit BMP5xx pressure and temperature sensor library
|
||||
*
|
||||
* @section intro_sec Introduction
|
||||
*
|
||||
* I2C Driver for BMP5xx pressure and temperature sensor
|
||||
*
|
||||
* This is a library for the Adafruit BMP5xx breakout:
|
||||
* https://www.adafruit.com/products/xxxx
|
||||
*
|
||||
* Adafruit invests time and resources providing this open source code,
|
||||
* please support Adafruit and open-source hardware by purchasing products from
|
||||
* Adafruit!
|
||||
*
|
||||
* @section author Author
|
||||
*
|
||||
* Limor "ladyada" Fried (Adafruit Industries)
|
||||
*
|
||||
* @section license License
|
||||
*
|
||||
* BSD license, all text above must be included in any redistribution
|
||||
*/
|
||||
|
||||
#include "Adafruit_BMP5xx.h"
|
||||
|
||||
/*!
|
||||
* @brief BMP5xx constructor
|
||||
*/
|
||||
Adafruit_BMP5xx::Adafruit_BMP5xx(void) {
|
||||
_temp_sensor = new Adafruit_BMP5xx_Temp(this);
|
||||
_pressure_sensor = new Adafruit_BMP5xx_Pressure(this);
|
||||
temperature = 0.0;
|
||||
pressure = 0.0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief BMP5xx destructor
|
||||
*/
|
||||
Adafruit_BMP5xx::~Adafruit_BMP5xx(void) {
|
||||
if (_i2c_dev) {
|
||||
delete _i2c_dev;
|
||||
}
|
||||
if (_spi_dev) {
|
||||
delete _spi_dev;
|
||||
}
|
||||
if (_temp_sensor) {
|
||||
delete _temp_sensor;
|
||||
}
|
||||
if (_pressure_sensor) {
|
||||
delete _pressure_sensor;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Initializes the sensor
|
||||
* @param addr Optional I2C address the sensor can be found on. Default is 0x46
|
||||
* @param theWire Optional Wire interface the sensor is connected to. Default is
|
||||
* &Wire
|
||||
* @return True if initialization was successful, otherwise false.
|
||||
*/
|
||||
bool Adafruit_BMP5xx::begin(uint8_t addr, TwoWire* theWire) {
|
||||
if (_i2c_dev) {
|
||||
delete _i2c_dev;
|
||||
}
|
||||
_i2c_dev = new Adafruit_I2CDevice(addr, theWire);
|
||||
|
||||
if (!_i2c_dev->begin()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setup Bosch API callbacks
|
||||
_bmp5_dev.intf_ptr = _i2c_dev;
|
||||
_bmp5_dev.intf = BMP5_I2C_INTF;
|
||||
_bmp5_dev.read = i2c_read;
|
||||
_bmp5_dev.write = i2c_write;
|
||||
_bmp5_dev.delay_us = delay_usec;
|
||||
|
||||
return _init();
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Initializes the sensor over SPI
|
||||
* @param cspin The pin to use for CS/Chip Select
|
||||
* @param theSPI Optional SPI interface the sensor is connected to. Default is
|
||||
* &SPI
|
||||
* @return True if initialization was successful, otherwise false.
|
||||
*/
|
||||
bool Adafruit_BMP5xx::begin(int8_t cspin, SPIClass* theSPI) {
|
||||
if (_spi_dev) {
|
||||
delete _spi_dev;
|
||||
}
|
||||
_spi_dev = new Adafruit_SPIDevice(cspin, 1000000, SPI_BITORDER_MSBFIRST,
|
||||
SPI_MODE0, theSPI);
|
||||
|
||||
if (!_spi_dev->begin()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setup Bosch API callbacks
|
||||
_bmp5_dev.intf_ptr = _spi_dev;
|
||||
_bmp5_dev.intf = BMP5_SPI_INTF;
|
||||
_bmp5_dev.read = spi_read;
|
||||
_bmp5_dev.write = spi_write;
|
||||
_bmp5_dev.delay_us = delay_usec;
|
||||
|
||||
return _init();
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Performs the actual initialization using Bosch API
|
||||
* @return True if initialization was successful, otherwise false.
|
||||
*/
|
||||
bool Adafruit_BMP5xx::_init(void) {
|
||||
// Reset the sensor first
|
||||
int8_t rslt = bmp5_soft_reset(&_bmp5_dev);
|
||||
if (rslt != BMP5_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Now initialize the sensor
|
||||
rslt = bmp5_init(&_bmp5_dev);
|
||||
if (rslt != BMP5_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set default configuration
|
||||
_osr_odr_config.osr_t = BMP5_OVERSAMPLING_2X;
|
||||
_osr_odr_config.osr_p = BMP5_OVERSAMPLING_16X;
|
||||
_osr_odr_config.odr = BMP5_ODR_50_HZ;
|
||||
_osr_odr_config.press_en = BMP5_ENABLE;
|
||||
|
||||
rslt = bmp5_set_osr_odr_press_config(&_osr_odr_config, &_bmp5_dev);
|
||||
if (rslt != BMP5_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set default IIR filter
|
||||
_iir_config.set_iir_t = BMP5_IIR_FILTER_COEFF_1;
|
||||
_iir_config.set_iir_p = BMP5_IIR_FILTER_COEFF_1;
|
||||
_iir_config.shdw_set_iir_t = BMP5_ENABLE;
|
||||
_iir_config.shdw_set_iir_p = BMP5_ENABLE;
|
||||
_iir_config.iir_flush_forced_en = BMP5_ENABLE;
|
||||
|
||||
rslt = bmp5_set_iir_config(&_iir_config, &_bmp5_dev);
|
||||
if (rslt != BMP5_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Set to normal mode
|
||||
rslt = bmp5_set_power_mode(BMP5_POWERMODE_NORMAL, &_bmp5_dev);
|
||||
if (rslt != BMP5_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Enable data ready interrupt for non-blocking data ready checking
|
||||
struct bmp5_int_source_select int_source_select = {0};
|
||||
int_source_select.drdy_en = BMP5_ENABLE;
|
||||
int_source_select.fifo_full_en = BMP5_DISABLE;
|
||||
int_source_select.fifo_thres_en = BMP5_DISABLE;
|
||||
int_source_select.oor_press_en = BMP5_DISABLE;
|
||||
|
||||
rslt = bmp5_int_source_select(&int_source_select, &_bmp5_dev);
|
||||
if (rslt != BMP5_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Configure interrupt pin as push-pull, active high, latched mode
|
||||
rslt = bmp5_configure_interrupt(BMP5_LATCHED, BMP5_ACTIVE_HIGH,
|
||||
BMP5_INTR_PUSH_PULL, BMP5_INTR_ENABLE,
|
||||
&_bmp5_dev);
|
||||
return rslt == BMP5_OK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Performs a reading of both temperature and pressure and stores values
|
||||
* in class instance variables
|
||||
* @return True if the reading was successful, otherwise false.
|
||||
*/
|
||||
bool Adafruit_BMP5xx::performReading(void) {
|
||||
struct bmp5_sensor_data sensor_data;
|
||||
|
||||
int8_t rslt =
|
||||
bmp5_get_sensor_data(&sensor_data, &_osr_odr_config, &_bmp5_dev);
|
||||
if (rslt != BMP5_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
temperature = sensor_data.temperature;
|
||||
pressure = sensor_data.pressure / 100.0; // Convert Pa to hPa
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Returns the temperature from the last reading
|
||||
* @return Temperature in degrees Celsius
|
||||
*/
|
||||
float Adafruit_BMP5xx::readTemperature(void) {
|
||||
performReading();
|
||||
return temperature;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Returns the pressure from the last reading
|
||||
* @return Pressure in hPa
|
||||
*/
|
||||
float Adafruit_BMP5xx::readPressure(void) {
|
||||
performReading();
|
||||
return pressure;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Calculates the approximate altitude using barometric pressure
|
||||
* @param seaLevel Sea level pressure in hPa (default = 1013.25)
|
||||
* @return Altitude in meters
|
||||
*/
|
||||
float Adafruit_BMP5xx::readAltitude(float seaLevel) {
|
||||
float atmospheric = readPressure();
|
||||
return 44330.0 * (1.0 - pow(atmospheric / seaLevel, 0.1903));
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Set temperature oversampling
|
||||
* @param oversampling Oversampling setting
|
||||
* @return True on success, False on failure
|
||||
*/
|
||||
bool Adafruit_BMP5xx::setTemperatureOversampling(
|
||||
bmp5xx_oversampling_t oversampling) {
|
||||
_osr_odr_config.osr_t = (uint8_t)oversampling;
|
||||
int8_t rslt = bmp5_set_osr_odr_press_config(&_osr_odr_config, &_bmp5_dev);
|
||||
return rslt == BMP5_OK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Set pressure oversampling
|
||||
* @param oversampling Oversampling setting
|
||||
* @return True on success, False on failure
|
||||
*/
|
||||
bool Adafruit_BMP5xx::setPressureOversampling(
|
||||
bmp5xx_oversampling_t oversampling) {
|
||||
_osr_odr_config.osr_p = (uint8_t)oversampling;
|
||||
int8_t rslt = bmp5_set_osr_odr_press_config(&_osr_odr_config, &_bmp5_dev);
|
||||
return rslt == BMP5_OK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Set IIR filter coefficient
|
||||
* @param filtercoeff IIR filter coefficient
|
||||
* @return True on success, False on failure
|
||||
*/
|
||||
bool Adafruit_BMP5xx::setIIRFilterCoeff(bmp5xx_iir_filter_t filtercoeff) {
|
||||
_iir_config.set_iir_t = (uint8_t)filtercoeff;
|
||||
_iir_config.set_iir_p = (uint8_t)filtercoeff;
|
||||
int8_t rslt = bmp5_set_iir_config(&_iir_config, &_bmp5_dev);
|
||||
return rslt == BMP5_OK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Set output data rate
|
||||
* @param odr Output data rate setting
|
||||
* @return True on success, False on failure
|
||||
*/
|
||||
bool Adafruit_BMP5xx::setOutputDataRate(bmp5xx_odr_t odr) {
|
||||
_osr_odr_config.odr = (uint8_t)odr;
|
||||
int8_t rslt = bmp5_set_osr_odr_press_config(&_osr_odr_config, &_bmp5_dev);
|
||||
return rslt == BMP5_OK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Set power mode
|
||||
* @param powermode Power mode setting
|
||||
* @return True on success, False on failure
|
||||
*/
|
||||
bool Adafruit_BMP5xx::setPowerMode(bmp5xx_powermode_t powermode) {
|
||||
int8_t rslt = bmp5_set_power_mode((enum bmp5_powermode)powermode, &_bmp5_dev);
|
||||
return rslt == BMP5_OK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Get temperature oversampling setting
|
||||
* @return Current temperature oversampling
|
||||
*/
|
||||
bmp5xx_oversampling_t Adafruit_BMP5xx::getTemperatureOversampling(void) {
|
||||
struct bmp5_osr_odr_press_config config;
|
||||
bmp5_get_osr_odr_press_config(&config, &_bmp5_dev);
|
||||
return (bmp5xx_oversampling_t)config.osr_t;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Get pressure oversampling setting
|
||||
* @return Current pressure oversampling
|
||||
*/
|
||||
bmp5xx_oversampling_t Adafruit_BMP5xx::getPressureOversampling(void) {
|
||||
struct bmp5_osr_odr_press_config config;
|
||||
bmp5_get_osr_odr_press_config(&config, &_bmp5_dev);
|
||||
return (bmp5xx_oversampling_t)config.osr_p;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Get IIR filter coefficient
|
||||
* @return Current IIR filter coefficient
|
||||
*/
|
||||
bmp5xx_iir_filter_t Adafruit_BMP5xx::getIIRFilterCoeff(void) {
|
||||
struct bmp5_iir_config config;
|
||||
bmp5_get_iir_config(&config, &_bmp5_dev);
|
||||
return (bmp5xx_iir_filter_t)config.set_iir_p;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Get output data rate
|
||||
* @return Current output data rate
|
||||
*/
|
||||
bmp5xx_odr_t Adafruit_BMP5xx::getOutputDataRate(void) {
|
||||
struct bmp5_osr_odr_press_config config;
|
||||
bmp5_get_osr_odr_press_config(&config, &_bmp5_dev);
|
||||
return (bmp5xx_odr_t)config.odr;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Get power mode
|
||||
* @return Current power mode
|
||||
*/
|
||||
bmp5xx_powermode_t Adafruit_BMP5xx::getPowerMode(void) {
|
||||
enum bmp5_powermode powermode;
|
||||
bmp5_get_power_mode(&powermode, &_bmp5_dev);
|
||||
return (bmp5xx_powermode_t)powermode;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Enable/disable pressure measurement
|
||||
* @param enable True to enable pressure, false to disable
|
||||
* @return True on success, False on failure
|
||||
*/
|
||||
bool Adafruit_BMP5xx::enablePressure(bool enable) {
|
||||
_osr_odr_config.press_en = enable ? BMP5_ENABLE : BMP5_DISABLE;
|
||||
int8_t rslt = bmp5_set_osr_odr_press_config(&_osr_odr_config, &_bmp5_dev);
|
||||
return rslt == BMP5_OK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Gets an Adafruit Unified Sensor object for the temp sensor component
|
||||
* @return Adafruit_Sensor pointer to temperature sensor
|
||||
*/
|
||||
Adafruit_Sensor* Adafruit_BMP5xx::getTemperatureSensor(void) {
|
||||
return _temp_sensor;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Gets an Adafruit Unified Sensor object for the pressure sensor
|
||||
* component
|
||||
* @return Adafruit_Sensor pointer to pressure sensor
|
||||
*/
|
||||
Adafruit_Sensor* Adafruit_BMP5xx::getPressureSensor(void) {
|
||||
return _pressure_sensor;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Check if new sensor data is ready
|
||||
* @return True if new data is available, false otherwise
|
||||
*/
|
||||
bool Adafruit_BMP5xx::dataReady(void) {
|
||||
uint8_t int_status = 0;
|
||||
int8_t rslt = bmp5_get_interrupt_status(&int_status, &_bmp5_dev);
|
||||
if (rslt != BMP5_OK) {
|
||||
return false;
|
||||
}
|
||||
// Check if data ready interrupt is asserted
|
||||
return (int_status & BMP5_INT_ASSERTED_DRDY) != 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Configure interrupt pin settings and sources
|
||||
* @param mode Interrupt mode (pulsed or latched)
|
||||
* @param polarity Interrupt polarity (active high or low)
|
||||
* @param drive Interrupt drive (push-pull or open-drain)
|
||||
* @param sources Interrupt sources (can be combined with bitwise OR)
|
||||
* @param enable Enable or disable interrupt pin
|
||||
* @return True if configuration was successful, false otherwise
|
||||
*/
|
||||
bool Adafruit_BMP5xx::configureInterrupt(bmp5xx_interrupt_mode_t mode,
|
||||
bmp5xx_interrupt_polarity_t polarity,
|
||||
bmp5xx_interrupt_drive_t drive,
|
||||
uint8_t sources, bool enable) {
|
||||
// Configure interrupt pin settings first
|
||||
enum bmp5_intr_en_dis int_enable =
|
||||
enable ? BMP5_INTR_ENABLE : BMP5_INTR_DISABLE;
|
||||
|
||||
int8_t rslt = bmp5_configure_interrupt(
|
||||
(enum bmp5_intr_mode)mode, (enum bmp5_intr_polarity)polarity,
|
||||
(enum bmp5_intr_drive)drive, int_enable, &_bmp5_dev);
|
||||
if (rslt != BMP5_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Configure interrupt sources after pin settings
|
||||
struct bmp5_int_source_select int_source_select = {0};
|
||||
int_source_select.drdy_en =
|
||||
(sources & BMP5XX_INTERRUPT_DATA_READY) ? BMP5_ENABLE : BMP5_DISABLE;
|
||||
int_source_select.fifo_full_en =
|
||||
(sources & BMP5XX_INTERRUPT_FIFO_FULL) ? BMP5_ENABLE : BMP5_DISABLE;
|
||||
int_source_select.fifo_thres_en =
|
||||
(sources & BMP5XX_INTERRUPT_FIFO_THRESHOLD) ? BMP5_ENABLE : BMP5_DISABLE;
|
||||
int_source_select.oor_press_en =
|
||||
(sources & BMP5XX_INTERRUPT_PRESSURE_OUT_OF_RANGE) ? BMP5_ENABLE
|
||||
: BMP5_DISABLE;
|
||||
|
||||
rslt = bmp5_int_source_select(&int_source_select, &_bmp5_dev);
|
||||
|
||||
return rslt == BMP5_OK;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief I2C read callback for Bosch API
|
||||
@param reg_addr Register address to read from
|
||||
@param reg_data Buffer to store read data
|
||||
@param len Number of bytes to read
|
||||
@param intf_ptr Pointer to interface (I2C device)
|
||||
@return 0 on success, negative on error
|
||||
*/
|
||||
/**************************************************************************/
|
||||
int8_t Adafruit_BMP5xx::i2c_read(uint8_t reg_addr, uint8_t* reg_data,
|
||||
uint32_t len, void* intf_ptr) {
|
||||
Adafruit_I2CDevice* i2c_dev = (Adafruit_I2CDevice*)intf_ptr;
|
||||
|
||||
if (!i2c_dev->write_then_read(®_addr, 1, reg_data, len)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief I2C write callback for Bosch API
|
||||
@param reg_addr Register address to write to
|
||||
@param reg_data Buffer containing data to write
|
||||
@param len Number of bytes to write
|
||||
@param intf_ptr Pointer to interface (I2C device)
|
||||
@return 0 on success, negative on error
|
||||
*/
|
||||
/**************************************************************************/
|
||||
int8_t Adafruit_BMP5xx::i2c_write(uint8_t reg_addr, const uint8_t* reg_data,
|
||||
uint32_t len, void* intf_ptr) {
|
||||
Adafruit_I2CDevice* i2c_dev = (Adafruit_I2CDevice*)intf_ptr;
|
||||
|
||||
// Create buffer with register address + data
|
||||
uint8_t buffer[len + 1];
|
||||
buffer[0] = reg_addr;
|
||||
memcpy(&buffer[1], reg_data, len);
|
||||
|
||||
if (!i2c_dev->write(buffer, len + 1)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief SPI read callback for Bosch API
|
||||
@param reg_addr Register address to read from
|
||||
@param reg_data Buffer to store read data
|
||||
@param len Number of bytes to read
|
||||
@param intf_ptr Pointer to interface (SPI device)
|
||||
@return 0 on success, negative on error
|
||||
*/
|
||||
/**************************************************************************/
|
||||
int8_t Adafruit_BMP5xx::spi_read(uint8_t reg_addr, uint8_t* reg_data,
|
||||
uint32_t len, void* intf_ptr) {
|
||||
Adafruit_SPIDevice* spi_dev = (Adafruit_SPIDevice*)intf_ptr;
|
||||
|
||||
// Set read bit for SPI
|
||||
reg_addr |= 0x80;
|
||||
|
||||
if (!spi_dev->write_then_read(®_addr, 1, reg_data, len)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief SPI write callback for Bosch API
|
||||
@param reg_addr Register address to write to
|
||||
@param reg_data Buffer containing data to write
|
||||
@param len Number of bytes to write
|
||||
@param intf_ptr Pointer to interface (SPI device)
|
||||
@return 0 on success, negative on error
|
||||
*/
|
||||
/**************************************************************************/
|
||||
int8_t Adafruit_BMP5xx::spi_write(uint8_t reg_addr, const uint8_t* reg_data,
|
||||
uint32_t len, void* intf_ptr) {
|
||||
Adafruit_SPIDevice* spi_dev = (Adafruit_SPIDevice*)intf_ptr;
|
||||
|
||||
// Create buffer with register address + data
|
||||
uint8_t buffer[len + 1];
|
||||
buffer[0] = reg_addr & 0x7F; // Clear read bit for write
|
||||
memcpy(&buffer[1], reg_data, len);
|
||||
|
||||
if (!spi_dev->write(buffer, len + 1)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/*!
|
||||
@brief Delay callback for Bosch API
|
||||
@param us Microseconds to delay
|
||||
@param intf_ptr Pointer to interface (unused)
|
||||
*/
|
||||
/**************************************************************************/
|
||||
void Adafruit_BMP5xx::delay_usec(uint32_t us, void* intf_ptr) {
|
||||
(void)intf_ptr; // Unused parameter
|
||||
delayMicroseconds(us);
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/* Adafruit_BMP5xx_Temp */
|
||||
/**************************************************************************/
|
||||
|
||||
/*!
|
||||
* @brief Gets the temperature as a standard sensor event
|
||||
* @param event Sensor event object that will be populated
|
||||
* @returns True
|
||||
*/
|
||||
bool Adafruit_BMP5xx_Temp::getEvent(sensors_event_t* event) {
|
||||
_theBMP5xx->readTemperature();
|
||||
|
||||
event->version = sizeof(sensors_event_t);
|
||||
event->sensor_id = _sensorID;
|
||||
event->type = SENSOR_TYPE_AMBIENT_TEMPERATURE;
|
||||
event->timestamp = millis();
|
||||
event->temperature = _theBMP5xx->temperature;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Gets the sensor_t device data
|
||||
* @param sensor Sensor description that will be populated
|
||||
*/
|
||||
void Adafruit_BMP5xx_Temp::getSensor(sensor_t* sensor) {
|
||||
memset(sensor, 0, sizeof(sensor_t));
|
||||
strncpy(sensor->name, "BMP5xx", sizeof(sensor->name) - 1);
|
||||
sensor->name[sizeof(sensor->name) - 1] = 0;
|
||||
sensor->version = 1;
|
||||
sensor->sensor_id = _sensorID;
|
||||
sensor->type = SENSOR_TYPE_AMBIENT_TEMPERATURE;
|
||||
sensor->min_delay = 0;
|
||||
sensor->min_value = -40.0; // Datasheet minimum
|
||||
sensor->max_value = 85.0; // Datasheet maximum
|
||||
sensor->resolution = 0.01; // Datasheet resolution
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
/* Adafruit_BMP5xx_Pressure */
|
||||
/**************************************************************************/
|
||||
|
||||
/*!
|
||||
* @brief Gets the pressure as a standard sensor event
|
||||
* @param event Sensor event object that will be populated
|
||||
* @returns True
|
||||
*/
|
||||
bool Adafruit_BMP5xx_Pressure::getEvent(sensors_event_t* event) {
|
||||
_theBMP5xx->readPressure();
|
||||
|
||||
event->version = sizeof(sensors_event_t);
|
||||
event->sensor_id = _sensorID;
|
||||
event->type = SENSOR_TYPE_PRESSURE;
|
||||
event->timestamp = millis();
|
||||
event->pressure = _theBMP5xx->pressure;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Gets the sensor_t device data
|
||||
* @param sensor Sensor description that will be populated
|
||||
*/
|
||||
void Adafruit_BMP5xx_Pressure::getSensor(sensor_t* sensor) {
|
||||
memset(sensor, 0, sizeof(sensor_t));
|
||||
strncpy(sensor->name, "BMP5xx", sizeof(sensor->name) - 1);
|
||||
sensor->name[sizeof(sensor->name) - 1] = 0;
|
||||
sensor->version = 1;
|
||||
sensor->sensor_id = _sensorID;
|
||||
sensor->type = SENSOR_TYPE_PRESSURE;
|
||||
sensor->min_delay = 0;
|
||||
sensor->min_value = 300.0; // Datasheet minimum 30kPa
|
||||
sensor->max_value = 1250.0; // Datasheet maximum 125kPa
|
||||
sensor->resolution = 0.016; // Datasheet RMS noise
|
||||
}
|
||||
|
|
@ -1,286 +0,0 @@
|
|||
/*!
|
||||
* @file Adafruit_BMP5xx.h
|
||||
*
|
||||
* I2C Driver for BMP5xx pressure and temperature sensor
|
||||
*
|
||||
* This is a library for the Adafruit BMP5xx breakout:
|
||||
* https://www.adafruit.com/products/xxxx
|
||||
*
|
||||
* Adafruit invests time and resources providing this open source code,
|
||||
* please support Adafruit and open-source hardware by purchasing products from
|
||||
* Adafruit!
|
||||
*
|
||||
* @author Limor "ladyada" Fried (Adafruit Industries)
|
||||
*
|
||||
* BSD license, all text above must be included in any redistribution
|
||||
*/
|
||||
|
||||
#ifndef ADAFRUIT_BMP5XX_H
|
||||
#define ADAFRUIT_BMP5XX_H
|
||||
|
||||
#include <Adafruit_I2CDevice.h>
|
||||
#include <Adafruit_SPIDevice.h>
|
||||
#include <Adafruit_Sensor.h>
|
||||
#include <Wire.h>
|
||||
|
||||
#include "Arduino.h"
|
||||
|
||||
extern "C" {
|
||||
#include "bmp5.h"
|
||||
}
|
||||
|
||||
/*=========================================================================
|
||||
I2C ADDRESS/BITS
|
||||
-----------------------------------------------------------------------*/
|
||||
/**! Default I2C address */
|
||||
#define BMP5XX_DEFAULT_ADDRESS (0x46)
|
||||
/**! Alternative I2C address */
|
||||
#define BMP5XX_ALTERNATIVE_ADDRESS (0x47)
|
||||
|
||||
/**! Chip ID for BMP580 */
|
||||
#define BMP580_CHIP_ID (0x50)
|
||||
/**! Chip ID for BMP581 */
|
||||
#define BMP581_CHIP_ID (0x51)
|
||||
|
||||
/*=========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Sampling rate enum
|
||||
*/
|
||||
typedef enum {
|
||||
BMP5XX_OVERSAMPLING_1X = BMP5_OVERSAMPLING_1X, ///< 1x oversampling
|
||||
BMP5XX_OVERSAMPLING_2X = BMP5_OVERSAMPLING_2X, ///< 2x oversampling
|
||||
BMP5XX_OVERSAMPLING_4X = BMP5_OVERSAMPLING_4X, ///< 4x oversampling
|
||||
BMP5XX_OVERSAMPLING_8X = BMP5_OVERSAMPLING_8X, ///< 8x oversampling
|
||||
BMP5XX_OVERSAMPLING_16X = BMP5_OVERSAMPLING_16X, ///< 16x oversampling
|
||||
BMP5XX_OVERSAMPLING_32X = BMP5_OVERSAMPLING_32X, ///< 32x oversampling
|
||||
BMP5XX_OVERSAMPLING_64X = BMP5_OVERSAMPLING_64X, ///< 64x oversampling
|
||||
BMP5XX_OVERSAMPLING_128X = BMP5_OVERSAMPLING_128X, ///< 128x oversampling
|
||||
} bmp5xx_oversampling_t;
|
||||
|
||||
/**
|
||||
* @brief IIR filter coefficients
|
||||
*/
|
||||
typedef enum {
|
||||
BMP5XX_IIR_FILTER_BYPASS = BMP5_IIR_FILTER_BYPASS, ///< No filtering
|
||||
BMP5XX_IIR_FILTER_COEFF_1 = BMP5_IIR_FILTER_COEFF_1, ///< Filter coeff 1
|
||||
BMP5XX_IIR_FILTER_COEFF_3 = BMP5_IIR_FILTER_COEFF_3, ///< Filter coeff 3
|
||||
BMP5XX_IIR_FILTER_COEFF_7 = BMP5_IIR_FILTER_COEFF_7, ///< Filter coeff 7
|
||||
BMP5XX_IIR_FILTER_COEFF_15 = BMP5_IIR_FILTER_COEFF_15, ///< Filter coeff 15
|
||||
BMP5XX_IIR_FILTER_COEFF_31 = BMP5_IIR_FILTER_COEFF_31, ///< Filter coeff 31
|
||||
BMP5XX_IIR_FILTER_COEFF_63 = BMP5_IIR_FILTER_COEFF_63, ///< Filter coeff 63
|
||||
BMP5XX_IIR_FILTER_COEFF_127 = BMP5_IIR_FILTER_COEFF_127, ///< Filter coeff 127
|
||||
} bmp5xx_iir_filter_t;
|
||||
|
||||
/**
|
||||
* @brief Output Data Rate settings
|
||||
*/
|
||||
typedef enum {
|
||||
BMP5XX_ODR_240_HZ = BMP5_ODR_240_HZ, ///< 240 Hz
|
||||
BMP5XX_ODR_218_5_HZ = BMP5_ODR_218_5_HZ, ///< 218.5 Hz
|
||||
BMP5XX_ODR_199_1_HZ = BMP5_ODR_199_1_HZ, ///< 199.1 Hz
|
||||
BMP5XX_ODR_179_2_HZ = BMP5_ODR_179_2_HZ, ///< 179.2 Hz
|
||||
BMP5XX_ODR_160_HZ = BMP5_ODR_160_HZ, ///< 160 Hz
|
||||
BMP5XX_ODR_149_3_HZ = BMP5_ODR_149_3_HZ, ///< 149.3 Hz
|
||||
BMP5XX_ODR_140_HZ = BMP5_ODR_140_HZ, ///< 140 Hz
|
||||
BMP5XX_ODR_129_8_HZ = BMP5_ODR_129_8_HZ, ///< 129.8 Hz
|
||||
BMP5XX_ODR_120_HZ = BMP5_ODR_120_HZ, ///< 120 Hz
|
||||
BMP5XX_ODR_110_1_HZ = BMP5_ODR_110_1_HZ, ///< 110.1 Hz
|
||||
BMP5XX_ODR_100_2_HZ = BMP5_ODR_100_2_HZ, ///< 100.2 Hz
|
||||
BMP5XX_ODR_89_6_HZ = BMP5_ODR_89_6_HZ, ///< 89.6 Hz
|
||||
BMP5XX_ODR_80_HZ = BMP5_ODR_80_HZ, ///< 80 Hz
|
||||
BMP5XX_ODR_70_HZ = BMP5_ODR_70_HZ, ///< 70 Hz
|
||||
BMP5XX_ODR_60_HZ = BMP5_ODR_60_HZ, ///< 60 Hz
|
||||
BMP5XX_ODR_50_HZ = BMP5_ODR_50_HZ, ///< 50 Hz
|
||||
BMP5XX_ODR_45_HZ = BMP5_ODR_45_HZ, ///< 45 Hz
|
||||
BMP5XX_ODR_40_HZ = BMP5_ODR_40_HZ, ///< 40 Hz
|
||||
BMP5XX_ODR_35_HZ = BMP5_ODR_35_HZ, ///< 35 Hz
|
||||
BMP5XX_ODR_30_HZ = BMP5_ODR_30_HZ, ///< 30 Hz
|
||||
BMP5XX_ODR_25_HZ = BMP5_ODR_25_HZ, ///< 25 Hz
|
||||
BMP5XX_ODR_20_HZ = BMP5_ODR_20_HZ, ///< 20 Hz
|
||||
BMP5XX_ODR_15_HZ = BMP5_ODR_15_HZ, ///< 15 Hz
|
||||
BMP5XX_ODR_10_HZ = BMP5_ODR_10_HZ, ///< 10 Hz
|
||||
BMP5XX_ODR_05_HZ = BMP5_ODR_05_HZ, ///< 5 Hz
|
||||
BMP5XX_ODR_04_HZ = BMP5_ODR_04_HZ, ///< 4 Hz
|
||||
BMP5XX_ODR_03_HZ = BMP5_ODR_03_HZ, ///< 3 Hz
|
||||
BMP5XX_ODR_02_HZ = BMP5_ODR_02_HZ, ///< 2 Hz
|
||||
BMP5XX_ODR_01_HZ = BMP5_ODR_01_HZ, ///< 1 Hz
|
||||
BMP5XX_ODR_0_5_HZ = BMP5_ODR_0_5_HZ, ///< 0.5 Hz
|
||||
BMP5XX_ODR_0_250_HZ = BMP5_ODR_0_250_HZ, ///< 0.25 Hz
|
||||
BMP5XX_ODR_0_125_HZ = BMP5_ODR_0_125_HZ, ///< 0.125 Hz
|
||||
} bmp5xx_odr_t;
|
||||
|
||||
/**
|
||||
* @brief Power mode settings
|
||||
*/
|
||||
typedef enum {
|
||||
BMP5XX_POWERMODE_STANDBY = BMP5_POWERMODE_STANDBY, ///< Standby mode
|
||||
BMP5XX_POWERMODE_NORMAL = BMP5_POWERMODE_NORMAL, ///< Normal mode
|
||||
BMP5XX_POWERMODE_FORCED = BMP5_POWERMODE_FORCED, ///< Forced mode
|
||||
BMP5XX_POWERMODE_CONTINUOUS = BMP5_POWERMODE_CONTINOUS, ///< Continuous mode
|
||||
BMP5XX_POWERMODE_CONTINOUS =
|
||||
BMP5_POWERMODE_CONTINOUS, ///< @deprecated Use BMP5XX_POWERMODE_CONTINUOUS
|
||||
BMP5XX_POWERMODE_DEEP_STANDBY =
|
||||
BMP5_POWERMODE_DEEP_STANDBY, ///< Deep standby mode
|
||||
} bmp5xx_powermode_t;
|
||||
|
||||
/**
|
||||
* @brief Interrupt polarity settings
|
||||
*/
|
||||
typedef enum {
|
||||
BMP5XX_INTERRUPT_ACTIVE_LOW = BMP5_ACTIVE_LOW, ///< Interrupt active low
|
||||
BMP5XX_INTERRUPT_ACTIVE_HIGH = BMP5_ACTIVE_HIGH ///< Interrupt active high
|
||||
} bmp5xx_interrupt_polarity_t;
|
||||
|
||||
/**
|
||||
* @brief Interrupt drive settings
|
||||
*/
|
||||
typedef enum {
|
||||
BMP5XX_INTERRUPT_PUSH_PULL = BMP5_INTR_PUSH_PULL, ///< Push-pull output
|
||||
BMP5XX_INTERRUPT_OPEN_DRAIN = BMP5_INTR_OPEN_DRAIN ///< Open-drain output
|
||||
} bmp5xx_interrupt_drive_t;
|
||||
|
||||
/**
|
||||
* @brief Interrupt mode settings
|
||||
*/
|
||||
typedef enum {
|
||||
BMP5XX_INTERRUPT_PULSED = BMP5_PULSED, ///< Pulsed interrupt
|
||||
BMP5XX_INTERRUPT_LATCHED = BMP5_LATCHED ///< Latched interrupt
|
||||
} bmp5xx_interrupt_mode_t;
|
||||
|
||||
/**
|
||||
* @brief Interrupt source settings (can be combined with bitwise OR)
|
||||
*/
|
||||
typedef enum {
|
||||
BMP5XX_INTERRUPT_DATA_READY = 0x01, ///< Data ready interrupt
|
||||
BMP5XX_INTERRUPT_FIFO_FULL = 0x02, ///< FIFO full interrupt
|
||||
BMP5XX_INTERRUPT_FIFO_THRESHOLD = 0x04, ///< FIFO threshold interrupt
|
||||
BMP5XX_INTERRUPT_PRESSURE_OUT_OF_RANGE =
|
||||
0x08 ///< Pressure out of range interrupt
|
||||
} bmp5xx_interrupt_source_t;
|
||||
|
||||
/**
|
||||
* @brief Adafruit Unified Sensor interface for temperature component of BMP5xx
|
||||
*/
|
||||
class Adafruit_BMP5xx_Temp : public Adafruit_Sensor {
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new Adafruit_BMP5xx_Temp object
|
||||
*
|
||||
* @param parent A pointer to the BMP5xx class
|
||||
*/
|
||||
Adafruit_BMP5xx_Temp(class Adafruit_BMP5xx* parent) {
|
||||
_theBMP5xx = parent;
|
||||
}
|
||||
|
||||
bool getEvent(sensors_event_t* event);
|
||||
void getSensor(sensor_t* sensor);
|
||||
|
||||
private:
|
||||
int _sensorID = 0x580; /**< ID number for temperature sensor */
|
||||
class Adafruit_BMP5xx* _theBMP5xx = NULL; /**< Pointer to BMP5xx instance */
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Adafruit Unified Sensor interface for pressure component of BMP5xx
|
||||
*/
|
||||
class Adafruit_BMP5xx_Pressure : public Adafruit_Sensor {
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a new Adafruit_BMP5xx_Pressure object
|
||||
*
|
||||
* @param parent A pointer to the BMP5xx class
|
||||
*/
|
||||
Adafruit_BMP5xx_Pressure(class Adafruit_BMP5xx* parent) {
|
||||
_theBMP5xx = parent;
|
||||
}
|
||||
|
||||
bool getEvent(sensors_event_t* event);
|
||||
void getSensor(sensor_t* sensor);
|
||||
|
||||
private:
|
||||
int _sensorID = 0x581; /**< ID number for pressure sensor */
|
||||
class Adafruit_BMP5xx* _theBMP5xx = NULL; /**< Pointer to BMP5xx instance */
|
||||
};
|
||||
|
||||
/**
|
||||
* Driver for the Adafruit BMP5xx barometric pressure sensor.
|
||||
*/
|
||||
class Adafruit_BMP5xx {
|
||||
public:
|
||||
Adafruit_BMP5xx();
|
||||
~Adafruit_BMP5xx(void);
|
||||
|
||||
bool begin(uint8_t addr = BMP5XX_DEFAULT_ADDRESS, TwoWire* theWire = &Wire);
|
||||
bool begin(int8_t cspin, SPIClass* theSPI = &SPI);
|
||||
|
||||
float readTemperature(void);
|
||||
float readPressure(void);
|
||||
float readAltitude(float seaLevel = 1013.25);
|
||||
|
||||
bool performReading(void);
|
||||
|
||||
bool setTemperatureOversampling(bmp5xx_oversampling_t oversampling);
|
||||
bool setPressureOversampling(bmp5xx_oversampling_t oversampling);
|
||||
bool setIIRFilterCoeff(bmp5xx_iir_filter_t filtercoeff);
|
||||
bool setOutputDataRate(bmp5xx_odr_t odr);
|
||||
bool setPowerMode(bmp5xx_powermode_t powermode);
|
||||
|
||||
bmp5xx_oversampling_t getTemperatureOversampling(void);
|
||||
bmp5xx_oversampling_t getPressureOversampling(void);
|
||||
bmp5xx_iir_filter_t getIIRFilterCoeff(void);
|
||||
bmp5xx_odr_t getOutputDataRate(void);
|
||||
bmp5xx_powermode_t getPowerMode(void);
|
||||
|
||||
Adafruit_Sensor* getTemperatureSensor(void);
|
||||
Adafruit_Sensor* getPressureSensor(void);
|
||||
|
||||
bool enablePressure(bool enable = true);
|
||||
bool dataReady(void);
|
||||
|
||||
bool configureInterrupt(bmp5xx_interrupt_mode_t mode,
|
||||
bmp5xx_interrupt_polarity_t polarity,
|
||||
bmp5xx_interrupt_drive_t drive,
|
||||
uint8_t sources = BMP5XX_INTERRUPT_DATA_READY,
|
||||
bool enable = true);
|
||||
|
||||
/**! Temperature (Celsius) assigned after calling performReading() */
|
||||
float temperature;
|
||||
/**! Pressure (hPa) assigned after calling performReading() */
|
||||
float pressure;
|
||||
|
||||
private:
|
||||
bool _init(void);
|
||||
|
||||
/**! BMP5xx device struct from Bosch API */
|
||||
struct bmp5_dev _bmp5_dev;
|
||||
|
||||
/**! Configuration struct for OSR/ODR settings */
|
||||
struct bmp5_osr_odr_press_config _osr_odr_config;
|
||||
|
||||
/**! Configuration struct for IIR filter settings */
|
||||
struct bmp5_iir_config _iir_config;
|
||||
|
||||
/**! I2C interface object */
|
||||
Adafruit_I2CDevice* _i2c_dev = NULL;
|
||||
/**! SPI interface object */
|
||||
Adafruit_SPIDevice* _spi_dev = NULL;
|
||||
|
||||
/**! Adafruit unified sensor interface for temperature */
|
||||
Adafruit_BMP5xx_Temp* _temp_sensor = NULL;
|
||||
/**! Adafruit unified sensor interface for pressure */
|
||||
Adafruit_BMP5xx_Pressure* _pressure_sensor = NULL;
|
||||
|
||||
// Static callback functions for Bosch API
|
||||
static int8_t i2c_read(uint8_t reg_addr, uint8_t* reg_data, uint32_t len,
|
||||
void* intf_ptr);
|
||||
static int8_t i2c_write(uint8_t reg_addr, const uint8_t* reg_data,
|
||||
uint32_t len, void* intf_ptr);
|
||||
static int8_t spi_read(uint8_t reg_addr, uint8_t* reg_data, uint32_t len,
|
||||
void* intf_ptr);
|
||||
static int8_t spi_write(uint8_t reg_addr, const uint8_t* reg_data,
|
||||
uint32_t len, void* intf_ptr);
|
||||
static void delay_usec(uint32_t us, void* intf_ptr);
|
||||
};
|
||||
|
||||
#endif // ADAFRUIT_BMP5XX_H
|
||||
2006
src/bmp5.c
667
src/bmp5.h
|
|
@ -1,667 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved.
|
||||
*
|
||||
* BSD-3-Clause
|
||||
*
|
||||
* 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 of the copyright holder 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 HOLDER 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.
|
||||
*
|
||||
* @file bmp5.h
|
||||
* @date 2021-08-27
|
||||
* @version v1.0.5
|
||||
*
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @defgroup bmp5 BMP5
|
||||
* @brief Sensor driver for BMP5 sensor
|
||||
*/
|
||||
|
||||
#ifndef BMP5_H_
|
||||
#define BMP5_H_
|
||||
|
||||
/*! CPP guard */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/*! Header files
|
||||
****************************************************************************/
|
||||
#include "bmp5_defs.h"
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
/*! BMP5 User Interface function prototypes
|
||||
****************************************************************************/
|
||||
|
||||
/**
|
||||
* \ingroup bmp5
|
||||
* \defgroup bmp5ApiInit Initialization
|
||||
* @brief Initialize the sensor and device structure
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiInit
|
||||
* \page bmp5_api_bmp5_init bmp5_init
|
||||
* \code
|
||||
* int8_t bmp5_init(struct bmp5_dev *dev);
|
||||
* \endcode
|
||||
* @details This API is the entry point. Call this API before using all other
|
||||
* APIs. This API reads the chip-id of the sensor and sets the resolution,
|
||||
* feature length and the type of variant.
|
||||
*
|
||||
* @param[in,out] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*
|
||||
*/
|
||||
int8_t bmp5_init(struct bmp5_dev* dev);
|
||||
|
||||
/**
|
||||
* \ingroup bmp5
|
||||
* \defgroup bmp5ApiRegister Registers
|
||||
* @brief Generic API for accessing sensor registers
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiRegister
|
||||
* \page bmp5_api_bmp5_get_regs bmp5_get_regs
|
||||
* \code
|
||||
* int8_t bmp5_get_regs(uint8_t reg_addr, uint8_t *data, uint32_t len, struct
|
||||
* bmp5_dev *dev); \endcode
|
||||
* @details This API reads the data from the given register address of sensor.
|
||||
*
|
||||
* @param[in] reg_addr : Register address from where the data to be read.
|
||||
* @param[out] data : Pointer to data buffer to store the read data.
|
||||
* @param[in] len : No of bytes of data to be read.
|
||||
* @param[in,out] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @return Result of API execution status
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_get_regs(uint8_t reg_addr, uint8_t* data, uint32_t len,
|
||||
struct bmp5_dev* dev);
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiRegister
|
||||
* \page bmp5_api_bmp5_set_regs bmp5_set_regs
|
||||
* \code
|
||||
* int8_t bmp5_set_regs(uint8_t reg_addr, const uint8_t *data, uint32_t len,
|
||||
* struct bmp5_dev *dev); \endcode
|
||||
* @details This API writes the given data to the register address of sensor.
|
||||
*
|
||||
* @param[in] reg_addr : Register address where the data is to be written.
|
||||
* @param[in] data : Pointer to data buffer, whose data is to be written
|
||||
* in the sensor.
|
||||
* @param[in] len : No of bytes of data to be writen.
|
||||
* @param[in,out] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @return Result of API execution status
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_set_regs(uint8_t reg_addr, const uint8_t* data, uint32_t len,
|
||||
struct bmp5_dev* dev);
|
||||
|
||||
/**
|
||||
* \ingroup bmp5
|
||||
* \defgroup bmp5ApiSystem System
|
||||
* @brief API that performs system-level operations
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiSystem
|
||||
* \page bmp5_api_bmp5_soft_reset bmp5_soft_reset
|
||||
* \code
|
||||
* int8_t bmp5_soft_reset(struct bmp5_dev *dev);
|
||||
* \endcode
|
||||
* @details This API is used to soft-reset the sensor where all the registers
|
||||
* are reset to their default values.
|
||||
*
|
||||
* @note If this register is set using I2C, an ACK will NOT be transmitted to
|
||||
* the host.
|
||||
*
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_soft_reset(struct bmp5_dev* dev);
|
||||
|
||||
/**
|
||||
* \ingroup bmp5
|
||||
* \defgroup bmp5ApiStatus NVM and Interrupt status
|
||||
* @brief NVM and Interrupt status API
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiStatus
|
||||
* \page bmp5_api_bmp5_get_interrupt_status bmp5_get_interrupt_status
|
||||
* \code
|
||||
* int8_t bmp5_get_interrupt_status(uint8_t *int_status, struct bmp5_dev *dev);
|
||||
* \endcode
|
||||
* @details This API is used to get the interrupt status (data ready interrupt,
|
||||
*fifo full interrupt, fifo threshold interrupt, pressure out of range interrupt
|
||||
*and power-on reset/software reset complete interrupt).
|
||||
*
|
||||
* @param[out] int_status : Variable to store interrupt status.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @note : Below are values of int_status possible.
|
||||
*
|
||||
*@verbatim
|
||||
* Macros | Functionality
|
||||
* -----------------------------------------|----------------------------
|
||||
* BMP5_INT_ASSERTED_DRDY | Data ready interrupt asserted
|
||||
* BMP5_INT_ASSERTED_FIFO_FULL | Fifo full interrupt asserted
|
||||
* BMP5_INT_ASSERTED_FIFO_THRES | Fifo threshold interrupt asserted
|
||||
* BMP5_INT_ASSERTED_PRESSURE_OOR | Pressure out of range interrupt
|
||||
*asserted BMP5_INT_ASSERTED_POR_SOFTRESET_COMPLETE | Power-on reset/Software
|
||||
*reset complete interrupt asserted
|
||||
*@endverbatim
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_get_interrupt_status(uint8_t* int_status, struct bmp5_dev* dev);
|
||||
|
||||
/**
|
||||
* \ingroup bmp5
|
||||
* \defgroup bmp5ApiPowermode Powermode
|
||||
* @brief Powermode of the sensor API
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiPowermode
|
||||
* \page bmp5_api_bmp5_set_power_mode bmp5_set_power_mode
|
||||
* \code
|
||||
* int8_t bmp5_set_power_mode(enum bmp5_powermode powermode, struct bmp5_dev
|
||||
**dev); \endcode
|
||||
* @details This API sets the power mode of the sensor.
|
||||
*
|
||||
* @param[in] powermode : Select powermode.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @note Below mentioned are the possible powermode that can be set by the user.
|
||||
*
|
||||
*@verbatim
|
||||
* powermode | Macros
|
||||
* -----------------|-------------------
|
||||
* 0 | BMP5_POWERMODE_STANBY
|
||||
* 1 | BMP5_POWERMODE_NORMAL
|
||||
* 2 | BMP5_POWERMODE_FORCED
|
||||
* 3 | BMP5_POWERMODE_CONTINOUS
|
||||
* 4 | BMP5_POWERMODE_DEEP_STANBY
|
||||
*@endverbatim
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_set_power_mode(enum bmp5_powermode powermode, struct bmp5_dev* dev);
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiPowermode
|
||||
* \page bmp5_api_bmp5_get_power_mode bmp5_get_power_mode
|
||||
* \code
|
||||
* int8_t bmp5_get_power_mode(enum bmp5_powermode *powermode, struct bmp5_dev
|
||||
**dev); \endcode
|
||||
* @details This API gets the power mode of the sensor.
|
||||
*
|
||||
* @param[out] powermode : To store the power mode.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @note Below mentioned are the possible powermode from the sensor
|
||||
*
|
||||
*@verbatim
|
||||
* powermode | Macros
|
||||
* -----------------|-------------------
|
||||
* 0 | BMP5_POWERMODE_STANBY
|
||||
* 1 | BMP5_POWERMODE_NORMAL
|
||||
* 2 | BMP5_POWERMODE_FORCED
|
||||
* 3 | BMP5_POWERMODE_CONTINOUS
|
||||
* 4 | BMP5_POWERMODE_DEEP_STANBY
|
||||
*@endverbatim
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_get_power_mode(enum bmp5_powermode* powermode,
|
||||
struct bmp5_dev* dev);
|
||||
|
||||
/**
|
||||
* \ingroup bmp5
|
||||
* \defgroup bmp5ApiData Sensor Data
|
||||
* @brief Get Sensor data
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiData
|
||||
* \page bmp5_api_bmp5_get_sensor_data bmp5_get_sensor_data
|
||||
* \code
|
||||
* int8_t bmp5_get_sensor_data(struct bmp5_sensor_data *sensor_data,
|
||||
* const struct bmp5_osr_odr_press_config
|
||||
* *osr_odr_press_cfg, struct bmp5_dev *dev); \endcode
|
||||
* @details This API reads the temperature(deg C) or both pressure(Pa) and
|
||||
* temperature(deg C) data from the sensor and store it in the bmp5_sensor_data
|
||||
* structure instance passed by the user.
|
||||
*
|
||||
* @param[out] sensor_data : Structure instance of bmp5_sensor_data.
|
||||
* @param[in] osr_odr_press_cfg : Structure instance of
|
||||
* bmp5_osr_odr_press_config.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @note If fixed point(BMP5_USE_FIXED_POINT) is selected then data return type
|
||||
* is uin64_t for pressure and int64_t for temperature. While for floating
|
||||
* point(BMP5_USE_FLOATING_POINT) data return type is float for pressure and
|
||||
* temperature.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_get_sensor_data(
|
||||
struct bmp5_sensor_data* sensor_data,
|
||||
const struct bmp5_osr_odr_press_config* osr_odr_press_cfg,
|
||||
struct bmp5_dev* dev);
|
||||
|
||||
/**
|
||||
* \ingroup bmp5
|
||||
* \defgroup bmp5ApiInterrupt Interrupt
|
||||
* @brief Interrupt API
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiInterrupt
|
||||
* \page bmp5_api_bmp5_int_source_select bmp5_int_source_select
|
||||
* \code
|
||||
* int8_t bmp5_int_source_select(const struct bmp5_int_source_select
|
||||
* *int_source_select, struct bmp5_dev *dev); \endcode
|
||||
* @details This API is used to enable the interrupts(drdy interrupt, fifo full
|
||||
* interrupt, fifo threshold enable and pressure data out of range interrupt).
|
||||
*
|
||||
* @param[in] int_source_select : Structure instance of bmp5_int_enable.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_int_source_select(
|
||||
const struct bmp5_int_source_select* int_source_select,
|
||||
struct bmp5_dev* dev);
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiInterrupt
|
||||
* \page bmp5_api_bmp5_configure_interrupt bmp5_configure_interrupt
|
||||
* \code
|
||||
* int8_t bmp5_configure_interrupt(enum bmp5_intr_mode int_mode,
|
||||
* enum bmp5_intr_polarity int_pol,
|
||||
* enum bmp5_intr_drive int_od,
|
||||
* enum bmp5_intr_en_dis int_en,
|
||||
* struct bmp5_dev *dev);
|
||||
* \endcode
|
||||
* @details This API is used to configure the interrupt settings.
|
||||
*
|
||||
* @param[in] int_mode : Sets either latched or pulsed.
|
||||
* @param[in] int_pol : Sets either polarity high or low.
|
||||
* @param[in] int_od : Sets either open drain or push pull.
|
||||
* @param[in] int_en : Enable/ Disable interrupt pin.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_configure_interrupt(enum bmp5_intr_mode int_mode,
|
||||
enum bmp5_intr_polarity int_pol,
|
||||
enum bmp5_intr_drive int_od,
|
||||
enum bmp5_intr_en_dis int_en,
|
||||
struct bmp5_dev* dev);
|
||||
|
||||
/**
|
||||
* \ingroup bmp5
|
||||
* \defgroup bmp5ApiSettings Settings
|
||||
* @brief Get/set sensor settings APIs
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiSettings
|
||||
* \page bmp5_api_bmp5_get_osr_odr_press_config bmp5_get_osr_odr_press_config
|
||||
* \code
|
||||
* int8_t bmp5_get_osr_odr_press_config(struct bmp5_osr_odr_press_config
|
||||
* *osr_odr_press_cfg, struct bmp5_dev *dev); \endcode
|
||||
* @details This API gets the configuration for oversampling of temperature,
|
||||
* oversampling of pressure and ODR configuration for normal mode along with
|
||||
* pressure enable.
|
||||
*
|
||||
* @param[out] osr_odr_press_cfg : Structure instance of
|
||||
* bmp5_osr_odr_press_config.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_get_osr_odr_press_config(
|
||||
struct bmp5_osr_odr_press_config* osr_odr_press_cfg, struct bmp5_dev* dev);
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiSettings
|
||||
* \page bmp5_api_bmp5_set_osr_odr_press_config bmp5_set_osr_odr_press_config
|
||||
* \code
|
||||
* int8_t bmp5_set_osr_odr_press_config(const struct bmp5_osr_odr_press_config
|
||||
* *osr_odr_press_cfg, struct bmp5_dev *dev); \endcode
|
||||
* @details This API sets the configuration for oversampling of temperature,
|
||||
* oversampling of pressure and ODR configuration along with pressure enable.
|
||||
*
|
||||
* @param[in] osr_odr_press_cfg : Structure instance of
|
||||
* bmp5_osr_odr_press_config.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @note If ODR is set to a value higher than 5Hz then powermode is set as
|
||||
* standby mode, as ODR value greater than 5HZ without disabling deep-standby
|
||||
* mode makes powermode invalid.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_set_osr_odr_press_config(
|
||||
const struct bmp5_osr_odr_press_config* osr_odr_press_cfg,
|
||||
struct bmp5_dev* dev);
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiSettings
|
||||
* \page bmp5_api_bmp5_get_iir_config bmp5_get_iir_config
|
||||
* \code
|
||||
* int8_t bmp5_get_iir_config(struct bmp5_iir_config *iir_cfg, struct bmp5_dev
|
||||
* *dev); \endcode
|
||||
* @details This API gets the configuration for IIR of temperature and pressure.
|
||||
*
|
||||
* @param[out] iir_cfg : Structure instance of bmp5_iir_config.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_get_iir_config(struct bmp5_iir_config* iir_cfg,
|
||||
struct bmp5_dev* dev);
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiSettings
|
||||
* \page bmp5_api_bmp5_set_iir_config bmp5_set_iir_config
|
||||
* \code
|
||||
* int8_t bmp5_set_iir_config(const struct bmp5_iir_config *iir_cfg, struct
|
||||
* bmp5_dev *dev); \endcode
|
||||
* @details This API sets the configuration for IIR of temperature and pressure.
|
||||
*
|
||||
* @note
|
||||
* 1. The IIR configuration can be performed only in standby mode. So in this
|
||||
* API before updating IIR configuration powermode is switched to standby mode
|
||||
* and reverted back to earlier powermode after IIR configuration is updated.
|
||||
* 2. If IIR value for both temperature and pressure is set a value other than
|
||||
* bypass then powermode is set as standby mode, as IIR with value other than
|
||||
* bypass without disabling deep-standby mode makes powermode invalid.
|
||||
*
|
||||
* @param[in] iir_cfg : Structure instance of bmp5_iir_config.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_set_iir_config(const struct bmp5_iir_config* iir_cfg,
|
||||
struct bmp5_dev* dev);
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiSettings
|
||||
* \page bmp5_api_bmp5_get_osr_odr_eff bmp5_get_osr_odr_eff
|
||||
* \code
|
||||
* int8_t bmp5_get_osr_odr_eff(struct bmp5_osr_odr_eff *osr_odr_eff, struct
|
||||
* bmp5_dev *dev); \endcode
|
||||
* @details This API gets the configuration for effective OSR of temperature,
|
||||
* effective OSR of pressure and ODR valid status.
|
||||
*
|
||||
* @param[out] osr_odr_eff : Structure instance of bmp5_osr_odr_eff.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_get_osr_odr_eff(struct bmp5_osr_odr_eff* osr_odr_eff,
|
||||
struct bmp5_dev* dev);
|
||||
|
||||
/**
|
||||
* \ingroup bmp5
|
||||
* \defgroup bmp5ApiFIFO FIFO
|
||||
* @brief FIFO operations of the sensor
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiFIFO
|
||||
* \page bmp5_api_bmp5_get_fifo_configuration bmp5_get_fifo_configuration
|
||||
* \code
|
||||
* int8_t bmp5_get_fifo_configuration(struct bmp5_fifo *fifo, struct bmp5_dev
|
||||
* *dev); \endcode
|
||||
* @details This API used to get the configurations of fifo from the sensor.
|
||||
*
|
||||
* @param[out] fifo : Structure instance of bmp5_fifo.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_get_fifo_configuration(struct bmp5_fifo* fifo,
|
||||
struct bmp5_dev* dev);
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiFIFO
|
||||
* \page bmp5_api_bmp5_set_fifo_configuration bmp5_set_fifo_configuration
|
||||
* \code
|
||||
* int8_t bmp5_set_fifo_configuration(const struct bmp5_fifo *fifo, struct
|
||||
* bmp5_dev *dev); \endcode
|
||||
* @details This API used to set the configurations of fifo in the sensor.
|
||||
*
|
||||
* @param[in] fifo : Structure instance of bmp5_fifo.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @note If Fifo frame selection is enabled then powermode is set as standby
|
||||
* mode, as fifo frame selection enabled without disabling deep-standby mode
|
||||
* makes powermode invalid.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_set_fifo_configuration(const struct bmp5_fifo* fifo,
|
||||
struct bmp5_dev* dev);
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiFIFO
|
||||
* \page bmp5_api_bmp5_get_fifo_len bmp5_get_fifo_len
|
||||
* \code
|
||||
* int8_t bmp5_get_fifo_len(uint8_t *fifo_len, struct bmp5_fifo *fifo, struct
|
||||
* bmp5_dev *dev); \endcode
|
||||
* @details This API is used to get the length of fifo from the sensor.
|
||||
*
|
||||
* @param[out] fifo_len : Variable to store fifo length.
|
||||
* @param[out] fifo : Structure instance of bmp5_fifo.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_get_fifo_len(uint16_t* fifo_len, struct bmp5_fifo* fifo,
|
||||
struct bmp5_dev* dev);
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiFIFO
|
||||
* \page bmp5_api_bmp5_get_fifo_data bmp5_get_fifo_data
|
||||
* \code
|
||||
* int8_t bmp5_get_fifo_data(struct bmp5_fifo *fifo, struct bmp5_dev *dev);
|
||||
* \endcode
|
||||
* @details This API is used to get the fifo data from the sensor.
|
||||
*
|
||||
* @param[out] fifo : Structure instance of bmp5_fifo.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_get_fifo_data(struct bmp5_fifo* fifo, struct bmp5_dev* dev);
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiFIFO
|
||||
* \page bmp5_api_bmp5_extract_fifo_data bmp5_extract_fifo_data
|
||||
* \code
|
||||
* int8_t bmp5_extract_fifo_data(const struct bmp5_fifo *fifo, struct
|
||||
* bmp5_sensor_data *sensor_data); \endcode
|
||||
* @details This API extract the temperature and/or pressure data from the fifo
|
||||
* data which is already read from the fifo.
|
||||
*
|
||||
* @param[in] fifo : Structure instance of bmp5_fifo.
|
||||
* @param[out] sensor_data : Structure instance of bmp5_sensor_data.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_extract_fifo_data(const struct bmp5_fifo* fifo,
|
||||
struct bmp5_sensor_data* sensor_data);
|
||||
|
||||
/**
|
||||
* \ingroup bmp5
|
||||
* \defgroup bmp5ApiOOR OOR pressure
|
||||
* @brief OOR pressure API
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiOOR
|
||||
* \page bmp5_api_bmp5_get_oor_configuration bmp5_get_oor_configuration
|
||||
* \code
|
||||
* int8_t bmp5_get_oor_configuration(struct bmp5_oor_press_configuration
|
||||
* *oor_press_config, struct bmp5_dev *dev); \endcode
|
||||
* @details This API gets the configuration for out-of-range pressure threshold,
|
||||
* range count limit and IIR.
|
||||
*
|
||||
* @param[out] oor_press_config : Structure instance of
|
||||
* bmp5_oor_press_configuration.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_get_oor_configuration(
|
||||
struct bmp5_oor_press_configuration* oor_press_config,
|
||||
struct bmp5_dev* dev);
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiOOR
|
||||
* \page bmp5_api_bmp5_set_oor_configuration bmp5_set_oor_configuration
|
||||
* \code
|
||||
* int8_t bmp5_set_oor_configuration(const struct bmp5_oor_press_configuration
|
||||
* *oor_press_config, struct bmp5_dev *dev); \endcode
|
||||
* @details This API sets the configuration for out-of-range pressure threshold,
|
||||
* range count limit and IIR.
|
||||
*
|
||||
* @param[in] oor_press_config : Structure instance of
|
||||
* bmp5_oor_press_configuration.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_set_oor_configuration(
|
||||
const struct bmp5_oor_press_configuration* oor_press_config,
|
||||
struct bmp5_dev* dev);
|
||||
|
||||
/**
|
||||
* \ingroup bmp5
|
||||
* \defgroup bmp5ApiNVM NVM
|
||||
* @brief NVM operation of the sensor
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiNVM
|
||||
* \page bmp5_api_bmp5_nvm_read bmp5_nvm_read
|
||||
* \code
|
||||
* int8_t bmp5_nvm_read(uint8_t nvm_addr, uint16_t *nvm_data, struct bmp5_dev
|
||||
* *dev); \endcode
|
||||
* @details This API is used to perform NVM read.
|
||||
*
|
||||
* @param[in] nvm_addr : Variable that holds the nvm address.
|
||||
* @param[out] nvm_data : Variable to store nvm data.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_nvm_read(uint8_t nvm_addr, uint16_t* nvm_data,
|
||||
struct bmp5_dev* dev);
|
||||
|
||||
/*!
|
||||
* \ingroup bmp5ApiNVM
|
||||
* \page bmp5_api_bmp5_nvm_write bmp5_nvm_write
|
||||
* \code
|
||||
* int8_t bmp5_nvm_write(uint8_t nvm_addr, const uint16_t *nvm_data, struct
|
||||
* bmp5_dev *dev); \endcode
|
||||
* @details This API used to perform NVM write.
|
||||
*
|
||||
* @param[in] nvm_addr : Variable that holds the nvm address.
|
||||
* @param[in] nvm_data : Variable that holds the nvm data.
|
||||
* @param[in] dev : Structure instance of bmp5_dev.
|
||||
*
|
||||
* @return Result of API execution status.
|
||||
* @return 0 -> Success
|
||||
* @return < 0 -> Fail
|
||||
*/
|
||||
int8_t bmp5_nvm_write(uint8_t nvm_addr, const uint16_t* nvm_data,
|
||||
struct bmp5_dev* dev);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* End of CPP guard */
|
||||
|
||||
#endif /* End of header guard macro */
|
||||
950
src/bmp5_defs.h
|
|
@ -1,950 +0,0 @@
|
|||
/**
|
||||
* Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved.
|
||||
*
|
||||
* BSD-3-Clause
|
||||
*
|
||||
* 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 of the copyright holder 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 HOLDER 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.
|
||||
*
|
||||
* @file bmp5_defs.h
|
||||
* @date 2021-08-27
|
||||
* @version v1.0.5
|
||||
*
|
||||
*/
|
||||
|
||||
/*! @file bmp5_defs.h
|
||||
* @brief Sensor Driver for BMP5 sensor
|
||||
*/
|
||||
#ifndef _BMP5_DEFS_H
|
||||
#define _BMP5_DEFS_H
|
||||
|
||||
/******************************************************************************/
|
||||
/*! @name HEADER INCLUDES */
|
||||
/******************************************************************************/
|
||||
#ifdef __KERNEL__
|
||||
#include <linux/types.h>
|
||||
#else
|
||||
#include <math.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
/******************************************************************************/
|
||||
/*! @name COMMON MACROS */
|
||||
/******************************************************************************/
|
||||
#ifdef __KERNEL__
|
||||
|
||||
#if (!defined(UINT8_C) && !defined(INT8_C))
|
||||
#define INT8_C(x) S8_C(x)
|
||||
#define UINT8_C(x) U8_C(x)
|
||||
#endif
|
||||
|
||||
#if (!defined(UINT16_C) && !defined(INT16_C))
|
||||
#define INT16_C(x) S16_C(x)
|
||||
#define UINT16_C(x) U16_C(x)
|
||||
#endif
|
||||
|
||||
#if (!defined(INT32_C) && !defined(UINT32_C))
|
||||
#define INT32_C(x) S32_C(x)
|
||||
#define UINT32_C(x) U32_C(x)
|
||||
#endif
|
||||
|
||||
#if (!defined(INT64_C) && !defined(UINT64_C))
|
||||
#define INT64_C(x) S64_C(x)
|
||||
#define UINT64_C(x) U64_C(x)
|
||||
#endif
|
||||
|
||||
#else /* __KERNEL__ */
|
||||
|
||||
#if (!defined(UINT8_C) && !defined(INT8_C))
|
||||
#define INT8_C(x) (x)
|
||||
#define UINT8_C(x) (x##U)
|
||||
#endif
|
||||
|
||||
#if (!defined(UINT16_C) && !defined(INT16_C))
|
||||
#define INT16_C(x) (x)
|
||||
#define UINT16_C(x) (x##U)
|
||||
#endif
|
||||
|
||||
#if (!defined(INT32_C) && !defined(UINT32_C))
|
||||
#define INT32_C(x) (x)
|
||||
#define UINT32_C(x) (x##U)
|
||||
#endif
|
||||
|
||||
#if (!defined(INT64_C) && !defined(UINT64_C))
|
||||
#define INT64_C(x) (x##LL)
|
||||
#define UINT64_C(x) (x##ULL)
|
||||
#endif
|
||||
|
||||
#endif /* __KERNEL__ */
|
||||
|
||||
/*! @name C standard macros */
|
||||
#ifndef NULL
|
||||
#ifdef __cplusplus
|
||||
#define NULL 0
|
||||
#else
|
||||
#define NULL ((void*)0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/******************************************************************************/
|
||||
/*! @name Compiler switch macros Definitions */
|
||||
/******************************************************************************/
|
||||
#ifndef BMP5_USE_FIXED_POINT /*< Check if floating point (using \
|
||||
BMP5_USE_FIXED_POINT) is enabled */
|
||||
#ifndef BMP5_USE_FLOATING_POINT /*< If fixed point is not enabled then enable \
|
||||
BMP5_USE_FLOATING_POINT */
|
||||
#define BMP5_USE_FLOATING_POINT
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef BMP5_USE_FIXED_POINT /*< If Fixed point is defined set \
|
||||
BMP5_FIXED_POINT_DIGIT_PRECISION */
|
||||
#ifdef BMP5_FIXED_POINT_DIGIT_PRECISION
|
||||
#if BMP5_FIXED_POINT_DIGIT_PRECISION > \
|
||||
6 /* If BMP5_FIXED_POINT_DIGIT_PRECISION(provided by user) is greater than \
|
||||
* 6 then set precision value to 6 digits */
|
||||
#undef BMP5_FIXED_POINT_DIGIT_PRECISION
|
||||
#define BMP5_FIXED_POINT_DIGIT_PRECISION UINT8_C(6)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* By default BMP5_FIXED_POINT_DIGIT_PRECISION will be 6 digits */
|
||||
/* User can vary the precision between 0 to 6 digits */
|
||||
#ifndef BMP5_FIXED_POINT_DIGIT_PRECISION
|
||||
#define BMP5_FIXED_POINT_DIGIT_PRECISION UINT8_C(6)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/******************************************************************************/
|
||||
/*! @name GENERAL MACRO DEFINITIONS */
|
||||
/******************************************************************************/
|
||||
|
||||
/*!
|
||||
* BMP5_INTF_RET_TYPE is the read/write interface return type which can be
|
||||
* overwritten by the build system.
|
||||
*/
|
||||
#ifndef BMP5_INTF_RET_TYPE
|
||||
#define BMP5_INTF_RET_TYPE int8_t
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* The last error code from read/write interface is stored in the device
|
||||
* structure as intf_rslt.
|
||||
*/
|
||||
#ifndef BMP5_INTF_RET_SUCCESS
|
||||
#define BMP5_INTF_RET_SUCCESS INT8_C(0)
|
||||
#endif
|
||||
|
||||
/*! @name BOOLEAN TYPES */
|
||||
#ifndef TRUE
|
||||
#define TRUE UINT8_C(0x01)
|
||||
#endif
|
||||
|
||||
#ifndef FALSE
|
||||
#define FALSE UINT8_C(0x00)
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL UINT8_C(0x00)
|
||||
#endif
|
||||
|
||||
#ifndef ABS
|
||||
#define ABS(a) ((a) > 0 ? (a) : -(a)) /*!< Absolute value */
|
||||
#endif
|
||||
|
||||
/*! @name UTILITY MACROS */
|
||||
#define BMP5_SET_LOW_BYTE UINT16_C(0x00FF)
|
||||
#define BMP5_SET_HIGH_BYTE UINT16_C(0xFF00)
|
||||
|
||||
/*! @name BIT SLICE GET AND SET FUNCTIONS */
|
||||
#define BMP5_GET_BITSLICE(regvar, bitname) \
|
||||
((regvar & bitname##_MSK) >> bitname##_POS)
|
||||
|
||||
#define BMP5_SET_BITSLICE(regvar, bitname, val) \
|
||||
((regvar & ~bitname##_MSK) | ((val << bitname##_POS) & bitname##_MSK))
|
||||
|
||||
#define BMP5_GET_LSB(var) (uint8_t)(var & BMP5_SET_LOW_BYTE)
|
||||
#define BMP5_GET_MSB(var) (uint8_t)((var & BMP5_SET_HIGH_BYTE) >> 8)
|
||||
|
||||
#define BMP5_SET_BIT_VAL_0(reg_data, bitname) (reg_data & ~(bitname##_MSK))
|
||||
|
||||
#define BMP5_SET_BITS_POS_0(reg_data, bitname, data) \
|
||||
((reg_data & ~(bitname##_MSK)) | (data & bitname##_MSK))
|
||||
|
||||
#define BMP5_GET_BITS_POS_0(reg_data, bitname) (reg_data & (bitname##_MSK))
|
||||
|
||||
/*! @name Chip id of BMP5 */
|
||||
#define BMP5_CHIP_ID UINT8_C(0x50)
|
||||
#define BMP585_CHIP_ID UINT8_C(0x51)
|
||||
|
||||
/*! @name API success code */
|
||||
#define BMP5_OK INT8_C(0)
|
||||
|
||||
/*! @name API error codes */
|
||||
#define BMP5_E_NULL_PTR INT8_C(-1)
|
||||
#define BMP5_E_COM_FAIL INT8_C(-2)
|
||||
#define BMP5_E_DEV_NOT_FOUND INT8_C(-3)
|
||||
#define BMP5_E_INVALID_CHIP_ID INT8_C(-4)
|
||||
#define BMP5_E_POWER_UP INT8_C(-5)
|
||||
#define BMP5_E_POR_SOFTRESET INT8_C(-6)
|
||||
#define BMP5_E_INVALID_POWERMODE INT8_C(-7)
|
||||
#define BMP5_E_INVALID_THRESHOLD INT8_C(-8)
|
||||
#define BMP5_E_FIFO_FRAME_EMPTY INT8_C(-9)
|
||||
#define BMP5_E_NVM_INVALID_ADDR INT8_C(-10)
|
||||
#define BMP5_E_NVM_NOT_READY INT8_C(-11)
|
||||
|
||||
#define BMP5_ENABLE UINT8_C(0x01)
|
||||
#define BMP5_DISABLE UINT8_C(0x00)
|
||||
|
||||
/*! @name Register addresses */
|
||||
#define BMP5_REG_CHIP_ID UINT8_C(0x01)
|
||||
#define BMP5_REG_REV_ID UINT8_C(0x02)
|
||||
#define BMP5_REG_CHIP_STATUS UINT8_C(0x11)
|
||||
#define BMP5_REG_DRIVE_CONFIG UINT8_C(0x13)
|
||||
#define BMP5_REG_INT_CONFIG UINT8_C(0x14)
|
||||
#define BMP5_REG_INT_SOURCE UINT8_C(0x15)
|
||||
#define BMP5_REG_FIFO_CONFIG UINT8_C(0x16)
|
||||
#define BMP5_REG_FIFO_COUNT UINT8_C(0x17)
|
||||
#define BMP5_REG_FIFO_SEL UINT8_C(0x18)
|
||||
#define BMP5_REG_TEMP_DATA_XLSB UINT8_C(0x1D)
|
||||
#define BMP5_REG_TEMP_DATA_LSB UINT8_C(0x1E)
|
||||
#define BMP5_REG_TEMP_DATA_MSB UINT8_C(0x1F)
|
||||
#define BMP5_REG_PRESS_DATA_XLSB UINT8_C(0x20)
|
||||
#define BMP5_REG_PRESS_DATA_LSB UINT8_C(0x21)
|
||||
#define BMP5_REG_PRESS_DATA_MSB UINT8_C(0x22)
|
||||
#define BMP5_REG_INT_STATUS UINT8_C(0x27)
|
||||
#define BMP5_REG_STATUS UINT8_C(0x28)
|
||||
#define BMP5_REG_FIFO_DATA UINT8_C(0x29)
|
||||
#define BMP5_REG_NVM_ADDR UINT8_C(0x2B)
|
||||
#define BMP5_REG_NVM_DATA_LSB UINT8_C(0x2C)
|
||||
#define BMP5_REG_NVM_DATA_MSB UINT8_C(0x2D)
|
||||
#define BMP5_REG_DSP_CONFIG UINT8_C(0x30)
|
||||
#define BMP5_REG_DSP_IIR UINT8_C(0x31)
|
||||
#define BMP5_REG_OOR_THR_P_LSB UINT8_C(0x32)
|
||||
#define BMP5_REG_OOR_THR_P_MSB UINT8_C(0x33)
|
||||
#define BMP5_REG_OOR_RANGE UINT8_C(0x34)
|
||||
#define BMP5_REG_OOR_CONFIG UINT8_C(0x35)
|
||||
#define BMP5_REG_OSR_CONFIG UINT8_C(0x36)
|
||||
#define BMP5_REG_ODR_CONFIG UINT8_C(0x37)
|
||||
#define BMP5_REG_OSR_EFF UINT8_C(0x38)
|
||||
#define BMP5_REG_CMD UINT8_C(0x7E)
|
||||
|
||||
/*! @name I2C addresses */
|
||||
#define BMP5_I2C_ADDR_PRIM UINT8_C(0x46)
|
||||
#define BMP5_I2C_ADDR_SEC UINT8_C(0x47)
|
||||
|
||||
/*! @name NVM addresses */
|
||||
#define BMP5_NVM_START_ADDR UINT8_C(0x20)
|
||||
#define BMP5_NVM_END_ADDR UINT8_C(0x22)
|
||||
|
||||
/*! @name Interface settings */
|
||||
#define BMP5_SPI_RD_MASK UINT8_C(0x80)
|
||||
|
||||
/*! @name Delay definition */
|
||||
#define BMP5_DELAY_US_SOFT_RESET UINT16_C(2000)
|
||||
#define BMP5_DELAY_US_STANDBY UINT16_C(2500)
|
||||
#define BMP5_DELAY_US_NVM_READY_READ UINT8_C(800)
|
||||
#define BMP5_DELAY_US_NVM_READY_WRITE UINT16_C(10000)
|
||||
|
||||
/*! @name Soft reset command */
|
||||
#define BMP5_SOFT_RESET_CMD UINT8_C(0xB6)
|
||||
|
||||
/*! NVM command */
|
||||
#define BMP5_NVM_FIRST_CMND UINT8_C(0x5D)
|
||||
#define BMP5_NVM_READ_ENABLE_CMND UINT8_C(0xA5)
|
||||
#define BMP5_NVM_WRITE_ENABLE_CMND UINT8_C(0xA0)
|
||||
|
||||
/*! @name Deepstandby enable/disable */
|
||||
#define BMP5_DEEP_ENABLED UINT8_C(0)
|
||||
#define BMP5_DEEP_DISABLED UINT8_C(1)
|
||||
|
||||
/*! @name ODR settings */
|
||||
#define BMP5_ODR_240_HZ UINT8_C(0x00)
|
||||
#define BMP5_ODR_218_5_HZ UINT8_C(0x01)
|
||||
#define BMP5_ODR_199_1_HZ UINT8_C(0x02)
|
||||
#define BMP5_ODR_179_2_HZ UINT8_C(0x03)
|
||||
#define BMP5_ODR_160_HZ UINT8_C(0x04)
|
||||
#define BMP5_ODR_149_3_HZ UINT8_C(0x05)
|
||||
#define BMP5_ODR_140_HZ UINT8_C(0x06)
|
||||
#define BMP5_ODR_129_8_HZ UINT8_C(0x07)
|
||||
#define BMP5_ODR_120_HZ UINT8_C(0x08)
|
||||
#define BMP5_ODR_110_1_HZ UINT8_C(0x09)
|
||||
#define BMP5_ODR_100_2_HZ UINT8_C(0x0A)
|
||||
#define BMP5_ODR_89_6_HZ UINT8_C(0x0B)
|
||||
#define BMP5_ODR_80_HZ UINT8_C(0x0C)
|
||||
#define BMP5_ODR_70_HZ UINT8_C(0x0D)
|
||||
#define BMP5_ODR_60_HZ UINT8_C(0x0E)
|
||||
#define BMP5_ODR_50_HZ UINT8_C(0x0F)
|
||||
#define BMP5_ODR_45_HZ UINT8_C(0x10)
|
||||
#define BMP5_ODR_40_HZ UINT8_C(0x11)
|
||||
#define BMP5_ODR_35_HZ UINT8_C(0x12)
|
||||
#define BMP5_ODR_30_HZ UINT8_C(0x13)
|
||||
#define BMP5_ODR_25_HZ UINT8_C(0x14)
|
||||
#define BMP5_ODR_20_HZ UINT8_C(0x15)
|
||||
#define BMP5_ODR_15_HZ UINT8_C(0x16)
|
||||
#define BMP5_ODR_10_HZ UINT8_C(0x17)
|
||||
#define BMP5_ODR_05_HZ UINT8_C(0x18)
|
||||
#define BMP5_ODR_04_HZ UINT8_C(0x19)
|
||||
#define BMP5_ODR_03_HZ UINT8_C(0x1A)
|
||||
#define BMP5_ODR_02_HZ UINT8_C(0x1B)
|
||||
#define BMP5_ODR_01_HZ UINT8_C(0x1C)
|
||||
#define BMP5_ODR_0_5_HZ UINT8_C(0x1D)
|
||||
#define BMP5_ODR_0_250_HZ UINT8_C(0x1E)
|
||||
#define BMP5_ODR_0_125_HZ UINT8_C(0x1F)
|
||||
|
||||
/*! @name Oversampling for temperature and pressure */
|
||||
#define BMP5_OVERSAMPLING_1X UINT8_C(0x00)
|
||||
#define BMP5_OVERSAMPLING_2X UINT8_C(0x01)
|
||||
#define BMP5_OVERSAMPLING_4X UINT8_C(0x02)
|
||||
#define BMP5_OVERSAMPLING_8X UINT8_C(0x03)
|
||||
#define BMP5_OVERSAMPLING_16X UINT8_C(0x04)
|
||||
#define BMP5_OVERSAMPLING_32X UINT8_C(0x05)
|
||||
#define BMP5_OVERSAMPLING_64X UINT8_C(0x06)
|
||||
#define BMP5_OVERSAMPLING_128X UINT8_C(0x07)
|
||||
|
||||
/*! @name IIR filter for temperature and pressure */
|
||||
#define BMP5_IIR_FILTER_BYPASS UINT8_C(0x00)
|
||||
#define BMP5_IIR_FILTER_COEFF_1 UINT8_C(0x01)
|
||||
#define BMP5_IIR_FILTER_COEFF_3 UINT8_C(0x02)
|
||||
#define BMP5_IIR_FILTER_COEFF_7 UINT8_C(0x03)
|
||||
#define BMP5_IIR_FILTER_COEFF_15 UINT8_C(0x04)
|
||||
#define BMP5_IIR_FILTER_COEFF_31 UINT8_C(0x05)
|
||||
#define BMP5_IIR_FILTER_COEFF_63 UINT8_C(0x06)
|
||||
#define BMP5_IIR_FILTER_COEFF_127 UINT8_C(0x07)
|
||||
|
||||
/*! Fifo frame configuration */
|
||||
#define BMP5_FIFO_EMPTY UINT8_C(0X7F)
|
||||
#define BMP5_FIFO_MAX_THRESHOLD_P_T_MODE UINT8_C(0x0F)
|
||||
#define BMP5_FIFO_MAX_THRESHOLD_P_MODE UINT8_C(0x1F)
|
||||
|
||||
/*! @name Macro is used to bypass both iir_t and iir_p together */
|
||||
#define BMP5_IIR_BYPASS UINT8_C(0xC0)
|
||||
|
||||
/*! @name Pressure Out-of-range count limit */
|
||||
#define BMP5_OOR_COUNT_LIMIT_1 UINT8_C(0x00)
|
||||
#define BMP5_OOR_COUNT_LIMIT_3 UINT8_C(0x01)
|
||||
#define BMP5_OOR_COUNT_LIMIT_7 UINT8_C(0x02)
|
||||
#define BMP5_OOR_COUNT_LIMIT_15 UINT8_C(0x03)
|
||||
|
||||
/*! @name Interrupt configurations */
|
||||
#define BMP5_INT_MODE_PULSED UINT8_C(0)
|
||||
#define BMP5_INT_MODE_LATCHED UINT8_C(1)
|
||||
|
||||
#define BMP5_INT_POL_ACTIVE_LOW UINT8_C(0)
|
||||
#define BMP5_INT_POL_ACTIVE_HIGH UINT8_C(1)
|
||||
|
||||
#define BMP5_INT_OD_PUSHPULL UINT8_C(0)
|
||||
#define BMP5_INT_OD_OPENDRAIN UINT8_C(1)
|
||||
|
||||
/*! @name NVM and Interrupt status asserted macros */
|
||||
#define BMP5_INT_ASSERTED_DRDY UINT8_C(0x01)
|
||||
#define BMP5_INT_ASSERTED_FIFO_FULL UINT8_C(0x02)
|
||||
#define BMP5_INT_ASSERTED_FIFO_THRES UINT8_C(0x04)
|
||||
#define BMP5_INT_ASSERTED_PRESSURE_OOR UINT8_C(0x08)
|
||||
#define BMP5_INT_ASSERTED_POR_SOFTRESET_COMPLETE UINT8_C(0x10)
|
||||
#define BMP5_INT_NVM_RDY UINT8_C(0x02)
|
||||
#define BMP5_INT_NVM_ERR UINT8_C(0x04)
|
||||
#define BMP5_INT_NVM_CMD_ERR UINT8_C(0x08)
|
||||
|
||||
/*! @name Interrupt configurations */
|
||||
#define BMP5_INT_MODE_MSK UINT8_C(0x01)
|
||||
|
||||
#define BMP5_INT_POL_MSK UINT8_C(0x02)
|
||||
#define BMP5_INT_POL_POS UINT8_C(1)
|
||||
|
||||
#define BMP5_INT_OD_MSK UINT8_C(0x04)
|
||||
#define BMP5_INT_OD_POS UINT8_C(2)
|
||||
|
||||
#define BMP5_INT_EN_MSK UINT8_C(0x08)
|
||||
#define BMP5_INT_EN_POS UINT8_C(3)
|
||||
|
||||
#define BMP5_INT_DRDY_EN_MSK UINT8_C(0x01)
|
||||
|
||||
#define BMP5_INT_FIFO_FULL_EN_MSK UINT8_C(0x02)
|
||||
#define BMP5_INT_FIFO_FULL_EN_POS UINT8_C(1)
|
||||
|
||||
#define BMP5_INT_FIFO_THRES_EN_MSK UINT8_C(0x04)
|
||||
#define BMP5_INT_FIFO_THRES_EN_POS UINT8_C(2)
|
||||
|
||||
#define BMP5_INT_OOR_PRESS_EN_MSK UINT8_C(0x08)
|
||||
#define BMP5_INT_OOR_PRESS_EN_POS UINT8_C(3)
|
||||
|
||||
/*! @name ODR configuration */
|
||||
#define BMP5_ODR_MSK UINT8_C(0x7C)
|
||||
#define BMP5_ODR_POS UINT8_C(2)
|
||||
|
||||
/*! @name OSR configurations */
|
||||
#define BMP5_TEMP_OS_MSK UINT8_C(0x07)
|
||||
|
||||
#define BMP5_PRESS_OS_MSK UINT8_C(0x38)
|
||||
#define BMP5_PRESS_OS_POS UINT8_C(3)
|
||||
|
||||
/*! @name Pressure enable */
|
||||
#define BMP5_PRESS_EN_MSK UINT8_C(0x40)
|
||||
#define BMP5_PRESS_EN_POS UINT8_C(6)
|
||||
|
||||
/*! @name IIR configurations */
|
||||
#define BMP5_SET_IIR_TEMP_MSK UINT8_C(0x07)
|
||||
|
||||
#define BMP5_SET_IIR_PRESS_MSK UINT8_C(0x38)
|
||||
#define BMP5_SET_IIR_PRESS_POS UINT8_C(3)
|
||||
|
||||
#define BMP5_OOR_SEL_IIR_PRESS_MSK UINT8_C(0x80)
|
||||
#define BMP5_OOR_SEL_IIR_PRESS_POS UINT8_C(7)
|
||||
|
||||
#define BMP5_SHDW_SET_IIR_TEMP_MSK UINT8_C(0x08)
|
||||
#define BMP5_SHDW_SET_IIR_TEMP_POS UINT8_C(3)
|
||||
|
||||
#define BMP5_SHDW_SET_IIR_PRESS_MSK UINT8_C(0x20)
|
||||
#define BMP5_SHDW_SET_IIR_PRESS_POS UINT8_C(5)
|
||||
|
||||
#define BMP5_SET_FIFO_IIR_TEMP_MSK UINT8_C(0x10)
|
||||
#define BMP5_SET_FIFO_IIR_TEMP_POS UINT8_C(4)
|
||||
|
||||
#define BMP5_SET_FIFO_IIR_PRESS_MSK UINT8_C(0x40)
|
||||
#define BMP5_SET_FIFO_IIR_PRESS_POS UINT8_C(6)
|
||||
|
||||
#define BMP5_IIR_FLUSH_FORCED_EN_MSK UINT8_C(0x04)
|
||||
#define BMP5_IIR_FLUSH_FORCED_EN_POS UINT8_C(2)
|
||||
|
||||
/*! @name Effective OSR configurations and ODR valid status */
|
||||
#define BMP5_OSR_TEMP_EFF_MSK UINT8_C(0x07)
|
||||
|
||||
#define BMP5_OSR_PRESS_EFF_MSK UINT8_C(0x38)
|
||||
#define BMP5_OSR_PRESS_EFF_POS UINT8_C(3)
|
||||
|
||||
#define BMP5_ODR_IS_VALID_MSK UINT8_C(0x80)
|
||||
#define BMP5_ODR_IS_VALID_POS UINT8_C(7)
|
||||
|
||||
/*! @name Powermode */
|
||||
#define BMP5_POWERMODE_MSK UINT8_C(0x03)
|
||||
|
||||
#define BMP5_DEEP_DISABLE_MSK UINT8_C(0x80)
|
||||
#define BMP5_DEEP_DISABLE_POS UINT8_C(7)
|
||||
|
||||
/*! @name Fifo configurations */
|
||||
#define BMP5_FIFO_THRESHOLD_MSK UINT8_C(0x1F)
|
||||
|
||||
#define BMP5_FIFO_MODE_MSK UINT8_C(0x20)
|
||||
#define BMP5_FIFO_MODE_POS UINT8_C(5)
|
||||
|
||||
#define BMP5_FIFO_DEC_SEL_MSK UINT8_C(0x1C)
|
||||
#define BMP5_FIFO_DEC_SEL_POS UINT8_C(2)
|
||||
|
||||
#define BMP5_FIFO_COUNT_MSK UINT8_C(0x3F)
|
||||
|
||||
#define BMP5_FIFO_FRAME_SEL_MSK UINT8_C(0x03)
|
||||
|
||||
/*! @name Out-of-range configuration */
|
||||
#define BMP5_OOR_THR_P_LSB_MSK UINT32_C(0x0000FF)
|
||||
|
||||
#define BMP5_OOR_THR_P_MSB_MSK UINT32_C(0x00FF00)
|
||||
|
||||
#define BMP5_OOR_THR_P_XMSB_MSK UINT32_C(0x010000)
|
||||
#define BMP5_OOR_THR_P_XMSB_POS UINT16_C(16)
|
||||
|
||||
/* Macro to mask xmsb value of oor threshold from register(0x35) value */
|
||||
#define BMP5_OOR_THR_P_XMSB_REG_MSK UINT8_C(0x01)
|
||||
|
||||
#define BMP5_OOR_COUNT_LIMIT_MSK UINT8_C(0xC0)
|
||||
#define BMP5_OOR_COUNT_LIMIT_POS UINT8_C(6)
|
||||
|
||||
/*! @name NVM configuration */
|
||||
#define BMP5_NVM_ADDR_MSK UINT8_C(0x3F)
|
||||
|
||||
#define BMP5_NVM_PROG_EN_MSK UINT8_C(0x40)
|
||||
#define BMP5_NVM_PROG_EN_POS UINT8_C(6)
|
||||
|
||||
#define BMP5_NVM_DATA_LSB_MSK UINT16_C(0x00FF)
|
||||
|
||||
#define BMP5_NVM_DATA_MSB_MSK UINT16_C(0xFF00)
|
||||
|
||||
/******************************************************************************/
|
||||
/*! @name TYPEDEF DEFINITIONS */
|
||||
/******************************************************************************/
|
||||
|
||||
/*!
|
||||
* @brief Bus communication function pointer which should be mapped to
|
||||
* the platform specific read functions of the user
|
||||
*
|
||||
* @param[in] reg_addr : Register address from which data is read.
|
||||
* @param[out] read_data : Pointer to data buffer where read data is stored.
|
||||
* @param[in] len : Number of bytes of data to be read.
|
||||
* @param[in, out] intf_ptr : Void pointer that can enable the linking of
|
||||
* descriptors for interface related call backs.
|
||||
*
|
||||
* @retval 0 for Success
|
||||
* @retval Non-zero for Failure
|
||||
*/
|
||||
typedef BMP5_INTF_RET_TYPE (*bmp5_read_fptr_t)(uint8_t reg_addr,
|
||||
uint8_t* read_data, uint32_t len,
|
||||
void* intf_ptr);
|
||||
|
||||
/*!
|
||||
* @brief Bus communication function pointer which should be mapped to
|
||||
* the platform specific write functions of the user
|
||||
*
|
||||
* @param[in] reg_addr : Register address to which the data is written.
|
||||
* @param[in] read_data : Pointer to data buffer in which data to be written
|
||||
* is stored.
|
||||
* @param[in] len : Number of bytes of data to be written.
|
||||
* @param[in, out] intf_ptr : Void pointer that can enable the linking of
|
||||
* descriptors for interface related call backs
|
||||
*
|
||||
* @retval 0 for Success
|
||||
* @retval Non-zero for Failure
|
||||
*/
|
||||
typedef BMP5_INTF_RET_TYPE (*bmp5_write_fptr_t)(uint8_t reg_addr,
|
||||
const uint8_t* read_data,
|
||||
uint32_t len, void* intf_ptr);
|
||||
|
||||
/*!
|
||||
* @brief Delay function pointer which should be mapped to
|
||||
* delay function of the user
|
||||
*
|
||||
* @param[in] period : Delay in microseconds.
|
||||
* @param[in, out] intf_ptr : Void pointer that can enable the linking of
|
||||
* descriptors for interface related call backs
|
||||
*
|
||||
*/
|
||||
typedef void (*bmp5_delay_us_fptr_t)(uint32_t period, void* intf_ptr);
|
||||
|
||||
/******************************************************************************/
|
||||
/*! @name ENUMERATION DEFINITIONS */
|
||||
/******************************************************************************/
|
||||
|
||||
/*!
|
||||
* @brief Enumerator for interface selection
|
||||
*/
|
||||
enum bmp5_intf {
|
||||
/*! SPI interface */
|
||||
BMP5_SPI_INTF,
|
||||
/*! I2C interface */
|
||||
BMP5_I2C_INTF,
|
||||
/*! I3C interface */
|
||||
BMP5_I3C_INTF
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief Enumerator for powermode selection
|
||||
*/
|
||||
enum bmp5_powermode {
|
||||
/*! Standby powermode */
|
||||
BMP5_POWERMODE_STANDBY,
|
||||
/*! Normal powermode */
|
||||
BMP5_POWERMODE_NORMAL,
|
||||
/*! Forced powermode */
|
||||
BMP5_POWERMODE_FORCED,
|
||||
/*! Continous powermode */
|
||||
BMP5_POWERMODE_CONTINOUS,
|
||||
/*! Deep standby powermode */
|
||||
BMP5_POWERMODE_DEEP_STANDBY
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief Enumerator for interrupt enable disable
|
||||
*/
|
||||
enum bmp5_intr_en_dis {
|
||||
/*! Interrupt diable */
|
||||
BMP5_INTR_DISABLE = BMP5_DISABLE,
|
||||
/*! Interrupt enable */
|
||||
BMP5_INTR_ENABLE = BMP5_ENABLE
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief Enumerator for interrupt mode
|
||||
*/
|
||||
enum bmp5_intr_mode {
|
||||
/*! Interrupt mode - pulsed */
|
||||
BMP5_PULSED = BMP5_INT_MODE_PULSED,
|
||||
/*! Interrupt mode - latched */
|
||||
BMP5_LATCHED = BMP5_INT_MODE_LATCHED
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief Enumerator for interrupt polarity
|
||||
*/
|
||||
enum bmp5_intr_polarity {
|
||||
/*! Interrupt polarity - active low */
|
||||
BMP5_ACTIVE_LOW = BMP5_INT_POL_ACTIVE_LOW,
|
||||
/*! Interrupt polarity - active high */
|
||||
BMP5_ACTIVE_HIGH = BMP5_INT_POL_ACTIVE_HIGH
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief Enumerator for interrupt drive
|
||||
*/
|
||||
enum bmp5_intr_drive {
|
||||
/*! Interrupt drive - push-pull */
|
||||
BMP5_INTR_PUSH_PULL = BMP5_INT_OD_PUSHPULL,
|
||||
/*! Interrupt drive - open drain */
|
||||
BMP5_INTR_OPEN_DRAIN = BMP5_INT_OD_OPENDRAIN
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief Enumerator for fifo frame selection
|
||||
*/
|
||||
enum bmp5_fifo_frame_sel {
|
||||
/*! Fifo disabled */
|
||||
BMP5_FIFO_NOT_ENABLED,
|
||||
/*! Fifo temperature data only enabled */
|
||||
BMP5_FIFO_TEMPERATURE_DATA,
|
||||
/*! Fifo pressure data only enabled */
|
||||
BMP5_FIFO_PRESSURE_DATA,
|
||||
/*! Fifo pressure and temperature data enabled */
|
||||
BMP5_FIFO_PRESS_TEMP_DATA
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief Enumerator for fifo decimation factor(downsampling) selection
|
||||
*/
|
||||
enum bmp5_fifo_dec_sel {
|
||||
/*! Fifo downsampling disabled */
|
||||
BMP5_FIFO_NO_DOWNSAMPLING,
|
||||
/*! Fifo 2X downsampling */
|
||||
BMP5_FIFO_DOWNSAMPLING_2X,
|
||||
/*! Fifo 4X downsampling */
|
||||
BMP5_FIFO_DOWNSAMPLING_4X,
|
||||
/*! Fifo 8X downsampling */
|
||||
BMP5_FIFO_DOWNSAMPLING_8X,
|
||||
/*! Fifo 16X downsampling */
|
||||
BMP5_FIFO_DOWNSAMPLING_16X,
|
||||
/*! Fifo 32X downsampling */
|
||||
BMP5_FIFO_DOWNSAMPLING_32X,
|
||||
/*! Fifo 64X downsampling */
|
||||
BMP5_FIFO_DOWNSAMPLING_64X,
|
||||
/*! Fifo 128X downsampling */
|
||||
BMP5_FIFO_DOWNSAMPLING_128X
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief Enumerator for fifo mode selection
|
||||
*/
|
||||
enum bmp5_fifo_mode {
|
||||
/*! Fifo mode - streaming */
|
||||
BMP5_FIFO_MODE_STREAMING,
|
||||
/*! Fifo mode - stop on full */
|
||||
BMP5_FIFO_MODE_STOP_ON_FULL
|
||||
};
|
||||
|
||||
/******************************************************************************/
|
||||
/*! @name STRUCTURE DEFINITIONS */
|
||||
/******************************************************************************/
|
||||
|
||||
/*!
|
||||
* @brief OSR, ODR and pressure configuration structure
|
||||
*/
|
||||
struct bmp5_osr_odr_press_config {
|
||||
/*! Temperature oversampling
|
||||
* Assignable macros :
|
||||
* - BMP5_OVERSAMPLING_1X
|
||||
* - BMP5_OVERSAMPLING_2X
|
||||
* - BMP5_OVERSAMPLING_4X
|
||||
* - BMP5_OVERSAMPLING_8X
|
||||
* - BMP5_OVERSAMPLING_16X
|
||||
* - BMP5_OVERSAMPLING_32X
|
||||
* - BMP5_OVERSAMPLING_64X
|
||||
* - BMP5_OVERSAMPLING_128X
|
||||
*/
|
||||
uint8_t osr_t;
|
||||
|
||||
/*! Pressure oversampling
|
||||
* Assignable macros :
|
||||
* - BMP5_OVERSAMPLING_1X
|
||||
* - BMP5_OVERSAMPLING_2X
|
||||
* - BMP5_OVERSAMPLING_4X
|
||||
* - BMP5_OVERSAMPLING_8X
|
||||
* - BMP5_OVERSAMPLING_16X
|
||||
* - BMP5_OVERSAMPLING_32X
|
||||
* - BMP5_OVERSAMPLING_64X
|
||||
* - BMP5_OVERSAMPLING_128X
|
||||
*/
|
||||
uint8_t osr_p;
|
||||
|
||||
/*! Enable pressure
|
||||
* BMP5_ENABLE = Enables pressure data
|
||||
* BMP5_DISABLE = Disables pressure data
|
||||
*/
|
||||
uint8_t press_en;
|
||||
|
||||
/*! Output Data Rate */
|
||||
uint8_t odr;
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief IIR configuration structure
|
||||
*/
|
||||
struct bmp5_iir_config {
|
||||
/*! Temperature IIR
|
||||
* Assignable macros :
|
||||
* - BMP5_IIR_FILTER_BYPASS
|
||||
* - BMP5_IIR_FILTER_0_20980
|
||||
* - BMP5_IIR_FILTER_0_08045
|
||||
* - BMP5_IIR_FILTER_0_03695
|
||||
* - BMP5_IIR_FILTER_0_01785
|
||||
* - BMP5_IIR_FILTER_0_00880
|
||||
* - BMP5_IIR_FILTER_0_00435
|
||||
* - BMP5_IIR_FILTER_0_00220
|
||||
*/
|
||||
uint8_t set_iir_t;
|
||||
|
||||
/*! Pressure IIR
|
||||
* Assignable macros :
|
||||
* - BMP5_IIR_FILTER_BYPASS
|
||||
* - BMP5_IIR_FILTER_0_20980
|
||||
* - BMP5_IIR_FILTER_0_08045
|
||||
* - BMP5_IIR_FILTER_0_03695
|
||||
* - BMP5_IIR_FILTER_0_01785
|
||||
* - BMP5_IIR_FILTER_0_00880
|
||||
* - BMP5_IIR_FILTER_0_00435
|
||||
* - BMP5_IIR_FILTER_0_00220
|
||||
*/
|
||||
uint8_t set_iir_p;
|
||||
|
||||
/*! Shadow IIR selection for temperature
|
||||
* Assignable macros :
|
||||
* - BMP5_ENABLE
|
||||
* - BMP5_DISABLE
|
||||
*/
|
||||
uint8_t shdw_set_iir_t;
|
||||
|
||||
/*! Shadow IIR selection for pressure
|
||||
* Assignable macros :
|
||||
* - BMP5_ENABLE
|
||||
* - BMP5_DISABLE
|
||||
*/
|
||||
uint8_t shdw_set_iir_p;
|
||||
|
||||
/*! IIR flush in forced mode enable
|
||||
* Assignable macros :
|
||||
* - BMP5_ENABLE
|
||||
* - BMP5_DISABLE
|
||||
*/
|
||||
uint8_t iir_flush_forced_en;
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief Effective OSR configuration and ODR valid status structure
|
||||
*/
|
||||
struct bmp5_osr_odr_eff {
|
||||
/*! Effective temperature OSR */
|
||||
uint8_t osr_t_eff;
|
||||
|
||||
/*! Effective pressure OSR */
|
||||
uint8_t osr_p_eff;
|
||||
|
||||
/*! If asserted, the ODR parametrization is valid */
|
||||
uint8_t odr_is_valid;
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief BMP5 interrupt source selection.
|
||||
*/
|
||||
struct bmp5_int_source_select {
|
||||
/*! Data ready interrupt enable
|
||||
* BMP5_ENABLE = Enables data ready interrupt
|
||||
* BMP5_DISABLE = Disables data ready interrupt
|
||||
*/
|
||||
uint8_t drdy_en;
|
||||
|
||||
/*! Fifo full interrupt enable
|
||||
* BMP5_ENABLE = Enables fifo full interrupt
|
||||
* BMP5_DISABLE = Disables fifo full interrupt
|
||||
*/
|
||||
uint8_t fifo_full_en;
|
||||
|
||||
/*! Fifo threshold interrupt enable
|
||||
* BMP5_ENABLE = Enables fifo threshold interrupt
|
||||
* BMP5_DISABLE = Disables fifo threshold interrupt
|
||||
*/
|
||||
uint8_t fifo_thres_en;
|
||||
|
||||
/*! Pressure out of range interrupt enable
|
||||
* BMP5_ENABLE = Enables pressure out of range interrupt
|
||||
* BMP5_DISABLE = Disables pressure out of range interrupt
|
||||
*/
|
||||
uint8_t oor_press_en;
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief BMP5 fifo configurations.
|
||||
*/
|
||||
struct bmp5_fifo {
|
||||
/*! Pointer to fifo data */
|
||||
uint8_t* data;
|
||||
|
||||
/*! Length of user defined bytes of fifo to be read */
|
||||
uint16_t length;
|
||||
|
||||
/*! Fifo frame data source selection
|
||||
* Assignable macros :
|
||||
* - BMP5_FIFO_NOT_ENABLED
|
||||
* - BMP5_FIFO_TEMPERATURE_DATA
|
||||
* - BMP5_FIFO_PRESSURE_DATA
|
||||
* - BMP5_FIFO_PRESS_TEMP_DATA
|
||||
*/
|
||||
uint8_t frame_sel;
|
||||
|
||||
/*! Fifo decimation factor(downsampling) selection
|
||||
* Assignable macros :
|
||||
* - BMP5_FIFO_NO_DOWNSAMPLING
|
||||
* - BMP5_FIFO_DOWNSAMPLING_2X
|
||||
* - BMP5_FIFO_DOWNSAMPLING_4X
|
||||
* - BMP5_FIFO_DOWNSAMPLING_8X
|
||||
* - BMP5_FIFO_DOWNSAMPLING_16X
|
||||
* - BMP5_FIFO_DOWNSAMPLING_32X
|
||||
* - BMP5_FIFO_DOWNSAMPLING_64X
|
||||
* - BMP5_FIFO_DOWNSAMPLING_128X
|
||||
*/
|
||||
uint8_t dec_sel;
|
||||
|
||||
/*! Fifo frame count */
|
||||
uint8_t fifo_count;
|
||||
|
||||
/*! Fifo mode selection
|
||||
* Assignable macros :
|
||||
* - BMP5_FIFO_MODE_STREAMING
|
||||
* - BMP5_FIFO_MODE_STOP_ON_FULL
|
||||
*/
|
||||
uint8_t mode;
|
||||
|
||||
/*! Threshold for fifo */
|
||||
uint8_t threshold;
|
||||
|
||||
/*! Fifo temperature IIR
|
||||
* Assignable macros :
|
||||
* - BMP5_ENABLE
|
||||
* - BMP5_DISABLE
|
||||
*/
|
||||
uint8_t set_fifo_iir_t;
|
||||
|
||||
/*! Fifo pressure IIR
|
||||
* Assignable macros :
|
||||
* - BMP5_ENABLE
|
||||
* - BMP5_DISABLE
|
||||
*/
|
||||
uint8_t set_fifo_iir_p;
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief BMP5 Out-of-range pressure configuration.
|
||||
*/
|
||||
struct bmp5_oor_press_configuration {
|
||||
/*! Out-of-range pressure threshold */
|
||||
uint32_t oor_thr_p;
|
||||
|
||||
/*! Out-of-range pressure range
|
||||
* Range can span up to +/- 255 Pa around the threshold value.
|
||||
*/
|
||||
uint8_t oor_range_p;
|
||||
|
||||
/*! Out-of-range pressure count limit
|
||||
* Assignable macros :
|
||||
* - BMP5_OOR_COUNT_LIMIT_1
|
||||
* - BMP5_OOR_COUNT_LIMIT_3
|
||||
* - BMP5_OOR_COUNT_LIMIT_7
|
||||
* - BMP5_OOR_COUNT_LIMIT_15
|
||||
*/
|
||||
uint8_t cnt_lim;
|
||||
|
||||
/*! Out-of-range pressure IIR
|
||||
* Assignable macros :
|
||||
* - BMP5_ENABLE
|
||||
* - BMP5_DISABLE
|
||||
*/
|
||||
uint8_t oor_sel_iir_p;
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief BMP5 sensor data structure which comprises of temperature and
|
||||
* pressure.
|
||||
*/
|
||||
|
||||
#ifdef BMP5_USE_FIXED_POINT
|
||||
|
||||
/*!
|
||||
* @brief BMP5 sensor data structure which comprises of temperature and pressure
|
||||
* in fixed point with data type as uint64_t for pressure and int64_t for
|
||||
* temperature.
|
||||
*/
|
||||
struct bmp5_sensor_data {
|
||||
/*! Pressure data */
|
||||
uint64_t pressure;
|
||||
|
||||
/*! Temperature data */
|
||||
int64_t temperature;
|
||||
};
|
||||
|
||||
#else
|
||||
|
||||
/*!
|
||||
* @brief BMP5 sensor data structure which comprises of temperature and pressure
|
||||
* in floating point with data type as float for pressure and temperature.
|
||||
*/
|
||||
struct bmp5_sensor_data {
|
||||
/*! Pressure data */
|
||||
float pressure;
|
||||
|
||||
/*! Temperature data */
|
||||
float temperature;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @brief API device structure
|
||||
*/
|
||||
struct bmp5_dev {
|
||||
/*! Chip ID */
|
||||
uint8_t chip_id;
|
||||
|
||||
/*!
|
||||
* The interface pointer is used to enable the user
|
||||
* to link their interface descriptors for reference during the
|
||||
* implementation of the read and write interfaces to the
|
||||
* hardware.
|
||||
*/
|
||||
void* intf_ptr;
|
||||
|
||||
/*! Read function pointer */
|
||||
bmp5_read_fptr_t read;
|
||||
|
||||
/*! Write function pointer */
|
||||
bmp5_write_fptr_t write;
|
||||
|
||||
/*! Delay function pointer */
|
||||
bmp5_delay_us_fptr_t delay_us;
|
||||
|
||||
/*! To store interface pointer error */
|
||||
BMP5_INTF_RET_TYPE intf_rslt;
|
||||
|
||||
/*! Type of Interface */
|
||||
enum bmp5_intf intf;
|
||||
};
|
||||
|
||||
#endif /* End of _BMP5_DEFS_H */
|
||||