Solaris Software
Loading...
Searching...
No Matches
bmp390.c File Reference

BMP390 pressure sensor driver and SPP producer implementation. More...

#include "spp/services/bmp390/bmp390.h"
#include "spp/hal/spi/spi.h"
#include "spp/hal/time/time.h"
#include "spp/services/log/log.h"
#include "spp/services/databank/databank.h"
#include "spp/core/packet.h"
#include "spp/core/pubsub/pubsub.h"
#include "spp/services/fsm/fsm.h"
#include <stdio.h>
#include <string.h>
#include <math.h>
Include dependency graph for bmp390.c:

Go to the source code of this file.

Macros

#define K_BMP390_TASK_TIMEOUT_MS   5000U
#define K_BMP390_TAG   "BMP390"
#define K_BMP390_PERFORMANCE_SAMPLES   (10000U)
#define K_BMP390_CALIBRATION_SAMPLES   500U

Functions

static SPP_RetVal_t SPP_SERVICES_BMP390_init (void)
 Initializes the BMP390 sensor and its hardware interfaces.
static SPP_RetVal_t SPP_SERVICES_BMP390_acquireData (SPP_Kpid_t kpid)
 Acquires BMP390 measurements and publishes them through PUBSUB.
static SPP_RetVal_t SPP_SERVICES_BMP390_softReset (void *p_spiHandler)
 Sends a soft-reset command to the sensor and waits 100 ms for it to reboot.
static SPP_RetVal_t SPP_SERVICES_BMP390_enableSpiMode (void *p_spiHandler)
 Writes the interface-config register to lock the sensor into SPI mode.
static SPP_RetVal_t SPP_SERVICES_BMP390_configCheck (void *p_spiHandler)
 Reads the chip-ID register and returns an error if the value is not 0x60.
static SPP_RetVal_t SPP_SERVICES_BMP390_auxConfig (void *p_spiHandler)
 Resets the sensor, enables SPI mode, and verifies the chip ID.
static SPP_RetVal_t SPP_SERVICES_BMP390_prepareMeasure (void *p_spiHandler)
 Writes OSR, ODR, IIR and power-control registers to start continuous measurements.
static SPP_RetVal_t SPP_SERVICES_BMP390_readRawTempCoeffs (void *p_spiHandler, BMP390_temp_calib_t *tcalib)
 Reads raw temperature calibration coefficients from the sensor's NVM registers.
static SPP_RetVal_t SPP_SERVICES_BMP390_calibrateTempParams (void *p_spiHandler, BMP390_temp_params_t *out)
 Reads raw temperature coefficients and scales them to floating-point parameters.
static SPP_RetVal_t SPP_SERVICES_BMP390_readRawTemp (void *p_spiHandler, uint32_t *raw_temp)
 Reads the 24-bit raw temperature ADC value from the sensor.
static float SPP_SERVICES_BMP390_compensateTemperature (spp_uint32_t raw_temp, BMP390_temp_params_t *params)
 Applies the BMP390 double-quadratic temperature compensation formula.
static SPP_RetVal_t SPP_SERVICES_BMP390_auxGetTemp (void *p_spiHandler, const BMP390_temp_params_t *temp_params, spp_uint32_t *raw_temp, float *comp_temp)
 Reads the raw temperature ADC and returns the compensated value.
static SPP_RetVal_t SPP_SERVICES_BMP390_readRawPressCoeffs (void *p_spiHandler, BMP390_press_calib_t *pcalib)
 Reads raw pressure calibration coefficients from the sensor's NVM registers.
static SPP_RetVal_t SPP_SERVICES_BMP390_calibratePressParams (void *p_spiHandler, BMP390_press_params_t *out)
 Reads raw pressure coefficients and scales them to floating-point parameters.
static SPP_RetVal_t SPP_SERVICES_BMP390_readRawPress (void *p_spiHandler, spp_uint32_t *raw_press)
 Reads the 24-bit raw pressure ADC value from the sensor.
