L14-Click 1.0
STM32WLE5CC LoRaWAN Sensor Platform
Loading...
Searching...
No Matches
bar_ils22qs.c File Reference
#include "bar_ils22qs.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_ils22qs.c:

Go to the source code of this file.

Macros

#define ILPS22QS_I2C_ADDR   (0x5C << 1)
#define REG_WHO_AM_I   0x0F
#define REG_CTRL_REG1   0x10
#define REG_PRESS_OUT_XL   0x28
#define REG_PRESS_OFFSET   0x1A
#define ILPS22QS_ID   0xB4

Functions

static HAL_StatusTypeDef bar_ils22qs_IsOn (I2C_HandleTypeDef *hi2c, uint8_t *onOff)
static HAL_StatusTypeDef barometer_onOff (I2C_HandleTypeDef *hi2c, uint8_t onOff)
int8_t bar_ils22qs_Is (I2C_HandleTypeDef *hi2c, int8_t tryInit)
 Check if the ILPS22QS barometric pressure sensor is present on the I2C bus.
HAL_StatusTypeDef bar_ils22qs_On (I2C_HandleTypeDef *hi2c)
 turn on sensor
HAL_StatusTypeDef bar_ils22qs_Off (I2C_HandleTypeDef *hi2c)
 turn off sensor
HAL_StatusTypeDef bar_ils22qs_Init (I2C_HandleTypeDef *hi2c)
 Initialise the ILPS22QS sensor and verify it is present on the I2C bus. The sensor is put into low-power standby mode after verification.
HAL_StatusTypeDef bar_ils22qs_Read (I2C_HandleTypeDef *hi2c)
 read value from sensor, pressure and temperature. Sensor must be turned on before
void bar_ils22qs_LogData (char *buf)
 log data to buffer

Variables

bar_ils22qs_t _bar_ils22qsData = {}
 Live measurement data from the ILPS22QS sensor; updated by bar_ils22qs_Read().
bar_ils22qs_t _bck_bar_ils22qsData = {}
 Snapshot copy of the last completed ILPS22QS measurement; used for LoRaWAN transmission.
static uint8_t _isBarometer = 0

Macro Definition Documentation

◆ ILPS22QS_I2C_ADDR

#define ILPS22QS_I2C_ADDR   (0x5C << 1)

◆ ILPS22QS_ID

#define ILPS22QS_ID   0xB4

Definition at line 29 of file bar_ils22qs.c.

Referenced by bar_ils22qs_Init().

◆ REG_CTRL_REG1

#define REG_CTRL_REG1   0x10

Definition at line 25 of file bar_ils22qs.c.

Referenced by bar_ils22qs_IsOn(), and barometer_onOff().

◆ REG_PRESS_OFFSET

#define REG_PRESS_OFFSET   0x1A

Definition at line 27 of file bar_ils22qs.c.

Referenced by bar_ils22qs_Read().

◆ REG_PRESS_OUT_XL

#define REG_PRESS_OUT_XL   0x28

Definition at line 26 of file bar_ils22qs.c.

Referenced by bar_ils22qs_Read().

◆ REG_WHO_AM_I

#define REG_WHO_AM_I   0x0F

Definition at line 24 of file bar_ils22qs.c.

Referenced by bar_ils22qs_Init().

Function Documentation

◆ bar_ils22qs_Init()

HAL_StatusTypeDef bar_ils22qs_Init ( I2C_HandleTypeDef * hi2c)

Initialise the ILPS22QS sensor and verify it is present on the I2C bus. The sensor is put into low-power standby mode after verification.

Parameters
hi2cPointer to the I2C handle.
Return values
HAL_OK– sensor found and initialised successfully.
HAL_ERROR– sensor not detected on the bus or initialisation failed.

Definition at line 101 of file bar_ils22qs.c.

References _isBarometer, bar_ils22qs_Off(), bar_ils22qs_On(), I2C_IsDeviceReadyMT(), ILPS22QS_I2C_ADDR, ILPS22QS_ID, and REG_WHO_AM_I.

Referenced by bar_ils22qs_Is().

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

◆ bar_ils22qs_Is()

int8_t bar_ils22qs_Is ( I2C_HandleTypeDef * hi2c,
int8_t tryInit )

Check if the ILPS22QS barometric pressure sensor is present on the I2C bus.

Parameters
hi2cPointer to the I2C handle.
tryInit1 – attempt to (re-)initialise if not yet done; 0 – no retry.
Return values
1– sensor is present and initialised.
0– sensor not detected.

Definition at line 67 of file bar_ils22qs.c.

References _isBarometer, and bar_ils22qs_Init().

Here is the call graph for this function:

◆ bar_ils22qs_IsOn()

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

Definition at line 35 of file bar_ils22qs.c.

References _isBarometer, ILPS22QS_I2C_ADDR, and REG_CTRL_REG1.

Referenced by bar_ils22qs_Read().

Here is the caller graph for this function:

◆ bar_ils22qs_LogData()

void bar_ils22qs_LogData ( char * buf)

log data to buffer

Definition at line 206 of file bar_ils22qs.c.

References _bar_ils22qsData, PRIf_02, and PRIf_02D.

◆ bar_ils22qs_Off()

HAL_StatusTypeDef bar_ils22qs_Off ( I2C_HandleTypeDef * hi2c)

turn off sensor

Return values
HAL_OK,HAL_ERROR

Definition at line 94 of file bar_ils22qs.c.

References barometer_onOff().

Referenced by bar_ils22qs_Init().

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

◆ bar_ils22qs_On()

HAL_StatusTypeDef bar_ils22qs_On ( I2C_HandleTypeDef * hi2c)

turn on sensor

Return values
HAL_OK,HAL_ERROR

Definition at line 74 of file bar_ils22qs.c.

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

Referenced by bar_ils22qs_Init().

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

◆ bar_ils22qs_Read()

HAL_StatusTypeDef bar_ils22qs_Read ( I2C_HandleTypeDef * hi2c)

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

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 129 of file bar_ils22qs.c.

References _bar_ils22qsData, _isBarometer, _systemParams, _tmphm_sht45Data, bar_ils22qs_IsOn(), ILPS22QS_I2C_ADDR, REG_PRESS_OFFSET, and REG_PRESS_OUT_XL.

Here is the call graph for this function:

◆ barometer_onOff()

HAL_StatusTypeDef barometer_onOff ( I2C_HandleTypeDef * hi2c,
uint8_t onOff )
static

Definition at line 52 of file bar_ils22qs.c.

References _isBarometer, ILPS22QS_I2C_ADDR, and REG_CTRL_REG1.

Referenced by bar_ils22qs_Off(), and bar_ils22qs_On().

Here is the caller graph for this function:

Variable Documentation

◆ _bar_ils22qsData

bar_ils22qs_t _bar_ils22qsData = {}

Live measurement data from the ILPS22QS sensor; updated by bar_ils22qs_Read().

Definition at line 31 of file bar_ils22qs.c.

Referenced by bar_ils22qs_LogData(), bar_ils22qs_On(), bar_ils22qs_Read(), and sensors_CopyToBck().

◆ _bck_bar_ils22qsData

bar_ils22qs_t _bck_bar_ils22qsData = {}

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

Definition at line 32 of file bar_ils22qs.c.

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

◆ _isBarometer

uint8_t _isBarometer = 0
static

Definition at line 33 of file bar_ils22qs.c.