Da Vinci Firmware 1
Firmware for the DaVinci-M rocket avionics board.
Loading...
Searching...
No Matches
Collaboration diagram for "BMP3":

Modules

 Initialization
 Initialize the sensor and device structure.
 
 Soft reset
 Perform soft reset of the sensor.
 
 Sensor settings
 Get / Set sensor settings.
 
 Power mode
 Set / Get power mode of the sensor.
 
 Sensor Data
 Get Sensor data.
 
 Registers
 Read / Write data to the given register address.
 
 FIFO
 FIFO operations of the sensor.
 
 Sensor Status
 Read status of the sensor.
 

Data Structures

struct  bmp3_reg_calib_data
 Register Trim Variables. More...
 
struct  bmp3_adv_settings
 bmp3 advance settings More...
 
struct  bmp3_odr_filter_settings
 bmp3 odr and filter settings More...
 
struct  bmp3_sens_status
 bmp3 sensor status flags More...
 
struct  bmp3_int_status
 bmp3 interrupt status flags More...
 
struct  bmp3_err_status
 bmp3 error status flags More...
 
struct  bmp3_status
 bmp3 status flags More...
 
struct  bmp3_int_ctrl_settings
 bmp3 interrupt pin settings More...
 
struct  bmp3_settings
 bmp3 device settings More...
 
struct  bmp3_fifo_data
 bmp3 fifo frame More...
 
struct  bmp3_fifo_settings
 bmp3 fifo configuration More...
 
struct  bmp3_quantized_calib_data
 Quantized Trim Variables. More...
 
struct  bmp3_calib_data
 Calibration data. More...
 
struct  bmp3_data
 bmp3 sensor structure which comprises of temperature and pressure data. More...
 
struct  bmp3_uncomp_data
 bmp3 sensor structure which comprises of un-compensated temperature and pressure data. More...
 
struct  bmp3_dev
 bmp3 device structure More...
 

Functions

int8_t bmp390_P_write (uint8_t reg_addr, const uint8_t *buf, uint32_t len, void *intf_ptr)
 SPI write function for the primary Barometer (bmp390).
 
int8_t bmp390_P_read (uint8_t reg_addr, uint8_t *buf, uint32_t len, void *intf_ptr)
 SPI read function for the primary Barometer (bmp390).
 
int8_t bmp390_B_write (uint8_t reg_addr, const uint8_t *buf, uint32_t len, void *intf_ptr)
 SPI write function for the backup Barometer (bmp390).
 
int8_t bmp390_B_read (uint8_t reg_addr, uint8_t *buf, uint32_t len, void *intf_ptr)
 SPI read function for the backup Barometer (bmp390).
 
int8_t init_bmp390_p (struct bmp3_dev *bmp390)
 Initializes the primary barometer (BMP390).
 
int8_t init_bmp390_B (struct bmp3_dev *bmp390)
 Initializes the backup barometer (BMP390).
 

Detailed Description

bmp3_fifo_flush

// * int8_t bmp3_fifo_flush(const struct bmp3_dev *dev);
// *
This API performs fifo flush
Parameters
[in]dev: Structure instance of bmp3_dev.
Returns
Result of API execution status
Return values
0-> Success
>0-> Warning
<0-> Error ‍/ int8_t bmp3_fifo_flush(struct bmp3_dev *dev);