static float SPP_SERVICES_BMP390_compensatePressure (spp_uint32_t raw_press, float t_lin, BMP390_press_params_t *p)
 Applies the BMP390 pressure compensation formula using the linearised temperature.
static SPP_RetVal_t SPP_SERVICES_BMP390_auxGetPress (void *p_spiHandler, const BMP390_press_params_t *press_params, float t_lin, spp_uint32_t *raw_press, float *comp_press)
 Reads raw pressure ADC and returns the compensated value in Pa.
static SPP_RetVal_t SPP_SERVICES_BMP390_getAltitude (void *p_spiHandler, float *altitude_m, float *pressure_pa, float *temperature_c)
 Reads compensated temperature and pressure, and computes relative altitude.
static SPP_RetVal_t SPP_SERVICES_BMP390_intEnableDrdy (void *p_spiHandler)
 Enables the active-high data-ready interrupt output on the sensor.
const SPP_SERVICE_ProducerContract_t * SPP_SERVICES_BMP390_getProducerContract (void)
 Returns the BMP390 producer contract for PUBSUB registration.

Variables

static const SPP_SERVICE_ProducerContract_t g_bmp390ProducerContract
static BMP390_t s_bmpData
static const char *const k_svcTag = "BMP_SVC"
static float s_pd1
static float s_pd2
static float s_pd3
static float s_pd4
static float s_po1
static float s_po2
static float s_compPress
spp_bool_t s_isCalibrated = false
spp_uint16_t s_calibrationSamples = 0
spp_float32_t s_pressureSum = 0.0f
spp_float32_t s_temperatureSum = 0.0f
spp_float32_t s_referencePressure = 0.0f
spp_float32_t s_referenceTemperature = 0.0f

Detailed Description

BMP390 pressure sensor driver and SPP producer implementation.

Handles sensor configuration, SPI acquisition, compensation, reference calibration and packet publication through PUBSUB.

Definition in file bmp390.c.

Macro Definition Documentation

◆ K_BMP390_TASK_TIMEOUT_MS

#define K_BMP390_TASK_TIMEOUT_MS   5000U

Definition at line 31 of file bmp390.c.

◆ K_BMP390_TAG

#define K_BMP390_TAG   "BMP390"

Definition at line 32 of file bmp390.c.

Referenced by SPP_SERVICES_BMP390_acquireData(), and SPP_SERVICES_BMP390_configCheck().

◆ K_BMP390_PERFORMANCE_SAMPLES

#define K_BMP390_PERFORMANCE_SAMPLES   (10000U)

Definition at line 61 of file bmp390.c.

◆ K_BMP390_CALIBRATION_SAMPLES

#define K_BMP390_CALIBRATION_SAMPLES   500U

Definition at line 87 of file bmp390.c.

Referenced by SPP_SERVICES_BMP390_acquireData().

Function Documentation

◆ SPP_SERVICES_BMP390_init()

SPP_RetVal_t SPP_SERVICES_BMP390_init ( void )
static

Initializes the BMP390 sensor and its hardware interfaces.

Configures the GPIO interrupt, initializes the SPI device, configures the sensor and enables data-ready interrupts.

Returns
K_SPP_OK on success, error code otherwise.

Definition at line 139 of file bmp390.c.

References BMP390_GpioConfig_t::drdyFlag, BMP390_t::gpioConfig, BMP390_GpioConfig_t::intIntrType, BMP390_GpioConfig_t::intPin, BMP390_GpioConfig_t::intPull, BMP390_GpioConfig_t::isrCtx, K_BMP390_INT_INTR_TYPE, K_BMP390_INT_PIN_NUM, K_BMP390_INT_PULL, K_BMP390_SPI_BUS_IDX, K_SPP_ERROR, K_SPP_OK, SPP_GpioIsrCtx_t::p_flag, BMP390_SpiConfig_t::p_spiHandler, s_bmpData, BMP390_t::spiConfig, BMP390_SpiConfig_t::spiDevIdx, SPP_HAL_GPIO_configInterrupt(), SPP_HAL_GPIO_registerIsr(), SPP_HAL_SPI_deviceInit(), SPP_HAL_SPI_getHandle(), SPP_SERVICES_BMP390_auxConfig(), SPP_SERVICES_BMP390_init(), SPP_SERVICES_BMP390_intEnableDrdy(), and SPP_SERVICES_BMP390_prepareMeasure().

