L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
bar_bmp585.c File Reference
#include "bar_bmp585.h"
#include "i2c.h"
#include "utils/mydefs.h"
#include "mymems.h"
#include "mysensors_base.h"
#include <stdio.h>
#include <math.h>
#include "tmphm_sht45.h"
Include dependency graph for bar_bmp585.c:

Go to the source code of this file.

Macros

#define BMP585_I2C_ADDR   (0x46 << 1)
#define REG_CHIP_ID   0x01
#define REG_STATUS   0x28
#define REG_DATA_0   0x20
#define REG_DATA_1   0x21
#define REG_DATA_2   0x22
#define REG_TEMP_DATA_0   0x1D
#define REG_TEMP_DATA_1   0x1E
#define REG_TEMP_DATA_2   0x1F
#define REG_OSR_CONFIG   0x36
#define REG_ODR_CONFIG   0x37
#define REG_INT_CONFIG   0x38
#define REG_IF_CONFIG   0x39
#define REG_CMD   0x7E
#define BMP585_CHIP_ID   0x50
#define BAR_MODE_STANDBY   0x00
#define BAR_MODE_NORMAL   0x01
#define BAR_MODE_FORCED   0x02
#define BAR_MODE_DEEP_SLEEP   0x00

Functions

static HAL_StatusTypeDef bar_bmp585_IsOn (I2C_HandleTypeDef *hi2c, uint8_t *onOff)
 Check if sensor is turned on.
static HAL_StatusTypeDef barometer_onOff (I2C_HandleTypeDef *hi2c, uint8_t onOff)
 Control sensor power mode.
int8_t bar_bmp585_Is (I2C_HandleTypeDef *hi2c, int8_t tryInit)
 Check if sensor is present.
HAL_StatusTypeDef bar_bmp585_On (I2C_HandleTypeDef *hi2c)
 Turn on sensor - wakeup the sensor and start to processing of pressure measure.
HAL_StatusTypeDef bar_bmp585_Off (I2C_HandleTypeDef *hi2c)
 Turn off sensor - stop measure and put sensor in very deep sleep mode.
HAL_StatusTypeDef bar_bmp585_Init (I2C_HandleTypeDef *hi2c)
 Initialize sensor, check if it really is this sensor. After check the sensor is turned off to save power.
HAL_StatusTypeDef bar_bmp585_Read (I2C_HandleTypeDef *hi2c)
 Read value from sensor, pressure and temperature. Sensor must be turned on before.
void bar_bmp585_LogData (char *buf)
 Log data to buffer.

Variables

bar_bmp585_t _bar_bmp585Data = {}
 Live measurement data from the BMP585 sensor; updated by bar_bmp585_Read().
bar_bmp585_t _bck_bar_bmp585Data = {}
 Snapshot copy of the last completed BMP585 measurement; used for LoRaWAN transmission.
static uint8_t _isBarometer = 0

Macro Definition Documentation

◆ BAR_MODE_DEEP_SLEEP

#define BAR_MODE_DEEP_SLEEP   0x00

Definition at line 45 of file bar_bmp585.c.

◆ BAR_MODE_FORCED

#define BAR_MODE_FORCED   0x02

Definition at line 44 of file bar_bmp585.c.

◆ BAR_MODE_NORMAL

#define BAR_MODE_NORMAL   0x01

Definition at line 43 of file bar_bmp585.c.

◆ BAR_MODE_STANDBY

#define BAR_MODE_STANDBY   0x00

Definition at line 42 of file bar_bmp585.c.

◆ BMP585_CHIP_ID

#define BMP585_CHIP_ID   0x50

Definition at line 39 of file bar_bmp585.c.

Referenced by bar_bmp585_Init().

◆ BMP585_I2C_ADDR

#define BMP585_I2C_ADDR   (0x46 << 1)

Definition at line 21 of file bar_bmp585.c.

Referenced by bar_bmp585_Init(), bar_bmp585_IsOn(), bar_bmp585_Read(), and barometer_onOff().

◆ REG_CHIP_ID

#define REG_CHIP_ID   0x01

Definition at line 24 of file bar_bmp585.c.

Referenced by bar_bmp585_Init().

◆ REG_CMD

#define REG_CMD   0x7E

Definition at line 36 of file bar_bmp585.c.

◆ REG_DATA_0

#define REG_DATA_0   0x20

Definition at line 26 of file bar_bmp585.c.

Referenced by bar_bmp585_Read().

◆ REG_DATA_1

#define REG_DATA_1   0x21

Definition at line 27 of file bar_bmp585.c.

◆ REG_DATA_2

#define REG_DATA_2   0x22

Definition at line 28 of file bar_bmp585.c.

◆ REG_IF_CONFIG

#define REG_IF_CONFIG   0x39

Definition at line 35 of file bar_bmp585.c.

◆ REG_INT_CONFIG

#define REG_INT_CONFIG   0x38

Definition at line 34 of file bar_bmp585.c.

◆ REG_ODR_CONFIG

#define REG_ODR_CONFIG   0x37

Definition at line 33 of file bar_bmp585.c.

Referenced by bar_bmp585_IsOn(), and barometer_onOff().

◆ REG_OSR_CONFIG

#define REG_OSR_CONFIG   0x36

Definition at line 32 of file bar_bmp585.c.

Referenced by bar_bmp585_Init().

◆ REG_STATUS

#define REG_STATUS   0x28

