Da Vinci Firmware 1
Firmware for the DaVinci-M rocket avionics board.
Loading...
Searching...
No Matches
bmp3.c File Reference

Sensor driver for BMP3 sensor. More...

#include "bmp3.h"
Include dependency graph for bmp3.c:

Go to the source code of this file.

Functions

static int8_t get_calib_data (struct bmp3_dev *dev)
 This internal API reads the calibration data from the sensor, parse it then compensates it and store in the device structure.
 
static void parse_calib_data (const uint8_t *reg_data, struct bmp3_dev *dev)
 This internal API is used to parse the calibration data, compensates it and store it in device structure.
 
static int8_t get_odr_filter_settings (struct bmp3_settings *settings, struct bmp3_dev *dev)
 This internal API gets the over sampling, ODR and filter settings from the sensor.
 
static void parse_sensor_data (const uint8_t *reg_data, struct bmp3_uncomp_data *uncomp_data)
 This internal API is used to parse the pressure and temperature data and store it in the bmp3_uncomp_data structure instance.
 
static int8_t compensate_data (uint8_t sensor_comp, const struct bmp3_uncomp_data *uncomp_data, struct bmp3_data *comp_data, struct bmp3_calib_data *calib_data)
 This internal API is used to compensate the pressure or temperature or both the data according to the component selected by the user.
 
static int8_t compensate_temperature (int64_t *temperature, const struct bmp3_uncomp_data *uncomp_data, struct bmp3_calib_data *calib_data)
 This internal API is used to compensate the raw temperature data and return the compensated temperature data in integer data type.
 
static int8_t compensate_pressure (uint64_t *pressure, const struct bmp3_uncomp_data *uncomp_data, const struct bmp3_calib_data *calib_data)
 This internal API is used to compensate the pressure data and return the compensated pressure data in integer data type.
 
static uint32_t pow_bmp3 (uint8_t base, uint8_t power)
 This internal API is used to calculate the power functionality.
 
static uint8_t are_settings_changed (uint32_t sub_settings, uint32_t settings)
 This internal API is used to identify the settings which the user wants to modify in the sensor.
 
static void interleave_reg_addr (const uint8_t *reg_addr, uint8_t *temp_buff, const uint8_t *reg_data, uint32_t len)
 This internal API interleaves the register address between the register data buffer for burst write operation.
 
static int8_t set_pwr_ctrl_settings (uint32_t desired_settings, const struct bmp3_settings *settings, struct bmp3_dev *dev)
 This internal API sets the pressure enable and temperature enable settings of the sensor.
 
static int8_t set_odr_filter_settings (uint32_t desired_settings, struct bmp3_settings *settings, struct bmp3_dev *dev)
 This internal API sets the over sampling, ODR and filter settings of the sensor based on the settings selected by the user.
 
static int8_t set_int_ctrl_settings (uint32_t desired_settings, const struct bmp3_settings *settings, struct bmp3_dev *dev)
 This internal API sets the interrupt control (output mode, level, latch and data ready) settings of the sensor based on the settings selected by the user.
 
static int8_t set_advance_settings (uint32_t desired_settings, const struct bmp3_settings *settings, struct bmp3_dev *dev)
 This internal API sets the advance (i2c_wdt_en, i2c_wdt_sel) settings of the sensor based on the settings selected by the user.
 
static void fill_osr_data (uint32_t desired_settings, uint8_t *addr, uint8_t *reg_data, uint8_t *len, const struct bmp3_settings *settings)
 This internal API fills the register address and register data of the the over sampling settings for burst write operation.
 
static void fill_odr_data (uint8_t *addr, uint8_t *reg_data, uint8_t *len, struct bmp3_settings *settings)
 This internal API fills the register address and register data of the the ODR settings for burst write operation.
 
static void fill_filter_data (uint8_t *addr, uint8_t *reg_data, uint8_t *len, const struct bmp3_settings *settings)
 This internal API fills the register address and register data of the the filter settings for burst write operation.
 
static int8_t null_ptr_check (const struct bmp3_dev *dev)
 This internal API is used to validate the device pointer for null conditions.
 
static void parse_sett_data (const uint8_t *reg_data, struct bmp3_settings *settings)
 This internal API parse the power control(power mode, pressure enable and temperature enable), over sampling, ODR, filter and interrupt control settings and store in the device structure.
 
static void parse_pwr_ctrl_settings (const uint8_t *reg_data, struct bmp3_settings *settings)
 This internal API parse the power control(power mode, pressure enable and temperature enable) settings and store in the device structure.
 
static void parse_odr_filter_settings (const uint8_t *reg_data, struct bmp3_odr_filter_settings *settings)
 This internal API parse the over sampling, ODR and filter settings and store in the device structure.
 
static void parse_int_ctrl_settings (const uint8_t *reg_data, struct bmp3_int_ctrl_settings *settings)
 This internal API parse the interrupt control(output mode, level, latch and data ready) settings and store in the device structure.
 
static void parse_advance_settings (const uint8_t *reg_data, struct bmp3_adv_settings *settings)
 This internal API parse the advance (i2c_wdt_en, i2c_wdt_sel) settings and store in the device structure.
 
static int8_t validate_normal_mode_settings (struct bmp3_settings *settings, struct bmp3_dev *dev)
 This internal API validate the normal mode settings of the sensor.
 
static int8_t validate_osr_and_odr_settings (const struct bmp3_settings *settings)
 This internal API validate the over sampling, ODR settings of the sensor.
 
static uint32_t calculate_press_meas_time (const struct bmp3_settings *settings)
 This internal API calculates the pressure measurement duration of the sensor.
 
static uint32_t calculate_temp_meas_time (const struct bmp3_settings *settings)
 This internal API calculates the temperature measurement duration of the sensor.
 
static int8_t verify_meas_time_and_odr_duration (uint32_t meas_t, uint32_t odr_duration)
 This internal API checks whether the measurement time and ODR duration of the sensor are proper.
 
static int8_t put_device_to_sleep (struct bmp3_dev *dev)
 This internal API puts the device to sleep mode.
 
static int8_t set_normal_mode (struct bmp3_settings *settings, struct bmp3_dev *dev)
 This internal API sets the normal mode in the sensor.
 
static int8_t write_power_mode (const struct bmp3_settings *settings, struct bmp3_dev *dev)
 This internal API writes the power mode in the sensor.
 
static int8_t get_sensor_status (struct bmp3_status *status, struct bmp3_dev *dev)
 This internal API fills the fifo_config_1(fifo_mode, fifo_stop_on_full, fifo_time_en, fifo_press_en, fifo_temp_en) settings in the reg_data variable so as to burst write in the sensor.
 
static int8_t get_int_status (struct bmp3_status *status, struct bmp3_dev *dev)
 This API gets the interrupt (fifo watermark, fifo full, data ready) status from the sensor.
 
static int8_t get_err_status (struct bmp3_status *status, struct bmp3_dev *dev)
 This API gets the fatal, command and configuration error from the sensor.
 
int8_t bmp3_init (struct bmp3_dev *dev)
 This internal API converts the no. of frames required by the user to bytes so as to write in the watermark length register.
 
int8_t bmp3_get_regs (uint8_t reg_addr, uint8_t *reg_data, uint32_t len, struct bmp3_dev *dev)
 This API reads the data from the given register address of the sensor.
 
int8_t bmp3_set_regs (uint8_t *reg_addr, const uint8_t *reg_data, uint32_t len, struct bmp3_dev *dev)
 This API writes the given data to the register address of the sensor.
 
int8_t bmp3_set_sensor_settings (uint32_t desired_settings, struct bmp3_settings *settings, struct bmp3_dev *dev)
 This API sets the power control(pressure enable and temperature enable), over sampling, ODR and filter settings in the sensor.
 
int8_t bmp3_get_sensor_settings (struct bmp3_settings *settings, struct bmp3_dev *dev)
 This API gets the power control(power mode, pressure enable and temperature enable), over sampling, ODR, filter, interrupt control and advance settings from the sensor.
 
int8_t bmp3_get_status (struct bmp3_status *status, struct bmp3_dev *dev)
 This API sets the fifo_config_1(fifo_mode, fifo_stop_on_full, fifo_time_en, fifo_press_en, fifo_temp_en), fifo_config_2(fifo_subsampling, data_select) and int_ctrl(fwtm_en, ffull_en) settings in the sensor.
 
int8_t bmp3_get_fifo_length (uint16_t *fifo_length, struct bmp3_dev *dev)
 This API gets the fifo length from the sensor.
 
int8_t bmp3_soft_reset (struct bmp3_dev *dev)
 This API performs the soft reset of the sensor.
 
int8_t bmp3_fifo_flush (struct bmp3_dev *dev)
 This API performs the soft reset of the sensor.
 
int8_t bmp3_set_op_mode (struct bmp3_settings *settings, struct bmp3_dev *dev)
 This API sets the power mode of the sensor.
 
int8_t bmp3_get_op_mode (uint8_t *op_mode, struct bmp3_dev *dev)
 This API gets the power mode of the sensor.
 
int8_t bmp3_get_sensor_data (uint8_t sensor_comp, struct bmp3_data *comp_data, struct bmp3_dev *dev)
 This API reads the pressure, temperature or both data from the sensor, compensates the data and store it in the bmp3_data structure instance passed by the user.
 

Detailed Description

Sensor driver for BMP3 sensor.

Copyright (c) 2022 Bosch Sensortec GmbH. All rights reserved.

BSD-3-Clause

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Date
2022-04-01
Version
v2.0.6

Definition in file bmp3.c.

Function Documentation

◆ are_settings_changed()

static uint8_t are_settings_changed ( uint32_t  sub_settings,
uint32_t  settings 
)
static

This internal API is used to identify the settings which the user wants to modify in the sensor.

Parameters
[in]sub_settings: Contains the settings subset to identify particular group of settings which the user is interested to change.
[in]settings: Contains the user specified settings.
Returns
Indicates whether user is interested to modify the settings which are related to sub_settings.
Return values
True-> User wants to modify this group of settings
False-> User does not want to modify this group of settings

Definition at line 2702 of file bmp3.c.

2703{
2704 uint8_t settings_changed = FALSE;
2705
2706 if (sub_settings & desired_settings)
2707 {
2708 /* User wants to modify this particular settings */
2709 settings_changed = TRUE;
2710 }
2711 else
2712 {
2713 /* User don't want to modify this particular settings */
2714 settings_changed = FALSE;
2715 }
2716
2717 return settings_changed;
2718}
#define TRUE
Definition bmp3_defs.h:93
#define FALSE
Definition bmp3_defs.h:97

References FALSE, and TRUE.

Referenced by bmp3_set_sensor_settings(), and set_odr_filter_settings().

Here is the caller graph for this function:

◆ bmp3_fifo_flush()

int8_t bmp3_fifo_flush ( struct bmp3_dev dev)

This API performs the soft reset of the sensor.

Definition at line 1307 of file bmp3.c.

1308{
1309 int8_t rslt;
1310 uint8_t reg_addr = BMP3_REG_CMD;
1311
1312 uint8_t fifo_flush_cmd = BMP3_FIFO_FLUSH;
1313 uint8_t cmd_rdy_status;
1314 uint8_t cmd_err_status;
1315
1316 /* Check for command ready status */
1317 rslt = bmp3_get_regs(BMP3_REG_SENS_STATUS, &cmd_rdy_status, 1, dev);
1318
1319 /* Device is ready to accept new command */
1320 if ((cmd_rdy_status & BMP3_CMD_RDY) && (rslt == BMP3_OK))
1321 {
1322 /* Write the soft reset command in the sensor */
1323 rslt = bmp3_set_regs(&reg_addr, &fifo_flush_cmd, 1, dev);
1324
1325 /* Proceed if everything is fine until now */
1326 if (rslt == BMP3_OK)
1327 {
1328 /* Wait for 2 ms */
1329 dev->delay_us(2000, dev->intf_ptr);
1330
1331 /* Read for command error status */
1332 rslt = bmp3_get_regs(BMP3_REG_ERR, &cmd_err_status, 1, dev);
1333
1334 /* check for command error status */
1335 if ((cmd_err_status & BMP3_REG_CMD) || (rslt != BMP3_OK))
1336 {
1337 /* Command not written hence return
1338 * error */
1340 }
1341 }
1342 }
1343
1344 return rslt;
1345}
int8_t bmp3_get_regs(uint8_t reg_addr, uint8_t *reg_data, uint32_t len, struct bmp3_dev *dev)
This API reads the data from the given register address of the sensor.
Definition bmp3.c:794
int8_t bmp3_set_regs(uint8_t *reg_addr, const uint8_t *reg_data, uint32_t len, struct bmp3_dev *dev)
This API writes the given data to the register address of the sensor.
Definition bmp3.c:844
#define BMP3_REG_CMD
Definition bmp3_defs.h:163
#define BMP3_REG_SENS_STATUS
Definition bmp3_defs.h:147
#define BMP3_CMD_RDY
Definition bmp3_defs.h:171
#define BMP3_FIFO_FLUSH
Definition bmp3_defs.h:255
#define BMP3_OK
Definition bmp3_defs.h:258
#define BMP3_REG_ERR
Definition bmp3_defs.h:146
#define BMP3_E_CMD_EXEC_FAILED
Definition bmp3_defs.h:264
bmp3_delay_us_fptr_t delay_us
Definition bmp3_defs.h:926
void * intf_ptr
Definition bmp3_defs.h:905

References BMP3_CMD_RDY, BMP3_E_CMD_EXEC_FAILED, BMP3_FIFO_FLUSH, bmp3_get_regs(), BMP3_OK, BMP3_REG_CMD, BMP3_REG_ERR, BMP3_REG_SENS_STATUS, bmp3_set_regs(), bmp3_dev::delay_us, and bmp3_dev::intf_ptr.

Here is the call graph for this function:

◆ bmp3_get_fifo_length()

int8_t bmp3_get_fifo_length ( uint16_t *  fifo_length,
struct bmp3_dev dev 
)

This API gets the fifo length from the sensor.

Definition at line 1236 of file bmp3.c.

1237{
1238 int8_t rslt;
1239 uint8_t reg_data[2];
1240
1241 if (fifo_length != NULL)
1242 {
1243 rslt = bmp3_get_regs(BMP3_REG_FIFO_LENGTH, reg_data, 2, dev);
1244
1245 /* Proceed if read from register is fine */
1246 if (rslt == BMP3_OK)
1247 {
1248 /* Update the fifo length */
1249 *fifo_length = BMP3_CONCAT_BYTES(reg_data[1], reg_data[0]);
1250 }
1251 }
1252 else
1253 {
1254 rslt = BMP3_E_NULL_PTR;
1255 }
1256
1257 return rslt;
1258}
#define NULL
Definition bmp3_defs.h:88
#define BMP3_REG_FIFO_LENGTH
Definition bmp3_defs.h:151
#define BMP3_E_NULL_PTR
Definition bmp3_defs.h:261
#define BMP3_CONCAT_BYTES(msb, lsb)
Definition bmp3_defs.h:418

References BMP3_CONCAT_BYTES, BMP3_E_NULL_PTR, bmp3_get_regs(), BMP3_OK, BMP3_REG_FIFO_LENGTH, and NULL.

Here is the call graph for this function:

◆ bmp3_get_op_mode()

int8_t bmp3_get_op_mode ( uint8_t *  op_mode,
struct bmp3_dev dev 
)

This API gets the power mode of the sensor.

Definition at line 1403 of file bmp3.c.

1404{
1405 int8_t rslt;
1406
1407 if (op_mode != NULL)
1408 {
1409 /* Read the power mode register */
1410 rslt = bmp3_get_regs(BMP3_REG_PWR_CTRL, op_mode, 1, dev);
1411
1412 /* Assign the power mode in the device structure */
1413 *op_mode = BMP3_GET_BITS(*op_mode, BMP3_OP_MODE);
1414 }
1415 else
1416 {
1417 rslt = BMP3_E_NULL_PTR;
1418 }
1419
1420 return rslt;
1421}
#define BMP3_REG_PWR_CTRL
Definition bmp3_defs.h:158
#define BMP3_GET_BITS(reg_data, bitname)
Definition bmp3_defs.h:429

