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 Type definitions
68 * @{
69 */
70 /**
71 * @brief BOD init structure definition
72 */
73 typedef ll_bod_init_t bod_init_t;
74 /** @} */
75
76 /** @addtogroup HAL_BOD_STRUCTURES Structures
77 * @{
78 */
79
80 /**
81 * @brief BOD handle Structure definition
82 */
83 typedef struct _bod_handle
84 {
85 bod_init_t init; /**< BOD configuration parameters */
86 __IO hal_lock_t lock; /**< Locking object */
87 } bod_handle_t;
88
89 /**
90 * @brief HAL BOD Callback function definition
91 */
92 typedef struct _hal_bod_callback
93 {
94 void (*bod_msp_init)(bod_handle_t *p_bod); /**< BOD init MSP callback */
95 void (*bod_msp_deinit)(bod_handle_t *p_bod); /**< BOD de-init MSP callback */
96 void (*bod_fedge_callback)(bod_handle_t *p_bod); /**< BOD conversion completed callback*/
97 void (*bod_redge_callback)(bod_handle_t *p_bod); /**< BOD conversion completed callback*/
98 } hal_bod_callback_t;
99
100 /** @} */
101
102 /**
103 * @defgroup HAL_BOD_MACRO Defines
104 * @{
105 */
106 /* Exported constants --------------------------------------------------------*/
107 /** @defgroup HAL_BOD_Exported_Constants BOD Exported Constants
108 * @{
109 */
110
111 /** @defgroup HAL_BOD_ENABLE BOD ENABLE
112 * @{
113 */
114 #define HAL_BOD_ENABLE LL_BOD_ENABLE /**< BOD enable */
115 #define HAL_BOD_DISABLE LL_BOD_DISABLE /**< BOD disable */
116 /** @} */
117
118 /** @defgroup HAL_BOD_BOD2_ENABLE BOD2 ENABLE
119 * @{
120 */
121 #define HAL_BOD2_ENABLE LL_BOD2_ENABLE /**< BOD2 enable */
122 #define HAL_BOD2_DISABLE LL_BOD2_DISABLE /**< BOD2 disable */
123 /** @} */
124
125 /** @defgroup BOD_HAL_STATIC_ENABLE BOD STATIC ENABLE
126 * @{
127 */
128 #define HAL_BOD_STATIC_ENABLE LL_BOD_STATIC_ENABLE /**< BOD STATIC enable */
129 #define HAL_BOD_STATIC_DISABLE LL_BOD_STATIC_DISABLE /**< BOD STATIC disable */
130 /** @} */
131
132 /** @defgroup HAL_BOD_BOD2_LEVEL BOD2 LVEVL
133 * @{
134 */
135 #define HAL_BOD2_LEVEL_0 LL_BOD2_LEVEL_0 /**< BOD2 Level 0 */
136 #define HAL_BOD2_LEVEL_1 LL_BOD2_LEVEL_1 /**< BOD2 Level 1 */
137 #define HAL_BOD2_LEVEL_2 LL_BOD2_LEVEL_2 /**< BOD2 Level 2 */
138 #define HAL_BOD2_LEVEL_3 LL_BOD2_LEVEL_3 /**< BOD2 Level 3 */
139 #define HAL_BOD2_LEVEL_4 LL_BOD2_LEVEL_4 /**< BOD2 Level 4 */
140 #define HAL_BOD2_LEVEL_5 LL_BOD2_LEVEL_5 /**< BOD2 Level 5 */
141 #define HAL_BOD2_LEVEL_6 LL_BOD2_LEVEL_6 /**< BOD2 Level 6 */
142 #define HAL_BOD2_LEVEL_7 LL_BOD2_LEVEL_7 /**< BOD2 Level 7 */
143 #define HAL_BOD2_LEVEL_8 LL_BOD2_LEVEL_8 /**< BOD2 Level 8 */
144 #define HAL_BOD2_LEVEL_9 LL_BOD2_LEVEL_9 /**< BOD2 Level 9 */
145 #define HAL_BOD2_LEVEL_10 LL_BOD2_LEVEL_10 /**< BOD2 Level 10 */
146 #define HAL_BOD2_LEVEL_11 LL_BOD2_LEVEL_11 /**< BOD2 Level 11 */
147 #define HAL_BOD2_LEVEL_12 LL_BOD2_LEVEL_12 /**< BOD2 Level 12 */
148 #define HAL_BOD2_LEVEL_13 LL_BOD2_LEVEL_13 /**< BOD2 Level 13 */
149 #define HAL_BOD2_LEVEL_14 LL_BOD2_LEVEL_14 /**< BOD2 Level 14 */
150 #define HAL_BOD2_LEVEL_15 LL_BOD2_LEVEL_15 /**< BOD2 Level 15 */
151 /** @} */
152 /** @} */
153 /** @} */
154
155 /* Exported functions --------------------------------------------------------*/
156 /** @addtogroup HAL_BOD_DRIVER_FUNCTIONS Functions
157 * @{
158 */
159
160 /* Exported functions --------------------------------------------------------*/
161
162 /**
163 ****************************************************************************************
164 * @brief Initialize the BOD according to the specified parameters
165 * in the bod_init_t and initialize the associated handle.
166 *
167 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
168 * the specified BOD module.
169 *
170 * @retval ::HAL_OK: Operation is OK.
171 * @retval ::HAL_ERROR: Parameter error or operation not supported.
172 * @retval ::HAL_BUSY: Driver is busy.
173 * @retval ::HAL_TIMEOUT: Timeout occurred.
174 ****************************************************************************************
175 */
176 hal_status_t hal_bod_init(bod_handle_t *p_bod);
177
178 /**
179 ****************************************************************************************
180 * @brief De-initialize the BOD peripheral.
181 *
182 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
183 * the specified BOD module.
184 *
185 * @retval ::HAL_OK: Operation is OK.
186 * @retval ::HAL_ERROR: Parameter error or operation not supported.
187 * @retval ::HAL_BUSY: Driver is busy.
188 * @retval ::HAL_TIMEOUT: Timeout occurred.
189 ****************************************************************************************
190 */
191 hal_status_t hal_bod_deinit(bod_handle_t *p_bod);
192
193 /**
194 ****************************************************************************************
195 * @brief Initialize the BOD MSP.
196 *
197 * @note This function should not be modified. When the callback is needed,
198 * the hal_bod_msp_init could be implemented in the user file
199 *
200 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
201 * the specified BOD module.
202 ****************************************************************************************
203 */
204 void hal_bod_msp_init(bod_handle_t *p_bod);
205
206 /**
207 ****************************************************************************************
208 * @brief De-initialize the BOD MSP.
209 *
210 * @note This function should not be modified. When the callback is needed,
211 * the hal_bod_msp_deinit could be implemented in the user file
212 *
213 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
214 * the specified BOD module.
215 ****************************************************************************************
216 */
217 void hal_bod_msp_deinit(bod_handle_t *p_bod);
218
219 /**
220 ****************************************************************************************
221 * @brief BOD fall edge callback.
222 *
223 * @note This function should not be modified. When the callback is needed,
224 * the hal_bod_fedge_callback can be implemented in the user file.
225 *
226 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
227 * the specified BOD module.
228 ****************************************************************************************
229 */
230 void hal_bod_fedge_callback(bod_handle_t *p_bod);
231
232 /**
233 ****************************************************************************************
234 * @brief BOD rise edge callback.
235 *
236 * @note This function should not be modified. When the callback is needed,
237 * the hal_bod_redge_callback can be implemented in the user file.
238 *
239 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
240 * the specified BOD module.
241 ****************************************************************************************
242 */
243 void hal_bod_redge_callback(bod_handle_t *p_bod);
244
245 /**
246 ****************************************************************************************
247 * @brief Handle BOD fall edge interrupt request.
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_fedge_irq_handler(bod_handle_t *p_bod);
254
255 /**
256 ****************************************************************************************
257 * @brief Handle BOD rise 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_redge_irq_handler(bod_handle_t *p_bod);
264
265 /**
266 ****************************************************************************************
267 * @brief enable bod
268 *
269 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
270 * the specified BOD module.
271 * @param[in] enable: bod enable flag. the value can be HAL_BOD_ENABLE or HAL_BOD_DISABLE
272 *
273 * @retval ::HAL_OK: Operation is OK.
274 * @retval ::HAL_ERROR: Parameter error or operation not supported.
275 * @retval ::HAL_BUSY: Driver is busy.
276 * @retval ::HAL_TIMEOUT: Timeout occurred.
277 ****************************************************************************************
278 */
279 hal_status_t hal_bod_enable(bod_handle_t *p_bod, uint8_t enable);
280
281 /**
282 ****************************************************************************************
283 * @brief enable bod2
284 *
285 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
286 * the specified BOD module.
287 * @param[in] enable: bod2 enable flag. the value can be HAL_BOD2_ENABLE or HAL_BOD2_DISABLE
288 *
289 * @retval ::HAL_OK: Operation is OK.
290 * @retval ::HAL_ERROR: Parameter error or operation not supported.
291 * @retval ::HAL_BUSY: Driver is busy.
292 * @retval ::HAL_TIMEOUT: Timeout occurred.
293 ****************************************************************************************
294 */
295 hal_status_t hal_bod2_enable(bod_handle_t *p_bod, uint8_t enable);
296
297 /**
298 ****************************************************************************************
299 * @brief Set BOD2 control level.
300 *
301 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
302 * the specified BOD module.
303 * @param[in] level: the level of bod2 control.the value range between 0x0 ~ 0xF
304 *
305 * @retval ::HAL_OK: Operation is OK.
306 * @retval ::HAL_ERROR: Parameter error or operation not supported.
307 * @retval ::HAL_BUSY: Driver is busy.
308 * @retval ::HAL_TIMEOUT: Timeout occurred.
309 ****************************************************************************************
310 */
311 hal_status_t hal_bod2_set_level(bod_handle_t *p_bod, uint8_t level);
312
313 /**
314 ****************************************************************************************
315 * @brief enable/disable static mode
316 *
317 * @param[in] p_bod: Pointer to an BOD handle which contains the configuration information for
318 * the specified BOD module.
319 * @param[in] enable: static enable flag. the value can be HAL_BOD_STATIC_ENABLE or HAL_BOD_STATIC_DISABLE
320 *
321 * @retval ::HAL_OK: Operation is OK.
322 * @retval ::HAL_ERROR: Parameter error or operation not supported.
323 * @retval ::HAL_BUSY: Driver is busy.
324 * @retval ::HAL_TIMEOUT: Timeout occurred.
325 ****************************************************************************************
326 */
327 hal_status_t hal_bod_static_mode_enable(bod_handle_t *p_bod, uint8_t enable);
328
329 /** @} */
330
331 #ifdef __cplusplus
332 }
333 #endif
334
335 #endif /* __GR55xx_HAL_BOD_H__ */
336
337 /** @} */
338
339 /** @} */
340
341 /** @} */
_bod_handle
BOD handle Structure definition.
Definition: gr55xx_hal_bod.h:84
hal_bod_fedge_irq_handler
void hal_bod_fedge_irq_handler(bod_handle_t *p_bod)
Handle BOD fall edge interrupt request.
hal_lock_t
hal_lock_t
HAL Lock structures definition.
Definition: gr55xx_hal_def.h:81
hal_bod2_enable
hal_status_t hal_bod2_enable(bod_handle_t *p_bod, uint8_t enable)
enable bod2
bod_init_t
ll_bod_init_t bod_init_t
BOD init structure definition.
Definition: gr55xx_hal_bod.h:73
hal_bod_msp_deinit
void hal_bod_msp_deinit(bod_handle_t *p_bod)
De-initialize the BOD MSP.
hal_bod_msp_init
void hal_bod_msp_init(bod_handle_t *p_bod)
Initialize the BOD MSP.
hal_bod_fedge_callback
void hal_bod_fedge_callback(bod_handle_t *p_bod)
BOD fall edge callback.
hal_bod_enable
hal_status_t hal_bod_enable(bod_handle_t *p_bod, uint8_t enable)
enable bod
_hal_bod_callback::bod_redge_callback
void(* bod_redge_callback)(bod_handle_t *p_bod)
BOD conversion completed callback.
Definition: gr55xx_hal_bod.h:97
_hal_bod_callback
HAL BOD Callback function definition.
Definition: gr55xx_hal_bod.h:93
_ll_bod_init
LL BOD init Structure definition.
Definition: gr55xx_ll_bod.h:75
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
bod_handle_t
struct _bod_handle bod_handle_t
BOD handle Structure definition.
hal_bod_redge_callback
void hal_bod_redge_callback(bod_handle_t *p_bod)
BOD rise edge callback.
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...
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)
BOD conversion completed callback.
Definition: gr55xx_hal_bod.h:96
_bod_handle::init
bod_init_t init
BOD configuration parameters
Definition: gr55xx_hal_bod.h:85
hal_bod_deinit
hal_status_t hal_bod_deinit(bod_handle_t *p_bod)
De-initialize the BOD peripheral.
hal_bod_callback_t
struct _hal_bod_callback hal_bod_callback_t
HAL BOD Callback function definition.
_hal_bod_callback::bod_msp_deinit
void(* bod_msp_deinit)(bod_handle_t *p_bod)
BOD de-init MSP callback
Definition: gr55xx_hal_bod.h:95
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
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.
_bod_handle::lock
__IO hal_lock_t lock
Locking object
Definition: gr55xx_hal_bod.h:86
_hal_bod_callback::bod_msp_init
void(* bod_msp_init)(bod_handle_t *p_bod)
BOD init MSP callback
Definition: gr55xx_hal_bod.h:94
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.