Da Vinci Firmware 1
Firmware for the DaVinci-M rocket avionics board.
Loading...
Searching...
No Matches
bmp3.h File Reference
#include "bmp3_defs.h"
Include dependency graph for bmp3.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

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_soft_reset (struct bmp3_dev *dev)
 This API performs the soft reset 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_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 *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.
 
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_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_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.
 

Detailed Description

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.h.

Function Documentation

◆ 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}
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
#define NULL
Definition bmp3_defs.h:88
#define BMP3_REG_PWR_CTRL
Definition bmp3_defs.h:158
#define BMP3_E_NULL_PTR
Definition bmp3_defs.h:261
#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
#define BMP3_OK
Definition bmp3_defs.h:258
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
void * intf_ptr
Definition bmp3_defs.h:905

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 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
bmp3_delay_us_fptr_t delay_us
Definition bmp3_defs.h:926
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}
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_SOFT_RESET
Definition bmp3_defs.h:252
#define BMP3_REG_ERR
Definition bmp3_defs.h:146
#define BMP3_E_CMD_EXEC_FAILED
Definition bmp3_defs.h:264

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: