![]() |
Da Vinci Firmware 1
Firmware for the DaVinci-M rocket avionics board.
|
#include "bmp3_defs.h"

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. | |
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:
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.
Definition in file bmp3.h.
| 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.
References BMP3_E_NULL_PTR, BMP3_GET_BITS, bmp3_get_regs(), BMP3_REG_PWR_CTRL, and NULL.
Referenced by bmp3_set_op_mode().


| 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.
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().


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.
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().


| 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.
References BMP3_E_NULL_PTR, bmp3_get_regs(), BMP3_LEN_GEN_SETT, BMP3_OK, BMP3_REG_INT_CTRL, NULL, and parse_sett_data().

| 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. ‍/
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.
References BMP3_E_NULL_PTR, BMP3_OK, get_err_status(), get_int_status(), get_sensor_status(), and NULL.

| 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.
| [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 |
| 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.
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().


| 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.
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().


| 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.
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().


| 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.
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().


| 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.
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().

