Loading...
Searching...
No Matches
bmp581.h
1
8
9#ifndef _BMP581_H
10#define _BMP581_H
11
12#include "stm32f439xx.h"
13#include "string.h"
14
15#include "devices.h"
16#include "spi.h"
17
18#define BMP581_TEMP_SENSITIVITY (1.0f / 65535)
19#define BMP581_PRESS_SENSITIVITY (1.0f / 64)
20#define BMP581_CHIP_ID 0x01
21#define BMP581_ODR_CFG 0x37
22#define BMP581_ODR_CFG_PWR 0x03
23#define BMP581_ODR_CFG_PWR_STANDBY 0x00
24#define BMP581_ODR_CFG_PWR_CONTINUOUS 0x03
25#define BMP581_ODR_CFG_DEEP_DIS 0x80
26#define BMP581_OSR_CFG_RESERVED 0x80
27#define BMP581_OSR_CFG 0x36
28#define BMP581_OSR_CFG_OSR_P 0x38
29#define BMP581_OSR_CFG_OSR_P_16 0x04
30#define BMP581_OSR_CFG_PRESS_EN 0x40
31#define BMP581_INT_STATUS 0x27
32#define BMP581_STATUS 0x28
33#define BMP581_STATUS_NVM_RDY 0x02
34#define BMP581_STATUS_NVM_ERR 0x04
35#define BMP581_OSR_CFG_PRESS_EN 0x40
36#define BMP581_TEMPERATURE_XLSB 0x1D
37#define BMP581_TEMPERATURE_LSB 0x1E
38#define BMP581_TEMPERATURE_MSB 0x1F
39#define BMP581_PRESSURE_XLSB 0x20
40#define BMP581_PRESSURE_LSB 0x21
41#define BMP581_PRESSURE_MSB 0x22
42#define BMP581_CMD 0x7E
43
44#define BMP581_DATA_SIZE 3 // Three bytes per reading
45#define BMP581_DATA_COUNT 2 // Two readings - temperature, pressure
46#define BMP581_DATA_TOTAL (BMP581_DATA_COUNT * BMP581_DATA_SIZE)
47
53
55typedef struct BMP581 {
56 SPI base;
57 float pressSensitivity;
58 float tempSensitivity;
59 void (*update)(struct BMP581 *);
60 void (*readTemp)(struct BMP581 *, float *);
61 void (*readPress)(struct BMP581 *, float *);
62 void (*readRawTemp)(struct BMP581 *, uint8_t *);
63 void (*readRawPress)(struct BMP581 *, uint8_t *);
64 void (*processRawTemp)(struct BMP581 *, uint8_t *, float *);
65 void (*processRawPress)(struct BMP581 *, uint8_t *, float *);
66 uint8_t rawTemp[BMP581_DATA_SIZE];
67 uint8_t rawPress[BMP581_DATA_SIZE];
68 float temp;
69 float press;
70 float groundPress;
71} BMP581;
72
73DeviceHandle_t BMP581_init(BMP581 *, char[DEVICE_NAME_LENGTH], GPIO_TypeDef *, unsigned long, const float, const float);
74void BMP581_update(BMP581 *);
75void BMP581_readTemp(BMP581 *, float *);
76void BMP581_readPress(BMP581 *, float *);
77void BMP581_readRawTemp(BMP581 *, uint8_t *);
78void BMP581_readRawPress(BMP581 *, uint8_t *);
79void BMP581_processRawTemp(BMP581 *, uint8_t *, float *);
80void BMP581_processRawPress(BMP581 *, uint8_t *, float *);
81
82uint8_t BMP581_readRegister(BMP581 *, uint8_t);
83void BMP581_readRegisters(BMP581 *, uint8_t , uint8_t , uint8_t *);
84void BMP581_writeRegister(BMP581 *, uint8_t, uint8_t);
85
87#endif
void BMP581_readRawPress(BMP581 *, uint8_t *)
Definition bmp581.c:172
void BMP581_readTemp(BMP581 *, float *)
Read the temperature from the BMP581 sensor.
Definition bmp581.c:105
void BMP581_processRawTemp(BMP581 *, uint8_t *, float *)
Processes raw temperature data from BMP581 sensor.
Definition bmp581.c:120
void BMP581_readRawTemp(BMP581 *, uint8_t *)
Definition bmp581.c:132
void BMP581_processRawPress(BMP581 *, uint8_t *, float *)
Definition bmp581.c:160
void BMP581_update(BMP581 *)
Updates the BMP581 barometer readings.
Definition bmp581.c:89
void BMP581_readPress(BMP581 *, float *)
Definition bmp581.c:146
DeviceHandle_t BMP581_init(BMP581 *, char[DEVICE_NAME_LENGTH], GPIO_TypeDef *, unsigned long, const float, const float)
Initialiser for a BMP581 barometer.
Definition bmp581.c:27
Struct definition for SPI interface. Provides the interface for API consumers to interact with the SP...
Definition spi.h:49