Update GitHub CI workflow to match Adafruit_AS5600 and apply clang formatting

- Remove build matrix strategy to match reference workflow
- Downgrade action versions (checkout@v2, setup-python@v1)
- Reorder steps (setup-python first)
- Change platform test to use main_platforms instead of matrix variable
- Move clang step before test platforms step
- Apply clang formatting to all source files

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Adafruit Developer 2025-08-10 08:49:15 -04:00
parent ea0d4c0bb1
commit 158e9af830
6 changed files with 895 additions and 838 deletions

View file

@ -4,19 +4,14 @@ on: [pull_request, push, repository_dispatch]
jobs:
build:
strategy:
fail-fast: false
matrix:
arduino-platform: ["uno", "leonardo", "zero", "esp8266", "esp32", "metro_m4"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
- uses: actions/setup-python@v1
with:
python-version: '3.x'
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- uses: actions/checkout@v2
with:
repository: adafruit/ci-arduino
path: ci
@ -24,12 +19,12 @@ jobs:
- name: pre-install
run: bash ci/actions_install.sh
- name: test platforms
run: python3 ci/build_platform.py ${{ matrix.arduino-platform }}
- 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 }}

View file

@ -213,6 +213,13 @@ void setup() {
}
void loop() {
// Check if new data is ready before reading
if (!bmp.dataReady()) {
delay(10);
return;
}
// Data is ready, perform reading
if (!bmp.performReading()) {
return;
}
@ -231,5 +238,5 @@ void loop() {
Serial.println(F("---"));
delay(100);
delay(10); // Short delay since we're checking dataReady()
}

View file

@ -56,10 +56,11 @@ Adafruit_BMP5xx::~Adafruit_BMP5xx(void) {
/*!
* @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
* @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) {
bool Adafruit_BMP5xx::begin(uint8_t addr, TwoWire* theWire) {
if (_i2c_dev) {
delete _i2c_dev;
}
@ -82,10 +83,11 @@ bool Adafruit_BMP5xx::begin(uint8_t addr, TwoWire *theWire) {
/*!
* @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
* @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) {
bool Adafruit_BMP5xx::begin(int8_t cspin, SPIClass* theSPI) {
if (_spi_dev) {
delete _spi_dev;
}
@ -165,18 +167,22 @@ bool Adafruit_BMP5xx::_init(void) {
}
// 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);
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
* @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);
int8_t rslt =
bmp5_get_sensor_data(&sensor_data, &_osr_odr_config, &_bmp5_dev);
if (rslt != BMP5_OK) {
return false;
}
@ -220,7 +226,8 @@ float Adafruit_BMP5xx::readAltitude(float seaLevel) {
* @param oversampling Oversampling setting
* @return True on success, False on failure
*/
bool Adafruit_BMP5xx::setTemperatureOversampling(bmp5xx_oversampling_t oversampling) {
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;
@ -231,7 +238,8 @@ bool Adafruit_BMP5xx::setTemperatureOversampling(bmp5xx_oversampling_t oversampl
* @param oversampling Oversampling setting
* @return True on success, False on failure
*/
bool Adafruit_BMP5xx::setPressureOversampling(bmp5xx_oversampling_t oversampling) {
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;
@ -335,15 +343,16 @@ bool Adafruit_BMP5xx::enablePressure(bool enable) {
* @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) {
Adafruit_Sensor* Adafruit_BMP5xx::getTemperatureSensor(void) {
return _temp_sensor;
}
/*!
* @brief Gets an Adafruit Unified Sensor object for the pressure sensor component
* @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) {
Adafruit_Sensor* Adafruit_BMP5xx::getPressureSensor(void) {
return _pressure_sensor;
}
@ -373,26 +382,29 @@ bool Adafruit_BMP5xx::dataReady(void) {
bool Adafruit_BMP5xx::configureInterrupt(bmp5xx_interrupt_mode_t mode,
bmp5xx_interrupt_polarity_t polarity,
bmp5xx_interrupt_drive_t drive,
uint8_t sources,
bool enable) {
uint8_t sources, bool enable) {
// Configure interrupt pin settings first
enum bmp5_intr_en_dis int_enable = enable ? BMP5_INTR_ENABLE : BMP5_INTR_DISABLE;
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);
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;
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);
@ -409,9 +421,9 @@ bool Adafruit_BMP5xx::configureInterrupt(bmp5xx_interrupt_mode_t mode,
@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;
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(&reg_addr, 1, reg_data, len)) {
return -1;
@ -430,9 +442,9 @@ int8_t Adafruit_BMP5xx::i2c_read(uint8_t reg_addr, uint8_t *reg_data,
@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;
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];
@ -456,9 +468,9 @@ int8_t Adafruit_BMP5xx::i2c_write(uint8_t reg_addr, const uint8_t *reg_data,
@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;
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;
@ -480,9 +492,9 @@ int8_t Adafruit_BMP5xx::spi_read(uint8_t reg_addr, uint8_t *reg_data,
@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;
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];
@ -503,7 +515,7 @@ int8_t Adafruit_BMP5xx::spi_write(uint8_t reg_addr, const uint8_t *reg_data,
@param intf_ptr Pointer to interface (unused)
*/
/**************************************************************************/
void Adafruit_BMP5xx::delay_usec(uint32_t us, void *intf_ptr) {
void Adafruit_BMP5xx::delay_usec(uint32_t us, void* intf_ptr) {
(void)intf_ptr; // Unused parameter
delayMicroseconds(us);
}
@ -517,7 +529,7 @@ void Adafruit_BMP5xx::delay_usec(uint32_t us, void *intf_ptr) {
* @param event Sensor event object that will be populated
* @returns True
*/
bool Adafruit_BMP5xx_Temp::getEvent(sensors_event_t *event) {
bool Adafruit_BMP5xx_Temp::getEvent(sensors_event_t* event) {
_theBMP5xx->readTemperature();
event->version = sizeof(sensors_event_t);
@ -533,7 +545,7 @@ bool Adafruit_BMP5xx_Temp::getEvent(sensors_event_t *event) {
* @brief Gets the sensor_t device data
* @param sensor Sensor description that will be populated
*/
void Adafruit_BMP5xx_Temp::getSensor(sensor_t *sensor) {
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;
@ -555,7 +567,7 @@ void Adafruit_BMP5xx_Temp::getSensor(sensor_t *sensor) {
* @param event Sensor event object that will be populated
* @returns True
*/
bool Adafruit_BMP5xx_Pressure::getEvent(sensors_event_t *event) {
bool Adafruit_BMP5xx_Pressure::getEvent(sensors_event_t* event) {
_theBMP5xx->readPressure();
event->version = sizeof(sensors_event_t);
@ -571,7 +583,7 @@ bool Adafruit_BMP5xx_Pressure::getEvent(sensors_event_t *event) {
* @brief Gets the sensor_t device data
* @param sensor Sensor description that will be populated
*/
void Adafruit_BMP5xx_Pressure::getSensor(sensor_t *sensor) {
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;

View file

@ -18,12 +18,13 @@
#ifndef ADAFRUIT_BMP5XX_H
#define ADAFRUIT_BMP5XX_H
#include "Arduino.h"
#include <Adafruit_I2CDevice.h>
#include <Adafruit_SPIDevice.h>
#include <Adafruit_Sensor.h>
#include <Wire.h>
#include "Arduino.h"
extern "C" {
#include "bmp5.h"
}
@ -117,8 +118,10 @@ typedef enum {
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_CONTINOUS =
BMP5_POWERMODE_CONTINOUS, ///< @deprecated Use BMP5XX_POWERMODE_CONTINUOUS
BMP5XX_POWERMODE_DEEP_STANDBY =
BMP5_POWERMODE_DEEP_STANDBY, ///< Deep standby mode
} bmp5xx_powermode_t;
/**
@ -152,60 +155,64 @@ 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_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:
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; }
Adafruit_BMP5xx_Temp(class Adafruit_BMP5xx* parent) {
_theBMP5xx = parent;
}
bool getEvent(sensors_event_t *event);
void getSensor(sensor_t *sensor);
bool getEvent(sensors_event_t* event);
void getSensor(sensor_t* sensor);
private:
private:
int _sensorID = 0x580; /**< ID number for temperature sensor */
class Adafruit_BMP5xx *_theBMP5xx = NULL; /**< Pointer to BMP5xx instance */
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:
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; }
Adafruit_BMP5xx_Pressure(class Adafruit_BMP5xx* parent) {
_theBMP5xx = parent;
}
bool getEvent(sensors_event_t *event);
void getSensor(sensor_t *sensor);
bool getEvent(sensors_event_t* event);
void getSensor(sensor_t* sensor);
private:
private:
int _sensorID = 0x581; /**< ID number for pressure sensor */
class Adafruit_BMP5xx *_theBMP5xx = NULL; /**< Pointer to BMP5xx instance */
class Adafruit_BMP5xx* _theBMP5xx = NULL; /**< Pointer to BMP5xx instance */
};
/**
* Driver for the Adafruit BMP5xx barometric pressure sensor.
*/
class Adafruit_BMP5xx {
public:
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);
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);
@ -225,8 +232,8 @@ public:
bmp5xx_odr_t getOutputDataRate(void);
bmp5xx_powermode_t getPowerMode(void);
Adafruit_Sensor *getTemperatureSensor(void);
Adafruit_Sensor *getPressureSensor(void);
Adafruit_Sensor* getTemperatureSensor(void);
Adafruit_Sensor* getPressureSensor(void);
bool enablePressure(bool enable = true);
bool dataReady(void);
@ -242,7 +249,7 @@ public:
/**! Pressure (hPa) assigned after calling performReading() */
float pressure;
private:
private:
bool _init(void);
/**! BMP5xx device struct from Bosch API */
@ -255,25 +262,25 @@ private:
struct bmp5_iir_config _iir_config;
/**! I2C interface object */
Adafruit_I2CDevice *_i2c_dev = NULL;
Adafruit_I2CDevice* _i2c_dev = NULL;
/**! SPI interface object */
Adafruit_SPIDevice *_spi_dev = NULL;
Adafruit_SPIDevice* _spi_dev = NULL;
/**! Adafruit unified sensor interface for temperature */
Adafruit_BMP5xx_Temp *_temp_sensor = NULL;
Adafruit_BMP5xx_Temp* _temp_sensor = NULL;
/**! Adafruit unified sensor interface for pressure */
Adafruit_BMP5xx_Pressure *_pressure_sensor = NULL;
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);
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

View file

@ -1,40 +1,40 @@
/**
* 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
*
*/
* 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
@ -72,9 +72,9 @@ extern "C" {
* \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.
* @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.
*
@ -83,7 +83,7 @@ extern "C" {
* @return < 0 -> Fail
*
*/
int8_t bmp5_init(struct bmp5_dev *dev);
int8_t bmp5_init(struct bmp5_dev* dev);
/**
* \ingroup bmp5
@ -95,8 +95,8 @@ int8_t bmp5_init(struct bmp5_dev *dev);
* \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
* 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.
@ -108,14 +108,15 @@ int8_t bmp5_init(struct bmp5_dev *dev);
* @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);
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
* 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.
@ -128,7 +129,8 @@ int8_t bmp5_get_regs(uint8_t reg_addr, uint8_t *data, uint32_t len, struct bmp5_
* @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);
int8_t bmp5_set_regs(uint8_t reg_addr, const uint8_t* data, uint32_t len,
struct bmp5_dev* dev);
/**
* \ingroup bmp5
@ -142,7 +144,8 @@ int8_t bmp5_set_regs(uint8_t reg_addr, const uint8_t *data, uint32_t len, struct
* \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.
* @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.
@ -153,7 +156,7 @@ int8_t bmp5_set_regs(uint8_t reg_addr, const uint8_t *data, uint32_t len, struct
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_soft_reset(struct bmp5_dev *dev);
int8_t bmp5_soft_reset(struct bmp5_dev* dev);
/**
* \ingroup bmp5
@ -167,8 +170,9 @@ int8_t bmp5_soft_reset(struct bmp5_dev *dev);
* \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).
* @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.
@ -181,15 +185,16 @@ int8_t bmp5_soft_reset(struct bmp5_dev *dev);
* 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
* 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);
int8_t bmp5_get_interrupt_status(uint8_t* int_status, struct bmp5_dev* dev);
/**
* \ingroup bmp5
@ -201,8 +206,8 @@ int8_t bmp5_get_interrupt_status(uint8_t *int_status, struct bmp5_dev *dev);
* \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
* 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.
@ -224,14 +229,14 @@ int8_t bmp5_get_interrupt_status(uint8_t *int_status, struct bmp5_dev *dev);
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_set_power_mode(enum bmp5_powermode powermode, struct bmp5_dev *dev);
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
* 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.
@ -253,7 +258,8 @@ int8_t bmp5_set_power_mode(enum bmp5_powermode powermode, struct bmp5_dev *dev);
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_get_power_mode(enum bmp5_powermode *powermode, struct bmp5_dev *dev);
int8_t bmp5_get_power_mode(enum bmp5_powermode* powermode,
struct bmp5_dev* dev);
/**
* \ingroup bmp5
@ -266,26 +272,30 @@ int8_t bmp5_get_power_mode(enum bmp5_powermode *powermode, struct bmp5_dev *dev)
* \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.
* 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] 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.
* @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);
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
@ -297,10 +307,10 @@ int8_t bmp5_get_sensor_data(struct bmp5_sensor_data *sensor_data,
* \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).
* 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.
@ -309,7 +319,9 @@ int8_t bmp5_get_sensor_data(struct bmp5_sensor_data *sensor_data,
* @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);
int8_t bmp5_int_source_select(
const struct bmp5_int_source_select* int_source_select,
struct bmp5_dev* dev);
/*!
* \ingroup bmp5ApiInterrupt
@ -337,7 +349,7 @@ 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);
struct bmp5_dev* dev);
/**
* \ingroup bmp5
@ -349,47 +361,54 @@ int8_t bmp5_configure_interrupt(enum bmp5_intr_mode int_mode,
* \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.
* 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[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);
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.
* 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] 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.
* @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);
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
* 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.
@ -399,22 +418,24 @@ int8_t bmp5_set_osr_odr_press_config(const struct bmp5_osr_odr_press_config *osr
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_get_iir_config(struct bmp5_iir_config *iir_cfg, struct bmp5_dev *dev);
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
* 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.
* 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.
@ -423,14 +444,15 @@ int8_t bmp5_get_iir_config(struct bmp5_iir_config *iir_cfg, struct bmp5_dev *dev
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_set_iir_config(const struct bmp5_iir_config *iir_cfg, struct bmp5_dev *dev);
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
* 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.
*
@ -441,7 +463,8 @@ int8_t bmp5_set_iir_config(const struct bmp5_iir_config *iir_cfg, struct bmp5_de
* @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);
int8_t bmp5_get_osr_odr_eff(struct bmp5_osr_odr_eff* osr_odr_eff,
struct bmp5_dev* dev);
/**
* \ingroup bmp5
@ -453,8 +476,8 @@ int8_t bmp5_get_osr_odr_eff(struct bmp5_osr_odr_eff *osr_odr_eff, struct bmp5_de
* \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
* 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.
@ -464,34 +487,37 @@ int8_t bmp5_get_osr_odr_eff(struct bmp5_osr_odr_eff *osr_odr_eff, struct bmp5_de
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_get_fifo_configuration(struct bmp5_fifo *fifo, struct bmp5_dev *dev);
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
* 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.
* @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);
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
* 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.
@ -502,7 +528,8 @@ int8_t bmp5_set_fifo_configuration(const struct bmp5_fifo *fifo, struct bmp5_dev
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_get_fifo_len(uint16_t *fifo_len, struct bmp5_fifo *fifo, struct bmp5_dev *dev);
int8_t bmp5_get_fifo_len(uint16_t* fifo_len, struct bmp5_fifo* fifo,
struct bmp5_dev* dev);
/*!
* \ingroup bmp5ApiFIFO
@ -519,16 +546,16 @@ int8_t bmp5_get_fifo_len(uint16_t *fifo_len, struct bmp5_fifo *fifo, struct bmp5
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_get_fifo_data(struct bmp5_fifo *fifo, struct bmp5_dev *dev);
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.
* 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.
@ -538,7 +565,8 @@ int8_t bmp5_get_fifo_data(struct bmp5_fifo *fifo, struct bmp5_dev *dev);
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_extract_fifo_data(const struct bmp5_fifo *fifo, struct bmp5_sensor_data *sensor_data);
int8_t bmp5_extract_fifo_data(const struct bmp5_fifo* fifo,
struct bmp5_sensor_data* sensor_data);
/**
* \ingroup bmp5
@ -550,37 +578,43 @@ int8_t bmp5_extract_fifo_data(const struct bmp5_fifo *fifo, struct bmp5_sensor_d
* \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.
* 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[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);
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.
* 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] 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);
int8_t bmp5_set_oor_configuration(
const struct bmp5_oor_press_configuration* oor_press_config,
struct bmp5_dev* dev);
/**
* \ingroup bmp5
@ -592,8 +626,8 @@ int8_t bmp5_set_oor_configuration(const struct bmp5_oor_press_configuration *oor
* \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
* 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.
@ -604,14 +638,15 @@ int8_t bmp5_set_oor_configuration(const struct bmp5_oor_press_configuration *oor
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_nvm_read(uint8_t nvm_addr, uint16_t *nvm_data, struct bmp5_dev *dev);
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
* 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.
@ -622,7 +657,8 @@ int8_t bmp5_nvm_read(uint8_t nvm_addr, uint16_t *nvm_data, struct bmp5_dev *dev)
* @return 0 -> Success
* @return < 0 -> Fail
*/
int8_t bmp5_nvm_write(uint8_t nvm_addr, const uint16_t *nvm_data, struct bmp5_dev *dev);
int8_t bmp5_nvm_write(uint8_t nvm_addr, const uint16_t* nvm_data,
struct bmp5_dev* dev);
#ifdef __cplusplus
}

View file

@ -1,40 +1,40 @@
/**
* 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
*
*/
* 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
@ -48,9 +48,9 @@
#ifdef __KERNEL__
#include <linux/types.h>
#else
#include <stdint.h>
#include <stddef.h>
#include <math.h>
#include <stddef.h>
#include <stdint.h>
#endif
/******************************************************************************/
@ -107,23 +107,27 @@
#ifdef __cplusplus
#define NULL 0
#else
#define NULL ((void *) 0)
#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 */
#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_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 */
#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
@ -141,14 +145,16 @@
/******************************************************************************/
/*!
* BMP5_INTF_RET_TYPE is the read/write interface return type which can be overwritten by the build system.
* 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.
* 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)
@ -180,8 +186,7 @@
((regvar & bitname##_MSK) >> bitname##_POS)
#define BMP5_SET_BITSLICE(regvar, bitname, val) \
((regvar & ~bitname##_MSK) | \
((val << bitname##_POS) & bitname##_MSK))
((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)
@ -189,8 +194,7 @@
#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))
((reg_data & ~(bitname##_MSK)) | (data & bitname##_MSK))
#define BMP5_GET_BITS_POS_0(reg_data, bitname) (reg_data & (bitname##_MSK))
@ -490,13 +494,15 @@
* @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.
* @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);
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
@ -506,25 +512,26 @@ typedef BMP5_INTF_RET_TYPE (*bmp5_read_fptr_t)(uint8_t reg_addr, uint8_t *read_d
* @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
* @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);
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
* @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);
typedef void (*bmp5_delay_us_fptr_t)(uint32_t period, void* intf_ptr);
/******************************************************************************/
/*! @name ENUMERATION DEFINITIONS */
@ -651,8 +658,7 @@ enum bmp5_fifo_mode {
/*!
* @brief OSR, ODR and pressure configuration structure
*/
struct bmp5_osr_odr_press_config
{
struct bmp5_osr_odr_press_config {
/*! Temperature oversampling
* Assignable macros :
* - BMP5_OVERSAMPLING_1X
@ -692,8 +698,7 @@ struct bmp5_osr_odr_press_config
/*!
* @brief IIR configuration structure
*/
struct bmp5_iir_config
{
struct bmp5_iir_config {
/*! Temperature IIR
* Assignable macros :
* - BMP5_IIR_FILTER_BYPASS
@ -745,8 +750,7 @@ struct bmp5_iir_config
/*!
* @brief Effective OSR configuration and ODR valid status structure
*/
struct bmp5_osr_odr_eff
{
struct bmp5_osr_odr_eff {
/*! Effective temperature OSR */
uint8_t osr_t_eff;
@ -760,8 +764,7 @@ struct bmp5_osr_odr_eff
/*!
* @brief BMP5 interrupt source selection.
*/
struct bmp5_int_source_select
{
struct bmp5_int_source_select {
/*! Data ready interrupt enable
* BMP5_ENABLE = Enables data ready interrupt
* BMP5_DISABLE = Disables data ready interrupt
@ -790,10 +793,9 @@ struct bmp5_int_source_select
/*!
* @brief BMP5 fifo configurations.
*/
struct bmp5_fifo
{
struct bmp5_fifo {
/*! Pointer to fifo data */
uint8_t *data;
uint8_t* data;
/*! Length of user defined bytes of fifo to be read */
uint16_t length;
@ -851,8 +853,7 @@ struct bmp5_fifo
/*!
* @brief BMP5 Out-of-range pressure configuration.
*/
struct bmp5_oor_press_configuration
{
struct bmp5_oor_press_configuration {
/*! Out-of-range pressure threshold */
uint32_t oor_thr_p;
@ -879,17 +880,18 @@ struct bmp5_oor_press_configuration
};
/*!
* @brief BMP5 sensor data structure which comprises of temperature and pressure.
* @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.
* @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
{
struct bmp5_sensor_data {
/*! Pressure data */
uint64_t pressure;
@ -900,11 +902,10 @@ struct bmp5_sensor_data
#else
/*!
* @brief BMP5 sensor data structure which comprises of temperature and pressure in floating point with data type as
* float for pressure and temperature.
* @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
{
struct bmp5_sensor_data {
/*! Pressure data */
float pressure;
@ -917,8 +918,7 @@ struct bmp5_sensor_data
/*!
* @brief API device structure
*/
struct bmp5_dev
{
struct bmp5_dev {
/*! Chip ID */
uint8_t chip_id;
@ -928,7 +928,7 @@ struct bmp5_dev
* implementation of the read and write interfaces to the
* hardware.
*/
void *intf_ptr;
void* intf_ptr;
/*! Read function pointer */
bmp5_read_fptr_t read;