Referenced by SPP_SERVICES_BMP390_init().

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

◆ SPP_SERVICES_BMP390_acquireData()

SPP_RetVal_t SPP_SERVICES_BMP390_acquireData ( SPP_Kpid_t kpid)
static

Acquires BMP390 measurements and publishes them through PUBSUB.

Checks the DRDY flag, reads compensated measurements and performs reference calibration using the first 500 samples. After calibration, publishes altitude, pressure and temperature.

Parameters
kpidAssigned producer KPID.
Returns
K_SPP_OK on normal execution, error code on acquisition or packet preparation failure.

Definition at line 202 of file bmp390.c.

References BMP390_GpioConfig_t::drdyFlag, BMP390_t::gpioConfig, K_BMP390_CALIBRATION_SAMPLES, K_BMP390_TAG, K_SPP_ERROR, K_SPP_OK, k_svcTag, BMP390_SpiConfig_t::p_spiHandler, s_bmpData, s_calibrationSamples, s_isCalibrated, s_pressureSum, s_referencePressure, s_referenceTemperature, s_temperatureSum, BMP390_t::seq, BMP390_t::spiConfig, SPP_LOGE, SPP_LOGI, SPP_LOGW, SPP_Packet_t, SPP_SERVICES_BMP390_acquireData(), SPP_SERVICES_BMP390_getAltitude(), SPP_SERVICES_DATABANK_getPacket(), SPP_SERVICES_DATABANK_packetData(), SPP_SERVICES_DATABANK_returnPacket(), SPP_SERVICES_PUBSUB_publish(), and SPP_Kpid_t::value.

Referenced by SPP_SERVICES_BMP390_acquireData().

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

◆ SPP_SERVICES_BMP390_softReset()

SPP_RetVal_t SPP_SERVICES_BMP390_softReset ( void * p_spiHandler)
static

Sends a soft-reset command to the sensor and waits 100 ms for it to reboot.

Parameters
p_spiHandlerSPI device handle.
Returns
K_SPP_OK on success, K_SPP_ERROR on SPI failure.

Definition at line 307 of file bmp390.c.

References BMP390_SOFT_RESET_CMD, K_BMP390_SOFT_RESET_REG, SPP_HAL_SPI_transmit(), SPP_HAL_TIME_delayMs(), and SPP_SERVICES_BMP390_softReset().

Referenced by SPP_SERVICES_BMP390_auxConfig(), and SPP_SERVICES_BMP390_softReset().

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

◆ SPP_SERVICES_BMP390_enableSpiMode()

SPP_RetVal_t SPP_SERVICES_BMP390_enableSpiMode ( void * p_spiHandler)
static

Writes the interface-config register to lock the sensor into SPI mode.

Parameters
p_spiHandlerSPI device handle.
Returns
K_SPP_OK on success, K_SPP_ERROR on SPI failure.

Definition at line 320 of file bmp390.c.

References BMP390_IF_CONF_SPI, K_BMP390_IF_CONF_REG, SPP_HAL_SPI_transmit(), SPP_HAL_TIME_delayMs(), and SPP_SERVICES_BMP390_enableSpiMode().

Referenced by SPP_SERVICES_BMP390_auxConfig(), and SPP_SERVICES_BMP390_enableSpiMode().

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

◆ SPP_SERVICES_BMP390_configCheck()

SPP_RetVal_t SPP_SERVICES_BMP390_configCheck ( void * p_spiHandler)
static

Reads the chip-ID register and returns an error if the value is not 0x60.

Parameters
p_spiHandlerSPI device handle.
Returns
K_SPP_OK if chip ID matches, K_SPP_ERROR otherwise.

Definition at line 333 of file bmp390.c.

