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

BMP390 barometric pressure sensor driver and service. More...

#include <stdint.h>
#include "spp/core/returnTypes.h"
#include "spp/core/types.h"
#include "spp/hal/gpio/gpio.h"
#include "spp/services/service.h"
Include dependency graph for bmp390.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  BMP390_temp_calib_t
 Raw temperature calibration coefficients (as read from sensor). More...
struct  BMP390_temp_params_t
 Scaled temperature calibration parameters. More...
struct  BMP390_press_calib_t
 Raw pressure calibration coefficients. More...
struct  BMP390_press_params_t
 Scaled pressure calibration parameters. More...
struct  BMP390_SpiConfig_t
struct  BMP390_GpioConfig_t
struct  BMP390_t
 BMP390 sensor instance. More...

Macros

#define K_BMP_SERVICE_TASK_PRIO   (5U)
#define K_BMP_SERVICE_TASK_DELAY_MS   (200U)
#define K_BMP_SERVICE_TASK_STACK_SIZE   (4096U)
#define K_BMP_SERVICE_PAYLOAD_LEN   (12U)
#define K_BMP390_SPI_READ   0x80U
#define K_BMP390_SPI_WRITE   0x00U
#define K_BMP390_PIN_NUM_CS   18U
#define K_BMP390_SPI_BUS_IDX   0U
#define K_BMP390_CHIP_ID_REG   0x00
#define K_BMP390_CHIP_ID_VALUE   0x60
#define K_BMP390_SOFT_RESET_REG   0x7E
#define BMP390_SOFT_RESET_CMD   0xB6
#define K_BMP390_IF_CONF_REG   0x1A
#define BMP390_IF_CONF_SPI   0x00
#define K_BMP390_REG_PWRCTRL   0x1B
#define BMP390_VALUE_PWRCTRL   0x33
#define K_BMP390_REG_OSR   0x1C
#define BMP390_VALUE_OSR   0x00
#define K_BMP390_REG_ODR   0x1D
#define BMP390_VALUE_ODR   0x01
#define K_BMP390_REG_IIR   0x1F
#define BMP390_VALUE_IIR   0x02
#define K_BMP390_REG_STATUS   0x03
#define K_BMP390_STATUS_DRDY_TEMP   0x40
#define BMP390_STATUS_DRDY_PRES   0x20
#define K_BMP390_TEMP_CALIB_REG_START   0x31
#define K_BMP390_TEMP_RAW_REG   0x07
#define K_BMP390_DRDY_TIMEOUT_MS   5000U
#define K_BMP390_PRESS_CALIB_REG_START   0x36
#define K_BMP390_PRESS_RAW_REG   0x04
#define K_BMP390_REG_INT_CTRL   0x19
#define K_BMP390_INT_CTRL_DRDY_EN   0x40
#define K_BMP390_INT_CTRL_LEVEL   0x02
#define K_BMP390_INT_PIN_NUM   3U
#define K_BMP390_INT_INTR_TYPE   1U
#define K_BMP390_INT_PULL   0U

Functions

const SPP_SERVICE_ProducerContract_t * SPP_SERVICES_BMP390_getProducerContract (void)
spp_uint16_t SPP_SERVICES_BMP390_getPerformanceSampleCount (void)
SPP_RetVal_t SPP_SERVICES_BMP390_getPerformanceSample (spp_uint16_t index, spp_uint32_t *p_bmpUs, spp_uint32_t *p_tempSpiUs, spp_uint32_t *p_pressSpiUs)

Detailed Description

BMP390 barometric pressure sensor driver and service.

Provides SPI-based communication with the Bosch BMP390 sensor for reading calibrated temperature, pressure and derived altitude. Supports data-ready interrupt via GPIO event groups.

The driver follows a three-step workflow:

  1. Initialise and configure the sensor (SPP_SERVICES_BMP390_init, SPP_SERVICES_BMP390_auxConfig, SPP_SERVICES_BMP390_prepareMeasure).
  2. Wait for the data-ready interrupt (SPP_SERVICES_BMP390_waitDrdy).
  3. Read compensated altitude/pressure/temperature (SPP_SERVICES_BMP390_getAltitude).

To use the SPP service registry, declare a BMP390_t with the hardware pin fields filled in, then call SPP_SERVICES_register() with g_bmp390Module.

