-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhts221.h
228 lines (189 loc) · 5.56 KB
/
hts221.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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
/**
******************************************************************************
* @file hts221.h
* @author MEMS Software Solutions Team
* @brief HTS221 header driver file
******************************************************************************
* @attention
*
* Copyright (c) 2014-2018 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef HTS221_H
#define HTS221_H
#ifdef __cplusplus
extern "C"
{
#endif
/* Includes ------------------------------------------------------------------*/
#include "hts221_reg.h"
#include <string.h>
/** @addtogroup BSP BSP
* @{
*/
/** @addtogroup Component Component
* @{
*/
/** @addtogroup HTS221 HTS221
* @{
*/
/** @defgroup HTS221_Exported_Types HTS221 Exported Types
* @{
*/
typedef int32_t (*HTS221_Init_Func)(void);
typedef int32_t (*HTS221_DeInit_Func)(void);
typedef int32_t (*HTS221_GetTick_Func)(void);
typedef void (*HTS221_Delay_Func)(uint32_t);
typedef int32_t (*HTS221_WriteReg_Func)(uint16_t, uint16_t, uint8_t *, uint16_t);
typedef int32_t (*HTS221_ReadReg_Func)(uint16_t, uint16_t, uint8_t *, uint16_t);
typedef struct
{
HTS221_Init_Func Init;
HTS221_DeInit_Func DeInit;
uint32_t BusType; /*0 means I2C, 1 means SPI-3-Wires */
uint8_t Address;
HTS221_WriteReg_Func WriteReg;
HTS221_ReadReg_Func ReadReg;
HTS221_GetTick_Func GetTick;
HTS221_Delay_Func Delay;
} HTS221_IO_t;
typedef struct
{
float x0;
float y0;
float x1;
float y1;
} lin_t;
typedef struct
{
HTS221_IO_t IO;
stmdev_ctx_t Ctx;
uint8_t is_initialized;
uint8_t hum_is_enabled;
uint8_t temp_is_enabled;
} HTS221_Object_t;
typedef struct
{
uint8_t Temperature;
uint8_t Pressure;
uint8_t Humidity;
uint8_t LowPower;
float HumMaxOdr;
float TempMaxOdr;
float PressMaxOdr;
} HTS221_Capabilities_t;
typedef struct
{
int32_t (*Init)(HTS221_Object_t *);
int32_t (*DeInit)(HTS221_Object_t *);
int32_t (*ReadID)(HTS221_Object_t *, uint8_t *);
int32_t (*GetCapabilities)(HTS221_Object_t *, HTS221_Capabilities_t *);
} HTS221_CommonDrv_t;
typedef struct
{
int32_t (*Enable)(HTS221_Object_t *);
int32_t (*Disable)(HTS221_Object_t *);
int32_t (*GetOutputDataRate)(HTS221_Object_t *, float *);
int32_t (*SetOutputDataRate)(HTS221_Object_t *, float);
int32_t (*GetHumidity)(HTS221_Object_t *, float *);
} HTS221_HUM_Drv_t;
typedef struct
{
int32_t (*Enable)(HTS221_Object_t *);
int32_t (*Disable)(HTS221_Object_t *);
int32_t (*GetOutputDataRate)(HTS221_Object_t *, float *);
int32_t (*SetOutputDataRate)(HTS221_Object_t *, float);
int32_t (*GetTemperature)(HTS221_Object_t *, float *);
} HTS221_TEMP_Drv_t;
typedef union
{
int16_t i16bit[3];
uint8_t u8bit[6];
} hts221_axis3bit16_t;
typedef union
{
int16_t i16bit;
uint8_t u8bit[2];
} hts221_axis1bit16_t;
typedef union
{
int32_t i32bit[3];
uint8_t u8bit[12];
} hts221_axis3bit32_t;
typedef union
{
int32_t i32bit;
uint8_t u8bit[4];
} hts221_axis1bit32_t;
/**
* @}
*/
/** @defgroup HTS221_Exported_Constants HTS221 Exported Constants
* @{
*/
#define HTS221_I2C_BUS 0U
#define HTS221_SPI_3WIRES_BUS 1U
/** HTS221 error codes **/
#define HTS221_OK 0
#define HTS221_ERROR -1
/**
* @}
*/
/** @addtogroup HTS221_Exported_Functions HTS221 Exported Functions
* @{
*/
int32_t HTS221_RegisterBusIO(HTS221_Object_t *pObj, HTS221_IO_t *pIO);
int32_t HTS221_Init(HTS221_Object_t *pObj);
int32_t HTS221_DeInit(HTS221_Object_t *pObj);
int32_t HTS221_ReadID(HTS221_Object_t *pObj, uint8_t *Id);
int32_t HTS221_GetCapabilities(HTS221_Object_t *pObj, HTS221_Capabilities_t *Capabilities);
int32_t HTS221_Get_Init_Status(HTS221_Object_t *pObj, uint8_t *Status);
int32_t HTS221_HUM_Enable(HTS221_Object_t *pObj);
int32_t HTS221_HUM_Disable(HTS221_Object_t *pObj);
int32_t HTS221_HUM_GetOutputDataRate(HTS221_Object_t *pObj, float *Odr);
int32_t HTS221_HUM_SetOutputDataRate(HTS221_Object_t *pObj, float Odr);
int32_t HTS221_HUM_GetHumidity(HTS221_Object_t *pObj, float *Value);
int32_t HTS221_HUM_Get_DRDY_Status(HTS221_Object_t *pObj, uint8_t *Status);
int32_t HTS221_TEMP_Enable(HTS221_Object_t *pObj);
int32_t HTS221_TEMP_Disable(HTS221_Object_t *pObj);
int32_t HTS221_TEMP_GetOutputDataRate(HTS221_Object_t *pObj, float *Odr);
int32_t HTS221_TEMP_SetOutputDataRate(HTS221_Object_t *pObj, float Odr);
int32_t HTS221_TEMP_GetTemperature(HTS221_Object_t *pObj, float *Value);
int32_t HTS221_TEMP_Get_DRDY_Status(HTS221_Object_t *pObj, uint8_t *Status);
int32_t HTS221_Read_Reg(HTS221_Object_t *pObj, uint8_t Reg, uint8_t *Data);
int32_t HTS221_Write_Reg(HTS221_Object_t *pObj, uint8_t Reg, uint8_t Data);
int32_t HTS221_Set_One_Shot(HTS221_Object_t *pObj);
int32_t HTS221_Get_One_Shot_Status(HTS221_Object_t *pObj, uint8_t *Status);
int32_t HTS221_Enable_DRDY_Interrupt(HTS221_Object_t *pObj);
/**
* @}
*/
/** @addtogroup HTS221_Exported_Variables HTS221 Exported Variables
* @{
*/
extern HTS221_CommonDrv_t HTS221_COMMON_Driver;
extern HTS221_HUM_Drv_t HTS221_HUM_Driver;
extern HTS221_TEMP_Drv_t HTS221_TEMP_Driver;
/**
* @}
*/
#ifdef __cplusplus
}
#endif
#endif
/**
* @}
*/
/**
* @}
*/
/**
* @}
*/