References BMP3_E_NULL_PTR, BMP3_GET_BITS, bmp3_get_regs(), BMP3_REG_PWR_CTRL, and NULL.

Referenced by bmp3_set_op_mode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmp3_get_regs()

int8_t bmp3_get_regs ( uint8_t  reg_addr,
uint8_t *  reg_data,
uint32_t  len,
struct bmp3_dev dev 
)

This API reads the data from the given register address of the sensor.

Definition at line 794 of file bmp3.c.

795{
796 int8_t rslt;
797 uint32_t idx;
798
799 /* Check for null pointer in the device structure */
800 rslt = null_ptr_check(dev);
801
802 /* Proceed if null check is fine */
803 if ((rslt == BMP3_OK) && (reg_data != NULL))
804 {
805 uint32_t temp_len = len + dev->dummy_byte;
806 uint8_t temp_buff[len + dev->dummy_byte];
807
808 /* If interface selected is SPI */
809 if (dev->intf != BMP3_I2C_INTF)
810 {
811 reg_addr = reg_addr | 0x80;
812
813 /* Read the data from the register */
814 dev->intf_rslt = dev->read(reg_addr, temp_buff, temp_len, dev->intf_ptr);
815 for (idx = 0; idx < len; idx++)
816 {
817 reg_data[idx] = temp_buff[idx + dev->dummy_byte];
818 }
819 }
820 else
821 {
822 /* Read the data using I2C */
823 dev->intf_rslt = dev->read(reg_addr, reg_data, len, dev->intf_ptr);
824 }
825
826 /* Check for communication error */
828 {
829 rslt = BMP3_E_COMM_FAIL;
830 }
831 }
832 else
833 {
834 rslt = BMP3_E_NULL_PTR;
835 }
836
837 return rslt;
838}
static int8_t null_ptr_check(const struct bmp3_dev *dev)
This internal API is used to validate the device pointer for null conditions.
Definition bmp3.c:2724
#define BMP3_INTF_RET_SUCCESS
Definition bmp3_defs.h:124
@ BMP3_I2C_INTF
Definition bmp3_defs.h:507
#define BMP3_E_COMM_FAIL
Definition bmp3_defs.h:262
bmp3_read_fptr_t read
Definition bmp3_defs.h:920
BMP3_INTF_RET_TYPE intf_rslt
Definition bmp3_defs.h:914
enum bmp3_intf intf
Definition bmp3_defs.h:911
uint8_t dummy_byte
Definition bmp3_defs.h:917

References BMP3_E_COMM_FAIL, BMP3_E_NULL_PTR, BMP3_I2C_INTF, BMP3_INTF_RET_SUCCESS, BMP3_OK, bmp3_dev::dummy_byte, bmp3_dev::intf, bmp3_dev::intf_ptr, bmp3_dev::intf_rslt, NULL, null_ptr_check(), and bmp3_dev::read.

Referenced by bmp3_fifo_flush(), bmp3_get_fifo_length(), bmp3_get_op_mode(), bmp3_get_sensor_data(), bmp3_get_sensor_settings(), bmp3_init(), bmp3_soft_reset(), get_calib_data(), get_err_status(), get_int_status(), get_odr_filter_settings(), get_sensor_status(), put_device_to_sleep(), set_advance_settings(), set_int_ctrl_settings(), set_normal_mode(), set_odr_filter_settings(), set_pwr_ctrl_settings(), and write_power_mode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmp3_get_sensor_data()

int8_t bmp3_get_sensor_data ( uint8_t  sensor_comp,
struct bmp3_data comp_data,
struct bmp3_dev dev 
)

This API reads the pressure, temperature or both data from the sensor, compensates the data and store it in the bmp3_data structure instance passed by the user.

Definition at line 1428 of file bmp3.c.

1429{
1430 int8_t rslt;
1431
1432 /* Array to store the pressure and temperature data read from
1433 * the sensor */
1434 uint8_t reg_data[BMP3_LEN_P_T_DATA] = { 0 };
1435 struct bmp3_uncomp_data uncomp_data = { 0 };
1436
1437 if (comp_data != NULL)
1438 {
1439 /* Read the pressure and temperature data from the sensor */
1440 rslt = bmp3_get_regs(BMP3_REG_DATA, reg_data, BMP3_LEN_P_T_DATA, dev);
1441
1442 if (rslt == BMP3_OK)
1443 {
1444 /* Parse the read data from the sensor */
1445 parse_sensor_data(reg_data, &uncomp_data);
1446
1447 /* Compensate the pressure/temperature/both data read
1448 * from the sensor */
1449 rslt = compensate_data(sensor_comp, &uncomp_data, comp_data, &dev->calib_data);
1450 }
1451 }
1452 else
1453 {
1454 rslt = BMP3_E_NULL_PTR;
1455 }
1456
1457 return rslt;
1458}
static void parse_sensor_data(const uint8_t *reg_data, struct bmp3_uncomp_data *uncomp_data)
This internal API is used to parse the pressure and temperature data and store it in the bmp3_uncomp_...
Definition bmp3.c:2273
static int8_t compensate_data(uint8_t sensor_comp, const struct bmp3_uncomp_data *uncomp_data, struct bmp3_data *comp_data, struct bmp3_calib_data *calib_data)
This internal API is used to compensate the pressure or temperature or both the data according to the...
Definition bmp3.c:2297
#define BMP3_LEN_P_T_DATA
Definition bmp3_defs.h:442
#define BMP3_REG_DATA
Definition bmp3_defs.h:148
struct bmp3_calib_data calib_data
Definition bmp3_defs.h:929
bmp3 sensor structure which comprises of un-compensated temperature and pressure data.
Definition bmp3_defs.h:882

References BMP3_E_NULL_PTR, bmp3_get_regs(), BMP3_LEN_P_T_DATA, BMP3_OK, BMP3_REG_DATA, bmp3_dev::calib_data, compensate_data(), NULL, and parse_sensor_data().

Referenced by StartSensor_Task().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmp3_get_sensor_settings()

int8_t bmp3_get_sensor_settings ( struct bmp3_settings settings,
struct bmp3_dev dev 
)

This API gets the power control(power mode, pressure enable and temperature enable), over sampling, ODR, filter, interrupt control and advance settings from the sensor.

Definition at line 953 of file bmp3.c.

954{
955 int8_t rslt;
956 uint8_t settings_data[BMP3_LEN_GEN_SETT];
957
958 if (settings != NULL)
959 {
960 rslt = bmp3_get_regs(BMP3_REG_INT_CTRL, settings_data, BMP3_LEN_GEN_SETT, dev);
961
962 if (rslt == BMP3_OK)
963 {
964 /* Parse the settings data */
965 parse_sett_data(settings_data, settings);
966 }
967 }
968 else
969 {
970 rslt = BMP3_E_NULL_PTR;
971 }
972
973 return rslt;
974}
static void parse_sett_data(const uint8_t *reg_data, struct bmp3_settings *settings)
This internal API parse the power control(power mode, pressure enable and temperature enable),...
Definition bmp3.c:1823
#define BMP3_LEN_GEN_SETT
Definition bmp3_defs.h:443
#define BMP3_REG_INT_CTRL
Definition bmp3_defs.h:156

References BMP3_E_NULL_PTR, bmp3_get_regs(), BMP3_LEN_GEN_SETT, BMP3_OK, BMP3_REG_INT_CTRL, NULL, and parse_sett_data().

Here is the call graph for this function:

◆ bmp3_get_status()

int8_t bmp3_get_status ( struct bmp3_status status,
struct bmp3_dev dev 
)

This API sets the fifo_config_1(fifo_mode, fifo_stop_on_full, fifo_time_en, fifo_press_en, fifo_temp_en), fifo_config_2(fifo_subsampling, data_select) and int_ctrl(fwtm_en, ffull_en) settings in the sensor.

 @brief This API gets the fifo_config_1(fifo_mode,
 fifo_stop_on_full, fifo_time_en, fifo_press_en, fifo_temp_en),
 fifo_config_2(fifo_subsampling, data_select) and int_ctrl(fwtm_en, ffull_en)
 settings from the sensor.
&zwj;/