References K_BMP390_CHIP_ID_REG, K_BMP390_IF_CONF_REG, K_BMP390_SOFT_RESET_REG, K_BMP390_SPI_READ, K_BMP390_SPI_WRITE, K_BMP390_TAG, K_SPP_ERROR, K_SPP_OK, SPP_HAL_SPI_transmit(), SPP_LOGE, SPP_LOGI, and SPP_SERVICES_BMP390_configCheck().

Referenced by SPP_SERVICES_BMP390_auxConfig(), and SPP_SERVICES_BMP390_configCheck().

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

◆ SPP_SERVICES_BMP390_auxConfig()

SPP_RetVal_t SPP_SERVICES_BMP390_auxConfig ( void * p_spiHandler)
static

Resets the sensor, enables SPI mode, and verifies the chip ID.

Parameters
p_spiHandlerSPI device handle.
Returns
K_SPP_OK on success, K_SPP_ERROR if any step fails.

Definition at line 363 of file bmp390.c.

References K_SPP_OK, SPP_SERVICES_BMP390_auxConfig(), SPP_SERVICES_BMP390_configCheck(), SPP_SERVICES_BMP390_enableSpiMode(), and SPP_SERVICES_BMP390_softReset().

Referenced by SPP_SERVICES_BMP390_auxConfig(), and SPP_SERVICES_BMP390_init().

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

◆ SPP_SERVICES_BMP390_prepareMeasure()

SPP_RetVal_t SPP_SERVICES_BMP390_prepareMeasure ( void * p_spiHandler)
static

Writes OSR, ODR, IIR and power-control registers to start continuous measurements.

Parameters
p_spiHandlerSPI device handle.
Returns
K_SPP_OK on success, K_SPP_ERROR on SPI failure.

Definition at line 393 of file bmp390.c.

References BMP390_VALUE_IIR, BMP390_VALUE_ODR, BMP390_VALUE_OSR, BMP390_VALUE_PWRCTRL, K_BMP390_REG_IIR, K_BMP390_REG_ODR, K_BMP390_REG_OSR, K_BMP390_REG_PWRCTRL, SPP_HAL_SPI_transmit(), and SPP_SERVICES_BMP390_prepareMeasure().

Referenced by SPP_SERVICES_BMP390_init(), and SPP_SERVICES_BMP390_prepareMeasure().

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

◆ SPP_SERVICES_BMP390_readRawTempCoeffs()

SPP_RetVal_t SPP_SERVICES_BMP390_readRawTempCoeffs ( void * p_spiHandler,
BMP390_temp_calib_t * tcalib )
static

Reads raw temperature calibration coefficients from the sensor's NVM registers.

Parameters
p_spiHandlerSPI device handle.
tcalibOutput struct populated with raw par_t1/t2/t3 values.
Returns
K_SPP_OK on success, K_SPP_ERROR on SPI failure.

Definition at line 413 of file bmp390.c.

References K_BMP390_SPI_READ, K_BMP390_SPI_WRITE, K_BMP390_TEMP_CALIB_REG_START, K_SPP_OK, BMP390_temp_calib_t::par_t1, BMP390_temp_calib_t::par_t2, BMP390_temp_calib_t::par_t3, SPP_HAL_SPI_transmit(), and SPP_SERVICES_BMP390_readRawTempCoeffs().

Referenced by SPP_SERVICES_BMP390_calibrateTempParams(), and SPP_SERVICES_BMP390_readRawTempCoeffs().

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

◆ SPP_SERVICES_BMP390_calibrateTempParams()

SPP_RetVal_t SPP_SERVICES_BMP390_calibrateTempParams ( void * p_spiHandler,
BMP390_temp_params_t * out )
static

Reads raw temperature coefficients and scales them to floating-point parameters.

Parameters
p_spiHandlerSPI device handle.
outOutput struct populated with scaled PAR_T1/T2/T3.
Returns
K_SPP_OK on success, K_SPP_ERROR on SPI failure.

Definition at line 448 of file bmp390.c.