Definition at line 25 of file bar_bmp585.c.

◆ REG_TEMP_DATA_0

#define REG_TEMP_DATA_0   0x1D

Definition at line 29 of file bar_bmp585.c.

Referenced by bar_bmp585_Read().

◆ REG_TEMP_DATA_1

#define REG_TEMP_DATA_1   0x1E

Definition at line 30 of file bar_bmp585.c.

◆ REG_TEMP_DATA_2

#define REG_TEMP_DATA_2   0x1F

Definition at line 31 of file bar_bmp585.c.

Function Documentation

◆ bar_bmp585_Init()

HAL_StatusTypeDef bar_bmp585_Init ( I2C_HandleTypeDef * hi2c)

Initialize sensor, check if it really is this sensor. After check the sensor is turned off to save power.

Parameters
hi2c- I2C handle
Return values
HAL_OK,HAL_ERROR

Definition at line 119 of file bar_bmp585.c.

References _isBarometer, bar_bmp585_Off(), bar_bmp585_On(), BMP585_CHIP_ID, BMP585_I2C_ADDR, I2C_IsDeviceReadyMT(), REG_CHIP_ID, and REG_OSR_CONFIG.

Referenced by bar_bmp585_Is().

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

◆ bar_bmp585_Is()

int8_t bar_bmp585_Is ( I2C_HandleTypeDef * hi2c,
int8_t tryInit )

Check if sensor is present.

Parameters
hi2c- I2C handle
tryInit- in case sensor is not yet initialized, 1 - attempt to initialize again, 0 - no
Return values
1- is present, 0 - is not

Definition at line 89 of file bar_bmp585.c.

References _isBarometer, and bar_bmp585_Init().

Here is the call graph for this function:

◆ bar_bmp585_IsOn()

HAL_StatusTypeDef bar_bmp585_IsOn ( I2C_HandleTypeDef * hi2c,
uint8_t * onOff )
static

Check if sensor is turned on.

Definition at line 54 of file bar_bmp585.c.

References _isBarometer, BMP585_I2C_ADDR, and REG_ODR_CONFIG.

Referenced by bar_bmp585_Read().

Here is the caller graph for this function:

◆ bar_bmp585_LogData()

void bar_bmp585_LogData ( char * buf)

Log data to buffer.

Parameters
buf- buffer to log data to

Definition at line 219 of file bar_bmp585.c.

References _bar_bmp585Data, PRIf_02, and PRIf_02D.

◆ bar_bmp585_Off()

HAL_StatusTypeDef bar_bmp585_Off ( I2C_HandleTypeDef * hi2c)

Turn off sensor - stop measure and put sensor in very deep sleep mode.

Parameters
hi2c- I2C handle
Return values
HAL_OK,HAL_ERROR

Definition at line 112 of file bar_bmp585.c.

References barometer_onOff().

Referenced by bar_bmp585_Init().

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

◆ bar_bmp585_On()

HAL_StatusTypeDef bar_bmp585_On ( I2C_HandleTypeDef * hi2c)

Turn on sensor - wakeup the sensor and start to processing of pressure measure.

Parameters
hi2c- I2C handle
Return values
HAL_OK,HAL_ERROR

Definition at line 96 of file bar_bmp585.c.

References _bar_bmp585Data, _memsMainBlock, barometer_onOff(), and mems_WriteMainBlock().

Referenced by bar_bmp585_Init().

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

◆ bar_bmp585_Read()

HAL_StatusTypeDef bar_bmp585_Read ( I2C_HandleTypeDef * hi2c)

Read value from sensor, pressure and temperature. Sensor must be turned on before.

Parameters
hi2c- I2C handle
Return values
HAL_OK- have data, HAL_BUSY - next reading in progress, HAL_TIMEOUT - sensor is not turned on HAL_ERROR - error

Definition at line 154 of file bar_bmp585.c.

References _bar_bmp585Data, _isBarometer, _systemParams, _tmphm_sht45Data, bar_bmp585_IsOn(), BMP585_I2C_ADDR, REG_DATA_0, and REG_TEMP_DATA_0.

Here is the call graph for this function:

◆ barometer_onOff()

HAL_StatusTypeDef barometer_onOff ( I2C_HandleTypeDef * hi2c,
uint8_t onOff )
static

Control sensor power mode.

Definition at line 73 of file bar_bmp585.c.

References _isBarometer, BMP585_I2C_ADDR, and REG_ODR_CONFIG.

Referenced by bar_bmp585_Off(), and bar_bmp585_On().

Here is the caller graph for this function:

Variable Documentation

◆ _bar_bmp585Data

bar_bmp585_t _bar_bmp585Data = {}

Live measurement data from the BMP585 sensor; updated by bar_bmp585_Read().

Definition at line 47 of file bar_bmp585.c.

Referenced by bar_bmp585_LogData(), bar_bmp585_On(), bar_bmp585_Read(), and sensors_CopyToBck().

◆ _bck_bar_bmp585Data

bar_bmp585_t _bck_bar_bmp585Data = {}

Snapshot copy of the last completed BMP585 measurement; used for LoRaWAN transmission.

Definition at line 48 of file bar_bmp585.c.

Referenced by sensors_CayennelFromBckData(), sensors_CopyToBck(), sensors_ReadToBckFromDataBlock(), and sensors_WriteFromBckToDataBlock().

◆ _isBarometer