int8_t bmp3_get_fifo_settings(struct bmp3_fifo_settings *fifo_settings, struct bmp3_dev *dev) { int8_t rslt; uint8_t fifo_sett[3]; uint8_t len = 3;

/* Proceed if null check is fine *‍/ if (fifo_settings != NULL) { rslt = bmp3_get_regs(BMP3_REG_FIFO_CONFIG_1, fifo_sett, len, dev);

/* Parse the fifo settings *‍/ parse_fifo_settings(fifo_sett, fifo_settings); } else { rslt = BMP3_E_NULL_PTR; }

return rslt; }

/*!

This API gets the fifo data from the sensor. ‍/ int8_t bmp3_get_fifo_data(struct bmp3_fifo_data *fifo, const struct bmp3_fifo_settings *fifo_settings, struct bmp3_dev *dev) { int8_t rslt; uint16_t fifo_len;

if ((fifo != NULL) && (fifo_settings != NULL)) { reset_fifo_index(fifo);

/* Get the total number of bytes available in FIFO *‍/ rslt = bmp3_get_fifo_length(&fifo_len, dev);

if (rslt == BMP3_OK) { /* For sensor time frame , add additional overhead bytes *‍/ if (fifo_settings->time_en == TRUE) { fifo_len = fifo_len + BMP3_SENSORTIME_OVERHEAD_BYTES; }

/* Update the fifo length in the fifo structure *‍/ fifo->byte_count = fifo_len;

/* Read the fifo data *‍/ rslt = bmp3_get_regs(BMP3_REG_FIFO_DATA, fifo->buffer, fifo_len, dev); } } else { rslt = BMP3_E_NULL_PTR; }

return rslt; }

/*!

This API sets the fifo watermark length according to the frames count set by the user in the device structure. Refer below for usage. ‍/ int8_t bmp3_set_fifo_watermark(const struct bmp3_fifo_data *fifo, const struct bmp3_fifo_settings *fifo_settings, struct bmp3_dev *dev) { int8_t rslt; uint8_t reg_data[2]; uint8_t reg_addr[2] = { BMP3_REG_FIFO_WM, BMP3_REG_FIFO_WM + 1 }; uint16_t watermark_len;

if ((fifo != NULL) && (fifo_settings != NULL)) { rslt = convert_frames_to_bytes(&watermark_len, fifo, fifo_settings);

if (rslt == BMP3_OK) { reg_data[0] = BMP3_GET_LSB(watermark_len); reg_data[1] = BMP3_GET_MSB(watermark_len) & 0x01; rslt = bmp3_set_regs(reg_addr, reg_data, 2, dev); } } else { rslt = BMP3_E_NULL_PTR; }

return rslt; }

/*!

This API sets the fifo watermark length according to the frames count set by the user in the device structure. Refer below for usage. ‍/ int8_t bmp3_get_fifo_watermark(uint16_t *watermark_len, struct bmp3_dev *dev) { int8_t rslt; uint8_t reg_data[2]; uint8_t reg_addr = BMP3_REG_FIFO_WM;

if (watermark_len != NULL) { rslt = bmp3_get_regs(reg_addr, reg_data, 2, dev); if (rslt == BMP3_OK) { *watermark_len = (reg_data[0]) + (reg_data[1] << 8); } } else { rslt = BMP3_E_NULL_PTR; }

return rslt; }

/*!

This API extracts the temperature and/or pressure data from the FIFO data which is already read from the fifo. ‍/ int8_t bmp3_extract_fifo_data(struct bmp3_data *data, struct bmp3_fifo_data *fifo, struct bmp3_dev *dev) { int8_t rslt; uint8_t header; uint8_t parsed_frames = 0; uint8_t t_p_frame; struct bmp3_uncomp_data uncomp_data = { 0 };

rslt = null_ptr_check(dev);

if ((rslt == BMP3_OK) && (fifo != NULL) && (data != NULL)) { uint16_t byte_index = fifo->start_idx;

while (byte_index < fifo->byte_count) { get_header_info(&header, fifo->buffer, &byte_index); t_p_frame = parse_fifo_data_frame(header, fifo, &byte_index, &uncomp_data, &parsed_frames);

/* If the frame is pressure and/or temperature data ‍/ if (t_p_frame != FALSE) { / Compensate temperature and pressure data *‍/ rslt = compensate_data(t_p_frame, &uncomp_data, &data[parsed_frames - 1], &dev->calib_data); } }

/* Check if any frames are parsed in FIFO ‍/ if (parsed_frames != 0) { / Update the bytes parsed in the device structure ‍/ fifo->start_idx = byte_index; fifo->parsed_frames += parsed_frames; } else { / No frames are there to parse. It is time to read the FIFO, if more frames are needed *‍/ fifo->frame_not_available = TRUE; } } else { rslt = BMP3_E_NULL_PTR; }

return rslt; }

/*!

This API gets the command ready, data ready for pressure and temperature and interrupt (fifo watermark, fifo full, data ready) and error status from the sensor.

Definition at line 1204 of file bmp3.c.

1205{
1206 int8_t rslt;
1207
1208 if (status != NULL)
1209 {
1210 rslt = get_sensor_status(status, dev);
1211
1212 /* Proceed further if the earlier operation is fine */
1213 if (rslt == BMP3_OK)
1214 {
1215 rslt = get_int_status(status, dev);
1216
1217 /* Proceed further if the earlier operation is fine */
1218 if (rslt == BMP3_OK)
1219 {
1220 /* Get the error status */
1221 rslt = get_err_status(status, dev);
1222 }
1223 }
1224 }
1225 else
1226 {
1227 rslt = BMP3_E_NULL_PTR;
1228 }
1229
1230 return rslt;
1231}
static int8_t get_err_status(struct bmp3_status *status, struct bmp3_dev *dev)
This API gets the fatal, command and configuration error from the sensor.
Definition bmp3.c:2945
static int8_t get_int_status(struct bmp3_status *status, struct bmp3_dev *dev)
This API gets the interrupt (fifo watermark, fifo full, data ready) status from the sensor.
Definition bmp3.c:2924
static int8_t get_sensor_status(struct bmp3_status *status, struct bmp3_dev *dev)
This internal API fills the fifo_config_1(fifo_mode, fifo_stop_on_full, fifo_time_en,...
Definition bmp3.c:2898

References BMP3_E_NULL_PTR, BMP3_OK, get_err_status(), get_int_status(), get_sensor_status(), and NULL.

Here is the call graph for this function:

◆ bmp3_init()

int8_t bmp3_init ( struct bmp3_dev dev)

This internal API converts the no. of frames required by the user to bytes so as to write in the watermark length register.

Parameters
[out]watermark_len: Pointer variable which contains the watermark length.
[in]fifo: Structure instance of bmp3_fifo_data
[in]fifo_settings: Structure instance of bmp3_fifo_settings
Returns
Result of API execution status.
Return values
0-> Success
<0-> Fail

This API is the entry point. It performs the selection of I2C/SPI read mechanism according to the selected interface and reads the chip-id and calibration data of the sensor.

Definition at line 738 of file bmp3.c.

739{
740 int8_t rslt;
741 uint8_t chip_id = 0;
742
743 /* Check for null pointer in the device structure */
744 rslt = null_ptr_check(dev);
745
746 /* Proceed if null check is fine */
747 if (rslt == BMP3_OK)
748 {
749 /* Read mechanism according to selected interface */
750 if (dev->intf != BMP3_I2C_INTF)
751 {
752 /* If SPI interface is selected, read extra byte */
753 dev->dummy_byte = 1;
754 }
755 else
756 {
757 /* If I2C interface is selected, no need to read
758 * extra byte */
759 dev->dummy_byte = 0;
760 }
761
762 /* Read the chip-id of bmp3 sensor */
763 rslt = bmp3_get_regs(BMP3_REG_CHIP_ID, &chip_id, 1, dev);
764
765 /* Proceed if everything is fine until now */
766 if (rslt == BMP3_OK)
767 {
768 /* Check for chip id validity */
769 if ((chip_id == BMP3_CHIP_ID) || (chip_id == BMP390_CHIP_ID))
770 {
771 dev->chip_id = chip_id;
772
773 /* Reset the sensor */
774 rslt = bmp3_soft_reset(dev);
775 if (rslt == BMP3_OK)
776 {
777 /* Read the calibration data */
778 rslt = get_calib_data(dev);
779 }
780 }
781 else
782 {
784 }
785 }
786 }
787
788 return rslt;
789}
static int8_t get_calib_data(struct bmp3_dev *dev)
This internal API reads the calibration data from the sensor, parse it then compensates it and store ...
Definition bmp3.c:1786
int8_t bmp3_soft_reset(struct bmp3_dev *dev)
This API performs the soft reset of the sensor.
Definition bmp3.c:1263
#define BMP3_CHIP_ID
Definition bmp3_defs.h:132
#define BMP3_E_DEV_NOT_FOUND
Definition bmp3_defs.h:267
#define BMP3_REG_CHIP_ID
Definition bmp3_defs.h:145
#define BMP390_CHIP_ID
Definition bmp3_defs.h:133
uint8_t chip_id
Definition bmp3_defs.h:897

References BMP390_CHIP_ID, BMP3_CHIP_ID, BMP3_E_DEV_NOT_FOUND, bmp3_get_regs(), BMP3_I2C_INTF, BMP3_OK, BMP3_REG_CHIP_ID, bmp3_soft_reset(), bmp3_dev::chip_id, bmp3_dev::dummy_byte, get_calib_data(), bmp3_dev::intf, and null_ptr_check().

Referenced by init_bmp390_B(), and init_bmp390_p().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmp3_set_op_mode()

int8_t bmp3_set_op_mode ( struct bmp3_settings settings,
struct bmp3_dev dev 
)

This API sets the power mode of the sensor.

Definition at line 1350 of file bmp3.c.

1351{
1352 int8_t rslt;
1353 uint8_t last_set_mode;
1354
1355 /* Check for null pointer in the device structure */
1356 rslt = null_ptr_check(dev);
1357
1358 if ((rslt == BMP3_OK) && (settings != NULL))
1359 {
1360 uint8_t curr_mode = settings->op_mode;
1361
1362 rslt = bmp3_get_op_mode(&last_set_mode, dev);
1363
1364 /* If the sensor is not in sleep mode put the device to sleep
1365 * mode */
1366 if ((last_set_mode != BMP3_MODE_SLEEP) && (rslt == BMP3_OK))
1367 {
1368 /* Device should be put to sleep before transiting to
1369 * forced mode or normal mode */
1370 rslt = put_device_to_sleep(dev);
1371
1372 /* Give some time for device to go into sleep mode */
1373 dev->delay_us(5000, dev->intf_ptr);
1374 }
1375
1376 /* Set the power mode */
1377 if (rslt == BMP3_OK)
1378 {
1379 if (curr_mode == BMP3_MODE_NORMAL)
1380 {
1381 /* Set normal mode and validate
1382 * necessary settings */
1383 rslt = set_normal_mode(settings, dev);
1384 }
1385 else if (curr_mode == BMP3_MODE_FORCED)
1386 {
1387 /* Set forced mode */
1388 rslt = write_power_mode(settings, dev);
1389 }
1390 }
1391 }
1392 else
1393 {
1394 rslt = BMP3_E_NULL_PTR;
1395 }
1396
1397 return rslt;
1398}
static int8_t write_power_mode(const struct bmp3_settings *settings, struct bmp3_dev *dev)
This internal API writes the power mode in the sensor.
Definition bmp3.c:1716
static int8_t set_normal_mode(struct bmp3_settings *settings, struct bmp3_dev *dev)
This internal API sets the normal mode in the sensor.
Definition bmp3.c:1680
static int8_t put_device_to_sleep(struct bmp3_dev *dev)
This internal API puts the device to sleep mode.
Definition bmp3.c:1743
int8_t bmp3_get_op_mode(uint8_t *op_mode, struct bmp3_dev *dev)
This API gets the power mode of the sensor.
Definition bmp3.c:1403
#define BMP3_MODE_FORCED
Definition bmp3_defs.h:177
#define BMP3_MODE_SLEEP
Definition bmp3_defs.h:176
#define BMP3_MODE_NORMAL
Definition bmp3_defs.h:178
uint8_t op_mode
Definition bmp3_defs.h:709

References BMP3_E_NULL_PTR, bmp3_get_op_mode(), BMP3_MODE_FORCED, BMP3_MODE_NORMAL, BMP3_MODE_SLEEP, BMP3_OK, bmp3_dev::delay_us, bmp3_dev::intf_ptr, NULL, null_ptr_check(), bmp3_settings::op_mode, put_device_to_sleep(), set_normal_mode(), and write_power_mode().

Referenced by init_bmp390_B(), and init_bmp390_p().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmp3_set_regs()

int8_t bmp3_set_regs ( uint8_t *  reg_addr,
const uint8_t *  reg_data,
uint32_t  len,
struct bmp3_dev dev 
)

This API writes the given data to the register address of the sensor.

Definition at line 844 of file bmp3.c.

845{
846 int8_t rslt;
847 uint8_t temp_buff[len * 2];
848 uint32_t temp_len;
849 uint8_t reg_addr_cnt;
850
851 /* Check for null pointer in the device structure */
852 rslt = null_ptr_check(dev);
853
854 /* Check for arguments validity */
855 if ((rslt == BMP3_OK) && (reg_addr != NULL) && (reg_data != NULL))
856 {
857 if (len != 0)
858 {
859 temp_buff[0] = reg_data[0];
860
861 /* If interface selected is SPI */
862 if (dev->intf == BMP3_SPI_INTF)
863 {
864 for (reg_addr_cnt = 0; reg_addr_cnt < len; reg_addr_cnt++)
865 {
866 reg_addr[reg_addr_cnt] = reg_addr[reg_addr_cnt] & 0x7F;
867 }
868 }
869
870 /* Burst write mode */
871 if (len > 1)
872 {
873 /* Interleave register address w.r.t data for
874 * burst write*/
875 interleave_reg_addr(reg_addr, temp_buff, reg_data, len);
876 temp_len = len * 2;
877 }
878 else
879 {
880 temp_len = len;
881 }
882
883 dev->intf_rslt = dev->write(reg_addr[0], temp_buff, temp_len, dev->intf_ptr);
884
885 /* Check for communication error */
887 {
888 rslt = BMP3_E_COMM_FAIL;
889 }
890 }
891 else
892 {
893 rslt = BMP3_E_INVALID_LEN;
894 }
895 }
896 else
897 {
898 rslt = BMP3_E_NULL_PTR;
899 }
900
901 return rslt;
902}
static void interleave_reg_addr(const uint8_t *reg_addr, uint8_t *temp_buff, const uint8_t *reg_data, uint32_t len)
This internal API interleaves the register address between the register data buffer for burst write o...
Definition bmp3.c:1807
@ BMP3_SPI_INTF
Definition bmp3_defs.h:505
#define BMP3_E_INVALID_LEN
Definition bmp3_defs.h:266
bmp3_write_fptr_t write
Definition bmp3_defs.h:923

References BMP3_E_COMM_FAIL, BMP3_E_INVALID_LEN, BMP3_E_NULL_PTR, BMP3_INTF_RET_SUCCESS, BMP3_OK, BMP3_SPI_INTF, interleave_reg_addr(), bmp3_dev::intf, bmp3_dev::intf_ptr, bmp3_dev::intf_rslt, NULL, null_ptr_check(), and bmp3_dev::write.

Referenced by bmp3_fifo_flush(), bmp3_soft_reset(), put_device_to_sleep(), set_advance_settings(), set_int_ctrl_settings(), set_odr_filter_settings(), set_pwr_ctrl_settings(), and write_power_mode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmp3_set_sensor_settings()

int8_t bmp3_set_sensor_settings ( uint32_t  desired_settings,
struct bmp3_settings settings,
struct bmp3_dev dev 
)

This API sets the power control(pressure enable and temperature enable), over sampling, ODR and filter settings in the sensor.

Definition at line 909 of file bmp3.c.

910{
911 int8_t rslt = BMP3_OK;
912
913 if (settings != NULL)
914 {
915
916 if (are_settings_changed(BMP3_POWER_CNTL, desired_settings))
917 {
918 /* Set the power control settings */
919 rslt = set_pwr_ctrl_settings(desired_settings, settings, dev);
920 }
921
922 if (are_settings_changed(BMP3_ODR_FILTER, desired_settings))
923 {
924 /* Set the over sampling, ODR and filter settings */
925 rslt = set_odr_filter_settings(desired_settings, settings, dev);
926 }
927
928 if (are_settings_changed(BMP3_INT_CTRL, desired_settings))
929 {
930 /* Set the interrupt control settings */
931 rslt = set_int_ctrl_settings(desired_settings, settings, dev);
932 }
933
934 if (are_settings_changed(BMP3_ADV_SETT, desired_settings))
935 {
936 /* Set the advance settings */
937 rslt = set_advance_settings(desired_settings, settings, dev);
938 }
939 }
940 else
941 {
942 rslt = BMP3_E_NULL_PTR;
943 }
944
945 return rslt;
946}
static int8_t set_advance_settings(uint32_t desired_settings, const struct bmp3_settings *settings, struct bmp3_dev *dev)
This internal API sets the advance (i2c_wdt_en, i2c_wdt_sel) settings of the sensor based on the sett...
Definition bmp3.c:2037
static int8_t set_pwr_ctrl_settings(uint32_t desired_settings, const struct bmp3_settings *settings, struct bmp3_dev *dev)
This internal API sets the pressure enable and temperature enable settings of the sensor.
Definition bmp3.c:1891
static uint8_t are_settings_changed(uint32_t sub_settings, uint32_t settings)
This internal API is used to identify the settings which the user wants to modify in the sensor.
Definition bmp3.c:2702
static int8_t set_int_ctrl_settings(uint32_t desired_settings, const struct bmp3_settings *settings, struct bmp3_dev *dev)
This internal API sets the interrupt control (output mode, level, latch and data ready) settings of t...
Definition bmp3.c:1987
static int8_t set_odr_filter_settings(uint32_t desired_settings, struct bmp3_settings *settings, struct bmp3_dev *dev)
This internal API sets the over sampling, ODR and filter settings of the sensor based on the settings...
Definition bmp3.c:1928
#define BMP3_POWER_CNTL
Definition bmp3_defs.h:450
#define BMP3_ADV_SETT
Definition bmp3_defs.h:459
#define BMP3_INT_CTRL
Definition bmp3_defs.h:456
#define BMP3_ODR_FILTER
Definition bmp3_defs.h:453

References are_settings_changed(), BMP3_ADV_SETT, BMP3_E_NULL_PTR, BMP3_INT_CTRL, BMP3_ODR_FILTER, BMP3_OK, BMP3_POWER_CNTL, NULL, set_advance_settings(), set_int_ctrl_settings(), set_odr_filter_settings(), and set_pwr_ctrl_settings().

Referenced by init_bmp390_B(), and init_bmp390_p().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bmp3_soft_reset()

int8_t bmp3_soft_reset ( struct bmp3_dev dev)

This API performs the soft reset of the sensor.

Definition at line 1263 of file bmp3.c.

1264{
1265 int8_t rslt;
1266 uint8_t reg_addr = BMP3_REG_CMD;
1267
1268 /* 0xB6 is the soft reset command */
1269 uint8_t soft_rst_cmd = BMP3_SOFT_RESET;
1270 uint8_t cmd_rdy_status;
1271 uint8_t cmd_err_status;
1272
1273 /* Check for command ready status */
1274 rslt = bmp3_get_regs(BMP3_REG_SENS_STATUS, &cmd_rdy_status, 1, dev);
1275
1276 /* Device is ready to accept new command */
1277 if ((cmd_rdy_status & BMP3_CMD_RDY) && (rslt == BMP3_OK))
1278 {
1279 /* Write the soft reset command in the sensor */
1280 rslt = bmp3_set_regs(&reg_addr, &soft_rst_cmd, 1, dev);
1281
1282 /* Proceed if everything is fine until now */
1283 if (rslt == BMP3_OK)
1284 {
1285 /* Wait for 2 ms */
1286 dev->delay_us(2000, dev->intf_ptr);
1287
1288 /* Read for command error status */
1289 rslt = bmp3_get_regs(BMP3_REG_ERR, &cmd_err_status, 1, dev);
1290
1291 /* check for command error status */
1292 if ((cmd_err_status & BMP3_REG_CMD) || (rslt != BMP3_OK))
1293 {
1294 /* Command not written hence return
1295 * error */
1297 }
1298 }
1299 }
1300
1301 return rslt;
1302}
#define BMP3_SOFT_RESET
Definition bmp3_defs.h:252

References BMP3_CMD_RDY, BMP3_E_CMD_EXEC_FAILED, bmp3_get_regs(), BMP3_OK, BMP3_REG_CMD, BMP3_REG_ERR, BMP3_REG_SENS_STATUS, bmp3_set_regs(), BMP3_SOFT_RESET, bmp3_dev::delay_us, and bmp3_dev::intf_ptr.

Referenced by bmp3_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_press_meas_time()

static uint32_t calculate_press_meas_time ( const struct bmp3_settings settings)
static

This internal API calculates the pressure measurement duration of the sensor.

Parameters
[out]settings: Structure instance of bmp3_settings.
Returns
Pressure measurement time
Return values
Pressuremeasurement time in microseconds

Definition at line 2153 of file bmp3.c.

2154{
2155 uint32_t press_meas_t;
2156 struct bmp3_odr_filter_settings odr_filter = settings->odr_filter;
2157
2158#ifdef BMP3_FLOAT_COMPENSATION
2159 double base = 2.0;
2160 float partial_out;
2161#else
2162 uint8_t base = 2;
2163 uint32_t partial_out;
2164#endif /* BMP3_FLOAT_COMPENSATION */
2165 partial_out = pow_bmp3(base, odr_filter.press_os);
2166 press_meas_t = (uint32_t)(BMP3_SETTLE_TIME_PRESS + partial_out * BMP3_ADC_CONV_TIME);
2167
2168 /* Output in microseconds */
2169 return press_meas_t;
2170}
static uint32_t pow_bmp3(uint8_t base, uint8_t power)
This internal API is used to calculate the power functionality.
Definition bmp3.c:2683
#define BMP3_ADC_CONV_TIME
Definition bmp3_defs.h:142
#define BMP3_SETTLE_TIME_PRESS
Definition bmp3_defs.h:136
bmp3 odr and filter settings
Definition bmp3_defs.h:602
struct bmp3_odr_filter_settings odr_filter
Definition bmp3_defs.h:718

References BMP3_ADC_CONV_TIME, BMP3_SETTLE_TIME_PRESS, bmp3_settings::odr_filter, pow_bmp3(), and bmp3_odr_filter_settings::press_os.

Referenced by validate_osr_and_odr_settings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_temp_meas_time()

static uint32_t calculate_temp_meas_time ( const struct bmp3_settings settings)
static

This internal API calculates the temperature measurement duration of the sensor.

Parameters
[out]settings: Structure instance of bmp3_settings.
Returns
Temperature measurement time
Return values
Temperaturemeasurement time in microseconds

Definition at line 2176 of file bmp3.c.

2177{
2178 uint32_t temp_meas_t;
2179 struct bmp3_odr_filter_settings odr_filter = settings->odr_filter;
2180
2181#ifdef BMP3_FLOAT_COMPENSATION
2182 double base = 2.0;
2183 float partial_out;
2184#else
2185 uint8_t base = 2;
2186 uint32_t partial_out;
2187#endif /* BMP3_FLOAT_COMPENSATION */
2188 partial_out = pow_bmp3(base, odr_filter.temp_os);
2189 temp_meas_t = (uint32_t)(BMP3_SETTLE_TIME_TEMP + partial_out * BMP3_ADC_CONV_TIME);
2190
2191 /* Output in uint32_t */
2192 return temp_meas_t;
2193}
#define BMP3_SETTLE_TIME_TEMP
Definition bmp3_defs.h:139

References BMP3_ADC_CONV_TIME, BMP3_SETTLE_TIME_TEMP, bmp3_settings::odr_filter, pow_bmp3(), and bmp3_odr_filter_settings::temp_os.

Referenced by validate_osr_and_odr_settings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compensate_data()

static int8_t compensate_data ( uint8_t  sensor_comp,
const struct bmp3_uncomp_data uncomp_data,
struct bmp3_data comp_data,
struct bmp3_calib_data calib_data 
)
static

This internal API is used to compensate the pressure or temperature or both the data according to the component selected by the user.

Parameters
[in]sensor_comp: Used to select pressure or temperature.
[in]uncomp_data: Contains the uncompensated pressure and temperature data.
[out]comp_data: Contains the compensated pressure and temperature data.
[in]calib_data: Pointer to the calibration data structure.
Returns
Result of API execution status
Return values
0-> Success
>0-> Warning
<0-> Fail

Definition at line 2297 of file bmp3.c.

2301{
2302 int8_t rslt = BMP3_OK;
2303
2304 if ((uncomp_data != NULL) && (comp_data != NULL) && (calib_data != NULL))
2305 {
2306 /* If pressure and temperature component is selected */
2307 if (sensor_comp == BMP3_PRESS_TEMP)
2308 {
2309 /*
2310 * NOTE : Temperature compensation must be done first.
2311 * Followed by pressure compensation
2312 * Compensated temperature updated in calib structure,
2313 * is needed for pressure calculation
2314 */
2315
2316 /* Compensate pressure and temperature data */
2317 rslt = compensate_temperature(&comp_data->temperature, uncomp_data, calib_data);
2318
2319 if (rslt == BMP3_OK)
2320 {
2321 rslt = compensate_pressure(&comp_data->pressure, uncomp_data, calib_data);
2322 }
2323 }
2324 else if (sensor_comp == BMP3_PRESS)
2325 {
2326 /*
2327 * NOTE : Temperature compensation must be done first.
2328 * Followed by pressure compensation
2329 * Compensated temperature updated in calib structure,
2330 * is needed for pressure calculation.
2331 * As only pressure is enabled in 'sensor_comp', after calculating
2332 * compensated temperature, assign it to zero.
2333 */
2334 (void)compensate_temperature(&comp_data->temperature, uncomp_data, calib_data);
2335 comp_data->temperature = 0;
2336
2337 /* Compensate the pressure data */
2338 rslt = compensate_pressure(&comp_data->pressure, uncomp_data, calib_data);
2339 }
2340 else if (sensor_comp == BMP3_TEMP)
2341 {
2342 /* Compensate the temperature data */
2343 rslt = compensate_temperature(&comp_data->temperature, uncomp_data, calib_data);
2344
2345 /*
2346 * As only temperature is enabled in 'sensor_comp'
2347 * make compensated pressure as zero
2348 */
2349 comp_data->pressure = 0;
2350 }
2351 else
2352 {
2353 comp_data->pressure = 0;
2354 comp_data->temperature = 0;
2355 }
2356 }
2357 else
2358 {
2359 rslt = BMP3_E_NULL_PTR;
2360 }
2361
2362 return rslt;
2363}
static int8_t compensate_pressure(uint64_t *pressure, const struct bmp3_uncomp_data *uncomp_data, const struct bmp3_calib_data *calib_data)
This internal API is used to compensate the pressure data and return the compensated pressure data in...
Definition bmp3.c:2618
static int8_t compensate_temperature(int64_t *temperature, const struct bmp3_uncomp_data *uncomp_data, struct bmp3_calib_data *calib_data)
This internal API is used to compensate the raw temperature data and return the compensated temperatu...
Definition bmp3.c:2572
#define BMP3_PRESS
Definition bmp3_defs.h:311
#define BMP3_TEMP
Definition bmp3_defs.h:312
#define BMP3_PRESS_TEMP
Definition bmp3_defs.h:313
double pressure
Definition bmp3_defs.h:847
double temperature
Definition bmp3_defs.h:844

References BMP3_E_NULL_PTR, BMP3_OK, BMP3_PRESS, BMP3_PRESS_TEMP, BMP3_TEMP, compensate_pressure(), compensate_temperature(), NULL, bmp3_data::pressure, and bmp3_data::temperature.

Referenced by bmp3_get_sensor_data().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ compensate_pressure()

static int8_t compensate_pressure ( uint64_t *  pressure,
const struct bmp3_uncomp_data uncomp_data,
const struct bmp3_calib_data calib_data 
)
static

This internal API is used to compensate the pressure data and return the compensated pressure data in integer data type.

This internal API is used to compensate the raw pressure data and return the compensated pressure data in integer data type. for eg return if pressure is 9528709 which is 9528709/100 = 95287.09 Pascal.

Parameters
[out]comp_pressure: Compensated pressure data in integer.
[in]uncomp_data: Contains the uncompensated pressure data.
[in]calib_data: Pointer to the calibration data structure.
Returns
Result of API execution status
Return values
0-> Success
>0-> Warning
<0-> Fail

Definition at line 2618 of file bmp3.c.

2621{
2622 int8_t rslt = BMP3_OK;
2623 const struct bmp3_reg_calib_data *reg_calib_data = &calib_data->reg_calib_data;
2624 int64_t partial_data1;
2625 int64_t partial_data2;
2626 int64_t partial_data3;
2627 int64_t partial_data4;
2628 int64_t partial_data5;
2629 int64_t partial_data6;
2630 int64_t offset;
2631 int64_t sensitivity;
2632 uint64_t comp_press;
2633
2634 partial_data1 = (int64_t)(reg_calib_data->t_lin * reg_calib_data->t_lin);
2635 partial_data2 = (int64_t)(partial_data1 / 64);
2636 partial_data3 = (int64_t)((partial_data2 * reg_calib_data->t_lin) / 256);
2637 partial_data4 = (int64_t)((reg_calib_data->par_p8 * partial_data3) / 32);
2638 partial_data5 = (int64_t)((reg_calib_data->par_p7 * partial_data1) * 16);
2639 partial_data6 = (int64_t)((reg_calib_data->par_p6 * reg_calib_data->t_lin) * 4194304);
2640 offset = (int64_t)((reg_calib_data->par_p5 * 140737488355328) + partial_data4 + partial_data5 + partial_data6);
2641 partial_data2 = (int64_t)((reg_calib_data->par_p4 * partial_data3) / 32);
2642 partial_data4 = (int64_t)((reg_calib_data->par_p3 * partial_data1) * 4);
2643 partial_data5 = (int64_t)((reg_calib_data->par_p2 - (int32_t)16384) * reg_calib_data->t_lin * 2097152);
2644 sensitivity =
2645 (int64_t)(((reg_calib_data->par_p1 - (int32_t)16384) * 70368744177664) + partial_data2 + partial_data4 +
2646 partial_data5);
2647 partial_data1 = (int64_t)((sensitivity / 16777216) * uncomp_data->pressure);
2648 partial_data2 = (int64_t)(reg_calib_data->par_p10 * reg_calib_data->t_lin);
2649 partial_data3 = (int64_t)(partial_data2 + ((int32_t)65536 * reg_calib_data->par_p9));
2650 partial_data4 = (int64_t)((partial_data3 * uncomp_data->pressure) / (int32_t)8192);
2651
2652 /* dividing by 10 followed by multiplying by 10
2653 * To avoid overflow caused by (uncomp_data->pressure * partial_data4)
2654 */
2655 partial_data5 = (int64_t)((uncomp_data->pressure * (partial_data4 / 10)) / (int32_t)512);
2656 partial_data5 = (int64_t)(partial_data5 * 10);
2657 partial_data6 = (int64_t)(uncomp_data->pressure * uncomp_data->pressure);
2658 partial_data2 = (int64_t)((reg_calib_data->par_p11 * partial_data6) / (int32_t)65536);
2659 partial_data3 = (int64_t)((int64_t)(partial_data2 * uncomp_data->pressure) / 128);
2660 partial_data4 = (int64_t)((offset / 4) + partial_data1 + partial_data5 + partial_data3);
2661 comp_press = (((uint64_t)partial_data4 * 25) / (uint64_t)1099511627776);
2662
2663 if (comp_press < BMP3_MIN_PRES_INT)
2664 {
2665 comp_press = BMP3_MIN_PRES_INT;
2666 rslt = BMP3_W_MIN_PRES;
2667 }
2668
2669 if (comp_press > BMP3_MAX_PRES_INT)
2670 {
2671 comp_press = BMP3_MAX_PRES_INT;
2672 rslt = BMP3_W_MAX_PRES;
2673 }
2674
2675 (*pressure) = comp_press;
2676
2677 return rslt;
2678}
#define BMP3_MAX_PRES_INT
Definition bmp3_defs.h:323
#define BMP3_MIN_PRES_INT
Definition bmp3_defs.h:322
#define BMP3_W_MAX_PRES
Definition bmp3_defs.h:276
#define BMP3_W_MIN_PRES
Definition bmp3_defs.h:275
struct bmp3_reg_calib_data reg_calib_data
Definition bmp3_defs.h:833
Register Trim Variables.
Definition bmp3_defs.h:564
uint64_t pressure
Definition bmp3_defs.h:884

References BMP3_MAX_PRES_INT, BMP3_MIN_PRES_INT, BMP3_OK, BMP3_W_MAX_PRES, BMP3_W_MIN_PRES, bmp3_reg_calib_data::par_p1, bmp3_reg_calib_data::par_p10, bmp3_reg_calib_data::par_p11, bmp3_reg_calib_data::par_p2, bmp3_reg_calib_data::par_p3, bmp3_reg_calib_data::par_p4, bmp3_reg_calib_data::par_p5, bmp3_reg_calib_data::par_p6, bmp3_reg_calib_data::par_p7, bmp3_reg_calib_data::par_p8, bmp3_reg_calib_data::par_p9, bmp3_uncomp_data::pressure, bmp3_calib_data::reg_calib_data, and bmp3_reg_calib_data::t_lin.

Referenced by compensate_data().

Here is the caller graph for this function:

◆ compensate_temperature()

static int8_t compensate_temperature ( int64_t *  temperature,
const struct bmp3_uncomp_data uncomp_data,
struct bmp3_calib_data calib_data 
)
static

This internal API is used to compensate the raw temperature data and return the compensated temperature data in integer data type.

This internal API is used to compensate the raw temperature data and return the compensated temperature data in integer data type. Returns temperature in integer. Actual temperature is obtained by dividing by 100 For eg : If returned temperature is 2426 then it is 2426/100 = 24 deg Celsius.

Parameters
[out]temperature: Compensated temperature data in integer.
[in]uncomp_data: Contains the uncompensated temperature data.
[in]calib_data: Pointer to calibration data structure.
Returns
Result of API execution status
Return values
0-> Success
>0-> Warning
<0-> Fail

Definition at line 2572 of file bmp3.c.

2575{
2576 int8_t rslt = BMP3_OK;
2577 int64_t partial_data1;
2578 int64_t partial_data2;
2579 int64_t partial_data3;
2580 int64_t partial_data4;
2581 int64_t partial_data5;
2582 int64_t partial_data6;
2583 int64_t comp_temp;
2584
2585 partial_data1 = (int64_t)(uncomp_data->temperature - ((int64_t)256 * calib_data->reg_calib_data.par_t1));
2586 partial_data2 = (int64_t)(calib_data->reg_calib_data.par_t2 * partial_data1);
2587 partial_data3 = (int64_t)(partial_data1 * partial_data1);
2588 partial_data4 = (int64_t)partial_data3 * calib_data->reg_calib_data.par_t3;
2589 partial_data5 = (int64_t)((int64_t)(partial_data2 * 262144) + partial_data4);
2590 partial_data6 = (int64_t)(partial_data5 / 4294967296);
2591
2592 /* Store t_lin in dev. structure for pressure calculation */
2593 calib_data->reg_calib_data.t_lin = (int64_t)partial_data6;
2594 comp_temp = (int64_t)((partial_data6 * 25) / 16384);
2595
2596 if (comp_temp < BMP3_MIN_TEMP_INT)
2597 {
2598 comp_temp = BMP3_MIN_TEMP_INT;
2599 rslt = BMP3_W_MIN_TEMP;
2600 }
2601
2602 if (comp_temp > BMP3_MAX_TEMP_INT)
2603 {
2604 comp_temp = BMP3_MAX_TEMP_INT;
2605 rslt = BMP3_W_MAX_TEMP;
2606 }
2607
2608 (*temperature) = comp_temp;
2609
2610 return rslt;
2611}
#define BMP3_MAX_TEMP_INT
Definition bmp3_defs.h:317
#define BMP3_W_MAX_TEMP
Definition bmp3_defs.h:274
#define BMP3_W_MIN_TEMP
Definition bmp3_defs.h:273
#define BMP3_MIN_TEMP_INT
Definition bmp3_defs.h:316
int64_t temperature
Definition bmp3_defs.h:887

References BMP3_MAX_TEMP_INT, BMP3_MIN_TEMP_INT, BMP3_OK, BMP3_W_MAX_TEMP, BMP3_W_MIN_TEMP, bmp3_reg_calib_data::par_t1, bmp3_reg_calib_data::par_t2, bmp3_reg_calib_data::par_t3, bmp3_calib_data::reg_calib_data, bmp3_reg_calib_data::t_lin, and bmp3_uncomp_data::temperature.

Referenced by compensate_data().

Here is the caller graph for this function:

◆ fill_filter_data()

static void fill_filter_data ( uint8_t *  addr,
uint8_t *  reg_data,
uint8_t *  len,
const struct bmp3_settings settings 
)
static

This internal API fills the register address and register data of the the filter settings for burst write operation.

This internal API fills the register address and register data of the filter settings for burst write operation.

Parameters
[out]addr: To store the address to fill in register buffer.
[out]reg_data: To store the register data to set the filter.
[out]len: To store the len for burst write.
[in]settings: Structure instance of bmp3_settings

Definition at line 2257 of file bmp3.c.

2258{
2259 struct bmp3_odr_filter_settings osr_settings = settings->odr_filter;
2260
2261 /* Set the iir settings in the register variable */
2262 reg_data[*len] = BMP3_SET_BITS(reg_data[3], BMP3_IIR_FILTER, osr_settings.iir_filter);
2263
2264 /* 0x1F is the register address of iir filter register */
2265 addr[*len] = BMP3_REG_CONFIG;
2266 (*len)++;
2267}
#define BMP3_REG_CONFIG
Definition bmp3_defs.h:161
#define BMP3_SET_BITS(reg_data, bitname, data)
Definition bmp3_defs.h:420

References BMP3_REG_CONFIG, BMP3_SET_BITS, bmp3_odr_filter_settings::iir_filter, and bmp3_settings::odr_filter.

Referenced by set_odr_filter_settings().

Here is the caller graph for this function:

◆ fill_odr_data()

static void fill_odr_data ( uint8_t *  addr,
uint8_t *  reg_data,
uint8_t *  len,
struct bmp3_settings settings 
)
static

This internal API fills the register address and register data of the the ODR settings for burst write operation.

This internal API fills the register address and register data of the ODR settings for burst write operation.

Parameters
[out]addr: To store the address to fill in register buffer.
[out]reg_data: To store the register data to set the odr data.
[out]len: To store the len for burst write.
[in]settings: Structure instance of bmp3_settings

Definition at line 2235 of file bmp3.c.

2236{
2237 struct bmp3_odr_filter_settings *osr_settings = &settings->odr_filter;
2238
2239 /* Limit the ODR to 0.001525879 Hz*/
2240 if (osr_settings->odr > BMP3_ODR_0_001_HZ)
2241 {
2242 osr_settings->odr = BMP3_ODR_0_001_HZ;
2243 }
2244
2245 /* Set the ODR settings in the register variable */
2246 reg_data[*len] = BMP3_SET_BITS_POS_0(reg_data[1], BMP3_ODR, osr_settings->odr);
2247
2248 /* 0x1D is the register address of output data rate register */
2249 addr[*len] = BMP3_REG_ODR;
2250 (*len)++;
2251}
#define BMP3_REG_ODR
Definition bmp3_defs.h:160
#define BMP3_ODR_0_001_HZ
Definition bmp3_defs.h:249
#define BMP3_SET_BITS_POS_0(reg_data, bitname, data)
Definition bmp3_defs.h:425

References BMP3_ODR_0_001_HZ, BMP3_REG_ODR, BMP3_SET_BITS_POS_0, bmp3_odr_filter_settings::odr, and bmp3_settings::odr_filter.

Referenced by set_odr_filter_settings().

Here is the caller graph for this function:

◆ fill_osr_data()

static void fill_osr_data ( uint32_t  desired_settings,
uint8_t *  addr,
uint8_t *  reg_data,
uint8_t *  len,
const struct bmp3_settings settings 
)
static

This internal API fills the register address and register data of the the over sampling settings for burst write operation.

This internal API fills the register address and register data of the over sampling settings for burst write operation.

Parameters
[in]desired_settings: Variable which specifies the settings which are to be set in the sensor.
[out]addr: To store the address to fill in register buffer.
[out]reg_data: To store the osr register data.
[out]len: To store the len for burst write.
[in]settings: Structure instance of bmp3_settings

Definition at line 2199 of file bmp3.c.

2204{
2205 struct bmp3_odr_filter_settings osr_settings = settings->odr_filter;
2206
2207 if (desired_settings & (BMP3_SEL_PRESS_OS | BMP3_SEL_TEMP_OS))
2208 {
2209 /* Pressure over sampling settings check */
2210 if (desired_settings & BMP3_SEL_PRESS_OS)
2211 {
2212 /* Set the pressure over sampling settings in the
2213 * register variable */
2214 reg_data[*len] = BMP3_SET_BITS_POS_0(reg_data[0], BMP3_PRESS_OS, osr_settings.press_os);
2215 }
2216
2217 /* Temperature over sampling settings check */
2218 if (desired_settings & BMP3_SEL_TEMP_OS)
2219 {
2220 /* Set the temperature over sampling settings in the
2221 * register variable */
2222 reg_data[*len] = BMP3_SET_BITS(reg_data[0], BMP3_TEMP_OS, osr_settings.temp_os);
2223 }
2224
2225 /* 0x1C is the register address of over sampling register */
2226 addr[*len] = BMP3_REG_OSR;
2227 (*len)++;
2228 }
2229}
#define BMP3_REG_OSR
Definition bmp3_defs.h:159
#define BMP3_SEL_PRESS_OS
Definition bmp3_defs.h:284
#define BMP3_SEL_TEMP_OS
Definition bmp3_defs.h:285

References BMP3_REG_OSR, BMP3_SEL_PRESS_OS, BMP3_SEL_TEMP_OS, BMP3_SET_BITS, BMP3_SET_BITS_POS_0, bmp3_settings::odr_filter, bmp3_odr_filter_settings::press_os, and bmp3_odr_filter_settings::temp_os.

Referenced by set_odr_filter_settings().

Here is the caller graph for this function:

◆ get_calib_data()

static int8_t get_calib_data ( struct bmp3_dev dev)
static

This internal API reads the calibration data from the sensor, parse it then compensates it and store in the device structure.

Parameters
[in]dev: Structure instance of bmp3_dev.
Returns
Result of API execution status
Return values
0-> Success
>0-> Warning
<0-> Fail

Definition at line 1786 of file bmp3.c.

1787{
1788 int8_t rslt;
1789 uint8_t reg_addr = BMP3_REG_CALIB_DATA;
1790
1791 /* Array to store calibration data */
1792 uint8_t calib_data[BMP3_LEN_CALIB_DATA] = { 0 };
1793
1794 /* Read the calibration data from the sensor */
1795 rslt = bmp3_get_regs(reg_addr, calib_data, BMP3_LEN_CALIB_DATA, dev);
1796
1797 /* Parse calibration data and store it in device structure */
1798 parse_calib_data(calib_data, dev);
1799
1800 return rslt;
1801}
static void parse_calib_data(const uint8_t *reg_data, struct bmp3_dev *dev)
This internal API is used to parse the calibration data, compensates it and store it in device struct...
Definition bmp3.c:2545
#define BMP3_LEN_CALIB_DATA
Definition bmp3_defs.h:439
#define BMP3_REG_CALIB_DATA
Definition bmp3_defs.h:162

References bmp3_get_regs(), BMP3_LEN_CALIB_DATA, BMP3_REG_CALIB_DATA, and parse_calib_data().

Referenced by bmp3_init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_err_status()

static int8_t get_err_status ( struct bmp3_status status,
struct bmp3_dev dev 
)
static

This API gets the fatal, command and configuration error from the sensor.

Parameters
[out]Structure instance of bmp3_status
[in]dev: Structure instance of bmp3_dev
Returns
Result of API execution status.
Return values
0-> Success
<0-> Fail

Definition at line 2945 of file bmp3.c.

2946{
2947 int8_t rslt;
2948 uint8_t reg_data;
2949
2950 rslt = bmp3_get_regs(BMP3_REG_ERR, &reg_data, 1, dev);
2951
2952 if (rslt == BMP3_OK)
2953 {
2954 status->err.fatal = BMP3_GET_BITS_POS_0(reg_data, BMP3_ERR_FATAL);
2955 status->err.cmd = BMP3_GET_BITS(reg_data, BMP3_ERR_CMD);
2956 status->err.conf = BMP3_GET_BITS(reg_data, BMP3_ERR_CONF);
2957 }
2958
2959 return rslt;
2960}
#define BMP3_GET_BITS_POS_0(reg_data, bitname)
Definition bmp3_defs.h:433
#define BMP3_ERR_CONF
Definition bmp3_defs.h:168
#define BMP3_ERR_CMD
Definition bmp3_defs.h:167
#define BMP3_ERR_FATAL
Definition bmp3_defs.h:166
struct bmp3_err_status err
Definition bmp3_defs.h:677

References BMP3_ERR_CMD, BMP3_ERR_CONF, BMP3_ERR_FATAL, BMP3_GET_BITS, BMP3_GET_BITS_POS_0, bmp3_get_regs(), BMP3_OK, BMP3_REG_ERR, bmp3_err_status::cmd, bmp3_err_status::conf, bmp3_status::err, and bmp3_err_status::fatal.

Referenced by bmp3_get_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_int_status()

static int8_t get_int_status ( struct bmp3_status status,
struct bmp3_dev dev 
)
static

This API gets the interrupt (fifo watermark, fifo full, data ready) status from the sensor.

Parameters
[out]Structure instance of bmp3_status
[in]dev: Structure instance of bmp3_dev
Returns
Result of API execution status.
Return values
0-> Success
<0-> Fail

Definition at line 2924 of file bmp3.c.

2925{
2926 int8_t rslt;
2927 uint8_t reg_data;
2928
2929 rslt = bmp3_get_regs(BMP3_REG_INT_STATUS, &reg_data, 1, dev);
2930
2931 if (rslt == BMP3_OK)
2932 {
2933 status->intr.fifo_wm = BMP3_GET_BITS_POS_0(reg_data, BMP3_INT_STATUS_FWTM);
2934 status->intr.fifo_full = BMP3_GET_BITS(reg_data, BMP3_INT_STATUS_FFULL);
2935 status->intr.drdy = BMP3_GET_BITS(reg_data, BMP3_INT_STATUS_DRDY);
2936 }
2937
2938 return rslt;
2939}
#define BMP3_REG_INT_STATUS
Definition bmp3_defs.h:150
uint8_t fifo_wm
Definition bmp3_defs.h:639
uint8_t fifo_full
Definition bmp3_defs.h:642
struct bmp3_int_status intr
Definition bmp3_defs.h:671

References BMP3_GET_BITS, BMP3_GET_BITS_POS_0, bmp3_get_regs(), BMP3_OK, BMP3_REG_INT_STATUS, bmp3_int_status::drdy, bmp3_int_status::fifo_full, bmp3_int_status::fifo_wm, and bmp3_status::intr.

Referenced by bmp3_get_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_odr_filter_settings()

static int8_t get_odr_filter_settings ( struct bmp3_settings settings,
struct bmp3_dev dev 
)
static

This internal API gets the over sampling, ODR and filter settings from the sensor.

This internal API gets the over sampling, ODR and filter settings of the sensor.

Parameters
[in]settings: Structure instance of bmp3_settings.
[in]dev: Structure instance of bmp3_dev.
Returns
Result of API execution status
Return values
0-> Success
>0-> Warning
<0-> Fail

Definition at line 2072 of file bmp3.c.

2073{
2074 int8_t rslt;
2075 uint8_t reg_data[4];
2076
2077 /* Read data beginning from 0x1C register */
2078 rslt = bmp3_get_regs(BMP3_REG_OSR, reg_data, 4, dev);
2079
2080 /* Parse the read data and store it in dev structure */
2081 parse_odr_filter_settings(reg_data, &settings->odr_filter);
2082
2083 return rslt;
2084}
static void parse_odr_filter_settings(const uint8_t *reg_data, struct bmp3_odr_filter_settings *settings)
This internal API parse the over sampling, ODR and filter settings and store in the device structure.
Definition bmp3.c:1870

References bmp3_get_regs(), BMP3_REG_OSR, bmp3_settings::odr_filter, and parse_odr_filter_settings().

Referenced by validate_normal_mode_settings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_sensor_status()

static int8_t get_sensor_status ( struct bmp3_status status,
struct bmp3_dev dev 
)
static

This internal API fills the fifo_config_1(fifo_mode, fifo_stop_on_full, fifo_time_en, fifo_press_en, fifo_temp_en) settings in the reg_data variable so as to burst write in the sensor.

This internal API is used to parse the fifo_config_1(fifo_mode, fifo_stop_on_full, fifo_time_en, fifo_press_en, fifo_temp_en), fifo_config_2(fifo_subsampling, data_select) and int_ctrl(fwtm_en, ffull_en) settings and store it in device structure.

Parameters
[in]desired_settings: Variable which specifies the settings which are to be set in the sensor.
[in]fifo_settings: Structure instance of bmp3_fifo_settings
[in]dev: Structure instance of bmp3_dev
 @brief This internal API fills the fifo_config_2(fifo_sub_sampling,
 data_select) settings in the reg_data variable so as to burst write
 in the sensor.

 @param[in] desired_settings : Variable which specifies the settings which
                               are to be set in the sensor.
 @param[in] fifo_settings    : Structure instance of bmp3_fifo_settings
 @param[in] dev              : Structure instance of bmp3_dev
&zwj;/

static int8_t fill_fifo_config_2(uint16_t desired_settings, const struct bmp3_fifo_settings *fifo_settings, struct bmp3_dev *dev);

/*!

This internal API fills the fifo interrupt control(fwtm_en, ffull_en) settings in the reg_data variable so as to burst write in the sensor.

Parameters
[in]desired_settings: Variable which specifies the settings which are to be set in the sensor.
[in]fifo_settings: Structure instance of bmp3_fifo_settings
[in]dev: Structure instance of bmp3_dev ‍/ static int8_t fill_fifo_int_ctrl(uint16_t desired_settings, const struct bmp3_fifo_settings *fifo_settings, struct bmp3_dev *dev);

/*!

This internal API is used to parse the fifo_config_1(fifo_mode, fifo_stop_on_full, fifo_time_en, fifo_press_en, fifo_temp_en), fifo_config_2(fifo_subsampling, data_select) and int_ctrl(fwtm_en, ffull_en) settings and store it in device structure

Parameters
[in]reg_data: Pointer variable which stores the fifo settings data read from the sensor.
[out]fifo_settings: Structure instance of bmp3_fifo_settings which contains the fifo settings after parsing. ‍/ static void parse_fifo_settings(const uint8_t *reg_data, struct bmp3_fifo_settings *fifo_settings);

/*!

This internal API parse the FIFO data frame from the fifo buffer and fills the byte count, uncompensated pressure and/or temperature data and no of parsed frames.

Parameters
[in]header: Pointer variable which stores the fifo settings data read from the sensor.
[in,out]fifo: Structure instance of bmp3_fifo
[out]byte_index: Byte count which is incremented according to the of data.
[out]uncomp_data: Uncompensated pressure and/or temperature data which is stored after parsing fifo buffer data.
[out]parsed_frames: Total number of parsed frames.
Returns
Result of API execution status.
Return values
0-> Success
<0-> Fail ‍/ static uint8_t parse_fifo_data_frame(uint8_t header, struct bmp3_fifo_data *fifo, uint16_t *byte_index, struct bmp3_uncomp_data *uncomp_data, uint8_t *parsed_frames);

/*!

This internal API unpacks the FIFO data frame from the fifo buffer and fills the byte count, uncompensated pressure and/or temperature data.

Parameters
[out]byte_index: Byte count of fifo buffer.
[in]fifo_buffer: FIFO buffer from where the temperature and pressure frames are unpacked.
[out]uncomp_data: Uncompensated temperature and pressure data after unpacking from fifo buffer. ‍/ static void unpack_temp_press_frame(uint16_t *byte_index, const uint8_t *fifo_buffer, struct bmp3_uncomp_data *uncomp_data);

/*!

This internal API unpacks the FIFO data frame from the fifo buffer and fills the byte count and uncompensated pressure data.

Parameters
[out]byte_index: Byte count of fifo buffer.
[in]fifo_buffer: FIFO buffer from where the pressure frames are unpacked.
[out]uncomp_data: Uncompensated pressure data after unpacking from fifo buffer. ‍/ static void unpack_press_frame(uint16_t *byte_index, const uint8_t *fifo_buffer, struct bmp3_uncomp_data *uncomp_data);

/*!

This internal API unpacks the FIFO data frame from the fifo buffer and fills the byte count and uncompensated temperature data.

Parameters
[out]byte_index: Byte count of fifo buffer.
[in]fifo_buffer: FIFO buffer from where the temperature frames are unpacked.
[out]uncomp_data: Uncompensated temperature data after unpacking from fifo buffer. ‍/ static void unpack_temp_frame(uint16_t *byte_index, const uint8_t *fifo_buffer, struct bmp3_uncomp_data *uncomp_data);

/*!

This internal API unpacks the time frame from the fifo data buffer and fills the byte count and update the sensor time variable.

Parameters
[out]byte_index: Byte count of fifo buffer.
[in]fifo_buffer: FIFO buffer from where the sensor time frames are unpacked.
[out]sensor_time: Variable used to store the sensor time. ‍/ static void unpack_time_frame(uint16_t *byte_index, const uint8_t *fifo_buffer, uint32_t *sensor_time);

/*!

This internal API parses the FIFO buffer and gets the header info.

Parameters
[out]header: Variable used to store the fifo header data.
[in]fifo_buffer: FIFO buffer from where the header data is retrieved.
[out]byte_index: Byte count of fifo buffer. ‍/ static void get_header_info(uint8_t *header, const uint8_t *fifo_buffer, uint16_t *byte_index);

/*!

This internal API parses the FIFO data frame from the fifo buffer and fills uncompensated temperature and/or pressure data.

Parameters
[in]sensor_comp: Variable used to select either temperature or pressure or both while parsing the fifo frames.
[in]fifo_buffer: FIFO buffer where the temperature or pressure or both the data to be parsed.
[out]uncomp_data: Uncompensated temperature or pressure or both the data after unpacking from fifo buffer. ‍/ static void parse_fifo_sensor_data(uint8_t sensor_comp, const uint8_t *fifo_buffer, struct bmp3_uncomp_data *uncomp_data);

/*!

This internal API resets the FIFO buffer, start index, parsed frame count, configuration change, configuration error and frame_not_available variables.

Parameters
[out]fifo: FIFO structure instance where the fifo related variables are reset. ‍/ static void reset_fifo_index(struct bmp3_fifo_data *fifo);

/*!

This API gets the command ready, data ready for pressure and temperature, power on reset status from the sensor.

Parameters
[out]Structure instance of bmp3_status
[in]dev: Structure instance of bmp3_dev
Returns
Result of API execution status.
Return values
0-> Success
<0-> Fail
 @brief This internal API fills the fifo_config_1(fifo_mode,
 fifo_stop_on_full, fifo_time_en, fifo_press_en, fifo_temp_en) settings in the
 reg_data variable so as to burst write in the sensor.
&zwj;/

static int8_t fill_fifo_config_1(uint16_t desired_settings, const struct bmp3_fifo_settings *fifo_settings, struct bmp3_dev *dev) { int8_t rslt; uint8_t reg_addr = BMP3_REG_FIFO_CONFIG_1; uint8_t reg_data;

rslt = bmp3_get_regs(reg_addr, &reg_data, 1, dev);

if (rslt == BMP3_OK) { if (desired_settings & BMP3_SEL_FIFO_MODE) { /* Fill the FIFO mode register data *‍/ reg_data = BMP3_SET_BITS_POS_0(reg_data, BMP3_FIFO_MODE, fifo_settings->mode); }

if (desired_settings & BMP3_SEL_FIFO_STOP_ON_FULL_EN) { /* Fill the stop on full data *‍/ reg_data = BMP3_SET_BITS(reg_data, BMP3_FIFO_STOP_ON_FULL, fifo_settings->stop_on_full_en); }

if (desired_settings & BMP3_SEL_FIFO_TIME_EN) { /* Fill the time enable data *‍/ reg_data = BMP3_SET_BITS(reg_data, BMP3_FIFO_TIME_EN, fifo_settings->time_en); }

if (desired_settings & (BMP3_SEL_FIFO_PRESS_EN | BMP3_SEL_FIFO_TEMP_EN)) { /* Fill the pressure enable data *‍/ reg_data = BMP3_SET_BITS(reg_data, BMP3_FIFO_PRESS_EN, fifo_settings->press_en);

/* Fill the temperature enable data *‍/ reg_data = BMP3_SET_BITS(reg_data, BMP3_FIFO_TEMP_EN, fifo_settings->temp_en); }

/* Write the power control settings in the register *‍/ rslt = bmp3_set_regs(&reg_addr, &reg_data, 1, dev); }

return rslt; }

/*!

This internal API fills the fifo_config_2(fifo_subsampling, data_select) settings in the reg_data variable so as to burst write in the sensor. ‍/ static int8_t fill_fifo_config_2(uint16_t desired_settings, const struct bmp3_fifo_settings *fifo_settings, struct bmp3_dev *dev) { int8_t rslt; uint8_t reg_addr = BMP3_REG_FIFO_CONFIG_2; uint8_t reg_data;

rslt = bmp3_get_regs(reg_addr, &reg_data, 1, dev);

if (rslt == BMP3_OK) { if (desired_settings & BMP3_SEL_FIFO_DOWN_SAMPLING) { /* To do check Normal mode ‍/ / Fill the down-sampling data *‍/ reg_data = BMP3_SET_BITS_POS_0(reg_data, BMP3_FIFO_DOWN_SAMPLING, fifo_settings->down_sampling); }

if (desired_settings & BMP3_SEL_FIFO_FILTER_EN) { /* Fill the filter enable data *‍/ reg_data = BMP3_SET_BITS(reg_data, BMP3_FIFO_FILTER_EN, fifo_settings->filter_en); }

/* Write the power control settings in the register *‍/ rslt = bmp3_set_regs(&reg_addr, &reg_data, 1, dev); }

return rslt; }

/*!

This internal API fills the fifo interrupt control(fwtm_en, ffull_en) settings in the reg_data variable so as to burst write in the sensor. ‍/ static int8_t fill_fifo_int_ctrl(uint16_t desired_settings, const struct bmp3_fifo_settings *fifo_settings, struct bmp3_dev *dev) { int8_t rslt; uint8_t reg_addr = BMP3_REG_INT_CTRL; uint8_t reg_data;

rslt = bmp3_get_regs(reg_addr, &reg_data, 1, dev);

if (rslt == BMP3_OK) { if (desired_settings & BMP3_SEL_FIFO_FWTM_EN) { /* Fill the FIFO watermark interrupt enable data *‍/ reg_data = BMP3_SET_BITS(reg_data, BMP3_FIFO_FWTM_EN, fifo_settings->fwtm_en); }

if (desired_settings & BMP3_SEL_FIFO_FULL_EN) { /* Fill the FIFO full interrupt enable data *‍/ reg_data = BMP3_SET_BITS(reg_data, BMP3_FIFO_FULL_EN, fifo_settings->ffull_en); }

/* Write the power control settings in the register *‍/ rslt = bmp3_set_regs(&reg_addr, &reg_data, 1, dev); }

return rslt; }

/*!

This API gets the command ready, data ready for pressure and temperature, power on reset status from the sensor.

Definition at line 2898 of file bmp3.c.

2899{
2900 int8_t rslt;
2901 uint8_t reg_addr;
2902 uint8_t reg_data;
2903
2904 reg_addr = BMP3_REG_SENS_STATUS;
2905 rslt = bmp3_get_regs(reg_addr, &reg_data, 1, dev);
2906
2907 if (rslt == BMP3_OK)
2908 {
2909 status->sensor.cmd_rdy = BMP3_GET_BITS(reg_data, BMP3_STATUS_CMD_RDY);
2910 status->sensor.drdy_press = BMP3_GET_BITS(reg_data, BMP3_STATUS_DRDY_PRESS);
2911 status->sensor.drdy_temp = BMP3_GET_BITS(reg_data, BMP3_STATUS_DRDY_TEMP);
2912 reg_addr = BMP3_REG_EVENT;
2913 rslt = bmp3_get_regs(reg_addr, &reg_data, 1, dev);
2914 status->pwr_on_rst = reg_data & 0x01;
2915 }
2916
2917 return rslt;
2918}
#define BMP3_REG_EVENT
Definition bmp3_defs.h:149
uint8_t drdy_press
Definition bmp3_defs.h:626
uint8_t drdy_temp
Definition bmp3_defs.h:629
struct bmp3_sens_status sensor
Definition bmp3_defs.h:674
uint8_t pwr_on_rst
Definition bmp3_defs.h:680

References BMP3_GET_BITS, bmp3_get_regs(), BMP3_OK, BMP3_REG_EVENT, BMP3_REG_SENS_STATUS, bmp3_sens_status::cmd_rdy, bmp3_sens_status::drdy_press, bmp3_sens_status::drdy_temp, bmp3_status::pwr_on_rst, and bmp3_status::sensor.

Referenced by bmp3_get_status().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ interleave_reg_addr()

static void interleave_reg_addr ( const uint8_t *  reg_addr,
uint8_t *  temp_buff,
const uint8_t *  reg_data,
uint32_t  len 
)
static

This internal API interleaves the register address between the register data buffer for burst write operation.

Parameters
[in]reg_addr: Contains the register address array.
[out]temp_buff: Contains the temporary buffer to store the register data and register address.
[in]reg_data: Contains the register data to be written in the temporary buffer.
[in]len: No of bytes of data to be written for burst write.

Definition at line 1807 of file bmp3.c.

1808{
1809 uint32_t index;
1810
1811 for (index = 1; index < len; index++)
1812 {
1813 temp_buff[(index * 2) - 1] = reg_addr[index];
1814 temp_buff[index * 2] = reg_data[index];
1815 }
1816}

Referenced by bmp3_set_regs().

Here is the caller graph for this function:

◆ null_ptr_check()

static int8_t null_ptr_check ( const struct bmp3_dev dev)
static

This internal API is used to validate the device pointer for null conditions.

This internal API is used to validate the device structure pointer for null conditions.

Parameters
[in]dev: Structure instance of bmp3_dev.
Returns
Result of API execution status
Return values
0-> Success
>0-> Warning
<0-> Fail

Definition at line 2724 of file bmp3.c.

2725{
2726 int8_t rslt;
2727
2728 if ((dev == NULL) || (dev->read == NULL) || (dev->write == NULL) || (dev->delay_us == NULL) ||
2729 (dev->intf_ptr == NULL))
2730 {
2731 /* Device structure pointer is not valid */
2732 rslt = BMP3_E_NULL_PTR;
2733 }
2734 else
2735 {
2736 /* Device structure is fine */
2737 rslt = BMP3_OK;
2738 }
2739
2740 return rslt;
2741}

