Loading...
Searching...
No Matches
lps22df.h
Go to the documentation of this file.
1
8
9// ALLOW FORMATTING
10#ifndef _LPS22DF_H
11#define _LPS22DF_H
12
13#include "barometer.h"
14
15#include "spi.h"
16#include "gpiopin.h"
17
18#define LPS22DF_TEMP_SENSITIVITY (1.0f / 100)
19#define LPS22DF_PRESS_SENSITIVITY (100.0f / 4096)
20
21#define LPS22DF_CTRL_REG1 0x10
22#define LPS22DF_CTRL_REG2 0x11
23#define LPS22DF_CTRL_REG3 0x12
24#define LPS22DF_CTRL_REG4 0x13
25
26#define LPS22DF_RPDS_L 0x1A
27#define LPS22DF_RPDS_H 0x1B
28
29#define LPS22DF_PRESS_OUT_XL 0x28
30#define LPS22DF_PRESS_OUT_L 0x29
31#define LPS22DF_PRESS_OUT_H 0x2A
32
33#define LPS22DF_TEMP_OUT_L 0x2B
34#define LPS22DF_TEMP_OUT_H 0x2C
35
36#define LPS22DF_CTRL_REG1_ODR_OFF 0x00
37#define LPS22DF_CTRL_REG1_ODR_1 0x08
38#define LPS22DF_CTRL_REG1_ODR_4 0x10
39#define LPS22DF_CTRL_REG1_ODR_10 0x18
40#define LPS22DF_CTRL_REG1_ODR_25 0x20
41#define LPS22DF_CTRL_REG1_ODR_50 0x28
42#define LPS22DF_CTRL_REG1_ODR_75 0x30
43#define LPS22DF_CTRL_REG1_ODR_100 0x38
44#define LPS22DF_CTRL_REG1_ODR_200 0x40
45
46#define LPS22DF_CTRL_REG1_AVG_4 0x00
47#define LPS22DF_CTRL_REG1_AVG_8 0x01
48#define LPS22DF_CTRL_REG1_AVG_16 0x02
49#define LPS22DF_CTRL_REG1_AVG_32 0x03
50#define LPS22DF_CTRL_REG1_AVG_64 0x04
51#define LPS22DF_CTRL_REG1_AVG_128 0x05
52#define LPS22DF_CTRL_REG1_AVG_512 0x07
53
54#define LPS22DF_CTRL_REG2_BDU 0x08
55#define LPS22DF_CTRL_REG2_SWRESET 0x04
56
57#define LPS22DF_PRESS_DATA_SIZE 3 // Three bytes per pressure reading
58#define LPS22DF_TEMP_DATA_SIZE 2 // Two bytes per temp reading
59#define LPS22DF_DATA_COUNT 2 // Two readings - temperature, pressure
60#define LPS22DF_DATA_TOTAL (LPS22DF_TEMP_DATA_SIZE + LPS22DF_PRESS_DATA_SIZE)
61
67
69typedef struct LPS22DF {
70 Baro_t base;
71 SPI_t *spi;
72 GPIOpin_t cs;
73 float pressSensitivity;
74 float tempSensitivity;
75 uint8_t rawTemp[LPS22DF_PRESS_DATA_SIZE];
76 uint8_t rawPress[LPS22DF_TEMP_DATA_SIZE];
77} LPS22DF_t;
78
79LPS22DF_t LPS22DF_init(LPS22DF_t *, SPI_t *, GPIOpin_t, const float, const float);
81void LPS22DF_readTemp(Baro_t *, float *);
82void LPS22DF_readPress(Baro_t *, float *);
83void LPS22DF_readRawTemp(Baro_t *, uint8_t *);
84void LPS22DF_readRawPress(Baro_t *, uint8_t *);
85void LPS22DF_processRawTemp(Baro_t *, uint8_t *, float *);
86void LPS22DF_processRawPress(Baro_t *, uint8_t *, float *);
87
89#endif
Defines the API for the Barometer sensor.
Struct definition for a GPIO pin.
Definition gpiopin.h:151
void LPS22DF_readRawPress(Baro_t *, uint8_t *)
Definition lps22df.c:159
void LPS22DF_readPress(Baro_t *, float *)
Definition lps22df.c:133
void LPS22DF_processRawTemp(Baro_t *, uint8_t *, float *)
Processes raw temperature data from LPS22DF sensor.
Definition lps22df.c:108
void LPS22DF_readTemp(Baro_t *, float *)
Read the temperature from the LPS22DF sensor.
Definition lps22df.c:93
void LPS22DF_processRawPress(Baro_t *, uint8_t *, float *)
Definition lps22df.c:147
void LPS22DF_readRawTemp(Baro_t *, uint8_t *)
Definition lps22df.c:120
LPS22DF_t LPS22DF_init(LPS22DF_t *, SPI_t *, GPIOpin_t, const float, const float)
Initialiser for a LPS22DF barometer.
Definition lps22df.c:27
void LPS22DF_update(Baro_t *)
Updates the LPS22DF barometer readings.
Definition lps22df.c:77
Struct definition for SPI interface. Provides the interface for API consumers to interact with the SP...
Definition spi.h:134