-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathBMP180_proc.h
148 lines (120 loc) · 4.86 KB
/
BMP180_proc.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*!\file BMP180_proc.h
** \author SMFSW
** \copyright MIT (c) 2017-2024, SMFSW
** \brief BMP180 Driver procedures
** \details BMP180: Digital pressure sensor
**/
/****************************************************************/
#ifndef __BMP180_PROC_H__
#define __BMP180_PROC_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "sarmfsw.h"
#include "BMP180.h"
#include "shared_APS.h"
#if defined(HAL_I2C_MODULE_ENABLED)
/****************************************************************/
// *****************************************************************************
// Section: Constants
// *****************************************************************************
#define BMP180_CHIP_ID 0x55 //!< BMP180 Chip ID to check against
// *****************************************************************************
// Section: Types
// *****************************************************************************
/*!\struct BMP180_calibration
** \brief BMP180 calibration parameters structure
**/
typedef struct BMP180_calibration {
int16_t AC1; //!< ac1 calibration value
int16_t AC2; //!< ac2 calibration value
int16_t AC3; //!< ac3 calibration value
uint16_t AC4; //!< ac4 calibration value
uint16_t AC5; //!< ac5 calibration value
uint16_t AC6; //!< ac6 calibration value
int16_t B1; //!< b1 calibration value
int16_t B2; //!< b2 calibration value
int16_t MB; //!< mb calibration value
int16_t MC; //!< mc calibration value
int16_t MD; //!< md calibration value
} BMP180_calib;
/*!\struct BMP180_t
** \brief BMP180 user interface struct
**/
typedef struct BMP180_t {
float Pressure; //!< Current atmospheric pressure
float Temperature; //!< Current temperature
float Altitude; //!< Current altitude
uint32_t hStartConversion; //!< Last conversion start tick
struct {
I2C_slave_t * slave_inst; //!< Slave structure
BMP180_oversampling OSS; //!< Oversampling
BMP180_calib Calib; //!< Calibration values
uint8_t ID; //!< Chip ID
float SeaLevelPressure; //!< Current atmospheric pressure at sea level
} cfg;
} BMP180_t;
extern BMP180_t BMP180[I2C_BMP180_NB]; //!< BMP180 User structure
// *****************************************************************************
// Section: Interface Routines
// *****************************************************************************
/******************/
/*** Procedures ***/
/******************/
/*!\brief Setter of Sea Level pressure for BMP180 peripheral
** \weak BMP180 Sea Level pressure setter may be user implemented
** \param[in] pCpnt - Pointer to BMP180 component
** \return FctERR - error code
**/
FctERR NONNULL__ BMP180_Set_SeaLevel_Pressure(BMP180_t * const pCpnt);
/*!\brief Initialization Sequence for BMP180 peripheral
** \weak BMP180 Init sequence may be user implemented if custom initialization sequence needed
** \param[in] pCpnt - Pointer to BMP180 component
** \return FctERR - error code
**/
FctERR NONNULL__ BMP180_Init_Sequence(BMP180_t * const pCpnt);
/*!\brief Set oversampling for BMP180 peripheral
** \param[in] pCpnt - Pointer to BMP180 component
** \param[in,out] oss - oversampling value
** \return FctERR - error code
**/
FctERR NONNULL__ BMP180_Set_Oversampling(BMP180_t * const pCpnt, const BMP180_oversampling oss);
/*!\brief Get calibration parameters from BMP180 peripheral
** \param[in] pCpnt - Pointer to BMP180 component
** \param[in,out] pCalib - pointer to calibration structure to read to
** \return FctERR - error code
**/
FctERR NONNULL__ BMP180_Get_Calibration(BMP180_t * const pCpnt, BMP180_calib * pCalib);
/*!\brief Gets the compensated pressure level
** \param[in] pCpnt - Pointer to BMP180 component
** \param[in,out] pres - pointer to atmospheric pressure level to read to (in hPa)
** \return FctERR - error code
**/
FctERR NONNULLX__(1) BMP180_Get_Pressure(BMP180_t * const pCpnt, float * pres);
/*!\brief Get the temperature
** \param[in] pCpnt - Pointer to BMP180 component
** \param[in,out] temp - pointer to temperature to read to (in Celsius degrees)
** \return FctERR - error code
**/
FctERR NONNULLX__(1) BMP180_Get_Temperature(BMP180_t * const pCpnt, float * temp);
/*!\brief Handler for BMP180 peripheral
** \weak BMP180 handler may be user implemented to suit custom needs
** \note Should be called periodically to handle BMP180 tasks
** \param[in] pCpnt - Pointer to BMP180 component
** \return FctERR - error code
**/
FctERR NONNULL__ BMP180_handler(BMP180_t * const pCpnt);
/*!\brief Handler for all BMP180 peripherals
** \note May be called periodically to handle all BMP180 tasks
**/
__INLINE void INLINE__ BMP180_handler_all(void) {
for (BMP180_t * pCpnt = BMP180 ; pCpnt < &BMP180[I2C_BMP180_NB] ; pCpnt++) {
BMP180_handler(pCpnt); }
}
/****************************************************************/
#endif
#ifdef __cplusplus
}
#endif
#endif /* __BMP180_PROC_H__ */
/****************************************************************/