/**

Function Documentation

◆ bmp390_B_read()

int8_t bmp390_B_read ( uint8_t  reg_addr,
uint8_t *  buf,
uint32_t  len,
void *  intf_ptr 
)

SPI read function for the backup Barometer (bmp390).

This function is designed to be passed as a function pointer to the STMicroelectronics barometer driver library. It handles SPI bus transactions.

Parameters
[in]reg_addrThe 7-bit register address to read from. The read bit is set automatically.
[out]bufPointer to the buffer where read data will be stored.
[in]lenThe number of bytes to read.
Returns
int32_t HAL_OK on success, HAL_ERROR on failure.

Definition at line 623 of file utilities.c.

623 {
624
625 int8_t result = HAL_ERROR;
626
627 if(HAL_GPIO_ReadPin(IMU_CS_GPIO_Port,IMU_CS_Pin)!=GPIO_PIN_SET){IMU_CS_HIGH;}
628 if(HAL_GPIO_ReadPin(MAG_CS_GPIO_Port,MAG_CS_Pin)!=GPIO_PIN_SET){MAG_CS_HIGH;}
629 BMP390_CS_LOW;
630
631
632
633 if (HAL_SPI_Transmit(&hspi3, &reg_addr, 1, 100) == HAL_OK) {
634 if (HAL_SPI_Receive(&hspi3, buf, len, 100) == HAL_OK) {
635 result = HAL_OK;
636 }
637 }
638
639
640 BMP390_CS_HIGH;
641
642
643
644 return result;
645}
SPI_HandleTypeDef hspi3
Definition main.c:63
@ HAL_ERROR
@ HAL_OK

References HAL_ERROR, HAL_OK, and hspi3.

Referenced by bmp3_B_spi_init().

Here is the caller graph for this function:

◆ bmp390_B_write()

int8_t bmp390_B_write ( uint8_t  reg_addr,
const uint8_t *  buf,
uint32_t  len,
void *  intf_ptr 
)

SPI write function for the backup Barometer (bmp390).

This function is designed to be passed as a function pointer to the STMicroelectronics barometer driver library. It handles SPI bus transactions.

Parameters
[in]reg_addrThe 7-bit register address to write to.
[in]bufPointer to the data buffer to be written.
[in]lenThe number of bytes to write.
Returns
int32_t HAL_OK on success, HAL_ERROR on failure.

Definition at line 603 of file utilities.c.

603 {
604
605 int8_t result = HAL_ERROR;
606
607
608 if(HAL_GPIO_ReadPin(IMU_CS_GPIO_Port,IMU_CS_Pin)!=GPIO_PIN_SET){IMU_CS_HIGH;}
609 if(HAL_GPIO_ReadPin(MAG_CS_GPIO_Port,MAG_CS_Pin)!=GPIO_PIN_SET){MAG_CS_HIGH;}
610 BMP390_CS_LOW;
611
612 if (HAL_SPI_Transmit(&hspi3, &reg_addr, 1, 100) == HAL_OK) {
613 if (HAL_SPI_Transmit(&hspi3, (uint8_t *)buf, len, 100) == HAL_OK) {
614 result = HAL_OK;
615 }
616 }
617
618 BMP390_CS_HIGH;
619
620 return result;
621}

References HAL_ERROR, HAL_OK, and hspi3.

Referenced by bmp3_B_spi_init().

Here is the caller graph for this function:

◆ bmp390_P_read()

int8_t bmp390_P_read ( uint8_t  reg_addr,
uint8_t *  buf,
uint32_t  len,
void *  intf_ptr 
)

SPI read function for the primary Barometer (bmp390).

This function is designed to be passed as a function pointer to the STMicroelectronics barometer driver library. It handles SPI bus transactions.

Parameters
[in]reg_addrThe 7-bit register address to read from. The read bit is set automatically.
[out]bufPointer to the buffer where read data will be stored.
[in]lenThe number of bytes to read.
Returns
int32_t HAL_OK on success, HAL_ERROR on failure.

Definition at line 122 of file utilities.c.

122 {
123
124
125 int8_t result = HAL_ERROR;
126 uint8_t tx_buffer[len + 1]; // Buffer for address + dummy bytes
127 uint8_t rx_buffer[len + 1]; // Buffer for received dummy byte + data
128
129 reg_addr |= 0x80; // Crucial: Set the MSB for a read operation (check datasheet if different)
130 tx_buffer[0] = reg_addr;
131
132 // Fill the rest of the transmit buffer with dummy bytes
133 for (uint32_t i = 1; i <= len; i++) {
134 tx_buffer[i] = 0xFF; // Or any dummy value
135 }
136
137 // Ensure other sensors are deselected
138 if(HAL_GPIO_ReadPin(IMU_CS_GPIO_Port,IMU_CS_Pin)!=GPIO_PIN_SET){IMU_CS_HIGH;}
139 if(HAL_GPIO_ReadPin(MAG_CS_GPIO_Port,MAG_CS_Pin)!=GPIO_PIN_SET){MAG_CS_HIGH;}
140
141 if(HAL_GPIO_ReadPin(BARO_CS_GPIO_Port,BARO_CS_Pin)!=GPIO_PIN_RESET){BMP390_CS_LOW;}
142
143
144
145 if (HAL_SPI_TransmitReceive(&hspi2, tx_buffer, rx_buffer, len + 1, 100) == HAL_OK) {
146 // Data from the sensor starts at rx_buffer[1]
147 for (uint32_t i = 0; i < len; i++) {
148 buf[i] = rx_buffer[i + 1];
149 }
150 result = HAL_OK;
151 }
152
153
154
155 if(HAL_GPIO_ReadPin(BARO_CS_GPIO_Port,BARO_CS_Pin)!=GPIO_PIN_SET){BMP390_CS_HIGH;}
156
157
158
159 return result;
160}
SPI_HandleTypeDef hspi2
Definition main.c:62

References HAL_ERROR, HAL_OK, and hspi2.

Referenced by bmp3_P_spi_init().

Here is the caller graph for this function:

◆ bmp390_P_write()

int8_t bmp390_P_write ( uint8_t  reg_addr,
const uint8_t *  buf,
uint32_t  len,
void *  intf_ptr 
)

SPI write function for the primary Barometer (bmp390).

This function is designed to be passed as a function pointer to the STMicroelectronics barometer driver library. It handles SPI bus transactions.

Parameters
[in]reg_addrThe 7-bit register address to write to.
[in]bufPointer to the data buffer to be written.
[in]lenThe number of bytes to write.
Returns
int32_t HAL_OK on success, HAL_ERROR on failure.

Definition at line 103 of file utilities.c.

103 {
104
105 int8_t result = HAL_ERROR;
106 if(HAL_GPIO_ReadPin(IMU_CS_GPIO_Port,IMU_CS_Pin)!=GPIO_PIN_SET){IMU_CS_HIGH;}
107 if(HAL_GPIO_ReadPin(MAG_CS_GPIO_Port,MAG_CS_Pin)!=GPIO_PIN_SET){MAG_CS_HIGH;}
108
109 if(HAL_GPIO_ReadPin(BARO_CS_GPIO_Port,BARO_CS_Pin)!=GPIO_PIN_RESET){BMP390_CS_LOW;}
110
111 if (HAL_SPI_Transmit(&hspi2, &reg_addr, 1, 100) == HAL_OK) {
112 if (HAL_SPI_Transmit(&hspi2, (uint8_t *)buf, len, 100) == HAL_OK) {
113 result = HAL_OK;
114 }
115 }
116
117 if(HAL_GPIO_ReadPin(BARO_CS_GPIO_Port,BARO_CS_Pin)!=GPIO_PIN_SET){BMP390_CS_HIGH;}
118
119 return result;
120}

References HAL_ERROR, HAL_OK, and hspi2.

Referenced by bmp3_P_spi_init().

Here is the caller graph for this function:

◆ init_bmp390_B()

int8_t init_bmp390_B ( struct bmp3_dev bmp390)

Initializes the backup barometer (BMP390).

Configures the barometer for normal operation with specified oversampling and data rate settings.

Parameters
[in,out]bmp390Pointer to the bmp3_dev driver context structure.
Returns
int8_t HAL_OK on successful initialization, HAL_ERROR otherwise.

Definition at line 723 of file utilities.c.

723 {
724
725 int8_t result = HAL_ERROR;
726 uint8_t settings_sel = 0;
727 struct bmp3_settings settings = { 0 };
728
729
730 result = bmp3_B_spi_init(bmp390);
731
732 if (result != BMP3_OK)
733 return HAL_ERROR;
734
735 result = bmp3_init(bmp390);
736
737 if (result != BMP3_OK)
738 return HAL_ERROR;
739
740 /* enabling both pressure and temperature reading */
741 settings.press_en = BMP3_ENABLE;
742 settings.temp_en = BMP3_ENABLE;
743
744 /* interrupt disabling */
746
747 /* pressure and temperature oversampling */
750
751 /* output data rate */
752 settings.odr_filter.odr = BMP3_ODR_200_HZ;
753
754 /* IIR filter disabling */
756
757 /* specifying all the settings we want to modify using the bmp3_settings struct */
758 settings_sel = BMP3_SEL_PRESS_EN | BMP3_SEL_TEMP_EN |
761
762 /* setting the previously specified settings */
763 result = bmp3_set_sensor_settings(settings_sel, &settings, bmp390);
764
765 if (result != BMP3_OK)
766 return HAL_ERROR;
767
768 /* setting the operating mode of the sensor */
769 settings.op_mode = BMP3_MODE_NORMAL;
770
771 result = bmp3_set_op_mode(&settings, bmp390);
772
773 if (result != BMP3_OK)
774 return HAL_ERROR;
775
776 return HAL_OK;
777}
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,...
Definition bmp3.c:909
int8_t bmp3_set_op_mode(struct bmp3_settings *settings, struct bmp3_dev *dev)
This API sets the power mode of the sensor.
Definition bmp3.c:1350
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 wate...
Definition bmp3.c:738
#define BMP3_ODR_200_HZ
Definition bmp3_defs.h:232
#define BMP3_DISABLE
Definition bmp3_defs.h:183
#define BMP3_IIR_FILTER_DISABLE
Definition bmp3_defs.h:222
#define BMP3_ENABLE
Definition bmp3_defs.h:182
#define BMP3_NO_OVERSAMPLING
Definition bmp3_defs.h:214
#define BMP3_SEL_ODR
Definition bmp3_defs.h:287
#define BMP3_OK
Definition bmp3_defs.h:258
#define BMP3_SEL_PRESS_EN
Definition bmp3_defs.h:281
#define BMP3_SEL_IIR_FILTER
Definition bmp3_defs.h:286
#define BMP3_SEL_PRESS_OS
Definition bmp3_defs.h:284
#define BMP3_SEL_TEMP_EN
Definition bmp3_defs.h:282
#define BMP3_SEL_TEMP_OS
Definition bmp3_defs.h:285
#define BMP3_MODE_NORMAL
Definition bmp3_defs.h:178
bmp3 device settings
Definition bmp3_defs.h:707
uint8_t op_mode
Definition bmp3_defs.h:709
uint8_t temp_en
Definition bmp3_defs.h:715
uint8_t press_en
Definition bmp3_defs.h:712
struct bmp3_int_ctrl_settings int_settings
Definition bmp3_defs.h:721
struct bmp3_odr_filter_settings odr_filter
Definition bmp3_defs.h:718
static int8_t bmp3_B_spi_init(struct bmp3_dev *dev)
Definition utilities.c:647

