gr55xx_hal_bod.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file gr55xx_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 "gr55xx_ll_bod.h"
61 #include "gr55xx_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  */
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 */
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*/
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_ENABLE /**< BOD enable */
120 #define HAL_BOD_DISABLE LL_BOD_DISABLE /**< BOD disable */
121 /** @} */
122 
123 /** @defgroup BOD2_HAL_ENABLE BOD2 ENABLE
124  * @{
125  */
126 #define HAL_BOD2_ENABLE LL_BOD2_ENABLE /**< BOD2 enable */
127 #define HAL_BOD2_DISABLE LL_BOD2_DISABLE /**< BOD2 disable */
128 /** @} */
129 
130 /** @defgroup BOD_HAL_STATIC_ENABLE BOD STATIC ENABLE
131  * @{
132  */
133 #define HAL_BOD_STATIC_ENABLE LL_BOD_STATIC_ENABLE /**< BOD STATIC enable */
134 #define HAL_BOD_STATIC_DISABLE LL_BOD_STATIC_DISABLE /**< BOD STATIC disable */
135 /** @} */
136 
137 /** @defgroup BOD2_HAL_LEVEL BOD2 LVEVL
138  * @{
139  */
140 #define HAL_BOD2_LEVEL_0 LL_BOD2_LEVEL_0 /**< BOD2 Level 0 */
141 #define HAL_BOD2_LEVEL_1 LL_BOD2_LEVEL_1 /**< BOD2 Level 1 */
142 #define HAL_BOD2_LEVEL_2 LL_BOD2_LEVEL_2 /**< BOD2 Level 2 */
143 #define HAL_BOD2_LEVEL_3 LL_BOD2_LEVEL_3 /**< BOD2 Level 3 */
144 #define HAL_BOD2_LEVEL_4 LL_BOD2_LEVEL_4 /**< BOD2 Level 4 */
145 #define HAL_BOD2_LEVEL_5 LL_BOD2_LEVEL_5 /**< BOD2 Level 5 */
146 #define HAL_BOD2_LEVEL_6 LL_BOD2_LEVEL_6 /**< BOD2 Level 6 */
147 #define HAL_BOD2_LEVEL_7 LL_BOD2_LEVEL_7 /**< BOD2 Level 7 */
148 #define HAL_BOD2_LEVEL_8 LL_BOD2_LEVEL_8 /**< BOD2 Level 8 */
149 #define HAL_BOD2_LEVEL_9 LL_BOD2_LEVEL_9 /**< BOD2 Level 9 */
150 #define HAL_BOD2_LEVEL_10 LL_BOD2_LEVEL_10 /**< BOD2 Level 10 */
151 #define HAL_BOD2_LEVEL_11 LL_BOD2_LEVEL_11 /**< BOD2 Level 11 */
152 #define HAL_BOD2_LEVEL_12 LL_BOD2_LEVEL_12 /**< BOD2 Level 12 */
153 #define HAL_BOD2_LEVEL_13 LL_BOD2_LEVEL_13 /**< BOD2 Level 13 */
154 #define HAL_BOD2_LEVEL_14 LL_BOD2_LEVEL_14 /**< BOD2 Level 14 */
155 #define HAL_BOD2_LEVEL_15 LL_BOD2_LEVEL_15 /**< BOD2 Level 15 */
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  */
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  */
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  */
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  */
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  */
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  */
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  */
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  */
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 */
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 */
337 
338 /** @} */
339 
340 /** @} */
341 
342 #ifdef __cplusplus
343 }
344 #endif
345 
346 #endif /* __GR55xx_HAL_BOD_H__ */
347 
348 /** @} */
349 
350 /** @} */
351 
352 /** @} */
_bod_handle
BOD handle Structure definition.
Definition: gr55xx_hal_bod.h:78
hal_lock_t
hal_lock_t
HAL Lock structures definition.
Definition: gr55xx_hal_def.h:81
bod_init_t
ll_bod_init_t bod_init_t
BOD init structure definition.
Definition: gr55xx_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
_hal_bod_callback::bod_redge_callback
void(* bod_redge_callback)(bod_handle_t *p_bod)
Definition: gr55xx_hal_bod.h:100
_hal_bod_callback
HAL BOD Callback function definition.
Definition: gr55xx_hal_bod.h:96
_ll_bod_init
LL BOD init Structure definition.
Definition: gr55xx_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
gr55xx_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: gr55xx_hal_bod.h:99
_bod_handle::init
bod_init_t init
Definition: gr55xx_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: gr55xx_hal_bod.h:98
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_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: gr55xx_hal_bod.h:80
_hal_bod_callback::bod_msp_init
void(* bod_msp_init)(bod_handle_t *p_bod)
Definition: gr55xx_hal_bod.h:97
hal_bod_msp_init
void hal_bod_msp_init(bod_handle_t *p_bod)
Initialize the BOD MSP.
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.