References K_SPP_OK, BMP390_temp_params_t::PAR_T1, BMP390_temp_calib_t::par_t1, BMP390_temp_params_t::PAR_T2, BMP390_temp_calib_t::par_t2, BMP390_temp_params_t::PAR_T3, BMP390_temp_calib_t::par_t3, SPP_SERVICES_BMP390_calibrateTempParams(), and SPP_SERVICES_BMP390_readRawTempCoeffs().

Referenced by SPP_SERVICES_BMP390_calibrateTempParams(), and SPP_SERVICES_BMP390_getAltitude().

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

◆ SPP_SERVICES_BMP390_readRawTemp()

SPP_RetVal_t SPP_SERVICES_BMP390_readRawTemp ( void * p_spiHandler,
uint32_t * raw_temp )
static

Reads the 24-bit raw temperature ADC value from the sensor.

Parameters
p_spiHandlerSPI device handle.
raw_tempOutput: raw 24-bit ADC reading.
Returns
K_SPP_OK on success, K_SPP_ERROR on SPI failure.

Definition at line 471 of file bmp390.c.

References K_BMP390_SPI_READ, K_BMP390_SPI_WRITE, K_BMP390_TEMP_RAW_REG, K_SPP_OK, SPP_HAL_SPI_transmit(), and SPP_SERVICES_BMP390_readRawTemp().

Referenced by SPP_SERVICES_BMP390_auxGetTemp(), and SPP_SERVICES_BMP390_readRawTemp().

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

◆ SPP_SERVICES_BMP390_compensateTemperature()

float SPP_SERVICES_BMP390_compensateTemperature ( spp_uint32_t raw_temp,
BMP390_temp_params_t * params )
static

Applies the BMP390 double-quadratic temperature compensation formula.

Parameters
raw_tempRaw 24-bit ADC reading from the sensor.
paramsScaled calibration parameters (PAR_T1/T2/T3).
Returns
Compensated temperature in degrees Celsius (t_lin).

Definition at line 504 of file bmp390.c.

References BMP390_temp_params_t::PAR_T1, BMP390_temp_params_t::PAR_T2, BMP390_temp_params_t::PAR_T3, and SPP_SERVICES_BMP390_compensateTemperature().

Referenced by SPP_SERVICES_BMP390_auxGetTemp(), and SPP_SERVICES_BMP390_compensateTemperature().

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

◆ SPP_SERVICES_BMP390_auxGetTemp()

SPP_RetVal_t SPP_SERVICES_BMP390_auxGetTemp ( void * p_spiHandler,
const BMP390_temp_params_t * temp_params,
spp_uint32_t * raw_temp,
float * comp_temp )
static

Reads the raw temperature ADC and returns the compensated value.

Parameters
p_spiHandlerSPI device handle.
temp_paramsScaled calibration parameters.
raw_tempOutput: raw ADC reading.
comp_tempOutput: compensated temperature in °C.
Returns
K_SPP_OK on success, K_SPP_ERROR on SPI failure.

Definition at line 521 of file bmp390.c.

References K_SPP_OK, SPP_SERVICES_BMP390_auxGetTemp(), SPP_SERVICES_BMP390_compensateTemperature(), and SPP_SERVICES_BMP390_readRawTemp().

Referenced by SPP_SERVICES_BMP390_auxGetTemp(), and SPP_SERVICES_BMP390_getAltitude().

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

◆ SPP_SERVICES_BMP390_readRawPressCoeffs()

SPP_RetVal_t SPP_SERVICES_BMP390_readRawPressCoeffs ( void * p_spiHandler,
BMP390_press_calib_t * pcalib )
static

Reads raw pressure calibration coefficients from the sensor's NVM registers.

Parameters
p_spiHandlerSPI device handle.
pcalibOutput struct populated with raw par_p1..p11 values.
Returns
K_SPP_OK on success, K_SPP_ERROR on SPI failure.

Definition at line 545 of file bmp390.c.