Naming conventions used in this file:

  • Constants/macros: K_BMP390_*
  • Types: BMP390_*_t
  • Public functions: BMP390_*()
  • Pointer params: p_*

Definition in file bmp390.h.

Macro Definition Documentation

◆ K_BMP_SERVICE_TASK_PRIO

#define K_BMP_SERVICE_TASK_PRIO   (5U)

FreeRTOS task priority for the BMP390 service.

Definition at line 39 of file bmp390.h.

◆ K_BMP_SERVICE_TASK_DELAY_MS

#define K_BMP_SERVICE_TASK_DELAY_MS   (200U)

Delay in ms between measurement cycles.

Definition at line 40 of file bmp390.h.

◆ K_BMP_SERVICE_TASK_STACK_SIZE

#define K_BMP_SERVICE_TASK_STACK_SIZE   (4096U)

Stack size in bytes for the BMP390 service task.

Definition at line 41 of file bmp390.h.

◆ K_BMP_SERVICE_PAYLOAD_LEN

#define K_BMP_SERVICE_PAYLOAD_LEN   (12U)

Payload length in bytes (temp + press + alt).

Definition at line 42 of file bmp390.h.

◆ K_BMP390_SPI_READ

#define K_BMP390_SPI_READ   0x80U

◆ K_BMP390_SPI_WRITE

#define K_BMP390_SPI_WRITE   0x00U

◆ K_BMP390_PIN_NUM_CS

#define K_BMP390_PIN_NUM_CS   18U

Chip-select GPIO pin (informational; set by HAL).

Definition at line 47 of file bmp390.h.

◆ K_BMP390_SPI_BUS_IDX

#define K_BMP390_SPI_BUS_IDX   0U

SPI bus index (informational; set by HAL).

Definition at line 48 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_init().

◆ K_BMP390_CHIP_ID_REG

#define K_BMP390_CHIP_ID_REG   0x00

Chip ID register address.

Definition at line 51 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_configCheck().

◆ K_BMP390_CHIP_ID_VALUE

#define K_BMP390_CHIP_ID_VALUE   0x60

Expected chip ID value.

Definition at line 52 of file bmp390.h.

◆ K_BMP390_SOFT_RESET_REG

#define K_BMP390_SOFT_RESET_REG   0x7E

Soft-reset register address.

Definition at line 53 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_configCheck(), and SPP_SERVICES_BMP390_softReset().

◆ BMP390_SOFT_RESET_CMD

#define BMP390_SOFT_RESET_CMD   0xB6

Soft-reset command byte.

Definition at line 54 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_softReset().

◆ K_BMP390_IF_CONF_REG

#define K_BMP390_IF_CONF_REG   0x1A

Interface configuration register address.

Definition at line 55 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_configCheck(), and SPP_SERVICES_BMP390_enableSpiMode().

◆ BMP390_IF_CONF_SPI

#define BMP390_IF_CONF_SPI   0x00

SPI interface mode value.

Definition at line 56 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_enableSpiMode().

◆ K_BMP390_REG_PWRCTRL

#define K_BMP390_REG_PWRCTRL   0x1B

Power control register address.

Definition at line 59 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_prepareMeasure().

◆ BMP390_VALUE_PWRCTRL

#define BMP390_VALUE_PWRCTRL   0x33

Power control value (temp+press on, normal mode).

Definition at line 60 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_prepareMeasure().

◆ K_BMP390_REG_OSR

#define K_BMP390_REG_OSR   0x1C

Oversampling register address.

Definition at line 61 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_prepareMeasure().

◆ BMP390_VALUE_OSR

#define BMP390_VALUE_OSR   0x00

Oversampling value (no oversampling).

Definition at line 62 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_prepareMeasure().

◆ K_BMP390_REG_ODR

#define K_BMP390_REG_ODR   0x1D

Output data rate register address.

Definition at line 63 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_prepareMeasure().

◆ BMP390_VALUE_ODR

#define BMP390_VALUE_ODR   0x01

Output data rate value.

Definition at line 64 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_prepareMeasure().

◆ K_BMP390_REG_IIR

#define K_BMP390_REG_IIR   0x1F

IIR filter register address.

Definition at line 65 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_prepareMeasure().

◆ BMP390_VALUE_IIR