References BMP3_E_NULL_PTR, BMP3_OK, bmp3_dev::delay_us, bmp3_dev::intf_ptr, NULL, bmp3_dev::read, and bmp3_dev::write.

Referenced by bmp3_get_regs(), bmp3_init(), bmp3_set_op_mode(), and bmp3_set_regs().

Here is the caller graph for this function:

◆ parse_advance_settings()

static void parse_advance_settings ( const uint8_t *  reg_data,
struct bmp3_adv_settings settings 
)
static

This internal API parse the advance (i2c_wdt_en, i2c_wdt_sel) settings and store in the device structure.

Parameters
[in]reg_data: Pointer variable which stores the register data to parse.
[out]settings: Structure instance of bmp3_adv_settings.

Definition at line 1849 of file bmp3.c.

1850{
1851 settings->i2c_wdt_en = BMP3_GET_BITS(*reg_data, BMP3_I2C_WDT_EN);
1852 settings->i2c_wdt_sel = BMP3_GET_BITS(*reg_data, BMP3_I2C_WDT_SEL);
1853}
uint8_t i2c_wdt_sel
Definition bmp3_defs.h:594

References BMP3_GET_BITS, bmp3_adv_settings::i2c_wdt_en, and bmp3_adv_settings::i2c_wdt_sel.

