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,7 +56,8 @@ 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) {
@ -82,7 +83,8 @@ 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) {
@ -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;
@ -340,7 +348,8 @@ Adafruit_Sensor *Adafruit_BMP5xx::getTemperatureSensor(void) {
}
/*!
* @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) {
@ -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);

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,7 +155,8 @@ 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;
/**
@ -165,7 +169,9 @@ public:
*
* @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);
@ -185,7 +191,9 @@ public:
*
* @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);
@ -200,7 +208,6 @@ private:
*/
class Adafruit_BMP5xx {
public:
Adafruit_BMP5xx();
~Adafruit_BMP5xx(void);

View file

@ -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.
*
@ -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.
@ -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,8 +185,9 @@ 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.
@ -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.
@ -230,8 +235,8 @@ 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,24 +272,28 @@ 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,
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);
@ -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
@ -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
@ -525,10 +552,10 @@ 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

@ -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
/******************************************************************************/
@ -114,16 +114,20 @@
/******************************************************************************/
/*! @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,22 +512,23 @@ 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);
@ -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,8 +793,7 @@ struct bmp5_int_source_select
/*!
* @brief BMP5 fifo configurations.
*/
struct bmp5_fifo
{
struct bmp5_fifo {
/*! Pointer to fifo data */
uint8_t* data;
@ -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;