References K_BMP390_PRESS_CALIB_REG_START, K_BMP390_SPI_READ, K_BMP390_SPI_WRITE, K_SPP_OK, BMP390_press_calib_t::par_p1, BMP390_press_calib_t::par_p10, BMP390_press_calib_t::par_p11, BMP390_press_calib_t::par_p2, BMP390_press_calib_t::par_p3, BMP390_press_calib_t::par_p4, BMP390_press_calib_t::par_p5, BMP390_press_calib_t::par_p6, BMP390_press_calib_t::par_p7, BMP390_press_calib_t::par_p8, BMP390_press_calib_t::par_p9, SPP_HAL_SPI_transmit(), and SPP_SERVICES_BMP390_readRawPressCoeffs().

Referenced by SPP_SERVICES_BMP390_calibratePressParams(), and SPP_SERVICES_BMP390_readRawPressCoeffs().

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

◆ SPP_SERVICES_BMP390_calibratePressParams()

SPP_RetVal_t SPP_SERVICES_BMP390_calibratePressParams ( void * p_spiHandler,
BMP390_press_params_t * out )
static

Reads raw pressure coefficients and scales them to floating-point parameters.

Parameters
p_spiHandlerSPI device handle.
outOutput struct populated with scaled PAR_P1..P11.
Returns
K_SPP_OK on success, K_SPP_ERROR on SPI failure.

Definition at line 629 of file bmp390.c.

References K_SPP_OK, BMP390_press_params_t::PAR_P1, BMP390_press_calib_t::par_p1, BMP390_press_params_t::PAR_P10, BMP390_press_calib_t::par_p10, BMP390_press_params_t::PAR_P11, BMP390_press_calib_t::par_p11, BMP390_press_params_t::PAR_P2, BMP390_press_calib_t::par_p2, BMP390_press_params_t::PAR_P3, BMP390_press_calib_t::par_p3, BMP390_press_params_t::PAR_P4, BMP390_press_calib_t::par_p4, BMP390_press_params_t::PAR_P5, BMP390_press_calib_t::par_p5, BMP390_press_params_t::PAR_P6, BMP390_press_calib_t::par_p6, BMP390_press_params_t::PAR_P7, BMP390_press_calib_t::par_p7, BMP390_press_params_t::PAR_P8, BMP390_press_calib_t::par_p8, BMP390_press_params_t::PAR_P9, BMP390_press_calib_t::par_p9, SPP_SERVICES_BMP390_calibratePressParams(), and SPP_SERVICES_BMP390_readRawPressCoeffs().

Referenced by SPP_SERVICES_BMP390_calibratePressParams(), and SPP_SERVICES_BMP390_getAltitude().

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

◆ SPP_SERVICES_BMP390_readRawPress()

SPP_RetVal_t SPP_SERVICES_BMP390_readRawPress ( void * p_spiHandler,
spp_uint32_t * raw_press )
static

Reads the 24-bit raw pressure ADC value from the sensor.

Parameters
p_spiHandlerSPI device handle.
raw_pressOutput: raw 24-bit ADC reading.
Returns
K_SPP_OK on success, K_SPP_ERROR on SPI failure.

Definition at line 660 of file bmp390.c.

References K_BMP390_PRESS_RAW_REG, K_BMP390_SPI_READ, K_BMP390_SPI_WRITE, K_SPP_OK, SPP_HAL_SPI_transmit(), and SPP_SERVICES_BMP390_readRawPress().

Referenced by SPP_SERVICES_BMP390_auxGetPress(), and SPP_SERVICES_BMP390_readRawPress().

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

◆ SPP_SERVICES_BMP390_compensatePressure()

float SPP_SERVICES_BMP390_compensatePressure ( spp_uint32_t raw_press,
float t_lin,
BMP390_press_params_t * p )
static

Applies the BMP390 pressure compensation formula using the linearised temperature.

Parameters
raw_pressRaw 24-bit ADC pressure reading.
t_linLinearised (compensated) temperature in °C.
pScaled pressure calibration parameters.
Returns
Compensated pressure in Pa.

Definition at line 694 of file bmp390.c.