#define BMP390_VALUE_IIR   0x02

IIR filter coefficient value.

Definition at line 66 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_prepareMeasure().

◆ K_BMP390_REG_STATUS

#define K_BMP390_REG_STATUS   0x03

Status register address.

Definition at line 69 of file bmp390.h.

◆ K_BMP390_STATUS_DRDY_TEMP

#define K_BMP390_STATUS_DRDY_TEMP   0x40

Status bit: temperature data ready.

Definition at line 70 of file bmp390.h.

◆ BMP390_STATUS_DRDY_PRES

#define BMP390_STATUS_DRDY_PRES   0x20

Status bit: pressure data ready.

Definition at line 71 of file bmp390.h.

◆ K_BMP390_TEMP_CALIB_REG_START

#define K_BMP390_TEMP_CALIB_REG_START   0x31

Start address of temperature calibration regs.

Definition at line 74 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_readRawTempCoeffs().

◆ K_BMP390_TEMP_RAW_REG

#define K_BMP390_TEMP_RAW_REG   0x07

Start address of raw temperature data regs.

Definition at line 75 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_readRawTemp().

◆ K_BMP390_DRDY_TIMEOUT_MS

#define K_BMP390_DRDY_TIMEOUT_MS   5000U

Timeout in ms for the data-ready interrupt wait.

Definition at line 76 of file bmp390.h.

◆ K_BMP390_PRESS_CALIB_REG_START

#define K_BMP390_PRESS_CALIB_REG_START   0x36

Start address of pressure calibration regs.

Definition at line 79 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_readRawPressCoeffs().

◆ K_BMP390_PRESS_RAW_REG

#define K_BMP390_PRESS_RAW_REG   0x04

Start address of raw pressure data regs.

Definition at line 80 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_readRawPress().

◆ K_BMP390_REG_INT_CTRL

#define K_BMP390_REG_INT_CTRL   0x19

Interrupt control register address.

Definition at line 83 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_intEnableDrdy().

◆ K_BMP390_INT_CTRL_DRDY_EN

#define K_BMP390_INT_CTRL_DRDY_EN   0x40

Interrupt control: enable data-ready interrupt.

Definition at line 84 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_intEnableDrdy().

◆ K_BMP390_INT_CTRL_LEVEL

#define K_BMP390_INT_CTRL_LEVEL   0x02

Interrupt control: active-high level.

Definition at line 85 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_intEnableDrdy().

◆ K_BMP390_INT_PIN_NUM

#define K_BMP390_INT_PIN_NUM   3U

Interrupt GPIO pin

Definition at line 86 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_init().

◆ K_BMP390_INT_INTR_TYPE

#define K_BMP390_INT_INTR_TYPE   1U

Interrupt trigger type (1=rising).

Definition at line 87 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_init().

◆ K_BMP390_INT_PULL

#define K_BMP390_INT_PULL   0U

Pull resistor: 0=none 1=up 2=down.

Definition at line 88 of file bmp390.h.

Referenced by SPP_SERVICES_BMP390_init().

Function Documentation

◆ SPP_SERVICES_BMP390_getProducerContract()

const SPP_SERVICE_ProducerContract_t * SPP_SERVICES_BMP390_getProducerContract ( void )

Definition at line 87 of file bmp390.c.

References g_bmp390ProducerContract, and SPP_SERVICES_BMP390_getProducerContract().

Referenced by CUSTOM_registerConsumerProducer(), and SPP_SERVICES_BMP390_getProducerContract().

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

◆ SPP_SERVICES_BMP390_getPerformanceSampleCount()

spp_uint16_t SPP_SERVICES_BMP390_getPerformanceSampleCount ( void )

References SPP_SERVICES_BMP390_getPerformanceSampleCount().

Referenced by SPP_SERVICES_BMP390_getPerformanceSampleCount().

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

◆ SPP_SERVICES_BMP390_getPerformanceSample()

SPP_RetVal_t SPP_SERVICES_BMP390_getPerformanceSample ( spp_uint16_t index,
spp_uint32_t * p_bmpUs,
spp_uint32_t * p_tempSpiUs,
spp_uint32_t * p_pressSpiUs )

References SPP_SERVICES_BMP390_getPerformanceSample().

Referenced by SPP_SERVICES_BMP390_getPerformanceSample().

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