Referenced by parse_sett_data().

Here is the caller graph for this function:

◆ parse_calib_data()

static void parse_calib_data ( const uint8_t *  reg_data,
struct bmp3_dev dev 
)
static

This internal API is used to parse the calibration data, compensates it and store it in device structure.

Parameters
[in]dev: Structure instance of bmp3_dev.
[out]reg_data: Contains calibration data to be parsed.

Definition at line 2545 of file bmp3.c.

2546{
2547 /* Temporary variable to store the aligned trim data */
2548 struct bmp3_reg_calib_data *reg_calib_data = &dev->calib_data.reg_calib_data;
2549
2550 reg_calib_data->par_t1 = BMP3_CONCAT_BYTES(reg_data[1], reg_data[0]);
2551 reg_calib_data->par_t2 = BMP3_CONCAT_BYTES(reg_data[3], reg_data[2]);
2552 reg_calib_data->par_t3 = (int8_t)reg_data[4];
2553 reg_calib_data->par_p1 = (int16_t)BMP3_CONCAT_BYTES(reg_data[6], reg_data[5]);
2554 reg_calib_data->par_p2 = (int16_t)BMP3_CONCAT_BYTES(reg_data[8], reg_data[7]);
2555 reg_calib_data->par_p3 = (int8_t)reg_data[9];
2556 reg_calib_data->par_p4 = (int8_t)reg_data[10];
2557 reg_calib_data->par_p5 = BMP3_CONCAT_BYTES(reg_data[12], reg_data[11]);
2558 reg_calib_data->par_p6 = BMP3_CONCAT_BYTES(reg_data[14], reg_data[13]);
2559 reg_calib_data->par_p7 = (int8_t)reg_data[15];
2560 reg_calib_data->par_p8 = (int8_t)reg_data[16];
2561 reg_calib_data->par_p9 = (int16_t)BMP3_CONCAT_BYTES(reg_data[18], reg_data[17]);
2562 reg_calib_data->par_p10 = (int8_t)reg_data[19];
2563 reg_calib_data->par_p11 = (int8_t)reg_data[20];
2564}