References BMP390_press_params_t::PAR_P1, BMP390_press_params_t::PAR_P10, BMP390_press_params_t::PAR_P11, BMP390_press_params_t::PAR_P2, BMP390_press_params_t::PAR_P3, BMP390_press_params_t::PAR_P4, BMP390_press_params_t::PAR_P5, BMP390_press_params_t::PAR_P6, BMP390_press_params_t::PAR_P7, BMP390_press_params_t::PAR_P8, BMP390_press_params_t::PAR_P9, s_compPress, s_pd1, s_pd2, s_pd3, s_pd4, s_po1, s_po2, and SPP_SERVICES_BMP390_compensatePressure().

Referenced by SPP_SERVICES_BMP390_auxGetPress(), and SPP_SERVICES_BMP390_compensatePressure().

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

◆ SPP_SERVICES_BMP390_auxGetPress()

SPP_RetVal_t SPP_SERVICES_BMP390_auxGetPress ( void * p_spiHandler,
const BMP390_press_params_t * press_params,
float t_lin,
spp_uint32_t * raw_press,
float * comp_press )
static

Reads raw pressure ADC and returns the compensated value in Pa.

Parameters
p_spiHandlerSPI device handle.
press_paramsScaled pressure calibration parameters.
t_linLinearised temperature used for pressure compensation.
raw_pressOutput: raw 24-bit ADC reading.
comp_pressOutput: compensated pressure in Pa.
Returns
K_SPP_OK on success, K_SPP_ERROR on SPI failure.

Definition at line 725 of file bmp390.c.

References K_SPP_OK, SPP_SERVICES_BMP390_auxGetPress(), SPP_SERVICES_BMP390_compensatePressure(), and SPP_SERVICES_BMP390_readRawPress().

Referenced by SPP_SERVICES_BMP390_auxGetPress(), and SPP_SERVICES_BMP390_getAltitude().

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

◆ SPP_SERVICES_BMP390_getAltitude()

SPP_RetVal_t SPP_SERVICES_BMP390_getAltitude ( void * p_spiHandler,
float * altitude_m,
float * pressure_pa,
float * temperature_c )
static

Reads compensated temperature and pressure, and computes relative altitude.

Parameters
p_spiHandlerSPI device handle.
altitude_mOutput: altitude relative to launch-site reference pressure and temperature.
pressure_paOutput: compensated pressure in Pa.
temperature_cOutput: compensated temperature in °C.
Returns
K_SPP_OK on success, K_SPP_ERROR_NULL_POINTER if any pointer is NULL, K_SPP_ERROR on SPI failure.

Definition at line 752 of file bmp390.c.

References K_SPP_ERROR_NULL_POINTER, K_SPP_OK, s_isCalibrated, s_referencePressure, s_referenceTemperature, SPP_SERVICES_BMP390_auxGetPress(), SPP_SERVICES_BMP390_auxGetTemp(), SPP_SERVICES_BMP390_calibratePressParams(), SPP_SERVICES_BMP390_calibrateTempParams(), and SPP_SERVICES_BMP390_getAltitude().

Referenced by SPP_SERVICES_BMP390_acquireData(), and SPP_SERVICES_BMP390_getAltitude().

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

◆ SPP_SERVICES_BMP390_intEnableDrdy()

SPP_RetVal_t SPP_SERVICES_BMP390_intEnableDrdy ( void * p_spiHandler)
static

Enables the active-high data-ready interrupt output on the sensor.

Parameters
p_spiHandlerSPI device handle.
Returns
K_SPP_OK on success, K_SPP_ERROR on SPI failure.

Definition at line 824 of file bmp390.c.

References K_BMP390_INT_CTRL_DRDY_EN, K_BMP390_INT_CTRL_LEVEL, K_BMP390_REG_INT_CTRL, SPP_HAL_SPI_transmit(), and SPP_SERVICES_BMP390_intEnableDrdy().

Referenced by SPP_SERVICES_BMP390_init(), and SPP_SERVICES_BMP390_intEnableDrdy().

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

◆ SPP_SERVICES_BMP390_getProducerContract()

const SPP_SERVICE_ProducerContract_t * SPP_SERVICES_BMP390_getProducerContract ( void )

