Loading...
Searching...
No Matches
bmp581.h
1
8
9#ifndef _BMP581_H
10#define _BMP581_H
11
12#include "barometer.h"
13
14#include "spi.h"
15#include "gpiopin.h"
16
17#define BMP581_TEMP_SENSITIVITY (1.0f / 65535)
18#define BMP581_PRESS_SENSITIVITY (1.0f / 64)
19#define BMP581_CHIP_ID 0x01
20#define BMP581_ODR_CFG 0x37
21#define BMP581_ODR_CFG_PWR 0x03
22#define BMP581_ODR_CFG_PWR_STANDBY 0x00
23#define BMP581_ODR_CFG_PWR_CONTINUOUS 0x03
24#define BMP581_ODR_CFG_DEEP_DIS 0x80
25#define BMP581_OSR_CFG_RESERVED 0x80
26#define BMP581_OSR_CFG 0x36
27#define BMP581_OSR_CFG_OSR_P 0x38
28#define BMP581_OSR_CFG_OSR_P_16 0x04
29#define BMP581_OSR_CFG_PRESS_EN 0x40
30#define BMP581_INT_STATUS 0x27
31#define BMP581_STATUS 0x28
32#define BMP581_STATUS_NVM_RDY 0x02
33#define BMP581_STATUS_NVM_ERR 0x04
34#define BMP581_OSR_CFG_PRESS_EN 0x40
35#define BMP581_TEMPERATURE_XLSB 0x1D
36#define BMP581_TEMPERATURE_LSB 0x1E
37#define BMP581_TEMPERATURE_MSB 0x1F
38#define BMP581_PRESSURE_XLSB 0x20
39#define BMP581_PRESSURE_LSB 0x21
40#define BMP581_PRESSURE_MSB 0x22
41#define BMP581_CMD 0x7E
42
43#define BMP581_DATA_SIZE 3 // Three bytes per reading
44#define BMP581_DATA_COUNT 2 // Two readings - temperature, pressure
45#define BMP581_DATA_TOTAL (BMP581_DATA_COUNT * BMP581_DATA_SIZE)
46
52
54typedef struct BMP581 {
55 Baro_t base;
56 SPI_t *spi;
57 GPIOpin_t cs;
58 float pressSensitivity;
59 float tempSensitivity;
60 uint8_t rawPress[BMP581_DATA_SIZE];
61 uint8_t rawTemp[BMP581_DATA_SIZE];
62} BMP581_t;
63
64BMP581_t BMP581_init(BMP581_t *, SPI_t *, GPIOpin_t, const float, const float);
65void BMP581_update(Baro_t *);
66void BMP581_readTemp(Baro_t *, float *);
67void BMP581_readPress(Baro_t *, float *);
68void BMP581_readRawTemp(Baro_t *, uint8_t *);
69void BMP581_readRawPress(Baro_t *, uint8_t *);
70void BMP581_processRawTemp(Baro_t *, uint8_t *, float *);
71void BMP581_processRawPress(Baro_t *, uint8_t *, float *);
72
73uint8_t BMP581_readRegister(BMP581_t *, uint8_t);
74void BMP581_readRegisters(BMP581_t *, uint8_t, uint8_t, uint8_t *);
75void BMP581_writeRegister(BMP581_t *, uint8_t, uint8_t);
76
78#endif
Defines the API for the Barometer sensor.
void BMP581_readTemp(Baro_t *, float *)
Read the temperature from the BMP581 sensor.
Definition bmp581.c:101
void BMP581_processRawTemp(Baro_t *, uint8_t *, float *)
Processes raw temperature data from BMP581 sensor.
Definition bmp581.c:116
void BMP581_readRawTemp(Baro_t *, uint8_t *)
Definition bmp581.c:128
BMP581_t BMP581_init(BMP581_t *, SPI_t *, GPIOpin_t, const float, const float)
Initialiser for a BMP581 barometer.
Definition bmp581.c:27
void BMP581_readPress(Baro_t *, float *)
Definition bmp581.c:142
void BMP581_readRawPress(Baro_t *, uint8_t *)
Definition bmp581.c:168
void BMP581_update(Baro_t *)
Updates the BMP581 barometer readings.
Definition bmp581.c:85
void BMP581_processRawPress(Baro_t *, uint8_t *, float *)
Definition bmp581.c:156
Struct definition for a GPIO pin.
Definition gpiopin.h:151
Struct definition for SPI interface. Provides the interface for API consumers to interact with the SP...
Definition spi.h:134