ChibiOS/HAL  6.1.0
hal_hygrometer.h
Go to the documentation of this file.
1 /*
2  ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 */
16 
17 /**
18  * @file hal_hygrometer.h
19  * @brief Generic hygrometer interface header.
20  *
21  * @addtogroup HAL_HYGROMETER
22  * @{
23  */
24 
25 #ifndef HAL_HYGROMETER_H
26 #define HAL_HYGROMETER_H
27 
28 #include "hal_sensors.h"
29 
30 /*===========================================================================*/
31 /* Driver constants. */
32 /*===========================================================================*/
33 
34 /*===========================================================================*/
35 /* Driver pre-compile time settings. */
36 /*===========================================================================*/
37 
38 /*===========================================================================*/
39 /* Derived constants and error checks. */
40 /*===========================================================================*/
41 
42 /*===========================================================================*/
43 /* Driver data structures and types. */
44 /*===========================================================================*/
45 
46 /**
47  * @brief BaseHygrometer specific methods.
48  */
49 #define _base_hygrometer_methods_alone \
50  /* Invoke the set bias procedure.*/ \
51  msg_t (*set_bias)(void *instance, float biases[]); \
52  /* Remove bias stored data.*/ \
53  msg_t (*reset_bias)(void *instance); \
54  /* Invoke the set sensitivity procedure.*/ \
55  msg_t (*set_sensitivity)(void *instance, float sensitivities[]); \
56  /* Restore sensitivity stored data to default.*/ \
57  msg_t (*reset_sensitivity)(void *instance);
58 
59 
60 /**
61  * @brief BaseHygrometer specific methods with inherited ones.
62  */
63 #define _base_hygrometer_methods \
64  _base_sensor_methods \
65  _base_hygrometer_methods_alone
66 
67 /**
68  * @brief @p BaseHygrometer virtual methods table.
69  */
72 };
73 
74 /**
75  * @brief @p BaseHygrometer specific data.
76  */
77 #define _base_hygrometer_data \
78  _base_sensor_data
79 
80 /**
81  * @extends BaseSensor
82  *
83  * @brief Base hygrometer class.
84  * @details This class represents a generic hygrometer.
85  */
86 typedef struct {
87  /** @brief Virtual Methods Table.*/
88  const struct BaseHygrometerVMT *vmt;
91 
92 /*===========================================================================*/
93 /* Driver macros. */
94 /*===========================================================================*/
95 /**
96  * @name Macro Functions (BaseHygrometer)
97  * @{
98  */
99 /**
100  * @brief Hygrometer get channels number.
101  *
102  * @param[in] ip pointer to a @p BaseHygrometer class.
103  * @return The number of channels of the BaseHygrometer
104  *
105  * @api
106  */
107 #define hygrometerGetChannelsNumber(ip) \
108  (ip)->vmt->get_channels_number(ip)
109 
110 /**
111  * @brief Hygrometer read raw data.
112  *
113  * @param[in] ip pointer to a @p BaseHygrometer class.
114  * @param[in] dp pointer to a data array.
115  *
116  * @return The operation status.
117  * @retval MSG_OK if the function succeeded.
118  * @retval MSG_RESET if one or more errors occurred.
119  *
120  * @api
121  */
122 #define hygrometerReadRaw(ip, dp) \
123  (ip)->vmt->read_raw(ip, dp)
124 
125 /**
126  * @brief Hygrometer read cooked data.
127  *
128  * @param[in] ip pointer to a @p BaseHygrometer class.
129  * @param[in] dp pointer to a data array.
130  *
131  * @return The operation status.
132  * @retval MSG_OK if the function succeeded.
133  * @retval MSG_RESET if one or more errors occurred.
134  *
135  * @api
136  */
137 #define hygrometerReadCooked(ip, dp) \
138  (ip)->vmt->read_cooked(ip, dp)
139 
140 /**
141  * @brief Updates hygrometer bias data from received buffer.
142  * @note The bias buffer must have the same length of the
143  * the hygrometer channels number.
144  *
145  * @param[in] ip pointer to a @p BaseHygrometer class.
146  * @param[in] bp pointer to a buffer of bias values.
147  *
148  * @return The operation status.
149  * @retval MSG_OK if the function succeeded.
150  * @retval MSG_RESET if one or more errors occurred.
151  *
152  * @api
153  */
154 #define hygrometerSetBias(ip, bp) \
155  (ip)->vmt->set_bias(ip, bp)
156 
157 /**
158  * @brief Reset hygrometer bias data restoring it to zero.
159  *
160  * @param[in] ip pointer to a @p BaseHygrometer class.
161  *
162  * @return The operation status.
163  * @retval MSG_OK if the function succeeded.
164  * @retval MSG_RESET if one or more errors occurred.
165  *
166  * @api
167  */
168 #define hygrometerResetBias(ip) \
169  (ip)->vmt->reset_bias(ip)
170 
171 /**
172  * @brief Updates hygrometer sensitivity data from received buffer.
173  * @note The sensitivity buffer must have the same length of the
174  * the hygrometer channels number.
175  *
176  * @param[in] ip pointer to a @p BaseHygrometer class.
177  * @param[in] sp pointer to a buffer of sensitivity values.
178  *
179  * @return The operation status.
180  * @retval MSG_OK if the function succeeded.
181  * @retval MSG_RESET if one or more errors occurred.
182  *
183  * @api
184  */
185 #define hygrometerSetSensitivity(ip, sp) \
186  (ip)->vmt->set_sensitivity(ip, sp)
187 
188 /**
189  * @brief Reset hygrometer sensitivity data restoring it to its typical
190  * value.
191  *
192  * @param[in] ip pointer to a @p BaseHygrometer class.
193  *
194  * @return The operation status.
195  * @retval MSG_OK if the function succeeded.
196  * @retval MSG_RESET if one or more errors occurred.
197  *
198  * @api
199  */
200 #define hygrometerResetSensitivity(ip) \
201  (ip)->vmt->reset_sensitivity(ip)
202 /** @} */
203 
204 /*===========================================================================*/
205 /* External declarations. */
206 /*===========================================================================*/
207 
208 #ifdef __cplusplus
209 extern "C" {
210 #endif
211 
212 #ifdef __cplusplus
213 }
214 #endif
215 
216 #endif /* HAL_HYGROMETER_H */
217 
218 /** @} */
Base hygrometer class.
#define _base_hygrometer_methods
BaseHygrometer specific methods with inherited ones.
Generic sensors interface header.
const struct BaseHygrometerVMT * vmt
Virtual Methods Table.
BaseHygrometer virtual methods table.
#define _base_hygrometer_data
BaseHygrometer specific data.