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

View file

@ -213,6 +213,13 @@ void setup() {
} }
void loop() { void loop() {
// Check if new data is ready before reading
if (!bmp.dataReady()) {
delay(10);
return;
}
// Data is ready, perform reading
if (!bmp.performReading()) { if (!bmp.performReading()) {
return; return;
} }
@ -231,5 +238,5 @@ void loop() {
Serial.println(F("---")); 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 * @brief Initializes the sensor
* @param addr Optional I2C address the sensor can be found on. Default is 0x46 * @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. * @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) { if (_i2c_dev) {
delete _i2c_dev; delete _i2c_dev;
} }
@ -82,10 +83,11 @@ bool Adafruit_BMP5xx::begin(uint8_t addr, TwoWire *theWire) {
/*! /*!
* @brief Initializes the sensor over SPI * @brief Initializes the sensor over SPI
* @param cspin The pin to use for CS/Chip Select * @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. * @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) { if (_spi_dev) {
delete _spi_dev; delete _spi_dev;
} }
@ -165,18 +167,22 @@ bool Adafruit_BMP5xx::_init(void) {
} }
// Configure interrupt pin as push-pull, active high, latched mode // 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; 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. * @return True if the reading was successful, otherwise false.
*/ */
bool Adafruit_BMP5xx::performReading(void) { bool Adafruit_BMP5xx::performReading(void) {
struct bmp5_sensor_data sensor_data; 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) { if (rslt != BMP5_OK) {
return false; return false;
} }
@ -220,7 +226,8 @@ float Adafruit_BMP5xx::readAltitude(float seaLevel) {
* @param oversampling Oversampling setting * @param oversampling Oversampling setting
* @return True on success, False on failure * @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; _osr_odr_config.osr_t = (uint8_t)oversampling;
int8_t rslt = bmp5_set_osr_odr_press_config(&_osr_odr_config, &_bmp5_dev); int8_t rslt = bmp5_set_osr_odr_press_config(&_osr_odr_config, &_bmp5_dev);
return rslt == BMP5_OK; return rslt == BMP5_OK;
@ -231,7 +238,8 @@ bool Adafruit_BMP5xx::setTemperatureOversampling(bmp5xx_oversampling_t oversampl
* @param oversampling Oversampling setting * @param oversampling Oversampling setting
* @return True on success, False on failure * @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; _osr_odr_config.osr_p = (uint8_t)oversampling;
int8_t rslt = bmp5_set_osr_odr_press_config(&_osr_odr_config, &_bmp5_dev); int8_t rslt = bmp5_set_osr_odr_press_config(&_osr_odr_config, &_bmp5_dev);
return rslt == BMP5_OK; 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 * @brief Gets an Adafruit Unified Sensor object for the temp sensor component
* @return Adafruit_Sensor pointer to temperature sensor * @return Adafruit_Sensor pointer to temperature sensor
*/ */
Adafruit_Sensor *Adafruit_BMP5xx::getTemperatureSensor(void) { Adafruit_Sensor* Adafruit_BMP5xx::getTemperatureSensor(void) {
return _temp_sensor; 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 * @return Adafruit_Sensor pointer to pressure sensor
*/ */
Adafruit_Sensor *Adafruit_BMP5xx::getPressureSensor(void) { Adafruit_Sensor* Adafruit_BMP5xx::getPressureSensor(void) {
return _pressure_sensor; return _pressure_sensor;
} }
@ -373,26 +382,29 @@ bool Adafruit_BMP5xx::dataReady(void) {
bool Adafruit_BMP5xx::configureInterrupt(bmp5xx_interrupt_mode_t mode, bool Adafruit_BMP5xx::configureInterrupt(bmp5xx_interrupt_mode_t mode,
bmp5xx_interrupt_polarity_t polarity, bmp5xx_interrupt_polarity_t polarity,
bmp5xx_interrupt_drive_t drive, bmp5xx_interrupt_drive_t drive,
uint8_t sources, uint8_t sources, bool enable) {
bool enable) {
// Configure interrupt pin settings first // 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, int8_t rslt = bmp5_configure_interrupt(
(enum bmp5_intr_polarity)polarity, (enum bmp5_intr_mode)mode, (enum bmp5_intr_polarity)polarity,
(enum bmp5_intr_drive)drive, (enum bmp5_intr_drive)drive, int_enable, &_bmp5_dev);
int_enable,
&_bmp5_dev);
if (rslt != BMP5_OK) { if (rslt != BMP5_OK) {
return false; return false;
} }
// Configure interrupt sources after pin settings // Configure interrupt sources after pin settings
struct bmp5_int_source_select int_source_select = {0}; 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.drdy_en =
int_source_select.fifo_full_en = (sources & BMP5XX_INTERRUPT_FIFO_FULL) ? BMP5_ENABLE : BMP5_DISABLE; (sources & BMP5XX_INTERRUPT_DATA_READY) ? BMP5_ENABLE : BMP5_DISABLE;
int_source_select.fifo_thres_en = (sources & BMP5XX_INTERRUPT_FIFO_THRESHOLD) ? BMP5_ENABLE : BMP5_DISABLE; int_source_select.fifo_full_en =
int_source_select.oor_press_en = (sources & BMP5XX_INTERRUPT_PRESSURE_OUT_OF_RANGE) ? BMP5_ENABLE : BMP5_DISABLE; (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); 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 @return 0 on success, negative on error
*/ */
/**************************************************************************/ /**************************************************************************/
int8_t Adafruit_BMP5xx::i2c_read(uint8_t reg_addr, uint8_t *reg_data, int8_t Adafruit_BMP5xx::i2c_read(uint8_t reg_addr, uint8_t* reg_data,
uint32_t len, void *intf_ptr) { uint32_t len, void* intf_ptr) {
Adafruit_I2CDevice *i2c_dev = (Adafruit_I2CDevice *)intf_ptr; Adafruit_I2CDevice* i2c_dev = (Adafruit_I2CDevice*)intf_ptr;
if (!i2c_dev->write_then_read(&reg_addr, 1, reg_data, len)) { if (!i2c_dev->write_then_read(&reg_addr, 1, reg_data, len)) {
return -1; 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 @return 0 on success, negative on error
*/ */
/**************************************************************************/ /**************************************************************************/
int8_t Adafruit_BMP5xx::i2c_write(uint8_t reg_addr, const uint8_t *reg_data, int8_t Adafruit_BMP5xx::i2c_write(uint8_t reg_addr, const uint8_t* reg_data,
uint32_t len, void *intf_ptr) { uint32_t len, void* intf_ptr) {
Adafruit_I2CDevice *i2c_dev = (Adafruit_I2CDevice *)intf_ptr; Adafruit_I2CDevice* i2c_dev = (Adafruit_I2CDevice*)intf_ptr;
// Create buffer with register address + data // Create buffer with register address + data
uint8_t buffer[len + 1]; 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 @return 0 on success, negative on error
*/ */
/**************************************************************************/ /**************************************************************************/
int8_t Adafruit_BMP5xx::spi_read(uint8_t reg_addr, uint8_t *reg_data, int8_t Adafruit_BMP5xx::spi_read(uint8_t reg_addr, uint8_t* reg_data,
uint32_t len, void *intf_ptr) { uint32_t len, void* intf_ptr) {
Adafruit_SPIDevice *spi_dev = (Adafruit_SPIDevice *)intf_ptr; Adafruit_SPIDevice* spi_dev = (Adafruit_SPIDevice*)intf_ptr;
// Set read bit for SPI // Set read bit for SPI
reg_addr |= 0x80; 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 @return 0 on success, negative on error
*/ */
/**************************************************************************/ /**************************************************************************/
int8_t Adafruit_BMP5xx::spi_write(uint8_t reg_addr, const uint8_t *reg_data, int8_t Adafruit_BMP5xx::spi_write(uint8_t reg_addr, const uint8_t* reg_data,
uint32_t len, void *intf_ptr) { uint32_t len, void* intf_ptr) {
Adafruit_SPIDevice *spi_dev = (Adafruit_SPIDevice *)intf_ptr; Adafruit_SPIDevice* spi_dev = (Adafruit_SPIDevice*)intf_ptr;
// Create buffer with register address + data // Create buffer with register address + data
uint8_t buffer[len + 1]; 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) @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 (void)intf_ptr; // Unused parameter
delayMicroseconds(us); 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 * @param event Sensor event object that will be populated
* @returns True * @returns True
*/ */
bool Adafruit_BMP5xx_Temp::getEvent(sensors_event_t *event) { bool Adafruit_BMP5xx_Temp::getEvent(sensors_event_t* event) {
_theBMP5xx->readTemperature(); _theBMP5xx->readTemperature();
event->version = sizeof(sensors_event_t); 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 * @brief Gets the sensor_t device data
* @param sensor Sensor description that will be populated * @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)); memset(sensor, 0, sizeof(sensor_t));
strncpy(sensor->name, "BMP5xx", sizeof(sensor->name) - 1); strncpy(sensor->name, "BMP5xx", sizeof(sensor->name) - 1);
sensor->name[sizeof(sensor->name) - 1] = 0; 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 * @param event Sensor event object that will be populated
* @returns True * @returns True
*/ */
bool Adafruit_BMP5xx_Pressure::getEvent(sensors_event_t *event) { bool Adafruit_BMP5xx_Pressure::getEvent(sensors_event_t* event) {
_theBMP5xx->readPressure(); _theBMP5xx->readPressure();
event->version = sizeof(sensors_event_t); 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 * @brief Gets the sensor_t device data
* @param sensor Sensor description that will be populated * @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)); memset(sensor, 0, sizeof(sensor_t));
strncpy(sensor->name, "BMP5xx", sizeof(sensor->name) - 1); strncpy(sensor->name, "BMP5xx", sizeof(sensor->name) - 1);
sensor->name[sizeof(sensor->name) - 1] = 0; sensor->name[sizeof(sensor->name) - 1] = 0;

View file

@ -18,12 +18,13 @@
#ifndef ADAFRUIT_BMP5XX_H #ifndef ADAFRUIT_BMP5XX_H
#define ADAFRUIT_BMP5XX_H #define ADAFRUIT_BMP5XX_H
#include "Arduino.h"
#include <Adafruit_I2CDevice.h> #include <Adafruit_I2CDevice.h>
#include <Adafruit_SPIDevice.h> #include <Adafruit_SPIDevice.h>
#include <Adafruit_Sensor.h> #include <Adafruit_Sensor.h>
#include <Wire.h> #include <Wire.h>
#include "Arduino.h"
extern "C" { extern "C" {
#include "bmp5.h" #include "bmp5.h"
} }
@ -117,8 +118,10 @@ typedef enum {
BMP5XX_POWERMODE_NORMAL = BMP5_POWERMODE_NORMAL, ///< Normal mode BMP5XX_POWERMODE_NORMAL = BMP5_POWERMODE_NORMAL, ///< Normal mode
BMP5XX_POWERMODE_FORCED = BMP5_POWERMODE_FORCED, ///< Forced mode BMP5XX_POWERMODE_FORCED = BMP5_POWERMODE_FORCED, ///< Forced mode
BMP5XX_POWERMODE_CONTINUOUS = BMP5_POWERMODE_CONTINOUS, ///< Continuous mode BMP5XX_POWERMODE_CONTINUOUS = BMP5_POWERMODE_CONTINOUS, ///< Continuous mode
BMP5XX_POWERMODE_CONTINOUS = BMP5_POWERMODE_CONTINOUS, ///< @deprecated Use BMP5XX_POWERMODE_CONTINUOUS BMP5XX_POWERMODE_CONTINOUS =
BMP5XX_POWERMODE_DEEP_STANDBY = BMP5_POWERMODE_DEEP_STANDBY, ///< Deep standby mode BMP5_POWERMODE_CONTINOUS, ///< @deprecated Use BMP5XX_POWERMODE_CONTINUOUS
BMP5XX_POWERMODE_DEEP_STANDBY =
BMP5_POWERMODE_DEEP_STANDBY, ///< Deep standby mode
} bmp5xx_powermode_t; } bmp5xx_powermode_t;
/** /**
@ -152,60 +155,64 @@ typedef enum {
BMP5XX_INTERRUPT_DATA_READY = 0x01, ///< Data ready interrupt BMP5XX_INTERRUPT_DATA_READY = 0x01, ///< Data ready interrupt
BMP5XX_INTERRUPT_FIFO_FULL = 0x02, ///< FIFO full interrupt BMP5XX_INTERRUPT_FIFO_FULL = 0x02, ///< FIFO full interrupt
BMP5XX_INTERRUPT_FIFO_THRESHOLD = 0x04, ///< FIFO threshold 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; } bmp5xx_interrupt_source_t;
/** /**
* @brief Adafruit Unified Sensor interface for temperature component of BMP5xx * @brief Adafruit Unified Sensor interface for temperature component of BMP5xx
*/ */
class Adafruit_BMP5xx_Temp : public Adafruit_Sensor { class Adafruit_BMP5xx_Temp : public Adafruit_Sensor {
public: public:
/** /**
* @brief Construct a new Adafruit_BMP5xx_Temp object * @brief Construct a new Adafruit_BMP5xx_Temp object
* *
* @param parent A pointer to the BMP5xx class * @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); bool getEvent(sensors_event_t* event);
void getSensor(sensor_t *sensor); void getSensor(sensor_t* sensor);
private: private:
int _sensorID = 0x580; /**< ID number for temperature sensor */ 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 * @brief Adafruit Unified Sensor interface for pressure component of BMP5xx
*/ */
class Adafruit_BMP5xx_Pressure : public Adafruit_Sensor { class Adafruit_BMP5xx_Pressure : public Adafruit_Sensor {
public: public:
/** /**
* @brief Construct a new Adafruit_BMP5xx_Pressure object * @brief Construct a new Adafruit_BMP5xx_Pressure object
* *
* @param parent A pointer to the BMP5xx class * @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); bool getEvent(sensors_event_t* event);
void getSensor(sensor_t *sensor); void getSensor(sensor_t* sensor);
private: private:
int _sensorID = 0x581; /**< ID number for pressure sensor */ 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. * Driver for the Adafruit BMP5xx barometric pressure sensor.
*/ */
class Adafruit_BMP5xx { class Adafruit_BMP5xx {
public: public:
Adafruit_BMP5xx(); Adafruit_BMP5xx();
~Adafruit_BMP5xx(void); ~Adafruit_BMP5xx(void);
bool begin(uint8_t addr = BMP5XX_DEFAULT_ADDRESS, TwoWire *theWire = &Wire); bool begin(uint8_t addr = BMP5XX_DEFAULT_ADDRESS, TwoWire* theWire = &Wire);
bool begin(int8_t cspin, SPIClass *theSPI = &SPI); bool begin(int8_t cspin, SPIClass* theSPI = &SPI);
float readTemperature(void); float readTemperature(void);
float readPressure(void); float readPressure(void);
@ -225,8 +232,8 @@ public:
bmp5xx_odr_t getOutputDataRate(void); bmp5xx_odr_t getOutputDataRate(void);
bmp5xx_powermode_t getPowerMode(void); bmp5xx_powermode_t getPowerMode(void);
Adafruit_Sensor *getTemperatureSensor(void); Adafruit_Sensor* getTemperatureSensor(void);
Adafruit_Sensor *getPressureSensor(void); Adafruit_Sensor* getPressureSensor(void);
bool enablePressure(bool enable = true); bool enablePressure(bool enable = true);
bool dataReady(void); bool dataReady(void);
@ -242,7 +249,7 @@ public:
/**! Pressure (hPa) assigned after calling performReading() */ /**! Pressure (hPa) assigned after calling performReading() */
float pressure; float pressure;
private: private:
bool _init(void); bool _init(void);
/**! BMP5xx device struct from Bosch API */ /**! BMP5xx device struct from Bosch API */
@ -255,25 +262,25 @@ private:
struct bmp5_iir_config _iir_config; struct bmp5_iir_config _iir_config;
/**! I2C interface object */ /**! I2C interface object */
Adafruit_I2CDevice *_i2c_dev = NULL; Adafruit_I2CDevice* _i2c_dev = NULL;
/**! SPI interface object */ /**! SPI interface object */
Adafruit_SPIDevice *_spi_dev = NULL; Adafruit_SPIDevice* _spi_dev = NULL;
/**! Adafruit unified sensor interface for temperature */ /**! 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 unified sensor interface for pressure */
Adafruit_BMP5xx_Pressure *_pressure_sensor = NULL; Adafruit_BMP5xx_Pressure* _pressure_sensor = NULL;
// Static callback functions for Bosch API // Static callback functions for Bosch API
static int8_t i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, static int8_t i2c_read(uint8_t reg_addr, uint8_t* reg_data, uint32_t len,
void *intf_ptr); void* intf_ptr);
static int8_t i2c_write(uint8_t reg_addr, const uint8_t *reg_data, static int8_t i2c_write(uint8_t reg_addr, const uint8_t* reg_data,
uint32_t len, void *intf_ptr); uint32_t len, void* intf_ptr);
static int8_t spi_read(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, static int8_t spi_read(uint8_t reg_addr, uint8_t* reg_data, uint32_t len,
void *intf_ptr); void* intf_ptr);
static int8_t spi_write(uint8_t reg_addr, const uint8_t *reg_data, static int8_t spi_write(uint8_t reg_addr, const uint8_t* reg_data,
uint32_t len, void *intf_ptr); uint32_t len, void* intf_ptr);
static void delay_usec(uint32_t us, void *intf_ptr); static void delay_usec(uint32_t us, void* intf_ptr);
}; };
#endif // ADAFRUIT_BMP5XX_H #endif // ADAFRUIT_BMP5XX_H

View file

@ -1,40 +1,40 @@
/** /**
* Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. * Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved.
* *
* BSD-3-Clause * BSD-3-Clause
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* 3. Neither the name of the copyright holder nor the names of its * 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from * contributors may be used to endorse or promote products derived from
* this software without specific prior written permission. * this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @file bmp5.h * @file bmp5.h
* @date 2021-08-27 * @date 2021-08-27
* @version v1.0.5 * @version v1.0.5
* *
*/ */
/*! /*!
* @defgroup bmp5 BMP5 * @defgroup bmp5 BMP5
@ -72,9 +72,9 @@ extern "C" {
* \code * \code
* int8_t bmp5_init(struct bmp5_dev *dev); * int8_t bmp5_init(struct bmp5_dev *dev);
* \endcode * \endcode
* @details This API is the entry point. Call this API before using all other APIs. * @details This API is the entry point. Call this API before using all other
* This API reads the chip-id of the sensor and sets the resolution, feature * APIs. This API reads the chip-id of the sensor and sets the resolution,
* length and the type of variant. * feature length and the type of variant.
* *
* @param[in,out] dev : Structure instance of bmp5_dev. * @param[in,out] dev : Structure instance of bmp5_dev.
* *
@ -83,7 +83,7 @@ extern "C" {
* @return < 0 -> Fail * @return < 0 -> Fail
* *
*/ */
int8_t bmp5_init(struct bmp5_dev *dev); int8_t bmp5_init(struct bmp5_dev* dev);
/** /**
* \ingroup bmp5 * \ingroup bmp5
@ -95,8 +95,8 @@ int8_t bmp5_init(struct bmp5_dev *dev);
* \ingroup bmp5ApiRegister * \ingroup bmp5ApiRegister
* \page bmp5_api_bmp5_get_regs bmp5_get_regs * \page bmp5_api_bmp5_get_regs bmp5_get_regs
* \code * \code
* 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
* \endcode * bmp5_dev *dev); \endcode
* @details This API reads the data from the given register address of sensor. * @details This API reads the data from the given register address of sensor.
* *
* @param[in] reg_addr : Register address from where the data to be read. * @param[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 -> Success
* @return < 0 -> Fail * @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 * \ingroup bmp5ApiRegister
* \page bmp5_api_bmp5_set_regs bmp5_set_regs * \page bmp5_api_bmp5_set_regs bmp5_set_regs
* \code * \code
* 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,
* \endcode * struct bmp5_dev *dev); \endcode
* @details This API writes the given data to the register address of sensor. * @details This API writes the given data to the register address of sensor.
* *
* @param[in] reg_addr : Register address where the data is to be written. * @param[in] 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 -> Success
* @return < 0 -> Fail * @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 * \ingroup bmp5
@ -142,7 +144,8 @@ int8_t bmp5_set_regs(uint8_t reg_addr, const uint8_t *data, uint32_t len, struct
* \code * \code
* int8_t bmp5_soft_reset(struct bmp5_dev *dev); * int8_t bmp5_soft_reset(struct bmp5_dev *dev);
* \endcode * \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 * @note If this register is set using I2C, an ACK will NOT be transmitted to
* the host. * 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 -> Success
* @return < 0 -> Fail * @return < 0 -> Fail
*/ */
int8_t bmp5_soft_reset(struct bmp5_dev *dev); int8_t bmp5_soft_reset(struct bmp5_dev* dev);
/** /**
* \ingroup bmp5 * \ingroup bmp5
@ -167,8 +170,9 @@ int8_t bmp5_soft_reset(struct bmp5_dev *dev);
* \code * \code
* 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);
* \endcode * \endcode
* @details This API is used to get the interrupt status (data ready interrupt, fifo full interrupt, * @details This API is used to get the interrupt status (data ready interrupt,
* fifo threshold interrupt, pressure out of range interrupt and power-on reset/software reset complete 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[out] int_status : Variable to store interrupt status.
* @param[in] dev : Structure instance of bmp5_dev. * @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_DRDY | Data ready interrupt asserted
* BMP5_INT_ASSERTED_FIFO_FULL | Fifo full interrupt asserted * BMP5_INT_ASSERTED_FIFO_FULL | Fifo full interrupt asserted
* BMP5_INT_ASSERTED_FIFO_THRES | Fifo threshold 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_PRESSURE_OOR | Pressure out of range interrupt
* BMP5_INT_ASSERTED_POR_SOFTRESET_COMPLETE | Power-on reset/Software reset complete interrupt asserted *asserted BMP5_INT_ASSERTED_POR_SOFTRESET_COMPLETE | Power-on reset/Software
*reset complete interrupt asserted
*@endverbatim *@endverbatim
* *
* @return Result of API execution status. * @return Result of API execution status.
* @return 0 -> Success * @return 0 -> Success
* @return < 0 -> Fail * @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 * \ingroup bmp5
@ -201,8 +206,8 @@ int8_t bmp5_get_interrupt_status(uint8_t *int_status, struct bmp5_dev *dev);
* \ingroup bmp5ApiPowermode * \ingroup bmp5ApiPowermode
* \page bmp5_api_bmp5_set_power_mode bmp5_set_power_mode * \page bmp5_api_bmp5_set_power_mode bmp5_set_power_mode
* \code * \code
* 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
* \endcode **dev); \endcode
* @details This API sets the power mode of the sensor. * @details This API sets the power mode of the sensor.
* *
* @param[in] powermode : Select powermode. * @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 -> Success
* @return < 0 -> Fail * @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 * \ingroup bmp5ApiPowermode
* \page bmp5_api_bmp5_get_power_mode bmp5_get_power_mode * \page bmp5_api_bmp5_get_power_mode bmp5_get_power_mode
* \code * \code
* 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
* \endcode **dev); \endcode
* @details This API gets the power mode of the sensor. * @details This API gets the power mode of the sensor.
* *
* @param[out] powermode : To store the power mode. * @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 -> Success
* @return < 0 -> Fail * @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 * \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 * \page bmp5_api_bmp5_get_sensor_data bmp5_get_sensor_data
* \code * \code
* 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); * const struct bmp5_osr_odr_press_config
* \endcode * *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 * @details This API reads the temperature(deg C) or both pressure(Pa) and
* sensor and store it in the bmp5_sensor_data structure instance passed by the user. * 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[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. * @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 * @note If fixed point(BMP5_USE_FIXED_POINT) is selected then data return type
* and int64_t for temperature. While for floating point(BMP5_USE_FLOATING_POINT) data return type is float for * is uin64_t for pressure and int64_t for temperature. While for floating
* pressure and temperature. * point(BMP5_USE_FLOATING_POINT) data return type is float for pressure and
* temperature.
* *
* @return Result of API execution status. * @return Result of API execution status.
* @return 0 -> Success * @return 0 -> Success
* @return < 0 -> Fail * @return < 0 -> Fail
*/ */
int8_t bmp5_get_sensor_data(struct bmp5_sensor_data *sensor_data, int8_t bmp5_get_sensor_data(
const struct bmp5_osr_odr_press_config *osr_odr_press_cfg, struct bmp5_sensor_data* sensor_data,
struct bmp5_dev *dev); const struct bmp5_osr_odr_press_config* osr_odr_press_cfg,
struct bmp5_dev* dev);
/** /**
* \ingroup bmp5 * \ingroup bmp5
@ -297,10 +307,10 @@ int8_t bmp5_get_sensor_data(struct bmp5_sensor_data *sensor_data,
* \ingroup bmp5ApiInterrupt * \ingroup bmp5ApiInterrupt
* \page bmp5_api_bmp5_int_source_select bmp5_int_source_select * \page bmp5_api_bmp5_int_source_select bmp5_int_source_select
* \code * \code
* 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
* \endcode * *int_source_select, struct bmp5_dev *dev); \endcode
* @details This API is used to enable the interrupts(drdy interrupt, fifo full interrupt, * @details This API is used to enable the interrupts(drdy interrupt, fifo full
* fifo threshold enable and pressure data out of range interrupt). * interrupt, fifo threshold enable and pressure data out of range interrupt).
* *
* @param[in] int_source_select : Structure instance of bmp5_int_enable. * @param[in] int_source_select : Structure instance of bmp5_int_enable.
* @param[in] dev : Structure instance of bmp5_dev. * @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 -> Success
* @return < 0 -> Fail * @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 * \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_polarity int_pol,
enum bmp5_intr_drive int_od, enum bmp5_intr_drive int_od,
enum bmp5_intr_en_dis int_en, enum bmp5_intr_en_dis int_en,
struct bmp5_dev *dev); struct bmp5_dev* dev);
/** /**
* \ingroup bmp5 * \ingroup bmp5
@ -349,47 +361,54 @@ int8_t bmp5_configure_interrupt(enum bmp5_intr_mode int_mode,
* \ingroup bmp5ApiSettings * \ingroup bmp5ApiSettings
* \page bmp5_api_bmp5_get_osr_odr_press_config bmp5_get_osr_odr_press_config * \page bmp5_api_bmp5_get_osr_odr_press_config bmp5_get_osr_odr_press_config
* \code * \code
* 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
* \endcode * *osr_odr_press_cfg, struct bmp5_dev *dev); \endcode
* @details This API gets the configuration for oversampling of temperature, oversampling of * @details This API gets the configuration for oversampling of temperature,
* pressure and ODR configuration for normal mode along with pressure enable. * 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. * @param[in] dev : Structure instance of bmp5_dev.
* *
* @return Result of API execution status. * @return Result of API execution status.
* @return 0 -> Success * @return 0 -> Success
* @return < 0 -> Fail * @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 * \ingroup bmp5ApiSettings
* \page bmp5_api_bmp5_set_osr_odr_press_config bmp5_set_osr_odr_press_config * \page bmp5_api_bmp5_set_osr_odr_press_config bmp5_set_osr_odr_press_config
* \code * \code
* 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
* \endcode * *osr_odr_press_cfg, struct bmp5_dev *dev); \endcode
* @details This API sets the configuration for oversampling of temperature, oversampling of * @details This API sets the configuration for oversampling of temperature,
* pressure and ODR configuration along with pressure enable. * 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. * @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 * @note If ODR is set to a value higher than 5Hz then powermode is set as
* without disabling deep-standby mode makes powermode invalid. * standby mode, as ODR value greater than 5HZ without disabling deep-standby
* mode makes powermode invalid.
* *
* @return Result of API execution status. * @return Result of API execution status.
* @return 0 -> Success * @return 0 -> Success
* @return < 0 -> Fail * @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 * \ingroup bmp5ApiSettings
* \page bmp5_api_bmp5_get_iir_config bmp5_get_iir_config * \page bmp5_api_bmp5_get_iir_config bmp5_get_iir_config
* \code * \code
* 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
* \endcode * *dev); \endcode
* @details This API gets the configuration for IIR of temperature and pressure. * @details This API gets the configuration for IIR of temperature and pressure.
* *
* @param[out] iir_cfg : Structure instance of bmp5_iir_config. * @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 -> Success
* @return < 0 -> Fail * @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 * \ingroup bmp5ApiSettings
* \page bmp5_api_bmp5_set_iir_config bmp5_set_iir_config * \page bmp5_api_bmp5_set_iir_config bmp5_set_iir_config
* \code * \code
* 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
* \endcode * bmp5_dev *dev); \endcode
* @details This API sets the configuration for IIR of temperature and pressure. * @details This API sets the configuration for IIR of temperature and pressure.
* *
* @note * @note
* 1. The IIR configuration can be performed only in standby mode. So in this API before updating IIR * 1. The IIR configuration can be performed only in standby mode. So in this
* configuration powermode is switched to standby mode and reverted back to earlier powermode after * API before updating IIR configuration powermode is switched to standby mode
* IIR configuration is updated. * 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 * 2. If IIR value for both temperature and pressure is set a value other than
* as standby mode, as IIR with value other than bypass without disabling deep-standby mode makes powermode invalid. * 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] iir_cfg : Structure instance of bmp5_iir_config.
* @param[in] dev : Structure instance of bmp5_dev. * @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 -> Success
* @return < 0 -> Fail * @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 * \ingroup bmp5ApiSettings
* \page bmp5_api_bmp5_get_osr_odr_eff bmp5_get_osr_odr_eff * \page bmp5_api_bmp5_get_osr_odr_eff bmp5_get_osr_odr_eff
* \code * \code
* 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
* \endcode * bmp5_dev *dev); \endcode
* @details This API gets the configuration for effective OSR of temperature, * @details This API gets the configuration for effective OSR of temperature,
* effective OSR of pressure and ODR valid status. * 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 -> Success
* @return < 0 -> Fail * @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 * \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 * \ingroup bmp5ApiFIFO
* \page bmp5_api_bmp5_get_fifo_configuration bmp5_get_fifo_configuration * \page bmp5_api_bmp5_get_fifo_configuration bmp5_get_fifo_configuration
* \code * \code
* 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
* \endcode * *dev); \endcode
* @details This API used to get the configurations of fifo from the sensor. * @details This API used to get the configurations of fifo from the sensor.
* *
* @param[out] fifo : Structure instance of bmp5_fifo. * @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 -> Success
* @return < 0 -> Fail * @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 * \ingroup bmp5ApiFIFO
* \page bmp5_api_bmp5_set_fifo_configuration bmp5_set_fifo_configuration * \page bmp5_api_bmp5_set_fifo_configuration bmp5_set_fifo_configuration
* \code * \code
* 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
* \endcode * bmp5_dev *dev); \endcode
* @details This API used to set the configurations of fifo in the sensor. * @details This API used to set the configurations of fifo in the sensor.
* *
* @param[in] fifo : Structure instance of bmp5_fifo. * @param[in] fifo : Structure instance of bmp5_fifo.
* @param[in] dev : Structure instance of bmp5_dev. * @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 * @note If Fifo frame selection is enabled then powermode is set as standby
* enabled without disabling deep-standby mode makes powermode invalid. * mode, as fifo frame selection enabled without disabling deep-standby mode
* makes powermode invalid.
* *
* @return Result of API execution status. * @return Result of API execution status.
* @return 0 -> Success * @return 0 -> Success
* @return < 0 -> Fail * @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 * \ingroup bmp5ApiFIFO
* \page bmp5_api_bmp5_get_fifo_len bmp5_get_fifo_len * \page bmp5_api_bmp5_get_fifo_len bmp5_get_fifo_len
* \code * \code
* int8_t bmp5_get_fifo_len(uint8_t *fifo_len, struct bmp5_fifo *fifo, struct bmp5_dev *dev); * int8_t bmp5_get_fifo_len(uint8_t *fifo_len, struct bmp5_fifo *fifo, struct
* \endcode * bmp5_dev *dev); \endcode
* @details This API is used to get the length of fifo from the sensor. * @details This API is used to get the length of fifo from the sensor.
* *
* @param[out] fifo_len : Variable to store fifo length. * @param[out] fifo_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 -> Success
* @return < 0 -> Fail * @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 * \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 -> Success
* @return < 0 -> Fail * @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 * \ingroup bmp5ApiFIFO
* \page bmp5_api_bmp5_extract_fifo_data bmp5_extract_fifo_data * \page bmp5_api_bmp5_extract_fifo_data bmp5_extract_fifo_data
* \code * \code
* 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
* \endcode * bmp5_sensor_data *sensor_data); \endcode
* @details This API extract the temperature and/or pressure data from the fifo data which is * @details This API extract the temperature and/or pressure data from the fifo
* already read from the fifo. * data which is already read from the fifo.
* *
* @param[in] fifo : Structure instance of bmp5_fifo. * @param[in] fifo : Structure instance of bmp5_fifo.
* @param[out] sensor_data : Structure instance of bmp5_sensor_data. * @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 -> Success
* @return < 0 -> Fail * @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 * \ingroup bmp5
@ -550,37 +578,43 @@ int8_t bmp5_extract_fifo_data(const struct bmp5_fifo *fifo, struct bmp5_sensor_d
* \ingroup bmp5ApiOOR * \ingroup bmp5ApiOOR
* \page bmp5_api_bmp5_get_oor_configuration bmp5_get_oor_configuration * \page bmp5_api_bmp5_get_oor_configuration bmp5_get_oor_configuration
* \code * \code
* 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
* \endcode * *oor_press_config, struct bmp5_dev *dev); \endcode
* @details This API gets the configuration for out-of-range pressure threshold, range * @details This API gets the configuration for out-of-range pressure threshold,
* count limit and IIR. * 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. * @param[in] dev : Structure instance of bmp5_dev.
* *
* @return Result of API execution status. * @return Result of API execution status.
* @return 0 -> Success * @return 0 -> Success
* @return < 0 -> Fail * @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 * \ingroup bmp5ApiOOR
* \page bmp5_api_bmp5_set_oor_configuration bmp5_set_oor_configuration * \page bmp5_api_bmp5_set_oor_configuration bmp5_set_oor_configuration
* \code * \code
* 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
* \endcode * *oor_press_config, struct bmp5_dev *dev); \endcode
* @details This API sets the configuration for out-of-range pressure threshold, range * @details This API sets the configuration for out-of-range pressure threshold,
* count limit and IIR. * 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. * @param[in] dev : Structure instance of bmp5_dev.
* *
* @return Result of API execution status. * @return Result of API execution status.
* @return 0 -> Success * @return 0 -> Success
* @return < 0 -> Fail * @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 * \ingroup bmp5
@ -592,8 +626,8 @@ int8_t bmp5_set_oor_configuration(const struct bmp5_oor_press_configuration *oor
* \ingroup bmp5ApiNVM * \ingroup bmp5ApiNVM
* \page bmp5_api_bmp5_nvm_read bmp5_nvm_read * \page bmp5_api_bmp5_nvm_read bmp5_nvm_read
* \code * \code
* 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
* \endcode * *dev); \endcode
* @details This API is used to perform NVM read. * @details This API is used to perform NVM read.
* *
* @param[in] nvm_addr : Variable that holds the nvm address. * @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 -> Success
* @return < 0 -> Fail * @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 * \ingroup bmp5ApiNVM
* \page bmp5_api_bmp5_nvm_write bmp5_nvm_write * \page bmp5_api_bmp5_nvm_write bmp5_nvm_write
* \code * \code
* 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
* \endcode * bmp5_dev *dev); \endcode
* @details This API used to perform NVM write. * @details This API used to perform NVM write.
* *
* @param[in] nvm_addr : Variable that holds the nvm address. * @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 -> Success
* @return < 0 -> Fail * @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 #ifdef __cplusplus
} }

View file

@ -1,40 +1,40 @@
/** /**
* Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved. * Copyright (c) 2021 Bosch Sensortec GmbH. All rights reserved.
* *
* BSD-3-Clause * BSD-3-Clause
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met: * modification, are permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright * 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer. * notice, this list of conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright * 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution. * documentation and/or other materials provided with the distribution.
* *
* 3. Neither the name of the copyright holder nor the names of its * 3. Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from * contributors may be used to endorse or promote products derived from
* this software without specific prior written permission. * this software without specific prior written permission.
* *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE. * POSSIBILITY OF SUCH DAMAGE.
* *
* @file bmp5_defs.h * @file bmp5_defs.h
* @date 2021-08-27 * @date 2021-08-27
* @version v1.0.5 * @version v1.0.5
* *
*/ */
/*! @file bmp5_defs.h /*! @file bmp5_defs.h
* @brief Sensor Driver for BMP5 sensor * @brief Sensor Driver for BMP5 sensor
@ -48,9 +48,9 @@
#ifdef __KERNEL__ #ifdef __KERNEL__
#include <linux/types.h> #include <linux/types.h>
#else #else
#include <stdint.h>
#include <stddef.h>
#include <math.h> #include <math.h>
#include <stddef.h>
#include <stdint.h>
#endif #endif
/******************************************************************************/ /******************************************************************************/
@ -107,23 +107,27 @@
#ifdef __cplusplus #ifdef __cplusplus
#define NULL 0 #define NULL 0
#else #else
#define NULL ((void *) 0) #define NULL ((void*)0)
#endif #endif
#endif #endif
/******************************************************************************/ /******************************************************************************/
/*! @name Compiler switch macros Definitions */ /*! @name Compiler switch macros Definitions */
/******************************************************************************/ /******************************************************************************/
#ifndef BMP5_USE_FIXED_POINT /*< Check if floating point (using BMP5_USE_FIXED_POINT) is enabled */ #ifndef BMP5_USE_FIXED_POINT /*< Check if floating point (using \
#ifndef BMP5_USE_FLOATING_POINT /*< If fixed point is not enabled then enable BMP5_USE_FLOATING_POINT */ 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 #define BMP5_USE_FLOATING_POINT
#endif #endif
#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 #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 #if BMP5_FIXED_POINT_DIGIT_PRECISION > \
* set precision value to 6 digits */ 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 #undef BMP5_FIXED_POINT_DIGIT_PRECISION
#define BMP5_FIXED_POINT_DIGIT_PRECISION UINT8_C(6) #define BMP5_FIXED_POINT_DIGIT_PRECISION UINT8_C(6)
#endif #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 #ifndef BMP5_INTF_RET_TYPE
#define BMP5_INTF_RET_TYPE int8_t #define BMP5_INTF_RET_TYPE int8_t
#endif #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 #ifndef BMP5_INTF_RET_SUCCESS
#define BMP5_INTF_RET_SUCCESS INT8_C(0) #define BMP5_INTF_RET_SUCCESS INT8_C(0)
@ -180,8 +186,7 @@
((regvar & bitname##_MSK) >> bitname##_POS) ((regvar & bitname##_MSK) >> bitname##_POS)
#define BMP5_SET_BITSLICE(regvar, bitname, val) \ #define BMP5_SET_BITSLICE(regvar, bitname, val) \
((regvar & ~bitname##_MSK) | \ ((regvar & ~bitname##_MSK) | ((val << bitname##_POS) & bitname##_MSK))
((val << bitname##_POS) & bitname##_MSK))
#define BMP5_GET_LSB(var) (uint8_t)(var & BMP5_SET_LOW_BYTE) #define BMP5_GET_LSB(var) (uint8_t)(var & BMP5_SET_LOW_BYTE)
#define BMP5_GET_MSB(var) (uint8_t)((var & BMP5_SET_HIGH_BYTE) >> 8) #define BMP5_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_BIT_VAL_0(reg_data, bitname) (reg_data & ~(bitname##_MSK))
#define BMP5_SET_BITS_POS_0(reg_data, bitname, data) \ #define BMP5_SET_BITS_POS_0(reg_data, bitname, data) \
((reg_data & ~(bitname##_MSK)) | \ ((reg_data & ~(bitname##_MSK)) | (data & bitname##_MSK))
(data & bitname##_MSK))
#define BMP5_GET_BITS_POS_0(reg_data, bitname) (reg_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[in] reg_addr : Register address from which data is read.
* @param[out] read_data : Pointer to data buffer where read data is stored. * @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] len : Number of bytes of data to be read.
* @param[in, out] intf_ptr : Void pointer that can enable the linking of descriptors * @param[in, out] intf_ptr : Void pointer that can enable the linking of
* for interface related call backs. * descriptors for interface related call backs.
* *
* @retval 0 for Success * @retval 0 for Success
* @retval Non-zero for Failure * @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 * @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 * @param[in] read_data : Pointer to data buffer in which data to be written
* is stored. * is stored.
* @param[in] len : Number of bytes of data to be written. * @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 * @param[in, out] intf_ptr : Void pointer that can enable the linking of
* for interface related call backs * descriptors for interface related call backs
* *
* @retval 0 for Success * @retval 0 for Success
* @retval Non-zero for Failure * @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, typedef BMP5_INTF_RET_TYPE (*bmp5_write_fptr_t)(uint8_t reg_addr,
void *intf_ptr); const uint8_t* read_data,
uint32_t len, void* intf_ptr);
/*! /*!
* @brief Delay function pointer which should be mapped to * @brief Delay function pointer which should be mapped to
* delay function of the user * delay function of the user
* *
* @param[in] period : Delay in microseconds. * @param[in] period : Delay in microseconds.
* @param[in, out] intf_ptr : Void pointer that can enable the linking of descriptors * @param[in, out] intf_ptr : Void pointer that can enable the linking of
* for interface related call backs * 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 */ /*! @name ENUMERATION DEFINITIONS */
@ -651,8 +658,7 @@ enum bmp5_fifo_mode {
/*! /*!
* @brief OSR, ODR and pressure configuration structure * @brief OSR, ODR and pressure configuration structure
*/ */
struct bmp5_osr_odr_press_config struct bmp5_osr_odr_press_config {
{
/*! Temperature oversampling /*! Temperature oversampling
* Assignable macros : * Assignable macros :
* - BMP5_OVERSAMPLING_1X * - BMP5_OVERSAMPLING_1X
@ -692,8 +698,7 @@ struct bmp5_osr_odr_press_config
/*! /*!
* @brief IIR configuration structure * @brief IIR configuration structure
*/ */
struct bmp5_iir_config struct bmp5_iir_config {
{
/*! Temperature IIR /*! Temperature IIR
* Assignable macros : * Assignable macros :
* - BMP5_IIR_FILTER_BYPASS * - BMP5_IIR_FILTER_BYPASS
@ -745,8 +750,7 @@ struct bmp5_iir_config
/*! /*!
* @brief Effective OSR configuration and ODR valid status structure * @brief Effective OSR configuration and ODR valid status structure
*/ */
struct bmp5_osr_odr_eff struct bmp5_osr_odr_eff {
{
/*! Effective temperature OSR */ /*! Effective temperature OSR */
uint8_t osr_t_eff; uint8_t osr_t_eff;
@ -760,8 +764,7 @@ struct bmp5_osr_odr_eff
/*! /*!
* @brief BMP5 interrupt source selection. * @brief BMP5 interrupt source selection.
*/ */
struct bmp5_int_source_select struct bmp5_int_source_select {
{
/*! Data ready interrupt enable /*! Data ready interrupt enable
* BMP5_ENABLE = Enables data ready interrupt * BMP5_ENABLE = Enables data ready interrupt
* BMP5_DISABLE = Disables data ready interrupt * BMP5_DISABLE = Disables data ready interrupt
@ -790,10 +793,9 @@ struct bmp5_int_source_select
/*! /*!
* @brief BMP5 fifo configurations. * @brief BMP5 fifo configurations.
*/ */
struct bmp5_fifo struct bmp5_fifo {
{
/*! Pointer to fifo data */ /*! Pointer to fifo data */
uint8_t *data; uint8_t* data;
/*! Length of user defined bytes of fifo to be read */ /*! Length of user defined bytes of fifo to be read */
uint16_t length; uint16_t length;
@ -851,8 +853,7 @@ struct bmp5_fifo
/*! /*!
* @brief BMP5 Out-of-range pressure configuration. * @brief BMP5 Out-of-range pressure configuration.
*/ */
struct bmp5_oor_press_configuration struct bmp5_oor_press_configuration {
{
/*! Out-of-range pressure threshold */ /*! Out-of-range pressure threshold */
uint32_t oor_thr_p; 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 #ifdef BMP5_USE_FIXED_POINT
/*! /*!
* @brief BMP5 sensor data structure which comprises of temperature and pressure in fixed point with data type as * @brief BMP5 sensor data structure which comprises of temperature and pressure
* uint64_t for pressure and int64_t for temperature. * 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 */ /*! Pressure data */
uint64_t pressure; uint64_t pressure;
@ -900,11 +902,10 @@ struct bmp5_sensor_data
#else #else
/*! /*!
* @brief BMP5 sensor data structure which comprises of temperature and pressure in floating point with data type as * @brief BMP5 sensor data structure which comprises of temperature and pressure
* float for pressure and temperature. * in floating point with data type as float for pressure and temperature.
*/ */
struct bmp5_sensor_data struct bmp5_sensor_data {
{
/*! Pressure data */ /*! Pressure data */
float pressure; float pressure;
@ -917,8 +918,7 @@ struct bmp5_sensor_data
/*! /*!
* @brief API device structure * @brief API device structure
*/ */
struct bmp5_dev struct bmp5_dev {
{
/*! Chip ID */ /*! Chip ID */
uint8_t chip_id; uint8_t chip_id;
@ -928,7 +928,7 @@ struct bmp5_dev
* implementation of the read and write interfaces to the * implementation of the read and write interfaces to the
* hardware. * hardware.
*/ */
void *intf_ptr; void* intf_ptr;
/*! Read function pointer */ /*! Read function pointer */
bmp5_read_fptr_t read; bmp5_read_fptr_t read;