Returns the BMP390 producer contract for PUBSUB registration.

Returns
Pointer to the static producer contract.

Definition at line 101 of file bmp390.c.

References g_bmp390ProducerContract, and SPP_SERVICES_BMP390_getProducerContract().

Referenced by CUSTOM_registerConsumerProducer(), guard_startInitializationOfModules(), and SPP_SERVICES_BMP390_getProducerContract().

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

Variable Documentation

◆ g_bmp390ProducerContract

const SPP_SERVICE_ProducerContract_t g_bmp390ProducerContract
static
Initial value:
= {.p_nameProducer = "bmp390",
#define K_BMP390_TASK_TIMEOUT_MS
Definition bmp390.c:31
static SPP_RetVal_t SPP_SERVICES_BMP390_init(void)
Initializes the BMP390 sensor and its hardware interfaces.
Definition bmp390.c:139
static SPP_RetVal_t SPP_SERVICES_BMP390_acquireData(SPP_Kpid_t kpid)
Acquires BMP390 measurements and publishes them through PUBSUB.
Definition bmp390.c:202

Definition at line 76 of file bmp390.c.

Referenced by SPP_SERVICES_BMP390_getProducerContract().

◆ s_bmpData

BMP390_t s_bmpData
static

Definition at line 80 of file bmp390.c.

Referenced by SPP_SERVICES_BMP390_acquireData(), and SPP_SERVICES_BMP390_init().

◆ k_svcTag

const char* const k_svcTag = "BMP_SVC"
static

Definition at line 81 of file bmp390.c.

Referenced by SPP_SERVICES_BMP390_acquireData().

◆ s_pd1

float s_pd1
static

Definition at line 82 of file bmp390.c.

Referenced by SPP_SERVICES_BMP390_compensatePressure().

◆ s_pd2

float s_pd2
static

Definition at line 82 of file bmp390.c.

Referenced by SPP_SERVICES_BMP390_compensatePressure().

◆ s_pd3

float s_pd3
static

Definition at line 82 of file bmp390.c.

Referenced by SPP_SERVICES_BMP390_compensatePressure().

◆ s_pd4

float s_pd4
static

Definition at line 82 of file bmp390.c.

Referenced by SPP_SERVICES_BMP390_compensatePressure().

◆ s_po1

float s_po1
static

Definition at line 83 of file bmp390.c.

Referenced by SPP_SERVICES_BMP390_compensatePressure().

◆ s_po2

float s_po2
static

Definition at line 83 of file bmp390.c.

Referenced by SPP_SERVICES_BMP390_compensatePressure().

◆ s_compPress

float s_compPress
static

Definition at line 84 of file bmp390.c.

Referenced by SPP_SERVICES_BMP390_compensatePressure().

◆ s_isCalibrated

spp_bool_t s_isCalibrated = false

Definition at line 88 of file bmp390.c.

Referenced by SPP_SERVICES_BMP390_acquireData(), and SPP_SERVICES_BMP390_getAltitude().

◆ s_calibrationSamples

spp_uint16_t s_calibrationSamples = 0

Definition at line 89 of file bmp390.c.

Referenced by SPP_SERVICES_BMP390_acquireData().

◆ s_pressureSum

spp_float32_t s_pressureSum = 0.0f

Definition at line 91 of file bmp390.c.

Referenced by SPP_SERVICES_BMP390_acquireData().

◆ s_temperatureSum

spp_float32_t s_temperatureSum = 0.0f

Definition at line 92 of file bmp390.c.

Referenced by SPP_SERVICES_BMP390_acquireData().

◆ s_referencePressure

spp_float32_t s_referencePressure = 0.0f

Definition at line 94 of file bmp390.c.

Referenced by SPP_SERVICES_BMP390_acquireData(), and SPP_SERVICES_BMP390_getAltitude().

◆ s_referenceTemperature

spp_float32_t s_referenceTemperature = 0.0f

Definition at line 95 of file bmp390.c.

Referenced by SPP_SERVICES_BMP390_acquireData(), and SPP_SERVICES_BMP390_getAltitude().