gr533x_hal_bod.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file gr533x_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 __GR55xx_HAL_BOD_H__
53 #define __GR55xx_HAL_BOD_H__
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr533x_ll_bod.h"
61 #include "gr533x_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 __IO hal_lock_t lock; /**< Locking object */
81 } bod_handle_t;
82 /** @} */
83
84 /** @addtogroup HAL_BOD_CALLBACK_STRUCTURES Callback Structures
85 * @{
86 */
87
88 /** @defgroup BOD_Callback BOD Callback
89 * @{
90 */
91
92 /**
93 * @brief HAL BOD Callback function definition
94 */
95 typedef struct _hal_bod_callback
96 {
97 void (*bod_msp_init)(bod_handle_t *p_bod); /**< BOD init MSP callback */
98 void (*bod_msp_deinit)(bod_handle_t *p_bod); /**< BOD de-init MSP callback */
99 void (*bod_fedge_callback)(bod_handle_t *p_bod); /**< BOD conversion completed callback*/
100 void (*bod_redge_callback)(bod_handle_t *p_bod); /**< BOD conversion completed callback*/
101 } hal_bod_callback_t;
102
103 /** @} */
104
105 /** @} */
106
107 /**
108 * @defgroup HAL_BOD_MACRO Defines
109 * @{
110 */
111 /* Exported constants --------------------------------------------------------*/
112 /** @defgroup BOD_Exported_Constants BOD Exported Constants
113 * @{
114 */
115
116 /** @defgroup BOD_HAL_ENABLE BOD ENABLE
117 * @{
118 */
119 #define HAL_BOD_ENABLE LL_BOD_BOD_ENABLE /**< BOD enable */
120 #define HAL_BOD_DISABLE LL_BOD_BOD_DISABLE /**< BOD disable */
121 /** @} */
122
123 /** @defgroup BOD2_HAL_ENABLE BOD2 ENABLE
124 * @{
125 */
126 #define HAL_BOD2_ENABLE LL_BOD_BOD2_ENABLE /**< BOD2 enable */
127 #define HAL_BOD2_DISABLE LL_BOD_BOD2_DISABLE /**< BOD2 disable */
128 /** @} */
129
130 /** @defgroup BOD2_HAL_LEVEL BOD2 LVEVL
131 * @{
132 */
133 #define HAL_BOD2_LEVEL_0 LL_BOD_BOD2_LEVEL_0 /**< BOD2 Level 0 */
134 #define HAL_BOD2_LEVEL_1 LL_BOD_BOD2_LEVEL_1 /**< BOD2 Level 1 */
135 #define HAL_BOD2_LEVEL_2 LL_BOD_BOD2_LEVEL_2 /**< BOD2 Level 2 */
136 #define HAL_BOD2_LEVEL_3 LL_BOD_BOD2_LEVEL_3 /**< BOD2 Level 3 */
137 #define HAL_BOD2_LEVEL_4 LL_BOD_BOD2_LEVEL_4 /**< BOD2 Level 4 */
138 #define HAL_BOD2_LEVEL_5 LL_BOD_BOD2_LEVEL_5 /**< BOD2 Level 5 */
139 #define HAL_BOD2_LEVEL_6 LL_BOD_BOD2_LEVEL_6 /**< BOD2 Level 6 */
140 #define HAL_BOD2_LEVEL_7 LL_BOD_BOD2_LEVEL_7 /**< BOD2 Level 7 */
141 /** @} */
142
143 /** @defgroup BOD_HAL_BOD2_AUTO_POWER_BYPASS BOD2 AUTO POWER BYPASS
144 * @{
145 */
146 #define HAL_BOD2_AUTO_POWER_BYPASS_ENABLE LL_BOD_BOD2_AUTO_POWER_BYPASS_ENABLE /**< BOD STATIC enable */
147 #define HAL_BOD2_AUTO_POWER_BYPASS_DISABLE LL_BOD_BOD2_AUTO_POWER_BYPASS_DISABLE /**< BOD STATIC disable */
148 /** @} */
149
150 /** @defgroup BOD_HAL_STATIC_ENABLE BOD STATIC ENABLE
151 * @{
152 */
153 #define HAL_BOD_STATIC_ENABLE LL_BOD_STATIC_ENABLE /**< BOD STATIC enable */
154 #define HAL_BOD_STATIC_DISABLE LL_BOD_STATIC_DISABLE /**< BOD STATIC disable */
155 /** @} */
156
157 /** @} */
158
159 /** @} */
160
161 /* Exported functions --------------------------------------------------------*/
162 /** @addtogroup HAL_BOD_DRIVER_FUNCTIONS Functions
163 * @{
164 */
165
166 /** @addtogroup BOD_Exported_Functions_Group1 Initialization and de-initialization Functions
167 * @brief Initialization and Configuration functions
168 * @{
169 */
170 /* Exported functions --------------------------------------------------------*/
171
172 /**
173 ****************************************************************************************
174 * @brief Initialize the BOD according to the specified parameters
175 * in the bod_init_t and initialize the associated handle.
176 *
177 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
178 * the specified BOD module.
179 *
180 * @retval ::HAL_OK: Operation is OK.
181 * @retval ::HAL_ERROR: Parameter error or operation not supported.
182 * @retval ::HAL_BUSY: Driver is busy.
183 * @retval ::HAL_TIMEOUT: Timeout occurred.
184 ****************************************************************************************
185 */
186 hal_status_t hal_bod_init(bod_handle_t *p_bod);
187
188 /**
189 ****************************************************************************************
190 * @brief De-initialize the BOD peripheral.
191 *
192 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
193 * the specified BOD module.
194 *
195 * @retval ::HAL_OK: Operation is OK.
196 * @retval ::HAL_ERROR: Parameter error or operation not supported.
197 * @retval ::HAL_BUSY: Driver is busy.
198 * @retval ::HAL_TIMEOUT: Timeout occurred.
199 ****************************************************************************************
200 */
201 hal_status_t hal_bod_deinit(bod_handle_t *p_bod);
202
203 /**
204 ****************************************************************************************
205 * @brief Initialize the BOD MSP.
206 *
207 * @note This function should not be modified. When the callback is needed,
208 * the hal_bod_msp_init could be implemented in the user file
209 *
210 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
211 * the specified BOD module.
212 ****************************************************************************************
213 */
214 void hal_bod_msp_init(bod_handle_t *p_bod);
215
216 /**
217 ****************************************************************************************
218 * @brief De-initialize the BOD MSP.
219 *
220 * @note This function should not be modified. When the callback is needed,
221 * the hal_bod_msp_deinit could be implemented in the user file
222 *
223 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
224 * the specified BOD module.
225 ****************************************************************************************
226 */
227 void hal_bod_msp_deinit(bod_handle_t *p_bod);
228
229 /**
230 ****************************************************************************************
231 * @brief BOD fall edge callback.
232 *
233 * @note This function should not be modified. When the callback is needed,
234 * the hal_bod_fedge_callback can be implemented in the user file.
235 *
236 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
237 * the specified BOD module.
238 ****************************************************************************************
239 */
240 void hal_bod_fedge_callback(bod_handle_t *p_bod);
241
242 /**
243 ****************************************************************************************
244 * @brief BOD rise edge callback.
245 *
246 * @note This function should not be modified. When the callback is needed,
247 * the hal_bod_redge_callback can be implemented in the user file.
248 *
249 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
250 * the specified BOD module.
251 ****************************************************************************************
252 */
253 void hal_bod_redge_callback(bod_handle_t *p_bod);
254
255 /**
256 ****************************************************************************************
257 * @brief Handle BOD fall edge interrupt request.
258 *
259 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
260 * the specified BOD module.
261 ****************************************************************************************
262 */
263 void hal_bod_fedge_irq_handler(bod_handle_t *p_bod);
264
265 /**
266 ****************************************************************************************
267 * @brief Handle BOD rise edge interrupt request.
268 *
269 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
270 * the specified BOD module.
271 ****************************************************************************************
272 */
273 void hal_bod_redge_irq_handler(bod_handle_t *p_bod);
274
275 /**
276 ****************************************************************************************
277 * @brief enable bod
278 *
279 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
280 * the specified BOD module.
281 * @param[in] enable: bod enable flag. the value can be HAL_BOD_ENABLE or HAL_BOD_DISABLE
282 *
283 * @retval ::HAL_OK: Operation is OK.
284 * @retval ::HAL_ERROR: Parameter error or operation not supported.
285 * @retval ::HAL_BUSY: Driver is busy.
286 * @retval ::HAL_TIMEOUT: Timeout occurred.
287 ****************************************************************************************
288 */
289 hal_status_t hal_bod_enable(bod_handle_t *p_bod, uint8_t enable);
290
291 /**
292 ****************************************************************************************
293 * @brief enable bod2
294 *
295 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
296 * the specified BOD module.
297 * @param[in] enable: bod2 enable flag. the value can be HAL_BOD2_ENABLE or HAL_BOD2_DISABLE
298 *
299 * @retval ::HAL_OK: Operation is OK.
300 * @retval ::HAL_ERROR: Parameter error or operation not supported.
301 * @retval ::HAL_BUSY: Driver is busy.
302 * @retval ::HAL_TIMEOUT: Timeout occurred.
303 ****************************************************************************************
304 */
305 hal_status_t hal_bod2_enable(bod_handle_t *p_bod, uint8_t enable);
306
307 /**
308 ****************************************************************************************
309 * @brief Set BOD2 control level.
310 *
311 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
312 * the specified BOD module.
313 * @param[in] level: the level of bod2 control.the value range between 0x0 ~ 0xF
314 *
315 * @retval ::HAL_OK: Operation is OK.
316 * @retval ::HAL_ERROR: Parameter error or operation not supported.
317 * @retval ::HAL_BUSY: Driver is busy.
318 * @retval ::HAL_TIMEOUT: Timeout occurred.
319 ****************************************************************************************
320 */
321 hal_status_t hal_bod2_set_level(bod_handle_t *p_bod, uint8_t level);
322
323 /**
324 ****************************************************************************************
325 * @brief enable/disable static mode
326 *
327 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
328 * the specified BOD module.
329 * @param[in] enable: static enable flag. the value can be HAL_BOD_STATIC_ENABLE or HAL_BOD_STATIC_DISABLE
330 *
331 * @retval ::HAL_OK: Operation is OK.
332 * @retval ::HAL_ERROR: Parameter error or operation not supported.
333 * @retval ::HAL_BUSY: Driver is busy.
334 * @retval ::HAL_TIMEOUT: Timeout occurred.
335 ****************************************************************************************
336 */
337 hal_status_t hal_bod_static_mode_enable(bod_handle_t *p_bod, uint8_t enable);
338
339 /**
340 ****************************************************************************************
341 * @brief enable/disable auto power bypass mode
342 *
343 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
344 * the specified BOD module.
345 * @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
346 *
347 * @retval ::HAL_OK: Operation is OK.
348 * @retval ::HAL_ERROR: Parameter error or operation not supported.
349 * @retval ::HAL_BUSY: Driver is busy.
350 * @retval ::HAL_TIMEOUT: Timeout occurred.
351 ****************************************************************************************
352 */
353 hal_status_t hal_bod2_auto_power_bypass_enable(bod_handle_t *p_bod, uint8_t enable);
354
355 /** @} */
356
357 /** @} */
358
359 #ifdef __cplusplus
360 }
361 #endif
362
363 #endif /* __GR533x_HAL_BOD_H__ */
364
365 /** @} */
366
367 /** @} */
368
369 /** @} */
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: gr533x_hal_bod.h:78
hal_lock_t
hal_lock_t
HAL Lock structures definition.
Definition: gr533x_hal_def.h:81
bod_init_t
ll_bod_init_t bod_init_t
BOD init structure definition.
Definition: gr533x_hal_bod.h:73
bod_handle_t
struct _bod_handle bod_handle_t
BOD handle Structure definition.
hal_bod_deinit
hal_status_t hal_bod_deinit(bod_handle_t *p_bod)
De-initialize the BOD peripheral.
hal_bod_init
hal_status_t hal_bod_init(bod_handle_t *p_bod)
Initialize the BOD according to the specified parameters in the bod_init_t and initialize the associa...
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
gr533x_ll_bod.h
Header file containing functions prototypes of CALENDAR LL library.
_hal_bod_callback::bod_redge_callback
void(* bod_redge_callback)(bod_handle_t *p_bod)
Definition: gr533x_hal_bod.h:100
_hal_bod_callback
HAL BOD Callback function definition.
Definition: gr533x_hal_bod.h:96
_ll_bod_init
LL BOD init Structure definition.
Definition: gr533x_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
_hal_bod_callback::bod_fedge_callback
void(* bod_fedge_callback)(bod_handle_t *p_bod)
Definition: gr533x_hal_bod.h:99
_bod_handle::init
bod_init_t init
Definition: gr533x_hal_bod.h:79
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: gr533x_hal_bod.h:98
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr533x_hal_def.h:70
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_redge_callback
void hal_bod_redge_callback(bod_handle_t *p_bod)
BOD rise edge callback.
_bod_handle::lock
__IO hal_lock_t lock
Definition: gr533x_hal_bod.h:80
_hal_bod_callback::bod_msp_init
void(* bod_msp_init)(bod_handle_t *p_bod)
Definition: gr533x_hal_bod.h:97
gr533x_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
hal_bod_msp_init
void hal_bod_msp_init(bod_handle_t *p_bod)
Initialize the BOD MSP.