References bmp3_B_spi_init(), BMP3_DISABLE, BMP3_ENABLE, BMP3_IIR_FILTER_DISABLE, bmp3_init(), BMP3_MODE_NORMAL, BMP3_NO_OVERSAMPLING, BMP3_ODR_200_HZ, BMP3_OK, BMP3_SEL_IIR_FILTER, BMP3_SEL_ODR, BMP3_SEL_PRESS_EN, BMP3_SEL_PRESS_OS, BMP3_SEL_TEMP_EN, BMP3_SEL_TEMP_OS, bmp3_set_op_mode(), bmp3_set_sensor_settings(), bmp3_int_ctrl_settings::drdy_en, HAL_ERROR, HAL_OK, bmp3_odr_filter_settings::iir_filter, bmp3_settings::int_settings, bmp3_odr_filter_settings::odr, bmp3_settings::odr_filter, bmp3_settings::op_mode, bmp3_settings::press_en, bmp3_odr_filter_settings::press_os, bmp3_settings::temp_en, and bmp3_odr_filter_settings::temp_os.

Referenced by main().

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

◆ init_bmp390_p()

int8_t init_bmp390_p ( struct bmp3_dev bmp390)

Initializes the primary barometer (BMP390).

Configures the barometer for normal operation with specified oversampling and data rate settings.