References BMP3_CONCAT_BYTES, bmp3_dev::calib_data, bmp3_reg_calib_data::par_p1, bmp3_reg_calib_data::par_p10, bmp3_reg_calib_data::par_p11, bmp3_reg_calib_data::par_p2, bmp3_reg_calib_data::par_p3, bmp3_reg_calib_data::par_p4, bmp3_reg_calib_data::par_p5, bmp3_reg_calib_data::par_p6, bmp3_reg_calib_data::par_p7, bmp3_reg_calib_data::par_p8, bmp3_reg_calib_data::par_p9, bmp3_reg_calib_data::par_t1, bmp3_reg_calib_data::par_t2, bmp3_reg_calib_data::par_t3, and bmp3_calib_data::reg_calib_data.

Referenced by get_calib_data().

Here is the caller graph for this function:

◆ parse_int_ctrl_settings()

static void parse_int_ctrl_settings ( const uint8_t *  reg_data,
struct bmp3_int_ctrl_settings settings 
)
static

This internal API parse the interrupt control(output mode, level, latch and data ready) settings and store in the device structure.

Parameters
[in]reg_data: Pointer variable which stores the register data to parse.
[out]settings: Structure instance of bmp3_int_ctrl_settings.

Definition at line 1842 of file bmp3.c.

1843{
1844 settings->output_mode = BMP3_GET_BITS_POS_0(*reg_data, BMP3_INT_OUTPUT_MODE);
1845 settings->level = BMP3_GET_BITS(*reg_data, BMP3_INT_LEVEL);
1846 settings->latch = BMP3_GET_BITS(*reg_data, BMP3_INT_LATCH);
1847 settings->drdy_en = BMP3_GET_BITS(*reg_data, BMP3_INT_DRDY_EN);
1848}

References BMP3_GET_BITS, BMP3_GET_BITS_POS_0, bmp3_int_ctrl_settings::drdy_en, bmp3_int_ctrl_settings::latch, bmp3_int_ctrl_settings::level, and bmp3_int_ctrl_settings::output_mode.

Referenced by parse_sett_data().

Here is the caller graph for this function:

◆ parse_odr_filter_settings()

static void parse_odr_filter_settings ( const uint8_t *  reg_data,
struct bmp3_odr_filter_settings settings 
)
static

This internal API parse the over sampling, ODR and filter settings and store in the device structure.

Parameters
[in]reg_data: Pointer variable which stores the register data to parse.
[out]settings: Structure instance of bmp3_odr_filter_settings.

Definition at line 1870 of file bmp3.c.

1871{
1872 uint8_t index = 0;
1873
1874 /* ODR and filter settings index starts from one (0x1C register) */
1875 settings->press_os = BMP3_GET_BITS_POS_0(reg_data[index], BMP3_PRESS_OS);
1876 settings->temp_os = BMP3_GET_BITS(reg_data[index], BMP3_TEMP_OS);
1877
1878 /* Move index to 0x1D register */
1879 index++;
1880 settings->odr = BMP3_GET_BITS_POS_0(reg_data[index], BMP3_ODR);
1881
1882 /* Move index to 0x1F register */
1883 index = index + 2;
1884 settings->iir_filter = BMP3_GET_BITS(reg_data[index], BMP3_IIR_FILTER);
1885}

References BMP3_GET_BITS, BMP3_GET_BITS_POS_0, bmp3_odr_filter_settings::iir_filter, bmp3_odr_filter_settings::odr, bmp3_odr_filter_settings::press_os, and bmp3_odr_filter_settings::temp_os.

Referenced by get_odr_filter_settings(), and parse_sett_data().

Here is the caller graph for this function:

◆ parse_pwr_ctrl_settings()

static void parse_pwr_ctrl_settings ( const uint8_t *  reg_data,
struct bmp3_settings settings 
)
static

This internal API parse the power control(power mode, pressure enable and temperature enable) settings and store in the device structure.

Parameters
[in]reg_data: Pointer variable which stores the register data to parse.
[out]settings: Structure instance of bmp3_settings.

Definition at line 1859 of file bmp3.c.

1860{
1861 settings->op_mode = BMP3_GET_BITS(*reg_data, BMP3_OP_MODE);
1862 settings->press_en = BMP3_GET_BITS_POS_0(*reg_data, BMP3_PRESS_EN);
1863 settings->temp_en = BMP3_GET_BITS(*reg_data, BMP3_TEMP_EN);
1864}
uint8_t temp_en
Definition bmp3_defs.h:715
uint8_t press_en
Definition bmp3_defs.h:712

References BMP3_GET_BITS, BMP3_GET_BITS_POS_0, bmp3_settings::op_mode, bmp3_settings::press_en, and bmp3_settings::temp_en.

Referenced by parse_sett_data().

Here is the caller graph for this function:

◆ parse_sensor_data()

static void parse_sensor_data ( const uint8_t *  reg_data,
struct bmp3_uncomp_data uncomp_data 
)
static

