hal_bod.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file hal_bod.h
5 * @author BLE Driver Team
6 * @brief Header file containing functions prototypes of ADC HAL library.
7 *
8 ****************************************************************************************
9 * @attention
10 #####Copyright (c) 2019 GOODIX
11 All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15 * Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17 * Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in the
19 documentation and/or other materials provided with the distribution.
20 * Neither the name of GOODIX nor the names of its contributors may be used
21 to endorse or promote products derived from this software without
22 specific prior written permission.
23
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 POSSIBILITY OF SUCH DAMAGE.
35 ****************************************************************************************
36 */
37
38 /** @addtogroup PERIPHERAL Peripheral Driver
39 * @{
40 */
41
42 /** @addtogroup HAL_DRIVER HAL Driver
43 * @{
44 */
45
46 /** @defgroup HAL_BOD BOD
47 * @brief BOD HAL module driver.
48 * @{
49 */
50
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef HAL_BOD_H
53 #define HAL_BOD_H
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* Includes ------------------------------------------------------------------*/
60 #include "ll_bod.h"
61 #include "hal_def.h"
62 #include <stdbool.h>
63
64 /* Exported types ------------------------------------------------------------*/
65
66
67 /** @addtogroup HAL_BOD_TYPEDEFS Structures
68 * @{
69 */
70 /**
71 * @brief BOD init structure definition
72 */
73 typedef ll_bod_init_t bod_init_t;
74 /**
75 * @brief BOD handle Structure definition
76 */
77 typedef struct _bod_handle
78 {
79 bod_init_t init; /**< BOD configuration parameters */
80 } bod_handle_t;
81 /** @} */
82
83 /** @addtogroup HAL_BOD_CALLBACK_STRUCTURES Callback Structures
84 * @{
85 */
86
87 /** @defgroup BOD_Callback BOD Callback
88 * @{
89 */
90
91 /**
92 * @brief HAL BOD Callback function definition
93 */
94 typedef struct _hal_bod_callback
95 {
96 void (*bod_msp_init)(bod_handle_t *p_bod); /**< BOD init MSP callback */
97 void (*bod_msp_deinit)(bod_handle_t *p_bod); /**< BOD de-init MSP callback */
98 void (*bod_fedge_callback)(bod_handle_t *p_bod); /**< BOD conversion completed callback*/
99 void (*bod_redge_callback)(bod_handle_t *p_bod); /**< BOD conversion completed callback*/
100 } hal_bod_callback_t;
101
102 /** @} */
103
104 /** @} */
105
106 /**
107 * @defgroup HAL_BOD_MACRO Defines
108 * @{
109 */
110 /* Exported constants --------------------------------------------------------*/
111 /** @defgroup BOD_Exported_Constants BOD Exported Constants
112 * @{
113 */
114
115 /** @defgroup BOD_HAL_ENABLE BOD ENABLE
116 * @{
117 */
118 #define HAL_BOD_ENABLE LL_BOD_BOD_ENABLE /**< BOD enable */
119 #define HAL_BOD_DISABLE LL_BOD_BOD_DISABLE /**< BOD disable */
120 /** @} */
121
122 /** @defgroup BOD2_HAL_ENABLE BOD2 ENABLE
123 * @{
124 */
125 #define HAL_BOD2_ENABLE LL_BOD_BOD2_ENABLE /**< BOD2 enable */
126 #define HAL_BOD2_DISABLE LL_BOD_BOD2_DISABLE /**< BOD2 disable */
127 /** @} */
128
129 /** @defgroup BOD2_HAL_LEVEL BOD2 LVEVL
130 * @{
131 */
132 #define HAL_BOD2_LEVEL_0 LL_BOD_BOD2_LEVEL_0 /**< BOD2 Level 0 */
133 #define HAL_BOD2_LEVEL_1 LL_BOD_BOD2_LEVEL_1 /**< BOD2 Level 1 */
134 #define HAL_BOD2_LEVEL_2 LL_BOD_BOD2_LEVEL_2 /**< BOD2 Level 2 */
135 #define HAL_BOD2_LEVEL_3 LL_BOD_BOD2_LEVEL_3 /**< BOD2 Level 3 */
136 #define HAL_BOD2_LEVEL_4 LL_BOD_BOD2_LEVEL_4 /**< BOD2 Level 4 */
137 #define HAL_BOD2_LEVEL_5 LL_BOD_BOD2_LEVEL_5 /**< BOD2 Level 5 */
138 #define HAL_BOD2_LEVEL_6 LL_BOD_BOD2_LEVEL_6 /**< BOD2 Level 6 */
139 #define HAL_BOD2_LEVEL_7 LL_BOD_BOD2_LEVEL_7 /**< BOD2 Level 7 */
140 /** @} */
141
142 /** @defgroup BOD_HAL_BOD2_AUTO_POWER_BYPASS BOD2 AUTO POWER BYPASS
143 * @{
144 */
145 #define HAL_BOD2_AUTO_POWER_BYPASS_ENABLE LL_BOD_BOD2_AUTO_POWER_BYPASS_ENABLE /**< BOD STATIC enable */
146 #define HAL_BOD2_AUTO_POWER_BYPASS_DISABLE LL_BOD_BOD2_AUTO_POWER_BYPASS_DISABLE /**< BOD STATIC disable */
147 /** @} */
148
149 /** @defgroup BOD_HAL_STATIC_ENABLE BOD STATIC ENABLE
150 * @{
151 */
152 #define HAL_BOD_STATIC_ENABLE LL_BOD_STATIC_ENABLE /**< BOD STATIC enable */
153 #define HAL_BOD_STATIC_DISABLE LL_BOD_STATIC_DISABLE /**< BOD STATIC disable */
154 /** @} */
155
156 /** @} */
157
158 /** @} */
159
160 /* Exported functions --------------------------------------------------------*/
161 /** @addtogroup HAL_BOD_DRIVER_FUNCTIONS Functions
162 * @{
163 */
164
165 /** @addtogroup BOD_Exported_Functions_Group1 Initialization and de-initialization Functions
166 * @brief Initialization and Configuration functions
167 * @{
168 */
169 /* Exported functions --------------------------------------------------------*/
170
171 /**
172 ****************************************************************************************
173 * @brief Initialize the BOD according to the specified parameters
174 * in the bod_init_t and initialize the associated handle.
175 *
176 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
177 * the specified BOD module.
178 *
179 * @retval ::HAL_OK: Operation is OK.
180 * @retval ::HAL_ERROR: Parameter error or operation not supported.
181 * @retval ::HAL_BUSY: Driver is busy.
182 * @retval ::HAL_TIMEOUT: Timeout occurred.
183 ****************************************************************************************
184 */
185 hal_status_t hal_bod_init(const bod_handle_t *p_bod);
186
187 /**
188 ****************************************************************************************
189 * @brief De-initialize the BOD peripheral.
190 *
191 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
192 * the specified BOD module.
193 *
194 * @retval ::HAL_OK: Operation is OK.
195 * @retval ::HAL_ERROR: Parameter error or operation not supported.
196 * @retval ::HAL_BUSY: Driver is busy.
197 * @retval ::HAL_TIMEOUT: Timeout occurred.
198 ****************************************************************************************
199 */
200 hal_status_t hal_bod_deinit(const bod_handle_t *p_bod);
201
202 /**
203 ****************************************************************************************
204 * @brief Initialize the BOD MSP.
205 *
206 * @note This function should not be modified. When the callback is needed,
207 * the hal_bod_msp_init could be implemented in the user file
208 *
209 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
210 * the specified BOD module.
211 ****************************************************************************************
212 */
213 void hal_bod_msp_init(bod_handle_t *p_bod);
214
215 /**
216 ****************************************************************************************
217 * @brief De-initialize the BOD MSP.
218 *
219 * @note This function should not be modified. When the callback is needed,
220 * the hal_bod_msp_deinit could be implemented in the user file
221 *
222 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
223 * the specified BOD module.
224 ****************************************************************************************
225 */
226 void hal_bod_msp_deinit(bod_handle_t *p_bod);
227
228 /**
229 ****************************************************************************************
230 * @brief BOD fall edge callback.
231 *
232 * @note This function should not be modified. When the callback is needed,
233 * the hal_bod_fedge_callback can be implemented in the user file.
234 *
235 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
236 * the specified BOD module.
237 ****************************************************************************************
238 */
239 void hal_bod_fedge_callback(bod_handle_t *p_bod);
240
241 /**
242 ****************************************************************************************
243 * @brief BOD rise edge callback.
244 *
245 * @note This function should not be modified. When the callback is needed,
246 * the hal_bod_redge_callback can be implemented in the user file.
247 *
248 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
249 * the specified BOD module.
250 ****************************************************************************************
251 */
252 void hal_bod_redge_callback(bod_handle_t *p_bod);
253
254 /**
255 ****************************************************************************************
256 * @brief Handle BOD fall edge interrupt request.
257 *
258 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
259 * the specified BOD module.
260 ****************************************************************************************
261 */
262 void hal_bod_fedge_irq_handler(bod_handle_t *p_bod);
263
264 /**
265 ****************************************************************************************
266 * @brief Handle BOD rise edge interrupt request.
267 *
268 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
269 * the specified BOD module.
270 ****************************************************************************************
271 */
272 void hal_bod_redge_irq_handler(bod_handle_t *p_bod);
273
274 /**
275 ****************************************************************************************
276 * @brief enable bod
277 *
278 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
279 * the specified BOD module.
280 * @param[in] enable: bod enable flag. the value can be HAL_BOD_ENABLE or HAL_BOD_DISABLE
281 *
282 * @retval ::HAL_OK: Operation is OK.
283 * @retval ::HAL_ERROR: Parameter error or operation not supported.
284 * @retval ::HAL_BUSY: Driver is busy.
285 * @retval ::HAL_TIMEOUT: Timeout occurred.
286 ****************************************************************************************
287 */
288 hal_status_t hal_bod_enable(bod_handle_t *p_bod, uint8_t enable);
289
290 /**
291 ****************************************************************************************
292 * @brief enable bod2
293 *
294 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
295 * the specified BOD module.
296 * @param[in] enable: bod2 enable flag. the value can be HAL_BOD2_ENABLE or HAL_BOD2_DISABLE
297 *
298 * @retval ::HAL_OK: Operation is OK.
299 * @retval ::HAL_ERROR: Parameter error or operation not supported.
300 * @retval ::HAL_BUSY: Driver is busy.
301 * @retval ::HAL_TIMEOUT: Timeout occurred.
302 ****************************************************************************************
303 */
304 hal_status_t hal_bod2_enable(bod_handle_t *p_bod, uint8_t enable);
305
306 /**
307 ****************************************************************************************
308 * @brief Set BOD2 control level.
309 *
310 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
311 * the specified BOD module.
312 * @param[in] level: the level of bod2 control.the value range between 0x0 ~ 0xF
313 *
314 * @retval ::HAL_OK: Operation is OK.
315 * @retval ::HAL_ERROR: Parameter error or operation not supported.
316 * @retval ::HAL_BUSY: Driver is busy.
317 * @retval ::HAL_TIMEOUT: Timeout occurred.
318 ****************************************************************************************
319 */
320 hal_status_t hal_bod2_set_level(bod_handle_t *p_bod, uint8_t level);
321
322 /**
323 ****************************************************************************************
324 * @brief enable/disable static mode
325 *
326 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
327 * the specified BOD module.
328 * @param[in] enable: static enable flag. the value can be HAL_BOD_STATIC_ENABLE or HAL_BOD_STATIC_DISABLE
329 *
330 * @retval ::HAL_OK: Operation is OK.
331 * @retval ::HAL_ERROR: Parameter error or operation not supported.
332 * @retval ::HAL_BUSY: Driver is busy.
333 * @retval ::HAL_TIMEOUT: Timeout occurred.
334 ****************************************************************************************
335 */
336 hal_status_t hal_bod_static_mode_enable(bod_handle_t *p_bod, uint8_t enable);
337
338 /**
339 ****************************************************************************************
340 * @brief enable/disable auto power bypass mode
341 *
342 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
343 * the specified BOD module.
344 * @param[in] enable: auto power bypass enable flag. the value can be HAL_BOD2_AUTO_POWER_BYPASS_ENABLE or HAL_BOD2_AUTO_POWER_BYPASS_DISABLE
345 *
346 * @retval ::HAL_OK: Operation is OK.
347 * @retval ::HAL_ERROR: Parameter error or operation not supported.
348 * @retval ::HAL_BUSY: Driver is busy.
349 * @retval ::HAL_TIMEOUT: Timeout occurred.
350 ****************************************************************************************
351 */
352 hal_status_t hal_bod2_auto_power_bypass_enable(bod_handle_t *p_bod, uint8_t enable);
353
354 /** @} */
355
356 /** @} */
357
358 #ifdef __cplusplus
359 }
360 #endif
361
362 #endif /* HAL_BOD_H */
363
364 /** @} */
365
366 /** @} */
367
368 /** @} */
hal_bod2_auto_power_bypass_enable
hal_status_t hal_bod2_auto_power_bypass_enable(bod_handle_t *p_bod, uint8_t enable)
enable/disable auto power bypass mode
_bod_handle
BOD handle Structure definition.
Definition: hal_bod.h:78
bod_init_t
ll_bod_init_t bod_init_t
BOD init structure definition.
Definition: hal_bod.h:73
bod_handle_t
struct _bod_handle bod_handle_t
BOD handle Structure definition.
hal_bod_enable
hal_status_t hal_bod_enable(bod_handle_t *p_bod, uint8_t enable)
enable bod
hal_bod2_enable
hal_status_t hal_bod2_enable(bod_handle_t *p_bod, uint8_t enable)
enable bod2
_hal_bod_callback::bod_redge_callback
void(* bod_redge_callback)(bod_handle_t *p_bod)
Definition: hal_bod.h:99
_hal_bod_callback
HAL BOD Callback function definition.
Definition: hal_bod.h:95
_ll_bod_init
LL BOD init Structure definition.
Definition: ll_bod.h:75
hal_bod_redge_irq_handler
void hal_bod_redge_irq_handler(bod_handle_t *p_bod)
Handle BOD rise edge interrupt request.
hal_bod2_set_level
hal_status_t hal_bod2_set_level(bod_handle_t *p_bod, uint8_t level)
Set BOD2 control level.
hal_bod_callback_t
struct _hal_bod_callback hal_bod_callback_t
HAL BOD Callback function definition.
hal_bod_static_mode_enable
hal_status_t hal_bod_static_mode_enable(bod_handle_t *p_bod, uint8_t enable)
enable/disable static mode
ll_bod.h
Header file containing functions prototypes of CALENDAR LL library.
_hal_bod_callback::bod_fedge_callback
void(* bod_fedge_callback)(bod_handle_t *p_bod)
Definition: hal_bod.h:98
_bod_handle::init
bod_init_t init
Definition: hal_bod.h:79
hal_bod_init
hal_status_t hal_bod_init(const bod_handle_t *p_bod)
Initialize the BOD according to the specified parameters in the bod_init_t and initialize the associa...
hal_bod_fedge_irq_handler
void hal_bod_fedge_irq_handler(bod_handle_t *p_bod)
Handle BOD fall edge interrupt request.
_hal_bod_callback::bod_msp_deinit
void(* bod_msp_deinit)(bod_handle_t *p_bod)
Definition: hal_bod.h:97
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr_common.h:140
hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
hal_bod_fedge_callback
void hal_bod_fedge_callback(bod_handle_t *p_bod)
BOD fall edge callback.
hal_bod_msp_deinit
void hal_bod_msp_deinit(bod_handle_t *p_bod)
De-initialize the BOD MSP.
hal_bod_deinit
hal_status_t hal_bod_deinit(const bod_handle_t *p_bod)
De-initialize the BOD peripheral.
hal_bod_redge_callback
void hal_bod_redge_callback(bod_handle_t *p_bod)
BOD rise edge callback.
_hal_bod_callback::bod_msp_init
void(* bod_msp_init)(bod_handle_t *p_bod)
Definition: hal_bod.h:96
hal_bod_msp_init
void hal_bod_msp_init(bod_handle_t *p_bod)
Initialize the BOD MSP.