gr55xx_hal_adc.h
Go to the documentation of this file.
1 /**
2 ****************************************************************************************
3 *
4 * @file gr55xx_hal_adc.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_ADC ADC
47 * @brief ADC HAL module driver.
48 * @{
49 */
50
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_ADC_H__
53 #define __GR55xx_HAL_ADC_H__
54
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx_ll_adc.h"
61 #include "gr55xx_hal_def.h"
62 #include "gr55xx_hal_dma.h"
63
64 /* Exported types ------------------------------------------------------------*/
65 /** @addtogroup HAL_ADC_ENUMERATIONS Enumerations
66 * @{
67 */
68
69 /** @defgroup HAL_ADC_state HAL ADC State
70 * @{
71 */
72
73 /**
74 * @brief HAL ADC State Enumerations definition
75 */
76 typedef enum
77 {
78 HAL_ADC_STATE_RESET = 0x00, /**< Peripheral not initialized */
79 HAL_ADC_STATE_READY = 0x01, /**< Peripheral initialized and ready for use */
80 HAL_ADC_STATE_BUSY = 0x02, /**< An internal process is ongoing */
81 HAL_ADC_STATE_ERROR = 0x04 /**< Peripheral in error */
82
83 } hal_adc_state_t;
84
85 /** @} */
86
87 /** @} */
88
89 /** @addtogroup HAL_ADC_STRUCTURES Structures
90 * @{
91 */
92
93 /** @defgroup ADC_Configuration ADC Configuration
94 * @{
95 */
96
97 /**
98 * @brief ADC init structure definition
99 */
100 typedef ll_adc_init_t adc_init_t;
101 /** @} */
102
103 /** @defgroup ADC_handle ADC Handle
104 * @{
105 */
106
107 /**
108 * @brief ADC handle Structure definition
109 */
110 typedef struct _adc_handle
111 {
112 adc_init_t init; /**< ADC configuration parameters */
113
114 uint16_t *p_buffer; /**< Pointer to ADC conversion buffer */
115
116 __IO uint32_t buff_size; /**< Conversion buffer size */
117
118 __IO uint32_t buff_count; /**< Conversion buffer counter */
119
120 dma_handle_t *p_dma; /**< ADC DMA Handle parameters */
121
122 __IO hal_lock_t lock; /**< Locking object */
123
124 __IO hal_adc_state_t state; /**< ADC communication state */
125
126 __IO uint32_t error_code; /**< ADC error code */
127
128 uint32_t retention[2]; /**< ADC important register information. */
129
130 } adc_handle_t;
131 /** @} */
132
133 /** @} */
134
135 /** @addtogroup HAL_ADC_CALLBACK_STRUCTURES Callback Structures
136 * @{
137 */
138
139 /** @defgroup ADC_Callback ADC Callback
140 * @{
141 */
142
143 /**
144 * @brief HAL ADC Callback function definition
145 */
146 typedef struct _hal_adc_callback
147 {
148 void (*adc_msp_init)(adc_handle_t *p_adc); /**< ADC init MSP callback */
149 void (*adc_msp_deinit)(adc_handle_t *p_adc); /**< ADC de-init MSP callback */
150 void (*adc_conv_cplt_callback)(adc_handle_t *p_adc); /**< ADC conversion completed callback */
151 } hal_adc_callback_t;
152
153 /** @} */
154
155 /** @} */
156
157 /**
158 * @brief ADC init structure definition
159 */
160
161 /**
162 * @defgroup HAL_ADC_MACRO Defines
163 * @{
164 */
165
166 /* Exported constants --------------------------------------------------------*/
167 /** @defgroup ADC_Exported_Constants ADC Exported Constants
168 * @{
169 */
170
171 /** @defgroup ADC_Error_Code ADC Error Code
172 * @{
173 */
174 #define HAL_ADC_ERROR_NONE ((uint32_t)0x00000000) /**< No error */
175 #define HAL_ADC_ERROR_TIMEOUT ((uint32_t)0x00000001) /**< Timeout error */
176 #define HAL_ADC_ERROR_DMA ((uint32_t)0x00000004) /**< DMA transfer error */
177 #define HAL_ADC_ERROR_INVALID_PARAM ((uint32_t)0x00000008) /**< Invalid parameter error */
178 /** @} */
179
180 /** @defgroup ADC_CLK ADC Clock Select
181 * @{
182 */
183 #define ADC_CLK_16M LL_ADC_CLK_16 /**< ADC Clock = 16 MHz */
184 #define ADC_CLK_1P6M LL_ADC_CLK_1P6 /**< ADC Clock = 1.6 MHz */
185 #define ADC_CLK_8M LL_ADC_CLK_8 /**< ADC Clock = 8 MHz */
186 #define ADC_CLK_4M LL_ADC_CLK_4 /**< ADC Clock = 4 MHz */
187 #define ADC_CLK_2M LL_ADC_CLK_2 /**< ADC Clock = 2 MHz */
188 #define ADC_CLK_1M LL_ADC_CLK_1 /**< ADC Clock = 1 MHz */
189 /** @} */
190
191 /** @defgroup ADC_REFERENCE ADC Reference Value Select
192 * @{
193 */
194 #define ADC_REF_VALUE_0P8 LL_ADC_REF_VALUE_0P8 /**< Reference = 0.85 V */
195 #define ADC_REF_VALUE_1P2 LL_ADC_REF_VALUE_1P2 /**< Reference = 1.28 V */
196 #define ADC_REF_VALUE_1P6 LL_ADC_REF_VALUE_1P6 /**< Reference = 1.60 V */
197 /** @} */
198
199 /** @defgroup ADC_INPUT_MODE ADC Input Mode
200 * @brief Single or Differential mode
201 * @{
202 */
203 #define ADC_INPUT_SINGLE LL_ADC_INPUT_SINGLE /**< Single ended mode */
204 #define ADC_INPUT_DIFFERENTIAL LL_ADC_INPUT_DIFFERENTIAL/**< Differential mode */
205 /** @} */
206
207 /** @defgroup ADC_INPUT_SOURCE ADC Input Channel Select
208 * @{
209 */
210 #define ADC_INPUT_SRC_IO0 LL_ADC_INPUT_SRC_IO0 /**< Select MSIO0 as input */
211 #define ADC_INPUT_SRC_IO1 LL_ADC_INPUT_SRC_IO1 /**< Select MSIO1 as input */
212 #define ADC_INPUT_SRC_IO2 LL_ADC_INPUT_SRC_IO2 /**< Select MSIO2 as input */
213 #define ADC_INPUT_SRC_IO3 LL_ADC_INPUT_SRC_IO3 /**< Select MSIO3 as input */
214 #define ADC_INPUT_SRC_IO4 LL_ADC_INPUT_SRC_IO4 /**< Select MSIO4 as input */
215 #define ADC_INPUT_SRC_TMP LL_ADC_INPUT_SRC_TMP /**< Select temperature as input */
216 #define ADC_INPUT_SRC_BAT LL_ADC_INPUT_SRC_BAT /**< Select Vbattery as input */
217 #define ADC_INPUT_SRC_REF LL_ADC_INPUT_SRC_REF /**< Select reference as input */
218
219 /** @} */
220
221 /** @defgroup ADC_REFERENCE_SOURCE ADC Reference Source Select
222 * @{
223 */
224 #define ADC_REF_SRC_BUF_INT LL_ADC_REF_SRC_BUF_INT /**< Select buffered internal reference as reference */
225 #define ADC_REF_SRC_IO0 LL_ADC_REF_SRC_IO0 /**< Select MSIO0 as reference */
226 #define ADC_REF_SRC_IO1 LL_ADC_REF_SRC_IO1 /**< Select MSIO1 as reference */
227 #define ADC_REF_SRC_IO2 LL_ADC_REF_SRC_IO2 /**< Select MSIO2 as reference */
228 #define ADC_REF_SRC_IO3 LL_ADC_REF_SRC_IO3 /**< Select MSIO3 as reference */
229 /** @} */
230
231 /**
232 * @brief ADC_default_config initStruct default configuartion
233 */
234 #define ADC_DEFAULT_CONFIG LL_ADC_DEFAULT_CONFIG
235 /** @} */
236
237 /* Exported macro ------------------------------------------------------------*/
238 /** @defgroup ADC_Exported_Macros ADC Exported Macros
239 * @{
240 */
241
242 /** @brief Reset ADC handle states.
243 * @param __HANDLE__ ADC handle.
244 * @retval None
245 */
246 #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_ADC_STATE_RESET)
247
248 /** @brief Enable the specified ADC peripheral.
249 * @param __HANDLE__ Specify the ADC Handle.
250 * @retval None
251 */
252 #define __HAL_ADC_ENABLE(__HANDLE__) ll_adc_enable()
253
254 /** @brief Disable the specified ADC peripheral.
255 * @param __HANDLE__ Specify the ADC Handle.
256 * @retval None
257 */
258 #define __HAL_ADC_DISABLE(__HANDLE__) ll_adc_disable()
259
260 /** @brief Enable the specified ADC clock.
261 * @param __HANDLE__ Specify the ADC Handle.
262 * @retval None
263 */
264 #define __HAL_ADC_ENABLE_CLOCK(__HANDLE__) ll_adc_enable_clock()
265
266 /** @brief Disable the specified ADC clock.
267 * @param __HANDLE__ Specify the ADC Handle.
268 * @retval None
269 */
270 #define __HAL_ADC_DISABLE_CLOCK(__HANDLE__) ll_adc_disable_clock()
271
272 /** @brief Check the FIFO is not empty.
273 * @param __HANDLE__ Specify the ADC Handle.
274 * @retval The new state of notempty flag (TRUE or FALSE).
275 */
276 #define __HAL_ADC_GET_FLAG_NOTEMPTY(__HANDLE__) ll_adc_is_fifo_notempty()
277
278 /** @brief Flush the FIFO.
279 * @param __HANDLE__ Specify the ADC Handle.
280 * @retval None
281 */
282 #define __HAL_ADC_FLUSH_FIFO(__HANDLE__) do { \
283 while(ll_adc_is_fifo_notempty()) \
284 { \
285 ll_adc_read_fifo(); \
286 } \
287 } while(0)
288
289 /** @} */
290
291 /* Private macros ------------------------------------------------------------*/
292 /** @addtogroup ADC_Private_Macros ADC Private Macros
293 * @{
294 */
295
296 /**
297 * @brief Check if ADC input source is valid.
298 * @param __INPUT__ ADC input source.
299 * @retval SET (__INPUT__ is valid) or RESET (__INPUT__ is invalid)
300 */
301 #define IS_ADC_INPUT(__INPUT__) (((__INPUT__) == ADC_INPUT_SRC_IO0) || \
302 ((__INPUT__) == ADC_INPUT_SRC_IO1) || \
303 ((__INPUT__) == ADC_INPUT_SRC_IO2) || \
304 ((__INPUT__) == ADC_INPUT_SRC_IO3) || \
305 ((__INPUT__) == ADC_INPUT_SRC_IO4) || \
306 ((__INPUT__) == ADC_INPUT_SRC_TMP) || \
307 ((__INPUT__) == ADC_INPUT_SRC_BAT) || \
308 ((__INPUT__) == ADC_INPUT_SRC_REF))
309
310 /**
311 * @brief Check if ADC input mode is valid.
312 * @param __MODE__ ADC input mode.
313 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
314 */
315 #define IS_ADC_INPUT_MODE(__MODE__) (((__MODE__) == ADC_INPUT_SINGLE) || \
316 ((__MODE__) == ADC_INPUT_DIFFERENTIAL)
317
318 /**
319 * @brief Check if ADC reference source is valid.
320 * @param __INPUT__ ADC reference source.
321 * @retval SET (__INPUT__ is valid) or RESET (__INPUT__ is invalid)
322 */
323 #define IS_ADC_REF(__INPUT__) (((__INPUT__) == ADC_REF_SRC_BUF_INT) || \
324 ((__INPUT__) == ADC_REF_SRC_INT) || \
325 ((__INPUT__) == ADC_REF_SRC_IO0) || \
326 ((__INPUT__) == ADC_REF_SRC_IO1) || \
327 ((__INPUT__) == ADC_REF_SRC_IO2) || \
328 ((__INPUT__) == ADC_REF_SRC_IO3))
329
330 /**
331 * @brief Check if ADC reference value is valid.
332 * @param __VALUE__ ADC reference value.
333 * @retval SET (__VALUE__ is valid) or RESET (__VALUE__ is invalid)
334 */
335 #define IS_ADC_REF_VALUE(__VALUE__) (((__VALUE__) >= ADC_REF_VALUE_0P8) && \
336 ((__VALUE__) <= ADC_REF_VALUE_1P6))
337
338 /**
339 * @brief Check if ADC clock is valid.
340 * @param __CLOCK__ ADC clock.
341 * @retval SET (__CLOCK__ is valid) or RESET (__CLOCK__ is invalid)
342 */
343 #define IS_ADC_CLOCK(__CLOCK__) (((__CLOCK__) == ADC_CLK_16M) || \
344 ((__CLOCK__) == ADC_CLK_8M) || \
345 ((__CLOCK__) == ADC_CLK_4M) || \
346 ((__CLOCK__) == ADC_CLK_2M) || \
347 ((__CLOCK__) == ADC_CLK_1M) || \
348 ((__CLOCK__) == ADC_CLK_1P6M))
349
350 /** @} */
351
352 /** @} */
353
354 /* Exported functions --------------------------------------------------------*/
355 /** @addtogroup HAL_ADC_DRIVER_FUNCTIONS Functions
356 * @{
357 */
358
359 /** @addtogroup ADC_Exported_Functions_Group1 Initialization and de-initialization Functions
360 * @brief Initialization and Configuration functions
361 * @{
362 */
363
364 /**
365 ****************************************************************************************
366 * @brief Initialize the ADC according to the specified parameters
367 * in the adc_init_t and initialize the associated handle.
368 *
369 * @param[in] p_adc: Pointer to an ADC handle which contains the configuration information for
370 * the specified ADC module.
371 *
372 * @retval ::HAL_OK: Operation is OK.
373 * @retval ::HAL_ERROR: Parameter error or operation not supported.
374 * @retval ::HAL_BUSY: Driver is busy.
375 * @retval ::HAL_TIMEOUT: Timeout occurred.
376 ****************************************************************************************
377 */
378 hal_status_t hal_adc_init(adc_handle_t *p_adc);
379
380 /**
381 ****************************************************************************************
382 * @brief De-initialize the ADC peripheral.
383 *
384 * @param[in] p_adc: Pointer to an ADC handle which contains the configuration information for
385 * the specified ADC module.
386 *
387 * @retval ::HAL_OK: Operation is OK.
388 * @retval ::HAL_ERROR: Parameter error or operation not supported.
389 * @retval ::HAL_BUSY: Driver is busy.
390 * @retval ::HAL_TIMEOUT: Timeout occurred.
391 ****************************************************************************************
392 */
393 hal_status_t hal_adc_deinit(adc_handle_t *p_adc);
394
395 /**
396 ****************************************************************************************
397 * @brief Initialize the ADC MSP.
398 *
399 * @note This function should not be modified. When the callback is needed,
400 * the hal_adc_msp_deinit can be implemented in the user file.
401 *
402 * @param[in] p_adc: Pointer to an ADC handle which contains the configuration information for
403 * the specified ADC module.
404 ****************************************************************************************
405 */
406 void hal_adc_msp_init(adc_handle_t *p_adc);
407
408 /**
409 ****************************************************************************************
410 * @brief De-initialize the ADC MSP.
411 *
412 * @note This function should not be modified. When the callback is needed,
413 * the hal_adc_msp_deinit can be implemented in the user file.
414 *
415 * @param[in] p_adc: Pointer to an ADC handle which contains the configuration information for
416 * the specified ADC module.
417 ****************************************************************************************
418 */
419 void hal_adc_msp_deinit(adc_handle_t *p_adc);
420
421 /** @} */
422
423 /** @addtogroup ADC_Exported_Functions_Group2 IO Operation Functions
424 * @brief ADC polling and DMA conversion management functions.
425 * @{
426 */
427
428 /**
429 ****************************************************************************************
430 * @brief Set the FIFO threshold for DMA trigger.
431 *
432 * @param[in] p_adc: Pointer to an ADC handle which contains the configuration information for
433 * the specified ADC module.
434 * @param[in] threshold: FIFO threshold value ranging bwtween 0x0U ~ 0x64U.
435 *
436 * @retval ::HAL_OK: Operation is OK.
437 * @retval ::HAL_ERROR: Parameter error or operation not supported.
438 * @retval ::HAL_BUSY: Driver is busy.
439 * @retval ::HAL_TIMEOUT: Timeout occurred.
440 ****************************************************************************************
441 */
442 hal_status_t hal_adc_set_dma_threshold(adc_handle_t *p_adc, uint32_t threshold);
443
444 /**
445 ****************************************************************************************
446 * @brief Get the FIFO threshold for DMA trigger.
447 *
448 * @param[in] p_adc: Pointer to an ADC handle which contains the configuration information for
449 * the specified ADC module.
450 *
451 * @return FIFO threshold
452 ****************************************************************************************
453 */
454 uint32_t hal_adc_get_dma_threshold(adc_handle_t *p_adc);
455
456 /**
457 ****************************************************************************************
458 * @brief Polling for conversion.
459 *
460 * @param[in] p_adc: Pointer to an ADC handle.
461 * @param[in] p_data: Pointer to data buffer which to store ADC conversion results.
462 * @param[in] length: Length of data buffer.
463 *
464 * @retval ::HAL_OK: Operation is OK.
465 * @retval ::HAL_ERROR: Parameter error or operation not supported.
466 * @retval ::HAL_BUSY: Driver is busy.
467 * @retval ::HAL_TIMEOUT: Timeout occurred.
468 ****************************************************************************************
469 */
470 hal_status_t hal_adc_poll_for_conversion(adc_handle_t *p_adc, uint16_t *p_data, uint32_t length);
471
472 /**
473 ****************************************************************************************
474 * @brief DMA for conversion.
475 *
476 * @param[in] p_adc: Pointer to an ADC handle.
477 * @param[in] p_data: Pointer to data buffer which to store ADC conversion results.
478 * @param[in] length: Length of data buffer, ranging between 0 and 4095.
479 *
480 * @retval ::HAL_OK: Operation is OK.
481 * @retval ::HAL_ERROR: Parameter error or operation not supported.
482 * @retval ::HAL_BUSY: Driver is busy.
483 * @retval ::HAL_TIMEOUT: Timeout occurred.
484 ****************************************************************************************
485 */
486 hal_status_t hal_adc_start_dma(adc_handle_t *p_adc, uint16_t *p_data, uint32_t length);
487
488 /**
489 ****************************************************************************************
490 * @brief Abort ongoing conversion (blocking mode).
491 *
492 * @note This procedure could be only used for aborting conversion started in DMA mode.
493 * This procedure performs following operations:
494 * - Disable ADC clock, stop conversion
495 * - Abort DMA transfer by calling hal_dma_abort (in case of transfer in DMA mode)
496 * - Set handle State to READY.
497 * This procedure is executed in blocking mode: when exiting function, Abort is considered as completed.
498 *
499 * @param[in] p_adc: ADC handle.
500 *
501 * @retval ::HAL_OK: Operation is OK.
502 * @retval ::HAL_ERROR: Parameter error or operation not supported.
503 * @retval ::HAL_BUSY: Driver is busy.
504 * @retval ::HAL_TIMEOUT: Timeout occurred.
505 ****************************************************************************************
506 */
507 hal_status_t hal_adc_stop_dma(adc_handle_t *p_adc);
508
509 /**
510 ****************************************************************************************
511 * @brief Conversion completed callback.
512 *
513 * @note This function should not be modified. When the callback is needed,
514 * the hal_adc_msp_deinit can be implemented in the user file.
515 *
516 * @param[in] p_adc: Pointer to an ADC handle which contains the configuration information for
517 * the specified ADC module.
518 ****************************************************************************************
519 */
520 void hal_adc_conv_cplt_callback(adc_handle_t* p_adc);
521
522 /** @} */
523
524 /** @defgroup ADC_Exported_Functions_Group3 Peripheral State and Errors Functions
525 * @brief ADC control functions
526 *
527 @verbatim
528 ===============================================================================
529 ##### Peripheral State and Errors functions #####
530 ===============================================================================
531 [..]
532 This subsection provides a set of functions allowing to control the ADC.
533 (+) hal_adc_get_state() API can be helpful to check in run-time the state of the ADC peripheral.
534 (+) hal_adc_get_error() check in run-time Errors occurring during communication.
535 @endverbatim
536 * @{
537 */
538
539 /**
540 ****************************************************************************************
541 * @brief Return the ADC handle state.
542 *
543 * @param[in] p_adc: Pointer to an ADC handle which contains the configuration information for
544 * the specified ADC module.
545 *
546 * @retval ::HAL_ADC_STATE_RESET: Peripheral not initialized.
547 * @retval ::HAL_ADC_STATE_READY: Peripheral initialized and ready for use.
548 * @retval ::HAL_ADC_STATE_BUSY: An internal process is ongoing.
549 * @retval ::HAL_ADC_STATE_ERROR: Peripheral in error.
550 ****************************************************************************************
551 */
552 hal_adc_state_t hal_adc_get_state(adc_handle_t *p_adc);
553
554 /**
555 ****************************************************************************************
556 * @brief Return the ADC error code.
557 *
558 * @param[in] p_adc: Pointer to an ADC handle which contains the configuration information for
559 * the specified ADC module.
560 *
561 * @return ADC error code in bitmap format
562 ****************************************************************************************
563 */
564 uint32_t hal_adc_get_error(adc_handle_t *p_adc);
565
566 /**
567 ****************************************************************************************
568 * @brief Suspend some registers related to ADC configuration before sleep.
569 * @param[in] p_adc: Pointer to a ADC handle which contains the configuration
570 * information for the specified ADC module.
571 * @retval ::HAL_OK: Operation is OK.
572 * @retval ::HAL_ERROR: Parameter error or operation not supported.
573 * @retval ::HAL_BUSY: Driver is busy.
574 * @retval ::HAL_TIMEOUT: Timeout occurred.
575 ****************************************************************************************
576 */
577 hal_status_t hal_adc_suspend_reg(adc_handle_t *p_adc);
578
579 /**
580 ****************************************************************************************
581 * @brief Restore some registers related to ADC configuration after sleep.
582 * This function must be used in conjunction with the hal_adc_suspend_reg().
583 * @param[in] p_adc: Pointer to a ADC handle which contains the configuration
584 * information for the specified ADC module.
585 * @retval ::HAL_OK: Operation is OK.
586 * @retval ::HAL_ERROR: Parameter error or operation not supported.
587 * @retval ::HAL_BUSY: Driver is busy.
588 * @retval ::HAL_TIMEOUT: Timeout occurred.
589 ****************************************************************************************
590 */
591 hal_status_t hal_adc_resume_reg(adc_handle_t *p_adc);
592
593 /** @} */
594
595 /** @} */
596
597
598 #ifdef __cplusplus
599 }
600 #endif
601
602 #endif /* __GR55xx_HAL_ADC_H__ */
603
604 /** @} */
605
606 /** @} */
607
608 /** @} */
hal_adc_poll_for_conversion
hal_status_t hal_adc_poll_for_conversion(adc_handle_t *p_adc, uint16_t *p_data, uint32_t length)
Polling for conversion.
_hal_adc_callback::adc_conv_cplt_callback
void(* adc_conv_cplt_callback)(adc_handle_t *p_adc)
ADC conversion completed callback
Definition: gr55xx_hal_adc.h:150
hal_adc_get_error
uint32_t hal_adc_get_error(adc_handle_t *p_adc)
Return the ADC error code.
hal_lock_t
hal_lock_t
HAL Lock structures definition.
Definition: gr55xx_hal_def.h:81
_adc_handle::error_code
__IO uint32_t error_code
ADC error code
Definition: gr55xx_hal_adc.h:126
HAL_ADC_STATE_BUSY
@ HAL_ADC_STATE_BUSY
An internal process is ongoing
Definition: gr55xx_hal_adc.h:80
_hal_adc_callback::adc_msp_init
void(* adc_msp_init)(adc_handle_t *p_adc)
ADC init MSP callback
Definition: gr55xx_hal_adc.h:148
gr55xx_ll_adc.h
Header file containing functions prototypes of ADC LL library.
HAL_ADC_STATE_RESET
@ HAL_ADC_STATE_RESET
Peripheral not initialized
Definition: gr55xx_hal_adc.h:78
_adc_handle::p_buffer
uint16_t * p_buffer
Pointer to ADC conversion buffer
Definition: gr55xx_hal_adc.h:114
hal_adc_stop_dma
hal_status_t hal_adc_stop_dma(adc_handle_t *p_adc)
Abort ongoing conversion (blocking mode).
hal_adc_init
hal_status_t hal_adc_init(adc_handle_t *p_adc)
Initialize the ADC according to the specified parameters in the adc_init_t and initialize the associa...
hal_adc_resume_reg
hal_status_t hal_adc_resume_reg(adc_handle_t *p_adc)
Restore some registers related to ADC configuration after sleep.
hal_adc_set_dma_threshold
hal_status_t hal_adc_set_dma_threshold(adc_handle_t *p_adc, uint32_t threshold)
Set the FIFO threshold for DMA trigger.
adc_handle_t
struct _adc_handle adc_handle_t
ADC handle Structure definition.
hal_adc_suspend_reg
hal_status_t hal_adc_suspend_reg(adc_handle_t *p_adc)
Suspend some registers related to ADC configuration before sleep.
_ll_adc_init
LL ADC init Structure definition.
Definition: gr55xx_ll_adc.h:77
hal_adc_state_t
hal_adc_state_t
HAL ADC State Enumerations definition.
Definition: gr55xx_hal_adc.h:77
hal_adc_msp_init
void hal_adc_msp_init(adc_handle_t *p_adc)
Initialize the ADC MSP.
_adc_handle::state
__IO hal_adc_state_t state
ADC communication state
Definition: gr55xx_hal_adc.h:124
hal_adc_conv_cplt_callback
void hal_adc_conv_cplt_callback(adc_handle_t *p_adc)
Conversion completed callback.
_adc_handle
ADC handle Structure definition.
Definition: gr55xx_hal_adc.h:111
gr55xx_hal_dma.h
Header file containing functions prototypes of DMA HAL library.
hal_adc_get_dma_threshold
uint32_t hal_adc_get_dma_threshold(adc_handle_t *p_adc)
Get the FIFO threshold for DMA trigger.
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
hal_adc_msp_deinit
void hal_adc_msp_deinit(adc_handle_t *p_adc)
De-initialize the ADC MSP.
adc_init_t
ll_adc_init_t adc_init_t
ADC init structure definition.
Definition: gr55xx_hal_adc.h:100
hal_adc_start_dma
hal_status_t hal_adc_start_dma(adc_handle_t *p_adc, uint16_t *p_data, uint32_t length)
DMA for conversion.
hal_adc_callback_t
struct _hal_adc_callback hal_adc_callback_t
HAL ADC Callback function definition.
_adc_handle::init
adc_init_t init
ADC configuration parameters
Definition: gr55xx_hal_adc.h:112
HAL_ADC_STATE_ERROR
@ HAL_ADC_STATE_ERROR
Peripheral in error
Definition: gr55xx_hal_adc.h:81
hal_adc_deinit
hal_status_t hal_adc_deinit(adc_handle_t *p_adc)
De-initialize the ADC peripheral.
_adc_handle::p_dma
dma_handle_t * p_dma
ADC DMA Handle parameters
Definition: gr55xx_hal_adc.h:120
_adc_handle::retention
uint32_t retention[2]
ADC important register information.
Definition: gr55xx_hal_adc.h:128
HAL_ADC_STATE_READY
@ HAL_ADC_STATE_READY
Peripheral initialized and ready for use
Definition: gr55xx_hal_adc.h:79
_adc_handle::lock
__IO hal_lock_t lock
Locking object
Definition: gr55xx_hal_adc.h:122
_dma_handle
DMA handle Structure definition.
Definition: gr55xx_hal_dma.h:179
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
_adc_handle::buff_count
__IO uint32_t buff_count
Conversion buffer counter
Definition: gr55xx_hal_adc.h:118
_hal_adc_callback
HAL ADC Callback function definition.
Definition: gr55xx_hal_adc.h:147
_adc_handle::buff_size
__IO uint32_t buff_size
Conversion buffer size
Definition: gr55xx_hal_adc.h:116
hal_adc_get_state
hal_adc_state_t hal_adc_get_state(adc_handle_t *p_adc)
Return the ADC handle state.
_hal_adc_callback::adc_msp_deinit
void(* adc_msp_deinit)(adc_handle_t *p_adc)
ADC de-init MSP callback
Definition: gr55xx_hal_adc.h:149