This internal API is used to parse the pressure and temperature data and store it in the bmp3_uncomp_data structure instance.

This internal API is used to parse the pressure or temperature or both the data and store it in the bmp3_uncomp_data structure instance.

Parameters
[in]reg_data: Contains the register data which needs to be parsed.
[out]uncomp_data: Contains the uncompensated press and temp data.

Definition at line 2273 of file bmp3.c.

2274{
2275 /* Temporary variables to store the sensor data */
2276 uint32_t data_xlsb;
2277 uint32_t data_lsb;
2278 uint32_t data_msb;
2279
2280 /* Store the parsed register values for pressure data */
2281 data_xlsb = (uint32_t)reg_data[0];
2282 data_lsb = (uint32_t)reg_data[1] << 8;
2283 data_msb = (uint32_t)reg_data[2] << 16;
2284 uncomp_data->pressure = data_msb | data_lsb | data_xlsb;
2285
2286 /* Store the parsed register values for temperature data */
2287 data_xlsb = (uint32_t)reg_data[3];
2288 data_lsb = (uint32_t)reg_data[4] << 8;
2289 data_msb = (uint32_t)reg_data[5] << 16;
2290 uncomp_data->temperature = data_msb | data_lsb | data_xlsb;
2291}

References bmp3_uncomp_data::pressure, and bmp3_uncomp_data::temperature.

Referenced by bmp3_get_sensor_data().

Here is the caller graph for this function:

◆ parse_sett_data()

static void parse_sett_data ( const uint8_t *  reg_data,
struct bmp3_settings settings 
)
static

This internal API parse the power control(power mode, pressure enable and temperature enable), over sampling, ODR, filter and interrupt control settings and store in the device structure.

This internal API parse the power control(power mode, pressure enable and temperature enable), over sampling, ODR, filter, interrupt control and advance settings and store in the device structure.

Parameters
[in]reg_data: Register data to be parsed.
[in]settings: Structure instance of bmp3_settings

Definition at line 1823 of file bmp3.c.

1824{
1825 /* Parse interrupt control settings and store in device structure */
1826 parse_int_ctrl_settings(&reg_data[0], &settings->int_settings);
1827
1828 /* Parse advance settings and store in device structure */
1829 parse_advance_settings(&reg_data[1], &settings->adv_settings);
1830
1831 /* Parse power control settings and store in device structure */
1832 parse_pwr_ctrl_settings(&reg_data[2], settings);
1833
1834 /* Parse ODR and filter settings and store in device structure */
1835 parse_odr_filter_settings(&reg_data[3], &settings->odr_filter);
1836}
static void parse_advance_settings(const uint8_t *reg_data, struct bmp3_adv_settings *settings)
This internal API parse the advance (i2c_wdt_en, i2c_wdt_sel) settings and store in the device struct...
Definition bmp3.c:1849
static void parse_pwr_ctrl_settings(const uint8_t *reg_data, struct bmp3_settings *settings)
This internal API parse the power control(power mode, pressure enable and temperature enable) setting...
Definition bmp3.c:1859
static void parse_int_ctrl_settings(const uint8_t *reg_data, struct bmp3_int_ctrl_settings *settings)
This internal API parse the interrupt control(output mode, level, latch and data ready) settings and ...
Definition bmp3.c:1842
struct bmp3_int_ctrl_settings int_settings
Definition bmp3_defs.h:721
struct bmp3_adv_settings adv_settings
Definition bmp3_defs.h:724

References bmp3_settings::adv_settings, bmp3_settings::int_settings, bmp3_settings::odr_filter, parse_advance_settings(), parse_int_ctrl_settings(), parse_odr_filter_settings(), and parse_pwr_ctrl_settings().

Referenced by bmp3_get_sensor_settings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pow_bmp3()

static uint32_t pow_bmp3 ( uint8_t  base,
uint8_t  power 
)
static

This internal API is used to calculate the power functionality.

Parameters
[in]base: Contains the base value.
[in]power: Contains the power value.
Returns
Output of power function.
Return values
Calculatedpower function output in integer.

Definition at line 2683 of file bmp3.c.

2684{
2685 uint32_t pow_output = 1;
2686
2687 while (power != 0)
2688 {
2689 pow_output = base * pow_output;
2690 power--;
2691 }
2692
2693 return pow_output;
2694}

Referenced by calculate_press_meas_time(), and calculate_temp_meas_time().

Here is the caller graph for this function:

◆ put_device_to_sleep()

static int8_t put_device_to_sleep ( struct bmp3_dev dev)
static

This internal API puts the device to sleep mode.

Parameters
[in]dev: Structure instance of bmp3_dev.
Returns
Result of API execution status.
Return values
0-> Success
>0-> Warning
<0-> Fail

Definition at line 1743 of file bmp3.c.

1744{
1745 int8_t rslt;
1746 uint8_t reg_addr = BMP3_REG_PWR_CTRL;
1747
1748 /* Temporary variable to store the value read from op-mode register */
1749 uint8_t op_mode_reg_val;
1750
1751 rslt = bmp3_get_regs(BMP3_REG_PWR_CTRL, &op_mode_reg_val, 1, dev);
1752
1753 if (rslt == BMP3_OK)
1754 {
1755 /* Set the power mode */
1756 op_mode_reg_val = op_mode_reg_val & (~(BMP3_OP_MODE_MSK));
1757
1758 /* Write the power mode in the register */
1759 rslt = bmp3_set_regs(&reg_addr, &op_mode_reg_val, 1, dev);
1760 }
1761
1762 return rslt;
1763}
#define BMP3_OP_MODE_MSK
Definition bmp3_defs.h:345

References bmp3_get_regs(), BMP3_OK, BMP3_OP_MODE_MSK, BMP3_REG_PWR_CTRL, and bmp3_set_regs().

Referenced by bmp3_set_op_mode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_advance_settings()

static int8_t set_advance_settings ( uint32_t  desired_settings,
const struct bmp3_settings settings,
struct bmp3_dev dev 
)
static

This internal API sets the advance (i2c_wdt_en, i2c_wdt_sel) settings of the sensor based on the settings selected by the user.

Parameters
[in]desired_settings: Variable used to select the settings which are to be set.
[in]settings: Structure instance of bmp3_settings
[in]dev: Structure instance of bmp3_dev.
Returns
Result of API execution status
Return values
0-> Success
>0-> Warning
<0-> Fail

Definition at line 2037 of file bmp3.c.

2039{
2040 int8_t rslt;
2041 uint8_t reg_addr;
2042 uint8_t reg_data;
2043 struct bmp3_adv_settings adv_settings = settings->adv_settings;
2044
2045 reg_addr = BMP3_REG_IF_CONF;
2046 rslt = bmp3_get_regs(reg_addr, &reg_data, 1, dev);
2047
2048 if (rslt == BMP3_OK)
2049 {
2050 if (desired_settings & BMP3_SEL_I2C_WDT_EN)
2051 {
2052 /* Set the i2c watch dog enable bits */
2053 reg_data = BMP3_SET_BITS(reg_data, BMP3_I2C_WDT_EN, adv_settings.i2c_wdt_en);
2054 }
2055
2056 if (desired_settings & BMP3_SEL_I2C_WDT)
2057 {
2058 /* Set the i2c watch dog select bits */
2059 reg_data = BMP3_SET_BITS(reg_data, BMP3_I2C_WDT_SEL, adv_settings.i2c_wdt_sel);
2060 }
2061
2062 rslt = bmp3_set_regs(&reg_addr, &reg_data, 1, dev);
2063 }
2064
2065 return rslt;
2066}
#define BMP3_SEL_I2C_WDT
Definition bmp3_defs.h:292
#define BMP3_REG_IF_CONF
Definition bmp3_defs.h:157
#define BMP3_SEL_I2C_WDT_EN
Definition bmp3_defs.h:291
bmp3 advance settings
Definition bmp3_defs.h:589

References bmp3_settings::adv_settings, bmp3_get_regs(), BMP3_OK, BMP3_REG_IF_CONF, BMP3_SEL_I2C_WDT, BMP3_SEL_I2C_WDT_EN, BMP3_SET_BITS, bmp3_set_regs(), bmp3_adv_settings::i2c_wdt_en, and bmp3_adv_settings::i2c_wdt_sel.

Referenced by bmp3_set_sensor_settings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_int_ctrl_settings()

static int8_t set_int_ctrl_settings ( uint32_t  desired_settings,
const struct bmp3_settings settings,
struct bmp3_dev dev 
)
static

This internal API sets the interrupt control (output mode, level, latch and data ready) settings of the sensor based on the settings selected by the user.

Parameters
[in]desired_settings: Variable used to select the settings which are to be set.
[in]settings: Structure instance of bmp3_settings
[in]dev: Structure instance of bmp3_dev.
Returns
Result of API execution status
Return values
0-> Success
>0-> Warning
<0-> Fail

Definition at line 1987 of file bmp3.c.

1990{
1991 int8_t rslt;
1992 uint8_t reg_data;
1993 uint8_t reg_addr;
1994 struct bmp3_int_ctrl_settings int_settings;
1995
1996 reg_addr = BMP3_REG_INT_CTRL;
1997 rslt = bmp3_get_regs(reg_addr, &reg_data, 1, dev);
1998
1999 if (rslt == BMP3_OK)
2000 {
2001 int_settings = settings->int_settings;
2002
2003 if (desired_settings & BMP3_SEL_OUTPUT_MODE)
2004 {
2005 /* Set the interrupt output mode bits */
2006 reg_data = BMP3_SET_BITS_POS_0(reg_data, BMP3_INT_OUTPUT_MODE, int_settings.output_mode);
2007 }
2008
2009 if (desired_settings & BMP3_SEL_LEVEL)
2010 {
2011 /* Set the interrupt level bits */
2012 reg_data = BMP3_SET_BITS(reg_data, BMP3_INT_LEVEL, int_settings.level);
2013 }
2014
2015 if (desired_settings & BMP3_SEL_LATCH)
2016 {
2017 /* Set the interrupt latch bits */
2018 reg_data = BMP3_SET_BITS(reg_data, BMP3_INT_LATCH, int_settings.latch);
2019 }
2020
2021 if (desired_settings & BMP3_SEL_DRDY_EN)
2022 {
2023 /* Set the interrupt data ready bits */
2024 reg_data = BMP3_SET_BITS(reg_data, BMP3_INT_DRDY_EN, int_settings.drdy_en);
2025 }
2026
2027 rslt = bmp3_set_regs(&reg_addr, &reg_data, 1, dev);
2028 }
2029
2030 return rslt;
2031}
#define BMP3_SEL_OUTPUT_MODE
Definition bmp3_defs.h:288
#define BMP3_SEL_LEVEL
Definition bmp3_defs.h:289
#define BMP3_SEL_DRDY_EN
Definition bmp3_defs.h:283
#define BMP3_SEL_LATCH
Definition bmp3_defs.h:290
bmp3 interrupt pin settings
Definition bmp3_defs.h:688

References bmp3_get_regs(), BMP3_OK, BMP3_REG_INT_CTRL, BMP3_SEL_DRDY_EN, BMP3_SEL_LATCH, BMP3_SEL_LEVEL, BMP3_SEL_OUTPUT_MODE, BMP3_SET_BITS, BMP3_SET_BITS_POS_0, bmp3_set_regs(), bmp3_int_ctrl_settings::drdy_en, bmp3_settings::int_settings, bmp3_int_ctrl_settings::latch, bmp3_int_ctrl_settings::level, and bmp3_int_ctrl_settings::output_mode.

Referenced by bmp3_set_sensor_settings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_normal_mode()

static int8_t set_normal_mode ( struct bmp3_settings settings,
struct bmp3_dev dev 
)
static

This internal API sets the normal mode in the sensor.

This internal API converts the no. of frames required by the user to bytes so as to write in the watermark length register.

Parameters
[in]settings: Structure instance of bmp3_settings.
[in]dev: Structure instance of bmp3_dev.
Returns
Result of API execution status.
Return values
0-> Success
>0-> Warning
<0-> Fail
 @brief This internal API resets the FIFO buffer, start index,
 parsed frame count, configuration change, configuration error and
 frame_not_available variables.
&zwj;/

//static void reset_fifo_index(struct bmp3_fifo_data <em>fifo) //{ // / Loop variable ‍/ // uint16_t index; // // / Variable for FIFO size ‍/ // uint16_t fifo_size = 512; // // / The size of FIFO in BMP3 is 512 bytes ‍/ // for (index = 0; index < fifo_size; index++) // { // / Initialize data buffer to zero ‍/ // fifo->buffer[index] = 0; // } // // fifo->byte_count = 0; // fifo->start_idx = 0; // fifo->parsed_frames = 0; // fifo->config_change = 0; // fifo->config_err = 0; // fifo->frame_not_available = 0; //} // ///! // * This internal API parse the FIFO data frame from the fifo buffer and // * fills the byte count, uncompensated pressure and/or temperature data and no // * of parsed frames. // *‍/ //static uint8_t parse_fifo_data_frame(uint8_t header, // struct bmp3_fifo_data *fifo, // uint16_t *byte_index, // struct bmp3_uncomp_data *uncomp_data, // uint8_t *parsed_frames) //{ // uint8_t t_p_frame = FALSE; // // switch (header) // { // case BMP3_FIFO_TEMP_PRESS_FRAME: // unpack_temp_press_frame(byte_index, fifo->buffer, uncomp_data); // *parsed_frames = *parsed_frames + 1; // t_p_frame = BMP3_PRESS_TEMP; // break; // case BMP3_FIFO_TEMP_FRAME: // unpack_temp_frame(byte_index, fifo->buffer, uncomp_data); // *parsed_frames = *parsed_frames + 1; // t_p_frame = BMP3_TEMP; // break; // case BMP3_FIFO_PRESS_FRAME: // unpack_press_frame(byte_index, fifo->buffer, uncomp_data); // *parsed_frames = *parsed_frames + 1; // t_p_frame = BMP3_PRESS; // break; // case BMP3_FIFO_TIME_FRAME: // unpack_time_frame(byte_index, fifo->buffer, &fifo->sensor_time); // break; // case BMP3_FIFO_CONFIG_CHANGE: // fifo->config_change = 1; // *byte_index = *byte_index + 1; // break; // case BMP3_FIFO_ERROR_FRAME: // fifo->config_err = 1; // *byte_index = *byte_index + 1; // break; // case BMP3_FIFO_EMPTY_FRAME: // *byte_index = fifo->byte_count; // break; // default: // fifo->config_err = 1; // *byte_index = *byte_index + 1; // break; // } // // return t_p_frame; //}