Parameters
[in,out]bmp390Pointer to the bmp3_dev driver context structure.
Returns
int8_t HAL_OK on successful initialization, HAL_ERROR otherwise.

Definition at line 252 of file utilities.c.

252 {
253
254 int8_t result = HAL_ERROR;
255 uint8_t settings_sel = 0;
256 struct bmp3_settings settings = { 0 };
257
258 //IMU_CS_HIGH;
259 //MAG_CS_HIGH;
260
261 result = bmp3_P_spi_init(bmp390);
262
263 if (result != BMP3_OK)
264 return HAL_ERROR;
265 //BMP390_CS_LOW;
266 result = bmp3_init(bmp390);
267
268 //BMP390_CS_HIGH;
269
270 if (result != BMP3_OK)
271
272 return HAL_ERROR;
273
274 /* enabling both pressure and temperature reading */
275 settings.press_en = BMP3_ENABLE;
276 settings.temp_en = BMP3_ENABLE;
277
278 /* interrupt disabling */
280
281 /* pressure and temperature oversampling */
284
285 /* output data rate */
286 settings.odr_filter.odr = BMP3_ODR_200_HZ;
287
288 /* IIR filter disabling */
290
291 /* specifying all the settings we want to modify using the bmp3_settings struct */
292 settings_sel = BMP3_SEL_PRESS_EN | BMP3_SEL_TEMP_EN |
295
296 /* setting the previously specified settings */
297 result = bmp3_set_sensor_settings(settings_sel, &settings, bmp390);
298
299 if (result != BMP3_OK)
300 return HAL_ERROR;
301
302 /* setting the operating mode of the sensor */
303 settings.op_mode = BMP3_MODE_NORMAL;
304
305 result = bmp3_set_op_mode(&settings, bmp390);
306
307 if (result != BMP3_OK)
308 return HAL_ERROR;
309
310 return HAL_OK;
311}
static int8_t bmp3_P_spi_init(struct bmp3_dev *dev)
Definition utilities.c:173

References BMP3_DISABLE, BMP3_ENABLE, BMP3_IIR_FILTER_DISABLE, bmp3_init(), BMP3_MODE_NORMAL, BMP3_NO_OVERSAMPLING, BMP3_ODR_200_HZ, BMP3_OK, bmp3_P_spi_init(), BMP3_SEL_IIR_FILTER, BMP3_SEL_ODR, BMP3_SEL_PRESS_EN, BMP3_SEL_PRESS_OS, BMP3_SEL_TEMP_EN, BMP3_SEL_TEMP_OS, bmp3_set_op_mode(), bmp3_set_sensor_settings(), bmp3_int_ctrl_settings::drdy_en, HAL_ERROR, HAL_OK, bmp3_odr_filter_settings::iir_filter, bmp3_settings::int_settings, bmp3_odr_filter_settings::odr, bmp3_settings::odr_filter, bmp3_settings::op_mode, bmp3_settings::press_en, bmp3_odr_filter_settings::press_os, bmp3_settings::temp_en, and bmp3_odr_filter_settings::temp_os.

Referenced by main().

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