-
Notifications
You must be signed in to change notification settings - Fork 2
/
bmp180_for_stm32_hal.h
78 lines (62 loc) · 1.83 KB
/
bmp180_for_stm32_hal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/* An STM32 HAL library written for the BMP180 temperature/pressure sensor. */
/* Library by @eepj www.github.com/eepj */
#ifndef BMP180_FOR_STM32_HAL_H
#define BMP180_FOR_STM32_HAL_H
#include "main.h"
#define BMP180_I2C_ADDR 0x77
#define BMP180_I2C_TIMEOUT 1000
#define BMP180_CONTROL_REG 0xf4
#define BMP180_MSB_REG 0xf6
#define BMP180_LSB_REG 0xf7
#define BMP180_XLSB_REG 0xf8
#define BMP180_SOFT_RESET_REG 0xe0
#define BMP180_SOFT_RESET 0xb6
typedef enum BMP180_OSS {
BMP180_LOW, BMP180_STANDARD, BMP180_HIGH, BMP180_ULTRA,
} BMP180_OSS;
typedef enum BMP180_CalIndex {
BMP180_INDEX_AC1,
BMP180_INDEX_AC2,
BMP180_INDEX_AC3,
BMP180_INDEX_AC4,
BMP180_INDEX_AC5,
BMP180_INDEX_AC6,
BMP180_INDEX_B1,
BMP180_INDEX_B2,
BMP180_INDEX_MB,
BMP180_INDEX_MC,
BMP180_INDEX_MD,
} BMP180_CalIndex;
typedef struct BMP180_EEPROM {
short BMP180_AC1;
short BMP180_AC2;
short BMP180_AC3;
unsigned short BMP180_AC4;
unsigned short BMP180_AC5;
unsigned short BMP180_AC6;
short BMP180_B1;
short BMP180_B2;
short BMP180_MB;
short BMP180_MC;
short BMP180_MD;
} BMP180_EEPROM;
extern I2C_HandleTypeDef *_bmp180_ui2c;
extern BMP180_EEPROM _bmp180_eeprom;
extern BMP180_OSS _bmp180_oss;
extern const uint8_t BMP180_EEPROM_ADDR_MSB[11];
extern const uint8_t BMP180_EEPROM_ADDR_LSB[11];
extern const uint8_t BMP180_CMD_TEMP;
extern const uint8_t BMP180_DELAY_TEMP;
extern const uint8_t BMP180_CMD_PRES[4];
extern const uint8_t BMP180_DELAY_PRES[4];
void BMP180_Init(I2C_HandleTypeDef *hi2c);
void BMP180_SetOversampling(BMP180_OSS oss);
void BMP180_UpdateCalibrationData(void);
void BMP180_WriteReg(uint8_t reg, uint8_t cmd);
uint8_t BMP180_ReadReg(uint8_t reg);
int32_t BMP180_GetRawTemperature(void);
int32_t BMP180_GetPressure(void);
float BMP180_GetTemperature(void);
int32_t BMP180_GetUT(void);
int32_t BMP180_GetUP(void);
#endif