/*!

This internal API unpacks the FIFO data frame from the fifo buffer and fills the byte count, uncompensated pressure and/or temperature data. ‍/ static void unpack_temp_press_frame(uint16_t *byte_index, const uint8_t *fifo_buffer, struct bmp3_uncomp_data *uncomp_data) { parse_fifo_sensor_data((BMP3_PRESS_TEMP), &fifo_buffer[*byte_index], uncomp_data); *byte_index = *byte_index + BMP3_LEN_P_T_DATA; }

/*!

This internal API unpacks the FIFO data frame from the fifo buffer and fills the byte count and uncompensated temperature data. ‍/ static void unpack_temp_frame(uint16_t *byte_index, const uint8_t *fifo_buffer, struct bmp3_uncomp_data *uncomp_data) { parse_fifo_sensor_data(BMP3_TEMP, &fifo_buffer[*byte_index], uncomp_data); *byte_index = *byte_index + BMP3_LEN_T_DATA; }

/*!

This internal API unpacks the FIFO data frame from the fifo buffer and fills the byte count and uncompensated pressure data. ‍/ static void unpack_press_frame(uint16_t *byte_index, const uint8_t *fifo_buffer, struct bmp3_uncomp_data *uncomp_data) { parse_fifo_sensor_data(BMP3_PRESS, &fifo_buffer[*byte_index], uncomp_data); *byte_index = *byte_index + BMP3_LEN_P_DATA; }

/*!

This internal API unpacks the time frame from the fifo data buffer and fills the byte count and update the sensor time variable. ‍/ static void unpack_time_frame(uint16_t *byte_index, const uint8_t *fifo_buffer, uint32_t *sensor_time) { uint16_t index = *byte_index; uint32_t xlsb = fifo_buffer[index]; uint32_t lsb = ((uint32_t)fifo_buffer[index + 1]) << 8; uint32_t msb = ((uint32_t)fifo_buffer[index + 2]) << 16;

*sensor_time = msb | lsb | xlsb; *byte_index = *byte_index + BMP3_LEN_SENSOR_TIME; }

/*!

This internal API parses the FIFO data frame from the fifo buffer and fills uncompensated temperature and/or pressure data. ‍/ static void parse_fifo_sensor_data(uint8_t sensor_comp, const uint8_t <em>fifo_buffer, struct bmp3_uncomp_data *uncomp_data) { / Temporary variables to store the sensor data *‍/ uint32_t data_xlsb; uint32_t data_lsb; uint32_t data_msb;

/* Store the parsed register values for temperature data *‍/ data_xlsb = (uint32_t)fifo_buffer[0]; data_lsb = (uint32_t)fifo_buffer[1] << 8; data_msb = (uint32_t)fifo_buffer[2] << 16;

if (sensor_comp == BMP3_TEMP) { /* Update uncompensated temperature *‍/ uncomp_data->temperature = data_msb | data_lsb | data_xlsb; }

if (sensor_comp == BMP3_PRESS) { /* Update uncompensated pressure *‍/ uncomp_data->pressure = data_msb | data_lsb | data_xlsb; }

if (sensor_comp == (BMP3_PRESS_TEMP)) { uncomp_data->temperature = data_msb | data_lsb | data_xlsb;

/* Store the parsed register values for pressure data *‍/ data_xlsb = (uint32_t)fifo_buffer[3]; data_lsb = (uint32_t)fifo_buffer[4] << 8; data_msb = (uint32_t)fifo_buffer[5] << 16; uncomp_data->pressure = data_msb | data_lsb | data_xlsb; } }

/*!

This internal API parses the FIFO buffer and gets the header info.

This internal API sets the normal mode in the sensor.

Definition at line 1680 of file bmp3.c.

1681{
1682 int8_t rslt;
1683 uint8_t conf_err_status;
1684
1685 rslt = validate_normal_mode_settings(settings, dev);
1686
1687 /* If OSR and ODR settings are proper then write the power mode */
1688 if (rslt == BMP3_OK)
1689 {
1690 rslt = write_power_mode(settings, dev);
1691
1692 /* check for configuration error */
1693 if (rslt == BMP3_OK)
1694 {
1695 /* Read the configuration error status */
1696 rslt = bmp3_get_regs(BMP3_REG_ERR, &conf_err_status, 1, dev);
1697
1698 /* Check if conf. error flag is set */
1699 if (rslt == BMP3_OK)
1700 {
1701 if (conf_err_status & BMP3_ERR_CONF)
1702 {
1703 /* OSR and ODR configuration is not proper */
1705 }
1706 }
1707 }
1708 }
1709
1710 return rslt;
1711}
static int8_t validate_normal_mode_settings(struct bmp3_settings *settings, struct bmp3_dev *dev)
This internal API validate the normal mode settings of the sensor.
Definition bmp3.c:1768
#define BMP3_E_CONFIGURATION_ERR
Definition bmp3_defs.h:265

References BMP3_E_CONFIGURATION_ERR, BMP3_ERR_CONF, bmp3_get_regs(), BMP3_OK, BMP3_REG_ERR, validate_normal_mode_settings(), and write_power_mode().

Referenced by bmp3_set_op_mode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_odr_filter_settings()

static int8_t set_odr_filter_settings ( uint32_t  desired_settings,
struct bmp3_settings settings,
struct bmp3_dev dev 
)
static

This internal API sets the over sampling, ODR and filter settings of the sensor based on the settings selected by the user.

Parameters
[in]desired_settings: Variable used to select the settings which are to be set.
[in]settings: Structure instance of bmp3_settings
[in]dev: Structure instance of bmp3_dev.
Returns
Result of API execution status
Return values
0-> Success
>0-> Warning
<0-> Fail

Definition at line 1928 of file bmp3.c.

1929{
1930 int8_t rslt;
1931
1932 /* No of registers to be configured is 3*/
1933 uint8_t reg_addr[3] = { 0 };
1934
1935 /* No of register data to be read is 4 */
1936 uint8_t reg_data[4];
1937 uint8_t len = 0;
1938
1939 rslt = bmp3_get_regs(BMP3_REG_OSR, reg_data, 4, dev);
1940
1941 if (rslt == BMP3_OK)
1942 {
1943 if (are_settings_changed((BMP3_SEL_PRESS_OS | BMP3_SEL_TEMP_OS), desired_settings))
1944 {
1945 /* Fill the over sampling register address and
1946 * register data to be written in the sensor */
1947 fill_osr_data(desired_settings, reg_addr, reg_data, &len, settings);
1948 }
1949
1950 if (are_settings_changed(BMP3_SEL_ODR, desired_settings))
1951 {
1952 /* Fill the output data rate register address and
1953 * register data to be written in the sensor */
1954 fill_odr_data(reg_addr, reg_data, &len, settings);
1955 }
1956
1957 if (are_settings_changed(BMP3_SEL_IIR_FILTER, desired_settings))
1958 {
1959 /* Fill the iir filter register address and
1960 * register data to be written in the sensor */
1961 fill_filter_data(reg_addr, reg_data, &len, settings);
1962 }
1963
1964 if (settings->op_mode == BMP3_MODE_NORMAL)
1965 {
1966 /* For normal mode, OSR and ODR settings should
1967 * be proper */
1968 rslt = validate_osr_and_odr_settings(settings);
1969 }
1970
1971 if (rslt == BMP3_OK)
1972 {
1973 /* Burst write the over sampling, ODR and filter
1974 * settings in the register */
1975 rslt = bmp3_set_regs(reg_addr, reg_data, len, dev);
1976 }
1977 }
1978
1979 return rslt;
1980}
static int8_t validate_osr_and_odr_settings(const struct bmp3_settings *settings)
This internal API validate the over sampling, ODR settings of the sensor.
Definition bmp3.c:2090
static void fill_osr_data(uint32_t desired_settings, uint8_t *addr, uint8_t *reg_data, uint8_t *len, const struct bmp3_settings *settings)
This internal API fills the register address and register data of the the over sampling settings for ...
Definition bmp3.c:2199
static void fill_filter_data(uint8_t *addr, uint8_t *reg_data, uint8_t *len, const struct bmp3_settings *settings)
This internal API fills the register address and register data of the the filter settings for burst w...
Definition bmp3.c:2257
static void fill_odr_data(uint8_t *addr, uint8_t *reg_data, uint8_t *len, struct bmp3_settings *settings)
This internal API fills the register address and register data of the the ODR settings for burst writ...
Definition bmp3.c:2235
#define BMP3_SEL_ODR
Definition bmp3_defs.h:287
#define BMP3_SEL_IIR_FILTER
Definition bmp3_defs.h:286

References are_settings_changed(), bmp3_get_regs(), BMP3_MODE_NORMAL, BMP3_OK, BMP3_REG_OSR, BMP3_SEL_IIR_FILTER, BMP3_SEL_ODR, BMP3_SEL_PRESS_OS, BMP3_SEL_TEMP_OS, bmp3_set_regs(), fill_filter_data(), fill_odr_data(), fill_osr_data(), bmp3_settings::op_mode, and validate_osr_and_odr_settings().

Referenced by bmp3_set_sensor_settings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_pwr_ctrl_settings()

static int8_t set_pwr_ctrl_settings ( uint32_t  desired_settings,
const struct bmp3_settings settings,
struct bmp3_dev dev 
)
static

This internal API sets the pressure enable and temperature enable settings of the sensor.

This API sets the pressure enable and temperature enable settings of the sensor.

Parameters
[in]desired_settings: Contains the settings which user wants to change.
[in]settings: Structure instance of bmp3_settings
[in]dev: Structure instance of bmp3_dev.
Returns
Result of API execution status
Return values
0-> Success
>0-> Warning
<0-> Fail

Definition at line 1891 of file bmp3.c.

1894{
1895 int8_t rslt;
1896 uint8_t reg_addr = BMP3_REG_PWR_CTRL;
1897 uint8_t reg_data;
1898
1899 rslt = bmp3_get_regs(reg_addr, &reg_data, 1, dev);
1900
1901 if (rslt == BMP3_OK)
1902 {
1903 if (desired_settings & BMP3_SEL_PRESS_EN)
1904 {
1905 /* Set the pressure enable settings in the
1906 * register variable */
1907 reg_data = BMP3_SET_BITS_POS_0(reg_data, BMP3_PRESS_EN, settings->press_en);
1908 }
1909
1910 if (desired_settings & BMP3_SEL_TEMP_EN)
1911 {
1912 /* Set the temperature enable settings in the
1913 * register variable */
1914 reg_data = BMP3_SET_BITS(reg_data, BMP3_TEMP_EN, settings->temp_en);
1915 }
1916
1917 /* Write the power control settings in the register */
1918 rslt = bmp3_set_regs(&reg_addr, &reg_data, 1, dev);
1919 }
1920
1921 return rslt;
1922}
#define BMP3_SEL_PRESS_EN
Definition bmp3_defs.h:281
#define BMP3_SEL_TEMP_EN
Definition bmp3_defs.h:282

References bmp3_get_regs(), BMP3_OK, BMP3_REG_PWR_CTRL, BMP3_SEL_PRESS_EN, BMP3_SEL_TEMP_EN, BMP3_SET_BITS, BMP3_SET_BITS_POS_0, bmp3_set_regs(), bmp3_settings::press_en, and bmp3_settings::temp_en.

Referenced by bmp3_set_sensor_settings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate_normal_mode_settings()

static int8_t validate_normal_mode_settings ( struct bmp3_settings settings,
struct bmp3_dev dev 
)
static

This internal API validate the normal mode settings of the sensor.

Parameters
[out]settings: Structure instance of bmp3_settings.
[in]dev: Structure instance of bmp3_dev.
Returns
Result of API execution status
Return values
0-> Success
>0-> Warning
<0-> Fail

Definition at line 1768 of file bmp3.c.

1769{
1770 int8_t rslt;
1771
1772 rslt = get_odr_filter_settings(settings, dev);
1773
1774 if (rslt == BMP3_OK)
1775 {
1776 rslt = validate_osr_and_odr_settings(settings);
1777 }
1778
1779 return rslt;
1780}
static int8_t get_odr_filter_settings(struct bmp3_settings *settings, struct bmp3_dev *dev)
This internal API gets the over sampling, ODR and filter settings from the sensor.
Definition bmp3.c:2072

References BMP3_OK, get_odr_filter_settings(), and validate_osr_and_odr_settings().

Referenced by set_normal_mode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ validate_osr_and_odr_settings()

static int8_t validate_osr_and_odr_settings ( const struct bmp3_settings settings)
static

This internal API validate the over sampling, ODR settings of the sensor.

Parameters
[out]settings: Structure instance of bmp3_settings.
Returns
Indicates whether ODR and OSR settings are valid or not.
Return values
0-> Success
<0-> Fail

Definition at line 2090 of file bmp3.c.

2091{
2092 int8_t rslt;
2093
2094 /* According to BMP388 datasheet at Section 3.9.2. "Measurement rate in
2095 * forced mode and normal mode" there is also the constant of 234us also to
2096 * be considered in the sum. */
2097 uint32_t meas_t = 234;
2098 uint32_t meas_t_p = 0;
2099
2100 /* Sampling period corresponding to ODR in microseconds */
2101 uint32_t odr[18] = {
2102 5000, 10000, 20000, 40000, 80000, 160000, 320000, 640000, 1280000, 2560000, 5120000, 10240000, 20480000,
2103 40960000, 81920000, 163840000, 327680000, 655360000
2104 };
2105
2106 if (settings->press_en)
2107 {
2108 /* Calculate the pressure measurement duration */
2109 meas_t_p += calculate_press_meas_time(settings);
2110 }
2111
2112 if (settings->temp_en)
2113 {
2114 /* Calculate the temperature measurement duration */
2115 meas_t_p += calculate_temp_meas_time(settings);
2116 }
2117
2118 /* Constant 234us added to the summation of temperature and pressure measurement duration */
2119 meas_t += meas_t_p;
2120
2121 rslt = verify_meas_time_and_odr_duration(meas_t, odr[settings->odr_filter.odr]);
2122
2123 return rslt;
2124}
static int8_t verify_meas_time_and_odr_duration(uint32_t meas_t, uint32_t odr_duration)
This internal API checks whether the measurement time and ODR duration of the sensor are proper.
Definition bmp3.c:2130
static uint32_t calculate_temp_meas_time(const struct bmp3_settings *settings)
This internal API calculates the temperature measurement duration of the sensor.
Definition bmp3.c:2176
static uint32_t calculate_press_meas_time(const struct bmp3_settings *settings)
This internal API calculates the pressure measurement duration of the sensor.
Definition bmp3.c:2153

References calculate_press_meas_time(), calculate_temp_meas_time(), bmp3_odr_filter_settings::odr, bmp3_settings::odr_filter, bmp3_settings::press_en, bmp3_settings::temp_en, and verify_meas_time_and_odr_duration().

Referenced by set_odr_filter_settings(), and validate_normal_mode_settings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ verify_meas_time_and_odr_duration()

static int8_t verify_meas_time_and_odr_duration ( uint32_t  meas_t,
uint32_t  odr_duration 
)
static

This internal API checks whether the measurement time and ODR duration of the sensor are proper.

Parameters
[in]meas_t: Pressure and temperature measurement time in microseconds.
[in]odr_duration: Duration in microseconds corresponding to the ODR value.
Returns
Indicates whether ODR and OSR settings are valid or not.
Return values
0-> Success
>0-> Warning

Definition at line 2130 of file bmp3.c.

2131{
2132 int8_t rslt;
2133
2134 if (meas_t < odr_duration)
2135 {
2136 /* If measurement duration is less than ODR duration
2137 * then OSR and ODR settings are fine */
2138 rslt = BMP3_OK;
2139 }
2140 else
2141 {
2142 /* OSR and ODR settings are not proper */
2144 }
2145
2146 return rslt;
2147}
#define BMP3_E_INVALID_ODR_OSR_SETTINGS
Definition bmp3_defs.h:263

References BMP3_E_INVALID_ODR_OSR_SETTINGS, and BMP3_OK.

Referenced by validate_osr_and_odr_settings().

Here is the caller graph for this function:

◆ write_power_mode()

static int8_t write_power_mode ( const struct bmp3_settings settings,
struct bmp3_dev dev 
)
static

This internal API writes the power mode in the sensor.

Parameters
[out]settings: Structure instance of bmp3_settings.
[in]dev: Structure instance of bmp3_dev.
Returns
Result of API execution status.
Return values
0-> Success
>0-> Warning
<0-> Fail

Definition at line 1716 of file bmp3.c.

1717{
1718 int8_t rslt;
1719 uint8_t reg_addr = BMP3_REG_PWR_CTRL;
1720 uint8_t op_mode = settings->op_mode;
1721
1722 /* Temporary variable to store the value read from op-mode register */
1723 uint8_t op_mode_reg_val;
1724
1725 /* Read the power mode register */
1726 rslt = bmp3_get_regs(reg_addr, &op_mode_reg_val, 1, dev);
1727
1728 /* Set the power mode */
1729 if (rslt == BMP3_OK)
1730 {
1731 op_mode_reg_val = BMP3_SET_BITS(op_mode_reg_val, BMP3_OP_MODE, op_mode);
1732
1733 /* Write the power mode in the register */
1734 rslt = bmp3_set_regs(&reg_addr, &op_mode_reg_val, 1, dev);
1735 }
1736
1737 return rslt;
1738}

References bmp3_get_regs(), BMP3_OK, BMP3_REG_PWR_CTRL, BMP3_SET_BITS, bmp3_set_regs(), and bmp3_settings::op_mode.

Referenced by bmp3_set_op_mode(), and set_normal_mode().

Here is the call graph for this function:
Here is the caller graph for this function: