1 /**
2   ******************************************************************************
3   * @file    stm32wb0x_hal_adc.h
4   * @author  GPM Application Team
5   * @brief   Header file of ADC HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2024 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32WB0x_HAL_ADC_H
21 #define STM32WB0x_HAL_ADC_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 
29 /* Include low level driver */
30 #include "stm32wb0x_ll_adc.h"
31 
32 /** @addtogroup STM32WB0x_HAL_Driver
33   * @{
34   */
35 
36 /** @addtogroup ADC
37   * @{
38   */
39 
40 /* Exported types ------------------------------------------------------------*/
41 /** @defgroup ADC_Exported_Types ADC Exported Types
42   * @{
43   */
44 
45 /**
46   * @brief  Structure definition for the configuration of the ADC watchdog.
47   */
48 typedef struct
49 {
50   uint32_t LowThreshold;              /*!< Set the lower threshold for the watchdog.
51                                            This parameter is a 12-bit value.  */
52 
53   uint32_t HighThreshold;             /*!< Set the higher threshold for the watchdog.
54                                            This parameter is a 12-bit value.  */
55 
56   uint32_t ChannelMask;               /*!< Select the input channels the watchdog has to use.
57                                            This parameter can be a value of @ref ADC_AWD_CHANNEL.  */
58 
59   uint32_t EventType;                 /*!< Select the event type used for the watchdog.
60                                            This parameter can be a value of @ref ADC_AWD_EVENTTYPE.  */
61 
62 } ADC_AnalogWDGConfTypeDef;
63 
64 /**
65   * @brief Structure definition with the setting for the Calibration Point().
66   */
67 typedef struct
68 {
69   uint32_t Number;                    /*!< Select the calibration point number
70                                            This parameter can be a value of @ref ADC_HAL_CALIB_POINT
71                                            Caution: Only one offset is allowed per input mode (Single positive, single
72                                                     negative and differential) and voltage range. This parameter
73                                                     overwrites the last setting.
74                                            Note: Use the ADC_CALIB_NONE to skip calibration parameter for this channel
75                                                  and leave offset and gain untouched. */
76 
77   uint32_t Offset;                    /*!< Define the offset to be subtracted from the raw converted data.
78                                            Offset value must be a positive number.
79                                            This parameter must be a number between Min_Data = 0x00 and
80                                            Max_Data = 0xFF.  */
81 
82   uint32_t Gain;                      /*!< Specify the ADC gain compensation coefficient to be applied to ADC raw
83                                            conversion data, based on following formula:
84                                            DATA = DATA(raw) * (gain compensation coef) / 4096
85                                            This parameter value can be:
86                                             - value "0": Gain will be set to default parameters
87                                             - value in range [0x001; 0xFFF]: Gain compensation will be set to specified
88                                            value */
89 
90 } ADC_CalibrationPointTypeDef;
91 
92 /**
93   * @brief  Structure definition for the configuration of the ADC watchdog.
94   */
95 typedef struct
96 {
97   uint32_t Channel;                              /*!< Specify the channel type the channel number code for the 1st
98                                                       conversion of the sequence.
99                                                       This parameter can be a value of @ref ADC_HAL_CH_NUM_CODE. */
100 
101   uint32_t Rank;                                 /*!< Assign a specific sequence number to the channel.
102                                                       This parameter can be a value of @ref ADC_HAL_EC_SEQ_RANKS. */
103 
104   uint32_t VoltRange;                            /*!< Specify the voltage range for the selected channel.
105                                                       This parameter can be a value of
106                                                       @ref ADC_HAL_INPUT_VOLTAGE_RANGE. */
107 
108   ADC_CalibrationPointTypeDef CalibrationPoint;  /*!< Specify the calibration parameter for the selected channel. */
109 
110 } ADC_ChannelConfTypeDef;
111 
112 /**
113   * @brief Structure definition with the setting for the Down Sampler (DS).
114   */
115 typedef struct
116 {
117   uint32_t    DataWidth;              /*!< Specify the width of the output data from the Down Sampler (DS).
118                                            This parameter can be a value of @ref ADC_HAL_DS_DATA_WIDTH. */
119 
120   uint32_t    DataRatio;              /*!< Specify the ratio of the output data from the Down Sampler (DS).
121                                            This parameter can be a value of @ref ADC_HAL_DS_RATIO. */
122 
123 } ADC_DSConfTypeDef;
124 
125 /**
126   * @brief Structure definition with the setting for the Decimation Filter (DF).
127   */
128 typedef struct
129 {
130   uint32_t    DynamicMode;                    /*!< Specify the input dynamic range for the Decimation Filter (DF).
131                                                    This parameter can be a value of @ref ADC_HAL_DF_DYN_RANGE. */
132 
133   uint32_t    HighPassFilter;                 /*!< Specify whether the high pass filter feature is enabled or disabled.
134                                                    This parameter can be set to ENABLE or DISABLE. */
135 
136   uint32_t    OutputDataFormatMode;           /*!< Specify the signed/unsigned output data format.
137                                                    This parameter can be a value of @ref ADC_HAL_DF_DATA_FORMAT. */
138 
139   uint32_t    InputDataFormatMode;            /*!< Specify the signed/unsigned input data format.
140                                                    This parameter can be a value of @ref ADC_HAL_DF_DATA_FORMAT. */
141 
142   uint32_t    FractionalInterpolator;         /*!< Specify whether fractional interpolator is enabled or disabled.
143                                                    This parameter can be set to ENABLE or DISABLE. */
144 
145   uint32_t    CICFilterDecimatorHalfFactor;   /*!< Specify if the decimator factor of the CIC filter is using integer or
146                                                    half.
147                                                    Note: this bit must be set only for the generation of a data rate at
148                                                    44.1 kps from ADC data at 1 MHz. Unpredictable result may happen if
149                                                    set for other configuration.
150                                                    This parameter can be a value of
151                                                    @ref ADC_HAL_CIC_DECIMATOR_HALF_FACTOR. */
152 
153   uint32_t    MCICOutputFrequency;            /*!< Specify the output frequency of the CIC filter.
154                                                    This parameter can be a value of @ref ADC_HAL_MICROPHONE_OUT_FREQ. */
155 
156 } ADC_DFConfTypeDef;
157 
158 /**
159   * @brief Structure definition with the setting for the Pulse Density Modulation (PDM)
160   */
161 typedef struct
162 {
163   uint32_t ClockDivider;              /*!< Specify the clock divider for the (PDM) Interface.
164                                            This parameter can be a value of @ref ADC_HAL_PDM_CLK_DIVIDER. */
165 } ADC_PDMConfTypeDef;
166 
167 /**
168   * @brief Structure definition with the setting for the Pulse Density Modulation (PDM)
169   */
170 typedef struct
171 {
172   uint32_t Bias;                      /*!< Specify the bias voltage (offset) for the Programmable Gain Amplifier (PGA).
173                                            This parameter can be a value of @ref ADC_HAL_PGA_BIAS. */
174 
175   uint32_t Gain;                      /*!< Specify the gain for the Programmable Gain Amplifier (PGA).
176                                            This parameter can be a value of @ref ADC_HAL_PGA_GAIN. */
177 
178 } ADC_PGAConfTypeDef;
179 
180 /**
181   * @brief Structure definition with common setting for the ADC.
182   */
183 typedef struct
184 {
185   uint32_t    ConversionType;          /*!< Specifies the conversion type: through the Down Sampler (DS) or
186                                             through the Decimation Filter (DF).
187                                             This parameter can be a value of @ref ADC_HAL_CONVERSION_TYPE. */
188 
189   FunctionalState ContinuousConvMode;  /*!< Specify whether the conversion is performed in single mode (one conversion)
190                                             or continuous mode for ADC group regular, after the first ADC conversion
191                                             start trigger occurred (software start or external trigger). This parameter
192                                             can be set to ENABLE or DISABLE. */
193 
194   uint32_t    SequenceLength;          /*!< Specify the length of the conversion sequence.
195                                             This parameter must be a number between Min_Data = 1 and
196                                             Max_Data = 16. */
197 
198   uint32_t    SamplingMode;            /*!< Specifies the input sampling mode.
199                                             This parameter can be a value of @ref ADC_HAL_SAMPLING_METHOD. */
200 
201   uint32_t    SampleRate;              /*!< Specify the ADC sample rate.
202                                             This parameter can be a value of @ref ADC_HAL_SAMPLE_RATE.     */
203 
204   ADC_DSConfTypeDef DownSamplerConfig; /*!< Specifies the Down Sampler parameters. */
205 
206   uint32_t    InvertOutputMode;        /*!< Specifies the bit to bit inversion (1' complement) for
207                                             differential input and/or single negative input.
208                                             This parameter can be a value of @ref ADC_HAL_DATA_INVERT.   */
209 
210   uint32_t    Overrun;                 /*!< Specifies the overrung policy applied to the data.
211                                             This parameter can be a value of @ref ADC_HAL_OVERRUN_CONFIG.  */
212 
213 
214 } ADC_InitTypeDef;
215 
216 /**
217   * @brief  ADC handle Structure definition
218   */
219 #if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
220 typedef struct __ADC_HandleTypeDef
221 #else
222 typedef struct
223 #endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
224 {
225   ADC_TypeDef        *Instance;    /*!< Register base address */
226   ADC_InitTypeDef    Init;         /*!< Parameters for ADC initialization */
227 
228   DMA_HandleTypeDef  *DMA_Handle;  /*!< Pointer DMA Handler */
229 
230   HAL_LockTypeDef    Lock;         /*!< ADC locking object */
231   __IO uint32_t      State;        /*!< ADC communication state (bitmap of ADC states) */
232   __IO uint32_t      ErrorCode;    /*!< ADC Error code */
233 
234 #if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
235   void (* ConvCpltCallback)(struct __ADC_HandleTypeDef *hadc);         /*!< ADC conversion complete callback */
236   void (* ConvHalfCpltCallback)(struct __ADC_HandleTypeDef *hadc);     /*!< ADC conversion DMA half-transfer callback */
237   void (* LevelOutOfWindowCallback)(struct __ADC_HandleTypeDef *hadc); /*!< ADC analog watchdog 1 callback */
238   void (* ErrorCallback)(struct __ADC_HandleTypeDef *hadc);            /*!< ADC error callback */
239   void (* MspInitCallback)(struct __ADC_HandleTypeDef *hadc);          /*!< ADC Msp Init callback */
240   void (* MspDeInitCallback)(struct __ADC_HandleTypeDef *hadc);        /*!< ADC Msp DeInit callback */
241 #endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
242 
243 } ADC_HandleTypeDef;
244 
245 
246 #if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
247 /**
248   * @brief  HAL ADC Callback ID enumeration definition
249   */
250 typedef enum
251 {
252   HAL_ADC_CONVERSION_COMPLETE_CB_ID     = 0x00U,  /*!< ADC conversion complete callback ID          */
253   HAL_ADC_CONVERSION_HALF_CB_ID         = 0x01U,  /*!< ADC conversion DMA half-transfer callback ID */
254   HAL_ADC_LEVEL_OUT_OF_WINDOW_1_CB_ID   = 0x02U,  /*!< ADC watchdog callback ID                 */
255   HAL_ADC_ERROR_CB_ID                   = 0x03U,  /*!< ADC error callback ID                        */
256   HAL_ADC_MSPINIT_CB_ID                 = 0x09U,  /*!< ADC Msp Init callback ID                     */
257   HAL_ADC_MSPDEINIT_CB_ID               = 0x0AU   /*!< ADC Msp DeInit callback ID                   */
258 } HAL_ADC_CallbackIDTypeDef;
259 
260 /**
261   * @brief  HAL ADC Callback pointer definition
262   */
263 typedef  void (*pADC_CallbackTypeDef)(ADC_HandleTypeDef *hadc); /*!< pointer to a ADC callback function */
264 
265 #endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
266 
267 /**
268   * @}
269   */
270 
271 
272 /* Exported constants --------------------------------------------------------*/
273 
274 /** @defgroup ADC_Exported_Constants ADC Exported Constants
275   * @{
276   */
277 
278 /** @defgroup ADC_States ADC States
279   * @{
280   */
281 
282 /**
283   * @brief  HAL ADC state machine: ADC states definition (bitfields)
284   * @note   ADC state machine is managed by bitfields, state must be compared
285   *         with bit by bit.
286   *         For example:
287   *           " if ((HAL_ADC_GetState(hadc) & HAL_ADC_STATEBUSY) != 0UL) "
288   *           " if ((HAL_ADC_GetState(hadc) & HAL_ADC_STATE_AWD1) != 0UL) "
289   */
290 /* States of ADC global scope */
291 #define HAL_ADC_STATE_RESET           (0x00000000UL)   /*!< ADC not yet initialized or disabled */
292 #define HAL_ADC_STATE_READY           (0x00000001UL)   /*!< ADC peripheral ready to use         */
293 #define HAL_ADC_STATE_BUSY_INTERNAL   (0x00000002UL)   /*!< ADC is busy due to an internal process (initialization, calibration) */
294 #define HAL_ADC_STATE_TIMEOUT         (0x00000004UL)   /*!< TimeOut occurrence                  */
295 
296 /* States of ADC errors */
297 #define HAL_ADC_STATE_ERROR_INTERNAL  (0x00000010UL)   /*!< Internal error occurrence      */
298 #define HAL_ADC_STATE_ERROR_CONFIG    (0x00000020UL)   /*!< Configuration error occurrence */
299 #define HAL_ADC_STATE_ERROR_DMA       (0x00000040UL)   /*!< DMA error occurrence           */
300 
301 /* States of ADC conversion */
302 #define HAL_ADC_STATE_DS_BUSY         (0x00000100UL)   /*!< A conversion on down sampler data path is ongoing or can
303                                                             occur */
304 #define HAL_ADC_STATE_DS_EOC          (0x00000200UL)   /*!< Converted data available in downsampler data register     */
305 #define HAL_ADC_STATE_DS_OVR          (0x00000400UL)   /*!< Overrun on down sampler data path occurrence              */
306 
307 #define HAL_ADC_STATE_DF_BUSY         (0x00001000UL)   /*!< A conversion on decimation filter path is ongoing or can
308                                                             occur */
309 #define HAL_ADC_STATE_DF_EOC          (0x00002000UL)   /*!< Converted data available in decimation filter data
310                                                             register */
311 #define HAL_ADC_STATE_DF_OVR          (0x00000400UL)   /*!< Overrun occurrence in decimation filter data              */
312 
313 /* States of ADC analog watchdog */
314 #define HAL_ADC_STATE_AWD1            (0x00010000UL)   /*!< Out-of-window occurrence of ADC analog watchdog */
315 
316 /**
317   * @}
318   */
319 
320 
321 /** @defgroup ADC_Error_Code ADC Error Code
322   * @{
323   */
324 
325 #define HAL_ADC_ERROR_NONE            (0x00U)   /*!< No error               */
326 #define HAL_ADC_ERROR_INTERNAL        (0x01U)   /*!< Internal error         */
327 #define HAL_ADC_ERROR_OVR             (0x02U)   /*!< Data overrun error     */
328 #define HAL_ADC_ERROR_DMA             (0x04U)   /*!< DMA transfer error     */
329 
330 #if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
331 #define HAL_ADC_ERROR_INVALID_CALLBACK  (0x10U) /*!< Invalid Callback error */
332 #endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
333 
334 /**
335   * @}
336   */
337 
338 #define ADC_DEFAULT_LDO_DELAY_US         (160UL)      /*!< Default delay for LDO stabilization (uS)*/
339 #define ADC_DEFAULT_VBIAS_PRECH_DELAY_US (600UL)      /*!< Default delay for the VBIAS precharge pulse duration (uS)*/
340 
341 /** @defgroup ADC_HAL_CH_NUM_CODE ADC channel number code for conversion definitions
342   * @{
343   */
344 
345 #define ADC_CHANNEL_VINM0            (LL_ADC_CHANNEL_VINM0)        /*!< ADC channel for VINM0 to single negative input */
346 #define ADC_CHANNEL_VINM1            (LL_ADC_CHANNEL_VINM1)        /*!< ADC channel for VINM1 to single negative input */
347 #define ADC_CHANNEL_VINM2            (LL_ADC_CHANNEL_VINM2)        /*!< ADC channel for VINM2 to single negative input */
348 #define ADC_CHANNEL_VINM3            (LL_ADC_CHANNEL_VINM3)        /*!< ADC channel for VINM3 to single negative input */
349 #define ADC_CHANNEL_VINP0            (LL_ADC_CHANNEL_VINP0)        /*!< ADC channel for VINP0 to single positive input */
350 #define ADC_CHANNEL_VINP1            (LL_ADC_CHANNEL_VINP1)        /*!< ADC channel for VINP1 to single positive input */
351 #define ADC_CHANNEL_VINP2            (LL_ADC_CHANNEL_VINP2)        /*!< ADC channel for VINP2 to single positive input */
352 #define ADC_CHANNEL_VINP3            (LL_ADC_CHANNEL_VINP3)        /*!< ADC channel for VINP3 to single positive input */
353 #define ADC_CHANNEL_VINP0_VINM0      (LL_ADC_CHANNEL_VINP0_VINM0)  /*!< ADC channel for VINP0 - VINM0 to differential input */
354 #define ADC_CHANNEL_VINP1_VINM1      (LL_ADC_CHANNEL_VINP1_VINM1)  /*!< ADC channel for VINP1 - VINM1 to differential input */
355 #define ADC_CHANNEL_VINP2_VINM2      (LL_ADC_CHANNEL_VINP2_VINM2)  /*!< ADC channel for VINP2 - VINM2 to differential input */
356 #define ADC_CHANNEL_VINP3_VINM3      (LL_ADC_CHANNEL_VINP3_VINM3)  /*!< ADC channel for VINP3 - VINM3 to differential input */
357 #define ADC_CHANNEL_VBAT             (LL_ADC_CHANNEL_VBAT)         /*!< ADC channel for VBAT, battery level detector        */
358 #define ADC_CHANNEL_TEMPSENSOR       (LL_ADC_CHANNEL_TEMPSENSOR)   /*!< ADC channel for temperature sensor                  */
359 
360 /**
361   * @}
362   */
363 
364 /** @defgroup ADC_HAL_SAMPLING_METHOD  ADC input sampling method definitions
365   * @{
366   */
367 
368 #define ADC_SAMPLING_AT_START    (LL_ADC_SAMPLING_AT_START)  /*!< Sampling only at conversion start (default) */
369 #define ADC_SAMPLING_AT_END      (LL_ADC_SAMPLING_AT_END)    /*!< Sampling sampling phase starts after end of
370                                                                   conversion, and stops upon trigger event
371                                                                   (Also known as Bulb sampling mode). */
372 
373 /**
374   * @}
375   */
376 
377 
378 /** @defgroup ADC_HAL_OVERRUN_CONFIG ADC overrun configuration definitions
379   * @{
380   */
381 #define ADC_NEW_DATA_IS_LOST    (LL_ADC_NEW_DATA_IS_LOST)        /*!< Previous data is preserved, new data is lost.   */
382 #define ADC_NEW_DATA_IS_KEPT    (LL_ADC_NEW_DATA_IS_KEPT)        /*!< Previous data is overwritten, new data is kept. */
383 
384 /**
385   * @}
386   */
387 
388 
389 /** @defgroup ADC_HAL_DATA_INVERT ADC invert bit to bit data output for differential or
390   *           single negative input (1' complement) definitions
391   * @{
392   */
393 
394 #define ADC_DATA_INVERT_NONE  (0x00UL)    /*!< No inversion                             */
395 #define ADC_DATA_INVERT_DIFF  (0x01UL)    /*!< Inversion only for differential input    */
396 #define ADC_DATA_INVERT_SING  (0x02UL)    /*!< Inversion only for single negative input */
397 #define ADC_DATA_INVERT_BOTH  (0x03UL)    /*!< Inversion for both input type            */
398 
399 /**
400   * @}
401   */
402 
403 /** @defgroup ADC_HAL_CONVERSION_TYPE ADC conversion type definitions
404   * @{
405   */
406 
407 #define ADC_CONVERSION_WITH_DS  (0x00UL)    /*!< ADC conversion through the Down Sampler (DS)      */
408 #define ADC_CONVERSION_WITH_DF  (0x01UL)    /*!< ADC conversion through the Decimation Filter (DF) */
409 
410 /**
411   * @}
412   */
413 
414 /** @defgroup ADC_HAL_SAMPLE_RATE ADC sample rate definitions
415   * @{
416   */
417 #define ADC_SAMPLE_RATE_16    (LL_ADC_SAMPLE_RATE_16)                     /*!< ADC conversion rate at F_ADC_CLK /  16 */
418 #define ADC_SAMPLE_RATE_20    (LL_ADC_SAMPLE_RATE_20)                     /*!< ADC conversion rate at F_ADC_CLK /  20 */
419 #define ADC_SAMPLE_RATE_24    (LL_ADC_SAMPLE_RATE_24)                     /*!< ADC conversion rate at F_ADC_CLK /  24 */
420 #define ADC_SAMPLE_RATE_28    (LL_ADC_SAMPLE_RATE_28)                     /*!< ADC conversion rate at F_ADC_CLK /  28 */
421 #if defined(ADC_CONF_SAMPLE_RATE_MSB)
422 #define ADC_SAMPLE_RATE_32    (LL_ADC_SAMPLE_RATE_32)                     /*!< ADC conversion rate at F_ADC_CLK /  32 */
423 #define ADC_SAMPLE_RATE_36    (LL_ADC_SAMPLE_RATE_36)                     /*!< ADC conversion rate at F_ADC_CLK /  36 */
424 #define ADC_SAMPLE_RATE_40    (LL_ADC_SAMPLE_RATE_40)                     /*!< ADC conversion rate at F_ADC_CLK /  40 */
425 #define ADC_SAMPLE_RATE_44    (LL_ADC_SAMPLE_RATE_44)                     /*!< ADC conversion rate at F_ADC_CLK /  44 */
426 #define ADC_SAMPLE_RATE_48    (LL_ADC_SAMPLE_RATE_48)                     /*!< ADC conversion rate at F_ADC_CLK /  48 */
427 #define ADC_SAMPLE_RATE_52    (LL_ADC_SAMPLE_RATE_52)                     /*!< ADC conversion rate at F_ADC_CLK /  52 */
428 #define ADC_SAMPLE_RATE_56    (LL_ADC_SAMPLE_RATE_56)                     /*!< ADC conversion rate at F_ADC_CLK /  56 */
429 #define ADC_SAMPLE_RATE_60    (LL_ADC_SAMPLE_RATE_60)                     /*!< ADC conversion rate at F_ADC_CLK /  60 */
430 #define ADC_SAMPLE_RATE_64    (LL_ADC_SAMPLE_RATE_64)                     /*!< ADC conversion rate at F_ADC_CLK /  64 */
431 #define ADC_SAMPLE_RATE_68    (LL_ADC_SAMPLE_RATE_68)                     /*!< ADC conversion rate at F_ADC_CLK /  68 */
432 #define ADC_SAMPLE_RATE_72    (LL_ADC_SAMPLE_RATE_72)                     /*!< ADC conversion rate at F_ADC_CLK /  72 */
433 #define ADC_SAMPLE_RATE_76    (LL_ADC_SAMPLE_RATE_76)                     /*!< ADC conversion rate at F_ADC_CLK /  76 */
434 #define ADC_SAMPLE_RATE_80    (LL_ADC_SAMPLE_RATE_80)                     /*!< ADC conversion rate at F_ADC_CLK /  80 */
435 #define ADC_SAMPLE_RATE_84    (LL_ADC_SAMPLE_RATE_84)                     /*!< ADC conversion rate at F_ADC_CLK /  84 */
436 #define ADC_SAMPLE_RATE_88    (LL_ADC_SAMPLE_RATE_88)                     /*!< ADC conversion rate at F_ADC_CLK /  88 */
437 #define ADC_SAMPLE_RATE_92    (LL_ADC_SAMPLE_RATE_92)                     /*!< ADC conversion rate at F_ADC_CLK /  92 */
438 #define ADC_SAMPLE_RATE_96    (LL_ADC_SAMPLE_RATE_96)                     /*!< ADC conversion rate at F_ADC_CLK /  96 */
439 #define ADC_SAMPLE_RATE_100   (LL_ADC_SAMPLE_RATE_100)                    /*!< ADC conversion rate at F_ADC_CLK / 100 */
440 #define ADC_SAMPLE_RATE_104   (LL_ADC_SAMPLE_RATE_104)                    /*!< ADC conversion rate at F_ADC_CLK / 104 */
441 #define ADC_SAMPLE_RATE_108   (LL_ADC_SAMPLE_RATE_108)                    /*!< ADC conversion rate at F_ADC_CLK / 108 */
442 #define ADC_SAMPLE_RATE_112   (LL_ADC_SAMPLE_RATE_112)                    /*!< ADC conversion rate at F_ADC_CLK / 112 */
443 #define ADC_SAMPLE_RATE_116   (LL_ADC_SAMPLE_RATE_116)                    /*!< ADC conversion rate at F_ADC_CLK / 116 */
444 #define ADC_SAMPLE_RATE_120   (LL_ADC_SAMPLE_RATE_120)                    /*!< ADC conversion rate at F_ADC_CLK / 120 */
445 #define ADC_SAMPLE_RATE_124   (LL_ADC_SAMPLE_RATE_124)                    /*!< ADC conversion rate at F_ADC_CLK / 124 */
446 #define ADC_SAMPLE_RATE_128   (LL_ADC_SAMPLE_RATE_128)                    /*!< ADC conversion rate at F_ADC_CLK / 128 */
447 #define ADC_SAMPLE_RATE_132   (LL_ADC_SAMPLE_RATE_132)                    /*!< ADC conversion rate at F_ADC_CLK / 132 */
448 #define ADC_SAMPLE_RATE_136   (LL_ADC_SAMPLE_RATE_136)                    /*!< ADC conversion rate at F_ADC_CLK / 136 */
449 #define ADC_SAMPLE_RATE_140   (LL_ADC_SAMPLE_RATE_140)                    /*!< ADC conversion rate at F_ADC_CLK / 140 */
450 
451 #endif /* ADC_CONF_SAMPLE_RATE_MSB */
452 /**
453   * @}
454   */
455 
456 
457 /** @defgroup ADC_HAL_OP_MODE ADC operation modes definitions
458   * @{
459   */
460 
461 #define ADC_OP_MODE_ADC      (LL_ADC_OP_MODE_ADC)    /*!< ADC operation mode ADC   */
462 #define ADC_OP_MODE_AUDIO    (LL_ADC_OP_MODE_AUDIO)  /*!< ADC operation mode AUDIO */
463 #define ADC_OP_MODE_FULL     (LL_ADC_OP_MODE_FULL)   /*!< ADC operation Full mode  */
464 
465 /**
466   * @}
467   */
468 
469 /** @defgroup ADC_HAL_EC_SEQ_RANKS  ADC Sequencer ranks
470   * @{
471   */
472 
473 #define ADC_RANK_1                (LL_ADC_RANK_1)  /*!< ADC sequencer rank  1 */
474 #define ADC_RANK_2                (LL_ADC_RANK_2)  /*!< ADC sequencer rank  2 */
475 #define ADC_RANK_3                (LL_ADC_RANK_3)  /*!< ADC sequencer rank  3 */
476 #define ADC_RANK_4                (LL_ADC_RANK_4)  /*!< ADC sequencer rank  4 */
477 #define ADC_RANK_5                (LL_ADC_RANK_5)  /*!< ADC sequencer rank  5 */
478 #define ADC_RANK_6                (LL_ADC_RANK_6)  /*!< ADC sequencer rank  6 */
479 #define ADC_RANK_7                (LL_ADC_RANK_7)  /*!< ADC sequencer rank  7 */
480 #define ADC_RANK_8                (LL_ADC_RANK_8)  /*!< ADC sequencer rank  8 */
481 #define ADC_RANK_9                (LL_ADC_RANK_9)  /*!< ADC sequencer rank  9 */
482 #define ADC_RANK_10               (LL_ADC_RANK_10) /*!< ADC sequencer rank 10 */
483 #define ADC_RANK_11               (LL_ADC_RANK_11) /*!< ADC sequencer rank 11 */
484 #define ADC_RANK_12               (LL_ADC_RANK_12) /*!< ADC sequencer rank 12 */
485 #define ADC_RANK_13               (LL_ADC_RANK_13) /*!< ADC sequencer rank 13 */
486 #define ADC_RANK_14               (LL_ADC_RANK_14) /*!< ADC sequencer rank 14 */
487 #define ADC_RANK_15               (LL_ADC_RANK_15) /*!< ADC sequencer rank 15 */
488 #define ADC_RANK_16               (LL_ADC_RANK_16) /*!< ADC sequencer rank 16 */
489 
490 /**
491   * @}
492   */
493 
494 #if defined(ADC_SUPPORT_AUDIO_FEATURES)
495 /** @defgroup ADC_HAL_OCM_SOURCE ADC occasional mode source definitions
496   * @{
497   */
498 
499 #define ADC_OCM_SRC_VBAT    (LL_ADC_OCM_SRC_VBAT)  /*!< ADC occasional mode source VBAT */
500 #define ADC_OCM_SRC_TEMP    (LL_ADC_OCM_SRC_TEMP)  /*!< ADC occasional mode source temperature sensor */
501 
502 /**
503   * @}
504   */
505 
506 
507 /** @defgroup ADC_HAL_PGA_BIAS ADC microphone bias voltage definitions
508   * @{
509   */
510 
511 #define ADC_PGA_BIAS_050_BAT   (LL_ADC_PGA_BIAS_050_BAT)  /*!< Set the microphone bias voltage at 0.50 V */
512 #define ADC_PGA_BIAS_055_BAT   (LL_ADC_PGA_BIAS_055_BAT)  /*!< Set the microphone bias voltage at 0.55 V */
513 #define ADC_PGA_BIAS_060_BAT   (LL_ADC_PGA_BIAS_060_BAT)  /*!< Set the microphone bias voltage at 0.60 V */
514 #define ADC_PGA_BIAS_065_BAT   (LL_ADC_PGA_BIAS_065_BAT)  /*!< Set the microphone bias voltage at 0.65 V */
515 #define ADC_PGA_BIAS_070_BAT   (LL_ADC_PGA_BIAS_070_BAT)  /*!< Set the microphone bias voltage at 0.70 V */
516 #define ADC_PGA_BIAS_075_BAT   (LL_ADC_PGA_BIAS_075_BAT)  /*!< Set the microphone bias voltage at 0.75 V */
517 #define ADC_PGA_BIAS_080_BAT   (LL_ADC_PGA_BIAS_080_BAT)  /*!< Set the microphone bias voltage at 0.80 V */
518 #define ADC_PGA_BIAS_090_BAT   (LL_ADC_PGA_BIAS_090_BAT)  /*!< Set the microphone bias voltage at 0.90 V */
519 
520 /**
521   * @}
522   */
523 
524 
525 /** @defgroup ADC_HAL_PGA_GAIN ADC microphone gain definitions
526   * @{
527   */
528 
529 #define ADC_PGA_GAIN_06_DB   (LL_ADC_PGA_GAIN_06_DB)  /*!< Set the microphone gain at 6 dB  */
530 #define ADC_PGA_GAIN_09_DB   (LL_ADC_PGA_GAIN_09_DB)  /*!< Set the microphone gain at 9 dB  */
531 #define ADC_PGA_GAIN_12_DB   (LL_ADC_PGA_GAIN_12_DB)  /*!< Set the microphone gain at 12 dB */
532 #define ADC_PGA_GAIN_15_DB   (LL_ADC_PGA_GAIN_15_DB)  /*!< Set the microphone gain at 15 dB */
533 #define ADC_PGA_GAIN_18_DB   (LL_ADC_PGA_GAIN_18_DB)  /*!< Set the microphone gain at 18 dB */
534 #define ADC_PGA_GAIN_21_DB   (LL_ADC_PGA_GAIN_21_DB)  /*!< Set the microphone gain at 21 dB */
535 #define ADC_PGA_GAIN_24_DB   (LL_ADC_PGA_GAIN_24_DB)  /*!< Set the microphone gain at 24 dB */
536 #define ADC_PGA_GAIN_27_DB   (LL_ADC_PGA_GAIN_27_DB)  /*!< Set the microphone gain at 27 dB */
537 #define ADC_PGA_GAIN_30_DB   (LL_ADC_PGA_GAIN_30_DB)  /*!< Set the microphone gain at 30 dB */
538 /**
539   * @}
540   */
541 #endif /* ADC_SUPPORT_AUDIO_FEATURES */
542 
543 /** @defgroup ADC_HAL_INPUT_VOLTAGE_RANGE ADC input voltage range definitions
544   * @{
545   */
546 
547 #define ADC_VIN_RANGE_1V2    (LL_ADC_VIN_RANGE_1V2)  /*!< ADC input voltage range up to 1.2 V */
548 #define ADC_VIN_RANGE_2V4    (LL_ADC_VIN_RANGE_2V4)  /*!< ADC input voltage range up to 2.4 V */
549 #define ADC_VIN_RANGE_3V6    (LL_ADC_VIN_RANGE_3V6)  /*!< ADC input voltage range up to 3.6 V */
550 
551 /**
552   * @}
553   */
554 
555 
556 #if defined(ADC_SUPPORT_AUDIO_FEATURES)
557 /** @defgroup ADC_HAL_DF_DYN_RANGE ADC Decimation Filter dynamic range definitions
558   * @{
559   */
560 
561 #define ADC_DF_DYN_RANGE_FULL    (LL_ADC_DF_DYN_RANGE_FULL)  /*!< ADC Decimation Filter dynamic full range */
562 #define ADC_DF_DYN_RANGE_HALF    (LL_ADC_DF_DYN_RANGE_HALF)  /*!< ADC Decimation Filter dynamic half range */
563 
564 /**
565   * @}
566   */
567 
568 /** @defgroup ADC_HAL_MIC_CHANNEL ADC microphone channel definitions
569   * @{
570   */
571 
572 #define ADC_DF_MIC_CH_RIGHT    (LL_ADC_DF_MIC_CH_RIGHT) /*!< ADC microphone channel right */
573 #define ADC_DF_MIC_CH_LEFT     (LL_ADC_DF_MIC_CH_LEFT)  /*!< ADC microphone channel left  */
574 
575 /**
576   * @}
577   */
578 
579 /** @defgroup ADC_HAL_DF_DATA_FORMAT ADC data format definitions
580   * @{
581   */
582 
583 #define ADC_DF_DATA_FORMAT_SIGNED    (LL_ADC_DF_DATA_FORMAT_SIGNED)    /*!< ADC data format signed   */
584 #define ADC_DF_DATA_FORMAT_UNSIGNED  (LL_ADC_DF_DATA_FORMAT_UNSIGNED)  /*!< ADC data format unsigned */
585 
586 /**
587   * @}
588   */
589 
590 /** @defgroup ADC_HAL_CIC_DECIMATOR_HALF_FACTOR ADC CIC decimator half factor definitions
591   * @{
592   */
593 
594 #define ADC_DF_CIC_DECIMATOR_FACTOR_HALF     (LL_ADC_DF_CIC_DECIMATOR_FACTOR_HALF)    /*!< ADC DF CIC decimator factor half    */
595 #define ADC_DF_CIC_DECIMATOR_FACTOR_INTEGER  (LL_ADC_DF_CIC_DECIMATOR_FACTOR_INTEGER) /*!< ADC DF CIC decimator factor integer */
596 
597 /**
598   * @}
599   */
600 
601 /** @defgroup ADC_HAL_PDM_CLK_DIVIDER ADC PDM clock divider definitions
602   * @{
603   */
604 
605 #define ADC_PDM_DIV_10   (LL_ADC_PDM_DIV_10)  /*!< ADC PDM clock divider 10 */
606 #define ADC_PDM_DIV_11   (LL_ADC_PDM_DIV_11)  /*!< ADC PDM clock divider 11 */
607 #define ADC_PDM_DIV_12   (LL_ADC_PDM_DIV_12)  /*!< ADC PDM clock divider 12 */
608 #define ADC_PDM_DIV_13   (LL_ADC_PDM_DIV_13)  /*!< ADC PDM clock divider 13 */
609 #define ADC_PDM_DIV_14   (LL_ADC_PDM_DIV_14)  /*!< ADC PDM clock divider 14 */
610 #define ADC_PDM_DIV_15   (LL_ADC_PDM_DIV_15)  /*!< ADC PDM clock divider 15 */
611 #define ADC_PDM_DIV_16   (LL_ADC_PDM_DIV_16)  /*!< ADC PDM clock divider 16 */
612 #define ADC_PDM_DIV_17   (LL_ADC_PDM_DIV_17)  /*!< ADC PDM clock divider 17 */
613 #define ADC_PDM_DIV_18   (LL_ADC_PDM_DIV_18)  /*!< ADC PDM clock divider 18 */
614 #define ADC_PDM_DIV_19   (LL_ADC_PDM_DIV_19)  /*!< ADC PDM clock divider 19 */
615 #define ADC_PDM_DIV_20   (LL_ADC_PDM_DIV_20)  /*!< ADC PDM clock divider 20 */
616 #define ADC_PDM_DIV_21   (LL_ADC_PDM_DIV_21)  /*!< ADC PDM clock divider 21 */
617 #define ADC_PDM_DIV_22   (LL_ADC_PDM_DIV_22)  /*!< ADC PDM clock divider 22 */
618 #define ADC_PDM_DIV_23   (LL_ADC_PDM_DIV_23)  /*!< ADC PDM clock divider 23 */
619 #define ADC_PDM_DIV_24   (LL_ADC_PDM_DIV_24)  /*!< ADC PDM clock divider 24 */
620 #define ADC_PDM_DIV_25   (LL_ADC_PDM_DIV_25)  /*!< ADC PDM clock divider 25 */
621 
622 /**
623   * @}
624   */
625 
626 /** @defgroup ADC_HAL_MICROPHONE_OUT_FREQ ADC microphone output frequency definitions
627   * @{
628   */
629 #define ADC_OUTPUT_FREQ_MIC_DIG_47619_HZ  (LL_ADC_OUTPUT_FREQ_MIC_DIG_47619_HZ)  /*!< ADC digital microphone output frequency 47.619 kHz */
630 #define ADC_OUTPUT_FREQ_MIC_DIG_44440_HZ  (LL_ADC_OUTPUT_FREQ_MIC_DIG_44440_HZ)  /*!< ADC digital microphone output frequency 44.44  kHz */
631 #define ADC_OUTPUT_FREQ_MIC_DIG_22220_HZ  (LL_ADC_OUTPUT_FREQ_MIC_DIG_22220_HZ)  /*!< ADC digital microphone output frequency 22.22  kHz */
632 #define ADC_OUTPUT_FREQ_MIC_DIG_15873_HZ  (LL_ADC_OUTPUT_FREQ_MIC_DIG_15873_HZ)  /*!< ADC digital microphone output frequency 15.873 kHz */
633 #define ADC_OUTPUT_FREQ_MIC_DIG_7936_HZ   (LL_ADC_OUTPUT_FREQ_MIC_DIG_7936_HZ)   /*!< ADC digital microphone output frequency 7.936  kHz */
634 
635 #define ADC_OUTPUT_FREQ_MIC_ANA_200000_HZ (LL_ADC_OUTPUT_FREQ_MIC_ANA_200000_HZ)  /*!< ADC analog microphone output frequency 200.00 kHz */
636 #define ADC_OUTPUT_FREQ_MIC_ANA_15873_HZ  (LL_ADC_OUTPUT_FREQ_MIC_ANA_15873_HZ)   /*!< ADC analog microphone output frequency 15.873 kHz */
637 #define ADC_OUTPUT_FREQ_MIC_ANA_7936_HZ   (LL_ADC_OUTPUT_FREQ_MIC_ANA_7936_HZ)    /*!< ADC analog microphone output frequency 7.936  kHz */
638 
639 /**
640   * @}
641   */
642 #endif /* ADC_SUPPORT_AUDIO_FEATURES */
643 
644 /** @defgroup ADC_HAL_DS_DATA_WIDTH ADC Down Sampler data width definitions
645   * @{
646   */
647 
648 #define ADC_DS_DATA_WIDTH_12_BIT  (LL_ADC_DS_DATA_WIDTH_12_BIT)  /*!< ADC Down Sampler data width 12 bits */
649 #define ADC_DS_DATA_WIDTH_13_BIT  (LL_ADC_DS_DATA_WIDTH_13_BIT)  /*!< ADC Down Sampler data width 13 bits */
650 #define ADC_DS_DATA_WIDTH_14_BIT  (LL_ADC_DS_DATA_WIDTH_14_BIT)  /*!< ADC Down Sampler data width 14 bits */
651 #define ADC_DS_DATA_WIDTH_15_BIT  (LL_ADC_DS_DATA_WIDTH_15_BIT)  /*!< ADC Down Sampler data width 15 bits */
652 #define ADC_DS_DATA_WIDTH_16_BIT  (LL_ADC_DS_DATA_WIDTH_16_BIT)  /*!< ADC Down Sampler data width 16 bits */
653 
654 /**
655   * @}
656   */
657 
658 
659 /** @defgroup ADC_HAL_DS_RATIO ADC Down Sampler ratio definitions
660   * @{
661   */
662 
663 #define ADC_DS_RATIO_1    (LL_ADC_DS_RATIO_1)       /*!< ADC Down Sampler ratio 1, no down sampling (default) */
664 #define ADC_DS_RATIO_2    (LL_ADC_DS_RATIO_2)       /*!< ADC Down Sampler ratio 2                             */
665 #define ADC_DS_RATIO_4    (LL_ADC_DS_RATIO_4)       /*!< ADC Down Sampler ratio 4                             */
666 #define ADC_DS_RATIO_8    (LL_ADC_DS_RATIO_8)       /*!< ADC Down Sampler ratio 8                             */
667 #define ADC_DS_RATIO_16   (LL_ADC_DS_RATIO_16)      /*!< ADC Down Sampler ratio 16                            */
668 #define ADC_DS_RATIO_32   (LL_ADC_DS_RATIO_32)      /*!< ADC Down Sampler ratio 32                            */
669 #define ADC_DS_RATIO_64   (LL_ADC_DS_RATIO_64)      /*!< ADC Down Sampler ratio 64                            */
670 #define ADC_DS_RATIO_128  (LL_ADC_DS_RATIO_128)     /*!< ADC Down Sampler ratio 128                           */
671 
672 /**
673   * @}
674   */
675 
676 
677 /** @defgroup ADC_HAL_CALIB_POINT ADC calibration points definitions
678   * @{
679   */
680 
681 #define ADC_CALIB_POINT_1  (LL_ADC_CALIB_POINT_1)  /*!< ADC calibration point 1 */
682 #define ADC_CALIB_POINT_2  (LL_ADC_CALIB_POINT_2)  /*!< ADC calibration point 2 */
683 #define ADC_CALIB_POINT_3  (LL_ADC_CALIB_POINT_3)  /*!< ADC calibration point 3 */
684 #define ADC_CALIB_POINT_4  (LL_ADC_CALIB_POINT_4)  /*!< ADC calibration point 4 */
685 #define ADC_CALIB_NONE     (LL_ADC_CALIB_POINT_1   \
686                             | LL_ADC_CALIB_POINT_2 \
687                             | LL_ADC_CALIB_POINT_3 \
688                             | LL_ADC_CALIB_POINT_4) /*!< ADC calibration point disabled: correction are left untouched
689                                                        for the selected channel */
690 
691 /**
692   * @}
693   */
694 
695 
696 /** @defgroup ADC_AWD_CHANNEL ADC watchdog channel selection for bit mask definitions
697   * @{
698   */
699 
700 #define ADC_AWD_CH_VINM0      (LL_ADC_AWD_CH_VINM0)      /*!< ADC watchdog channel selection: VINM0 to ADC negative input  */
701 #define ADC_AWD_CH_VINM1      (LL_ADC_AWD_CH_VINM1)      /*!< ADC watchdog channel selection: VINM1 to ADC negative input  */
702 #define ADC_AWD_CH_VINM2      (LL_ADC_AWD_CH_VINM2)      /*!< ADC watchdog channel selection: VINM2 to ADC negative input  */
703 #define ADC_AWD_CH_VINM3      (LL_ADC_AWD_CH_VINM3)      /*!< ADC watchdog channel selection: VINM3 to ADC negative input  */
704 #define ADC_AWD_CH_VINP0      (LL_ADC_AWD_CH_VINP0)      /*!< ADC watchdog channel selection: VINP0 to ADC positive input  */
705 #define ADC_AWD_CH_VINP1      (LL_ADC_AWD_CH_VINP1)      /*!< ADC watchdog channel selection: VINP1 to ADC positive input  */
706 #define ADC_AWD_CH_VINP2      (LL_ADC_AWD_CH_VINP2)      /*!< ADC watchdog channel selection: VINP2 to ADC positive input  */
707 #define ADC_AWD_CH_VINP3      (LL_ADC_AWD_CH_VINP3)      /*!< ADC watchdog channel selection: VINP3 to ADC positive input  */
708 #define ADC_AWD_CH_MICROM     (LL_ADC_AWD_CH_MICROM)     /*!< ADC watchdog channel selection: MICROM to ADC negative input */
709 #define ADC_AWD_CH_MICROP     (LL_ADC_AWD_CH_MICROP)     /*!< ADC watchdog channel selection: MICROP to ADC positive input */
710 #define ADC_AWD_CH_VBAT       (LL_ADC_AWD_CH_VBAT)       /*!< ADC watchdog channel selection: VBAT to ADC negative input   */
711 #define ADC_AWD_CH_TEMPSENSOR (LL_ADC_AWD_CH_TEMPSENSOR) /*!< ADC watchdog channel selection: TEMPSENSOR to ADC positive input   */
712 #define ADC_AWD_CH_GND_NEG    (LL_ADC_AWD_CH_GND_NEG)    /*!< ADC watchdog channel selection: GND to ADC negative input    */
713 #define ADC_AWD_CH_GND_POS    (LL_ADC_AWD_CH_GND_POS)    /*!< ADC watchdog channel selection: GND to ADC positive input    */
714 #define ADC_AWD_CH_VDDA_NEG   (LL_ADC_AWD_CH_VDDA_NEG)   /*!< ADC watchdog channel selection: VDDA to ADC negative input   */
715 #define ADC_AWD_CH_VDDA_POS   (LL_ADC_AWD_CH_VDDA_POS)   /*!< ADC watchdog channel selection: VDDA to ADC positive input   */
716 
717 /**
718   * @}
719   */
720 
721 /** @defgroup ADC_AWD_EVENTTYPE ADC watchdog event type definitions
722   * @{
723   */
724 
725 #define ADC_AWD_EVENT_POLLING       (0x00U)  /*!< ADC watchdog event type polling   */
726 #define ADC_AWD_EVENT_INTERRUPT     (0x01U)  /*!< ADC watchdog event type interrupt */
727 
728 /**
729   * @}
730   */
731 
732 
733 /** @defgroup ADC_HAL_IRQ_STATUS_MASK ADC IRQ_STATUS register mask definitions
734   * @{
735   */
736 #if defined(ADC_SUPPORT_AUDIO_FEATURES)
737 #define ADC_IRQ_FLAG_OVRFL   (LL_ADC_IRQ_FLAG_OVRFL) /*!< ADC IRQ flag OVRFL Decimation Filter Saturated */
738 #define ADC_IRQ_FLAG_OVRDF   (LL_ADC_IRQ_FLAG_OVRDF) /*!< ADC IRQ flag OVRDF Decimation Filter Overrun */
739 #define ADC_IRQ_FLAG_EODF    (LL_ADC_IRQ_FLAG_EODF)  /*!< ADC IRQ flag EODF  End of Decimation Filter conversion */
740 #endif /* ADC_SUPPORT_AUDIO_FEATURES */
741 #define ADC_IRQ_FLAG_OVRDS   (LL_ADC_IRQ_FLAG_OVRDS) /*!< ADC IRQ flag OVRDS Down Sampler overrun */
742 #define ADC_IRQ_FLAG_AWD1    (LL_ADC_IRQ_FLAG_AWD1)  /*!< ADC IRQ flag AWD1 Analog watchdog event */
743 #define ADC_IRQ_FLAG_EOS     (LL_ADC_IRQ_FLAG_EOS)   /*!< ADC IRQ flag EOS  End of conversion Sequence */
744 #define ADC_IRQ_FLAG_EOC     (LL_ADC_IRQ_FLAG_EOC)   /*!< ADC IRQ flag EOC  End of conversion */
745 #define ADC_IRQ_FLAG_EODS    (LL_ADC_IRQ_FLAG_EODS)  /*!< ADC IRQ flag EODS End of Down Sampler conversion */
746 
747 /**
748   * @}
749   */
750 
751 
752 /** @defgroup ADC_HAL_IRQ_STATUS_MASK ADC IRQ_STATUS register mask definitions
753   * @{
754   */
755 #if defined(ADC_SUPPORT_AUDIO_FEATURES)
756 #define ADC_IRQ_FLAGS_MASK      (ADC_IRQ_FLAG_OVRFL | \
757                                  ADC_IRQ_FLAG_OVRDF | \
758                                  ADC_IRQ_FLAG_OVRDS | \
759                                  ADC_IRQ_FLAG_AWD1  | \
760                                  ADC_IRQ_FLAG_EOS   | \
761                                  ADC_IRQ_FLAG_EOC   | \
762                                  ADC_IRQ_FLAG_EODF  | \
763                                  ADC_IRQ_FLAG_EODS)
764 
765 #else
766 #define ADC_IRQ_FLAGS_MASK      (ADC_IRQ_FLAG_OVRDS | \
767                                  ADC_IRQ_FLAG_AWD1  | \
768                                  ADC_IRQ_FLAG_EOS   | \
769                                  ADC_IRQ_FLAG_EOC   | \
770                                  ADC_IRQ_FLAG_EODS)
771 #endif /* ADC_SUPPORT_AUDIO_FEATURES */
772 
773 /**
774   * @}
775   */
776 
777 
778 /** @defgroup ADC_HAL_IRQ_ENABLE ADC interrupts enable definitions
779   * @{
780   */
781 #if defined(ADC_SUPPORT_AUDIO_FEATURES)
782 #define ADC_IRQ_EN_OVRFL   (LL_ADC_IRQ_EN_OVRFL)    /*!< ADC IRQ enable OVRFL */
783 #define ADC_IRQ_EN_OVRDF   (LL_ADC_IRQ_EN_OVRDF)    /*!< ADC IRQ enable OVRDF */
784 #define ADC_IRQ_EN_EODF    (LL_ADC_IRQ_EN_EODF)     /*!< ADC IRQ enable EODF  */
785 #endif /* ADC_SUPPORT_AUDIO_FEATURES */
786 #define ADC_IRQ_EN_OVRDS   (LL_ADC_IRQ_EN_OVRDS)    /*!< ADC IRQ enable OVRDS */
787 #define ADC_IRQ_EN_AWD1    (LL_ADC_IRQ_EN_AWD1)     /*!< ADC IRQ enable AWD1   */
788 #define ADC_IRQ_EN_EOS     (LL_ADC_IRQ_EN_EOS)      /*!< ADC IRQ enable EOS   */
789 #define ADC_IRQ_EN_EOC     (LL_ADC_IRQ_EN_EOC)      /*!< ADC IRQ enable EOC   */
790 #define ADC_IRQ_EN_EODS    (LL_ADC_IRQ_EN_EODS)     /*!< ADC IRQ enable EODS  */
791 
792 /**
793   * @}
794   */
795 
796 
797 /** @defgroup ADC_HAL_IRQ_ENABLE_MASK ADC IRQ_ENABLE register mask definitions
798   * @{
799   */
800 #if defined(ADC_SUPPORT_AUDIO_FEATURES)
801 #define ADC_IRQ_EN_MASK      (ADC_IRQ_EN_OVRFL | \
802                               ADC_IRQ_EN_OVRDF | \
803                               ADC_IRQ_EN_OVRDS | \
804                               ADC_IRQ_EN_AWD1  | \
805                               ADC_IRQ_EN_EOS   | \
806                               ADC_IRQ_EN_EOC   | \
807                               ADC_IRQ_EN_EODF  | \
808                               ADC_IRQ_EN_EODS)
809 #else
810 #define ADC_IRQ_EN_MASK      (ADC_IRQ_EN_OVRDS | \
811                               ADC_IRQ_EN_AWD1  | \
812                               ADC_IRQ_EN_EOS   | \
813                               ADC_IRQ_EN_EOC   | \
814                               ADC_IRQ_EN_EODS)
815 #endif /* ADC_SUPPORT_AUDIO_FEATURES */
816 /**
817   * @}
818   */
819 
820 
821 /**
822   * @}
823   */
824 
825 
826 /* Private macro -------------------------------------------------------------*/
827 
828 /** @defgroup ADC_Private_Macros ADC Private Macros
829   * @{
830   */
831 /* Macro reserved for internal HAL driver usage, not intended to be used in   */
832 /* code of final user.                                                        */
833 
834 /**
835   * @brief Clear ADC error code (set it to no error code "HAL_ADC_ERROR_NONE").
836   * @param __HANDLE__ ADC handle
837   * @retval None
838   */
839 #define ADC_CLEAR_ERRORCODE(__HANDLE__) ((__HANDLE__)->ErrorCode = HAL_ADC_ERROR_NONE)
840 
841 /**
842   * @brief Simultaneously clear and set specific bits of the handle State.
843   * @note  ADC_STATE_CLR_SET() macro is merely aliased to generic macro MODIFY_REG(),
844   *        the first parameter is the ADC handle State, the second parameter is the
845   *        bit field to clear, the third and last parameter is the bit field to set.
846   * @retval None
847   */
848 #define ADC_STATE_CLR_SET MODIFY_REG
849 
850 /**
851   * @brief Verify the length of the scheduled conversions group.
852   * @param __LENGTH__ number of programmed conversions.
853   * @retval SET (__LENGTH__ is within the maximum number of possible programmable conversions)
854   *         or RESET (__LENGTH__ is null or too large)
855   */
856 #define IS_ADC_NB_CONV(__LENGTH__) (((__LENGTH__) >= (1UL)) && ((__LENGTH__) <= (16UL)))
857 
858 /**
859   * @brief Verify the ADC data width setting.
860   * @param __DATA_WIDTH__ programmed ADC resolution.
861   * @retval SET (__DATA_WIDTH__ is a valid value) or RESET (__DATA_WIDTH__ is invalid)
862   */
863 #define IS_ADC_DATAWIDTH(__DATA_WIDTH__) (((__DATA_WIDTH__) == ADC_DS_DATA_WIDTH_12_BIT) || \
864                                           ((__DATA_WIDTH__) == ADC_DS_DATA_WIDTH_13_BIT) || \
865                                           ((__DATA_WIDTH__) == ADC_DS_DATA_WIDTH_14_BIT) || \
866                                           ((__DATA_WIDTH__) == ADC_DS_DATA_WIDTH_15_BIT) || \
867                                           ((__DATA_WIDTH__) == ADC_DS_DATA_WIDTH_16_BIT)   )
868 /**
869   * @brief Verify the ADC downsampler ratio setting.
870   * @param __DATA_RATIO__ programmed ADC downsampler ratio.
871   * @retval SET (__DATA_RATIO__ is a valid value) or RESET (__DATA_RATIO__ is invalid)
872   */
873 #define IS_ADC_DATARATIO(__DATA_RATIO__) (((__DATA_RATIO__) == ADC_DS_RATIO_1)  || \
874                                           ((__DATA_RATIO__) == ADC_DS_RATIO_2)  || \
875                                           ((__DATA_RATIO__) == ADC_DS_RATIO_4)  || \
876                                           ((__DATA_RATIO__) == ADC_DS_RATIO_8)  || \
877                                           ((__DATA_RATIO__) == ADC_DS_RATIO_16) || \
878                                           ((__DATA_RATIO__) == ADC_DS_RATIO_32) || \
879                                           ((__DATA_RATIO__) == ADC_DS_RATIO_64) || \
880                                           ((__DATA_RATIO__) == ADC_DS_RATIO_128)   )
881 
882 /**
883   * @brief Verify the ADC conversion type setting.
884   * @param __CONVERSION_TYPE__ ADC conversion type.
885   * @retval SET (__CONVERSION_TYPE__ is a valid value) or RESET (__CONVERSION_TYPE__ is invalid)
886   */
887 #define IS_ADC_CONVERSIONTYPE(__CONVERSION_TYPE__) (((__CONVERSION_TYPE__) == ADC_CONVERSION_WITH_DS)  || \
888                                                     ((__CONVERSION_TYPE__) == ADC_CONVERSION_WITH_DF)    )
889 
890 /**
891   * @brief Verify the ADC conversions overrun handling.
892   * @param __OVR__ ADC conversions overrun handling.
893   * @retval SET (__OVR__ is a valid value) or RESET (__OVR__ is invalid)
894   */
895 #define IS_ADC_OVERRUN(__OVR__) (((__OVR__) == ADC_NEW_DATA_IS_LOST)  || \
896                                  ((__OVR__) == ADC_NEW_DATA_IS_KEPT)    )
897 
898 /**
899   * @brief Verify the ADC sampling mode setting.
900   * @param __SAMPLING_MODE__ programmed ADC sampling mode.
901   * @retval SET (__SAMPLING_MODE__ is a valid value) or RESET (__SAMPLING_MODE__ is invalid)
902   */
903 #define IS_ADC_SAMPLINGMODE(__SAMPLING_MODE__) (((__SAMPLING_MODE__) == ADC_SAMPLING_AT_START) || \
904                                                 ((__SAMPLING_MODE__) == ADC_SAMPLING_AT_END)     )
905 
906 /**
907   * @brief Verify the ADC calibration calibration point setting.
908   * @param __POINT_NUMBER__ selected ADC calibration point number
909   * @retval SET (__POINT_NUMBER__ is a valid value) or RESET (__POINT_NUMBER__ is invalid)
910   */
911 #define IS_ADC_CALIBRATION_POINT(__POINT_NUMBER__) (((__POINT_NUMBER__) == ADC_CALIB_POINT_1) || \
912                                                     ((__POINT_NUMBER__) == ADC_CALIB_POINT_2) || \
913                                                     ((__POINT_NUMBER__) == ADC_CALIB_POINT_3) || \
914                                                     ((__POINT_NUMBER__) == ADC_CALIB_POINT_4) || \
915                                                     ((__POINT_NUMBER__) == ADC_CALIB_NONE)      )
916 
917 /**
918   * @brief Verify the ADC calibration calibration gain setting.
919   * @param __GAIN__ selected ADC calibration gain
920   * @retval SET (__GAIN__ is a valid value) or RESET (__GAIN__ is invalid)
921   */
922 #define IS_ADC_CALIBRATION_GAIN(__GAIN__) ((__GAIN__ <= 0xFFFUL))
923 
924 /**
925   * @brief Verify the ADC calibration calibration offset setting.
926   * @param __OFFSET__ selected ADC calibration offset
927   * @retval SET (__OFFSET__ is a valid value) or RESET (__OFFSET__ is invalid)
928   */
929 #define IS_ADC_CALIBRATION_OFFSET(__OFFSET__) ((__OFFSET__ <= 0xFFUL))
930 
931 /**
932   * @brief Verify the ADC conversions sampling time.
933   * @param __SAMPLERATE__ ADC conversions sampling time.
934   * @retval SET (__SAMPLING_TIME__ is a valid value) or RESET (__SAMPLING_TIME__ is invalid)
935   */
936 #if defined(ADC_CONF_SAMPLE_RATE_MSB)
937 #define IS_ADC_SAMPLERATE(__SAMPLERATE__)    (((__SAMPLERATE__) == ADC_SAMPLE_RATE_16)  || \
938                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_20)  || \
939                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_24)  || \
940                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_28)  || \
941                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_32)  || \
942                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_36)  || \
943                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_40)  || \
944                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_44)  || \
945                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_48)  || \
946                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_52)  || \
947                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_56)  || \
948                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_60)  || \
949                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_64)  || \
950                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_68)  || \
951                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_72)  || \
952                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_76)  || \
953                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_80)  || \
954                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_84)  || \
955                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_88)  || \
956                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_92)  || \
957                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_96)  || \
958                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_100) || \
959                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_104) || \
960                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_108) || \
961                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_112) || \
962                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_116) || \
963                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_120) || \
964                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_124) || \
965                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_128) || \
966                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_132) || \
967                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_136) || \
968                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_140)  )
969 #else
970 #define IS_ADC_SAMPLERATE(__SAMPLERATE__)    (((__SAMPLERATE__) == ADC_SAMPLE_RATE_16)  || \
971                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_20)  || \
972                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_24)  || \
973                                               ((__SAMPLERATE__) == ADC_SAMPLE_RATE_28)   )
974 #endif /* ADC_CONF_SAMPLE_RATE_MSB */
975 
976 /**
977   * @brief Verify the ADC bit inversion mode
978   * @param  __OUTBIT_MODE__ ADC invert bit to bit data output.
979   * @retval SET (__OUTBIT_MODE__ is valid) or RESET (__OUTBIT_MODE__ is invalid)
980   */
981 #define IS_ADC_DATA_INVERT(__OUTBIT_MODE__)   (((__OUTBIT_MODE__) == ADC_DATA_INVERT_NONE) || \
982                                                ((__OUTBIT_MODE__) == ADC_DATA_INVERT_DIFF) || \
983                                                ((__OUTBIT_MODE__) == ADC_DATA_INVERT_SING) || \
984                                                ((__OUTBIT_MODE__) == ADC_DATA_INVERT_BOTH)  )
985 
986 /**
987   * @brief Verify the ADC sequencer rank setting.
988   * @param  __RANK__ selected position in sequencer.
989   * @retval SET (__RANK__ is valid) or RESET (__RANK__ is invalid)
990   */
991 #define IS_ADC_RANK(__RANK__) (((__RANK__) == ADC_RANK_1 ) || \
992                                ((__RANK__) == ADC_RANK_2 ) || \
993                                ((__RANK__) == ADC_RANK_3 ) || \
994                                ((__RANK__) == ADC_RANK_4 ) || \
995                                ((__RANK__) == ADC_RANK_5 ) || \
996                                ((__RANK__) == ADC_RANK_6 ) || \
997                                ((__RANK__) == ADC_RANK_7 ) || \
998                                ((__RANK__) == ADC_RANK_8 ) || \
999                                ((__RANK__) == ADC_RANK_9 ) || \
1000                                ((__RANK__) == ADC_RANK_10) || \
1001                                ((__RANK__) == ADC_RANK_11) || \
1002                                ((__RANK__) == ADC_RANK_12) || \
1003                                ((__RANK__) == ADC_RANK_13) || \
1004                                ((__RANK__) == ADC_RANK_14) || \
1005                                ((__RANK__) == ADC_RANK_15) || \
1006                                ((__RANK__) == ADC_RANK_16)   )
1007 
1008 /**
1009   * @brief Verify the ADC channel voltage range setting.
1010   * @param  __VOLTAGE_RANGE__ selected voltage range.
1011   * @retval SET (__VOLTAGE_RANGE_ is valid) or RESET (__VOLTAGE_RANGE_ is invalid)
1012   */
1013 #define IS_ADC_VOLTAGE_RANGE(__VOLTAGE_RANGE__) (((__VOLTAGE_RANGE__) == ADC_VIN_RANGE_1V2) || \
1014                                                  ((__VOLTAGE_RANGE__) == ADC_VIN_RANGE_2V4) || \
1015                                                  ((__VOLTAGE_RANGE__) == ADC_VIN_RANGE_3V6)   )
1016 
1017 /**
1018   * @brief Verify the ADC channel setting.
1019   * @param  __CHANNEL__ selected ADC channel.
1020   * @retval SET (__CHANNEL__ is valid) or RESET (__CHANNEL__ is invalid)
1021   */
1022 #define IS_ADC_CHANNEL(__CHANNEL__) (((__CHANNEL__) == ADC_CHANNEL_VINM0)       || \
1023                                      ((__CHANNEL__) == ADC_CHANNEL_VINM1)       || \
1024                                      ((__CHANNEL__) == ADC_CHANNEL_VINM2)       || \
1025                                      ((__CHANNEL__) == ADC_CHANNEL_VINM3)       || \
1026                                      ((__CHANNEL__) == ADC_CHANNEL_VINP0)       || \
1027                                      ((__CHANNEL__) == ADC_CHANNEL_VINP1)       || \
1028                                      ((__CHANNEL__) == ADC_CHANNEL_VINP2)       || \
1029                                      ((__CHANNEL__) == ADC_CHANNEL_VINP3)       || \
1030                                      ((__CHANNEL__) == ADC_CHANNEL_VINP0_VINM0) || \
1031                                      ((__CHANNEL__) == ADC_CHANNEL_VINP1_VINM1) || \
1032                                      ((__CHANNEL__) == ADC_CHANNEL_VINP2_VINM2) || \
1033                                      ((__CHANNEL__) == ADC_CHANNEL_VINP3_VINM3) || \
1034                                      ((__CHANNEL__) == ADC_CHANNEL_VBAT)        || \
1035                                      ((__CHANNEL__) == ADC_CHANNEL_TEMPSENSOR)    )
1036 
1037 #if defined(ADC_SUPPORT_AUDIO_FEATURES)
1038 /**
1039   * @brief Verify the ADC event setting.
1040   * @param  __EVENT__ ADC event.
1041   * @retval SET (__EVENT__ is valid) or RESET (__EVENT__ is invalid)
1042   */
1043 #define IS_ADC_EVENT_TYPE(__EVENT__) (((__EVENT__) == ADC_IRQ_FLAG_OVRFL) || \
1044                                       ((__EVENT__) == ADC_IRQ_FLAG_OVRDF) || \
1045                                       ((__EVENT__) == ADC_IRQ_FLAG_OVRDS) || \
1046                                       ((__EVENT__) == ADC_IRQ_FLAG_AWD1)  || \
1047                                       ((__EVENT__) == ADC_IRQ_FLAG_EOS)   || \
1048                                       ((__EVENT__) == ADC_IRQ_FLAG_EODF)  || \
1049                                       ((__EVENT__) == ADC_IRQ_FLAG_EODS)    )
1050 #else
1051 /**
1052   * @brief Verify the ADC event setting.
1053   * @param  __EVENT__ ADC event.
1054   * @retval SET (__EVENT__ is valid) or RESET (__EVENT__ is invalid)
1055   */
1056 #define IS_ADC_EVENT_TYPE(__EVENT__) (((__EVENT__) == ADC_IRQ_FLAG_OVRDS) || \
1057                                       ((__EVENT__) == ADC_IRQ_FLAG_AWD1)  || \
1058                                       ((__EVENT__) == ADC_IRQ_FLAG_EOS)   || \
1059                                       ((__EVENT__) == ADC_IRQ_FLAG_EODS)    )
1060 #endif /* ADC_SUPPORT_AUDIO_FEATURES */
1061 
1062 /**
1063   * @brief Verify the ADC watchdog channel setting.
1064   * @param  __CHANNEL__ ADC channel selection monitored by watchdog.
1065   * @retval SET (__CHANNEL__ is valid) or RESET (__CHANNEL__ is invalid)
1066   */
1067 #define IS_ADC_AWD_CHANNEL(__CHANNEL__) \
1068   (((__CHANNEL__) != 0UL)  \
1069    && (((__CHANNEL__) & ~(ADC_AWD_CH_VINM0   | ADC_AWD_CH_VINM1   | ADC_AWD_CH_VINM2    | ADC_AWD_CH_VINM3      | \
1070                           ADC_AWD_CH_VINP0   | ADC_AWD_CH_VINP1   | ADC_AWD_CH_VINP2    | ADC_AWD_CH_VINP3      | \
1071                           ADC_AWD_CH_MICROM  | ADC_AWD_CH_MICROP  | ADC_AWD_CH_VBAT     | ADC_AWD_CH_TEMPSENSOR | \
1072                           ADC_AWD_CH_GND_NEG | ADC_AWD_CH_GND_POS | ADC_AWD_CH_VDDA_NEG | ADC_AWD_CH_VDDA_POS ))  \
1073        == 0UL))
1074 
1075 /**
1076   * @brief Verify the ADC watchdog event setting.
1077   * @param  __EVENT__ ADC watchdog event.
1078   * @retval SET (__EVENT__ is valid) or RESET (__EVENT__ is invalid)
1079   */
1080 #define IS_ADC_AWD_EVENT_TYPE(__EVENT__) (((__EVENT__) == ADC_AWD_EVENT_POLLING) || \
1081                                           ((__EVENT__) == ADC_AWD_EVENT_INTERRUPT) )
1082 
1083 #if defined(ADC_SUPPORT_AUDIO_FEATURES)
1084 /**
1085   * @brief Verify the ADC Decimation filter dynamic range setting.
1086   * @param  __RANGE__ Decimation filter selected dynamic range.
1087   * @retval SET (__RANGE__ is valid) or RESET (__RANGE__ is invalid)
1088   */
1089 #define IS_ADC_DF_DYNAMIC_RANGE(__RANGE__) (((__RANGE__) == ADC_DF_DYN_RANGE_FULL) || \
1090                                             ((__RANGE__) == ADC_DF_DYN_RANGE_HALF) )
1091 
1092 /**
1093   * @brief Verify the ADC Decimation filter data format setting.
1094   * @param  __SIGN__ Selected data sign.
1095   * @retval SET (__SIGN__ is valid) or RESET (__SIGN__ is invalid)
1096   */
1097 #define IS_ADC_DF_DATA_FORMAT(__SIGN__) (((__SIGN__) == ADC_DF_DATA_FORMAT_SIGNED) || \
1098                                          ((__SIGN__) == ADC_DF_DATA_FORMAT_UNSIGNED) )
1099 
1100 /**
1101   * @brief Verify the ADC Decimation filter CIC Filter factor format setting.
1102   * @param  __FACTOR__ Selected Decimation filter CIC Filter factor format.
1103   * @retval SET (__FACTOR__ is valid) or RESET (__FACTOR__ is invalid)
1104   */
1105 #define IS_ADC_DF_CIC_DECIMATOR_HALF_FACTOR(__FACTOR__) (((__FACTOR__) == ADC_DF_CIC_DECIMATOR_FACTOR_HALF) || \
1106                                                          ((__FACTOR__) == ADC_DF_CIC_DECIMATOR_FACTOR_INTEGER) )
1107 
1108 /**
1109   * @brief Verify the ADC Decimation filter CIC Filter factor setting.
1110   * @param  __FACTOR__ Selected CIC Filter factor.
1111   * @retval SET (__FACTOR__ is valid) or RESET (__FACTOR__ is invalid)
1112   */
1113 #define IS_ADC_DF_CIC_DECIMATOR_FACTOR(__FACTOR__) ((__FACTOR__) <= 0x3FUL)
1114 
1115 /**
1116   * @brief Verify the ADC Decimation filter microphone channel setting.
1117   * @param  __CHANNEL__ ADC microphone channel.
1118   * @retval SET (__CHANNEL__ is valid) or RESET (__CHANNEL__ is invalid)
1119   */
1120 #define IS_ADC_DF_MICROPHONE_CHANNEL(__CHANNEL__) (((__CHANNEL__) == ADC_DF_MIC_CH_LEFT) || \
1121                                                    ((__CHANNEL__) == ADC_DF_MIC_CH_RIGHT)  )
1122 
1123 /**
1124   * @brief Verify the ADC PDM clock divider setting.
1125   * @param  __CLOCK_DIV__  ADC PDM clock divider.
1126   * @retval SET (__CLOCK_DIV__ is valid) or RESET (__CLOCK_DIV__ is invalid)
1127   */
1128 #define IS_ADC_PDM_CLOCK_DIVIDER(__CLOCK_DIV__) (((__CLOCK_DIV__) == ADC_PDM_DIV_10) || \
1129                                                  ((__CLOCK_DIV__) == ADC_PDM_DIV_11) || \
1130                                                  ((__CLOCK_DIV__) == ADC_PDM_DIV_12) || \
1131                                                  ((__CLOCK_DIV__) == ADC_PDM_DIV_13) || \
1132                                                  ((__CLOCK_DIV__) == ADC_PDM_DIV_14) || \
1133                                                  ((__CLOCK_DIV__) == ADC_PDM_DIV_15) || \
1134                                                  ((__CLOCK_DIV__) == ADC_PDM_DIV_16) || \
1135                                                  ((__CLOCK_DIV__) == ADC_PDM_DIV_17) || \
1136                                                  ((__CLOCK_DIV__) == ADC_PDM_DIV_18) || \
1137                                                  ((__CLOCK_DIV__) == ADC_PDM_DIV_19) || \
1138                                                  ((__CLOCK_DIV__) == ADC_PDM_DIV_20) || \
1139                                                  ((__CLOCK_DIV__) == ADC_PDM_DIV_21) || \
1140                                                  ((__CLOCK_DIV__) == ADC_PDM_DIV_22) || \
1141                                                  ((__CLOCK_DIV__) == ADC_PDM_DIV_23) || \
1142                                                  ((__CLOCK_DIV__) == ADC_PDM_DIV_24) || \
1143                                                  ((__CLOCK_DIV__) == ADC_PDM_DIV_25)   )
1144 
1145 /**
1146   * @brief Verify the ADC Programmable Gain Amplifier voltage bias setting.
1147   * @param  __BIAS__  ADC PGA voltage bias.
1148   * @retval SET (__BIAS__ is valid) or RESET (__BIAS__ is invalid)
1149   */
1150 #define IS_ADC_PGA_BIAS(__BIAS__) (((__BIAS__) == ADC_PGA_BIAS_050_BAT) || \
1151                                    ((__BIAS__) == ADC_PGA_BIAS_055_BAT) || \
1152                                    ((__BIAS__) == ADC_PGA_BIAS_060_BAT) || \
1153                                    ((__BIAS__) == ADC_PGA_BIAS_065_BAT) || \
1154                                    ((__BIAS__) == ADC_PGA_BIAS_070_BAT) || \
1155                                    ((__BIAS__) == ADC_PGA_BIAS_075_BAT) || \
1156                                    ((__BIAS__) == ADC_PGA_BIAS_080_BAT) || \
1157                                    ((__BIAS__) == ADC_PGA_BIAS_090_BAT)   )
1158 
1159 /**
1160   * @brief Verify the ADC Programmable Gain Amplifier gain setting.
1161   * @param  __GAIN__  ADC PGA gain.
1162   * @retval SET (__GAIN__ is valid) or RESET (__GAIN__ is invalid)
1163   */
1164 #define IS_ADC_PGA_GAIN(__GAIN__) (((__GAIN__) == ADC_PGA_GAIN_06_DB) || \
1165                                    ((__GAIN__) == ADC_PGA_GAIN_09_DB) || \
1166                                    ((__GAIN__) == ADC_PGA_GAIN_12_DB) || \
1167                                    ((__GAIN__) == ADC_PGA_GAIN_15_DB) || \
1168                                    ((__GAIN__) == ADC_PGA_GAIN_18_DB) || \
1169                                    ((__GAIN__) == ADC_PGA_GAIN_21_DB) || \
1170                                    ((__GAIN__) == ADC_PGA_GAIN_24_DB) || \
1171                                    ((__GAIN__) == ADC_PGA_GAIN_27_DB) || \
1172                                    ((__GAIN__) == ADC_PGA_GAIN_30_DB)   )
1173 
1174 /**
1175   * @brief Verify the ADC Occasional mode source channel setting.
1176   * @param  __CHANNEL__  selected ADC Occasional mode source channel.
1177   * @retval SET (__CHANNEL__ is valid) or RESET (__CHANNEL__ is invalid)
1178   */
1179 #define IS_ADC_OCM_SOURCE(__CHANNEL__) (((__CHANNEL__) == ADC_OCM_SRC_VBAT) || \
1180                                         ((__CHANNEL__) == ADC_OCM_SRC_TEMP)   )
1181 
1182 /**
1183   * @brief Verify the Programmable Gain Amplifier voltage bias precharge delay.
1184   * @param  __DELAY__  ADC PGA voltage bias precharge delay (microseconds).
1185   * @retval SET (__DELAY__ is valid) or RESET (__DELAY__ is invalid)
1186   */
1187 #define IS_ADC_PGA_VBIAS_PRECHARGE_DELAY(__DELAY__) ((__DELAY__) <= 1044480UL)
1188 #endif /* ADC_SUPPORT_AUDIO_FEATURES */
1189 
1190 /**
1191   * @brief Verify the LDO stabilization delay.
1192   * @param  __DELAY__  LDO stabilization delay (microseconds).
1193   * @retval SET (__DELAY__ is valid) or RESET (__DELAY__ is invalid)
1194   */
1195 #define IS_ADC_LDO_DELAY(__DELAY__) ((__DELAY__) <= 1020UL)
1196 
1197 /**
1198   * @}
1199   */
1200 
1201 
1202 /* Private constants ---------------------------------------------------------*/
1203 
1204 /** @defgroup ADC_Private_Constants ADC Private Constants
1205   * @{
1206   */
1207 
1208 
1209 /**
1210   * @}
1211   */
1212 
1213 /* Exported macro ------------------------------------------------------------*/
1214 
1215 /** @defgroup ADC_Exported_Macros ADC Exported Macros
1216   * @{
1217   */
1218 
1219 /** @defgroup ADC_HAL_EM_HANDLE_IT_FLAG HAL ADC macro to manage HAL ADC handle,
1220   *           IT and flags.
1221   * @{
1222   */
1223 
1224 /** @brief  Reset ADC handle state.
1225   * @param __HANDLE__ ADC handle
1226   * @retval None
1227   */
1228 #if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
1229 #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__)     \
1230   do                                                 \
1231   {                                                  \
1232     (__HANDLE__)->State = HAL_ADC_STATE_RESET;       \
1233     (__HANDLE__)->MspInitCallback = NULL;            \
1234     (__HANDLE__)->MspDeInitCallback = NULL;          \
1235   } while(0)
1236 #else
1237 #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__)     \
1238   ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
1239 #endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
1240 
1241 
1242 /**
1243   * @brief Enable ADC interrupt.
1244   * @param __HANDLE__ ADC handle
1245   * @param __INTERRUPT__ ADC Interrupt
1246   *        This parameter can be a combination of the following values:
1247   *            @arg @ref ADC_IRQ_EN_OVRFL  ADC Decimation Filter saturated interrupt source
1248   *            @arg @ref ADC_IRQ_EN_OVRDF  ADC Decimation Filter overrung interrupt source
1249   *            @arg @ref ADC_IRQ_EN_OVRDS  ADC Down Sampler overrun interrupt source
1250   *            @arg @ref ADC_IRQ_EN_AWD1   ADC Watchdog alert interrupt source
1251   *            @arg @ref ADC_IRQ_EN_EOC    ADC End of conversion interrupt source
1252   *            @arg @ref ADC_IRQ_EN_EOS    ADC End of conversion of a sequence interrupt source
1253   *            @arg @ref ADC_IRQ_EN_EODF   ADC End of conversion from Decimation Filter interrupt source
1254   *            @arg @ref ADC_IRQ_EN_EODS   ADC End of conversion from Down Sampler interrupt source
1255   * @retval None
1256   */
1257 #define __HAL_ADC_ENABLE_IT(__HANDLE__, __INTERRUPT__)     LL_ADC_EnableIT((__HANDLE__)->Instance, __INTERRUPT__)
1258 
1259 
1260 /**
1261   * @brief Disable ADC interrupt.
1262   * @param __HANDLE__ ADC handle
1263   * @param __INTERRUPT__ ADC Interrupt
1264   *        This parameter can be a combination of the following values:
1265   *            @arg @ref ADC_IRQ_EN_OVRFL  ADC Decimation Filter saturated interrupt source
1266   *            @arg @ref ADC_IRQ_EN_OVRDF  ADC Decimation Filter overrung interrupt source
1267   *            @arg @ref ADC_IRQ_EN_OVRDS  ADC Down Sampler overrun interrupt source
1268   *            @arg @ref ADC_IRQ_EN_AWD1   ADC Watchdog alert interrupt source
1269   *            @arg @ref ADC_IRQ_EN_EOC    ADC End of conversion interrupt source
1270   *            @arg @ref ADC_IRQ_EN_EOS    ADC End of conversion of a sequence interrupt source
1271   *            @arg @ref ADC_IRQ_EN_EODF   ADC End of conversion from Decimation Filter interrupt source
1272   *            @arg @ref ADC_IRQ_EN_EODS   ADC End of conversion from Down Sampler interrupt source
1273   * @retval None
1274   */
1275 #define __HAL_ADC_DISABLE_IT(__HANDLE__, __INTERRUPT__)    LL_ADC_DisableIT((__HANDLE__)->Instance, __INTERRUPT__)
1276 
1277 
1278 /** @brief  Checks if the specified ADC interrupt source is enabled or disabled.
1279   * @param __HANDLE__ ADC handle
1280   * @param __INTERRUPT__ ADC interrupt source to check
1281   *          This parameter can be one of the following values:
1282   *            @arg @ref ADC_IRQ_EN_OVRFL  ADC Decimation Filter saturated interrupt source
1283   *            @arg @ref ADC_IRQ_EN_OVRDF  ADC Decimation Filter overrung interrupt source
1284   *            @arg @ref ADC_IRQ_EN_OVRDS  ADC Down Sampler overrun interrupt source
1285   *            @arg @ref ADC_IRQ_EN_AWD1   ADC Watchdog alert interrupt source
1286   *            @arg @ref ADC_IRQ_EN_EOC    ADC End of conversion interrupt source
1287   *            @arg @ref ADC_IRQ_EN_EOS    ADC End of conversion of a sequence interrupt source
1288   *            @arg @ref ADC_IRQ_EN_EODF   ADC End of conversion from Decimation Filter interrupt source
1289   *            @arg @ref ADC_IRQ_EN_EODS   ADC End of conversion from Down Sampler interrupt source
1290   * @retval State of interruption (SET or RESET)
1291   */
1292 #define __HAL_ADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)    LL_ADC_IsEnabledIT((__HANDLE__)->Instance, __INTERRUPT__)
1293 
1294 
1295 /**
1296   * @brief Check whether the specified ADC flag is set or not.
1297   * @param __HANDLE__ ADC handle
1298   * @param __FLAG__ ADC flag
1299   *        This parameter can be one of the following values:
1300   *            @arg @ref ADC_IRQ_FLAG_OVRFL  ADC Decimation Filter saturated interrupt source
1301   *            @arg @ref ADC_IRQ_FLAG_OVRDF  ADC Decimation Filter overrung interrupt source
1302   *            @arg @ref ADC_IRQ_FLAG_OVRDS  ADC Down Sampler overrun interrupt source
1303   *            @arg @ref ADC_IRQ_FLAG_AWD1   ADC Watchdog alert interrupt source
1304   *            @arg @ref ADC_IRQ_FLAG_EOC    ADC End of conversion interrupt source
1305   *            @arg @ref ADC_IRQ_FLAG_EOS    ADC End of conversion of a sequence interrupt source
1306   *            @arg @ref ADC_IRQ_FLAG_EODF   ADC End of conversion from Decimation Filter interrupt source
1307   *            @arg @ref ADC_IRQ_FLAG_EODS   ADC End of conversion from Down Sampler interrupt source
1308   * @retval State of flag (TRUE or FALSE).
1309   */
1310 #define __HAL_ADC_GET_FLAG(__HANDLE__, __FLAG__)    LL_ADC_IsActiveFlag((__HANDLE__)->Instance, __FLAG__)
1311 
1312 
1313 /**
1314   * @brief Clear the specified ADC flag.
1315   * @param __HANDLE__ ADC handle
1316   * @param __FLAG__ ADC flag
1317   *        This parameter can be a combination of the following values:
1318   *            @arg @ref ADC_IRQ_FLAG_OVRFL  ADC Decimation Filter saturated interrupt source
1319   *            @arg @ref ADC_IRQ_FLAG_OVRDF  ADC Decimation Filter overrung interrupt source
1320   *            @arg @ref ADC_IRQ_FLAG_OVRDS  ADC Down Sampler overrun interrupt source
1321   *            @arg @ref ADC_IRQ_FLAG_AWD1   ADC Watchdog alert interrupt source
1322   *            @arg @ref ADC_IRQ_FLAG_EOC    ADC End of conversion interrupt source
1323   *            @arg @ref ADC_IRQ_FLAG_EOS    ADC End of conversion of a sequence interrupt source
1324   *            @arg @ref ADC_IRQ_FLAG_EODF   ADC End of conversion from Decimation Filter interrupt source
1325   *            @arg @ref ADC_IRQ_FLAG_EODS   ADC End of conversion from Down Sampler interrupt source
1326   * @retval None
1327   */
1328 /* Note: bit cleared bit by writing 1 (writing 0 has no effect on any bit of register ISR) */
1329 #define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__)    LL_ADC_ClearActiveFlags((__HANDLE__)->Instance, __FLAG__)
1330 
1331 
1332 /**
1333   * @}
1334   */
1335 
1336 /** @defgroup ADC_HAL_EM_HELPER_MACRO HAL ADC helper macro
1337   * @{
1338   */
1339 
1340 /**
1341   * @brief  Helper macro to determine whether the selected channel
1342   *         corresponds to literal definitions of driver.
1343   * @param  __CHANNEL__ This parameter can be one of the following values:
1344   *         @arg @ref ADC_CHANNEL_VINM0
1345   *         @arg @ref ADC_CHANNEL_VINM1
1346   *         @arg @ref ADC_CHANNEL_VINM2
1347   *         @arg @ref ADC_CHANNEL_VINM3
1348   *         @arg @ref ADC_CHANNEL_VINP0
1349   *         @arg @ref ADC_CHANNEL_VINP1
1350   *         @arg @ref ADC_CHANNEL_VINP2
1351   *         @arg @ref ADC_CHANNEL_VINP3
1352   *         @arg @ref ADC_CHANNEL_VINP0_VINM0
1353   *         @arg @ref ADC_CHANNEL_VINP1_VINM1
1354   *         @arg @ref ADC_CHANNEL_VINP2_VINM2
1355   *         @arg @ref ADC_CHANNEL_VINP3_VINM3
1356   *         @arg @ref ADC_CHANNEL_VBAT
1357   *         @arg @ref ADC_CHANNEL_TEMPSENSOR
1358   * @retval Value "0" if the channel corresponds to a parameter definition of a ADC external channel
1359   *         (channel connected to a GPIO pin).
1360   *         Value "1" if the channel corresponds to a parameter definition of a ADC internal channel.
1361   */
1362 #define __HAL_ADC_IS_CHANNEL_INTERNAL(__CHANNEL__)                             \
1363   __LL_ADC_IS_CHANNEL_INTERNAL((__CHANNEL__))
1364 
1365 /**
1366   * @brief  Helper macro to convert the ADC conversion data from
1367   *         a resolution to another resolution.
1368   * @param  __DATA__ ADC conversion data to be converted
1369   * @param  __ADC_WIDTH_CURRENT__ Resolution of the data to be converted
1370   *         This parameter can be one of the following values:
1371   *         @arg @ref ADC_DS_DATA_WIDTH_12_BIT
1372   *         @arg @ref ADC_DS_DATA_WIDTH_13_BIT
1373   *         @arg @ref ADC_DS_DATA_WIDTH_14_BIT
1374   *         @arg @ref ADC_DS_DATA_WIDTH_15_BIT
1375   *         @arg @ref ADC_DS_DATA_WIDTH_16_BIT
1376   * @param  __ADC_WIDTH_TARGET__ Resolution of the data after conversion
1377   *         This parameter can be one of the following values:
1378   *         @arg @ref ADC_DS_DATA_WIDTH_12_BIT
1379   *         @arg @ref ADC_DS_DATA_WIDTH_13_BIT
1380   *         @arg @ref ADC_DS_DATA_WIDTH_14_BIT
1381   *         @arg @ref ADC_DS_DATA_WIDTH_15_BIT
1382   *         @arg @ref ADC_DS_DATA_WIDTH_16_BIT
1383   * @retval ADC conversion data to the requested resolution
1384   */
1385 #define __HAL_ADC_CONVERT_DATA_RESOLUTION(__DATA__,\
1386                                           __ADC_WIDTH_CURRENT__,\
1387                                           __ADC_WIDTH_TARGET__)\
1388 __LL_ADC_CONVERT_DATA_RESOLUTION((__DATA__),                                   \
1389                                  (__ADC_WIDTH_CURRENT__),                      \
1390                                  (__ADC_WIDTH_TARGET__))
1391 
1392 /**
1393   * @brief  Helper macro to calculate the voltage (unit: mVolt)
1394   *         corresponding to a ADC conversion data (unit: digital value).
1395   * @param  __INPUT_VOLTAGE_RANGE__ Analog reference voltage (unit: mV)
1396   *         @arg @ref ADC_VIN_RANGE_3V6
1397   *         @arg @ref ADC_VIN_RANGE_2V4
1398   *         @arg @ref ADC_VIN_RANGE_1V2
1399   * @param  __ADC_DATA__ ADC conversion data (unit: digital value).
1400   * @param  __ADC_WIDTH__ This parameter can be one of the following values:
1401   *         @arg @ref ADC_DS_DATA_WIDTH_12_BIT
1402   *         @arg @ref ADC_DS_DATA_WIDTH_13_BIT
1403   *         @arg @ref ADC_DS_DATA_WIDTH_14_BIT
1404   *         @arg @ref ADC_DS_DATA_WIDTH_15_BIT
1405   *         @arg @ref ADC_DS_DATA_WIDTH_16_BIT
1406   * @retval ADC conversion data equivalent voltage value (unit: mVolt)
1407   */
1408 #define __HAL_ADC_CALC_DATA_TO_VOLTAGE(__INPUT_VOLTAGE_RANGE__,\
1409                                        __ADC_DATA__,\
1410                                        __ADC_WIDTH__)\
1411 __LL_ADC_CALC_DATA_TO_VOLTAGE((__INPUT_VOLTAGE_RANGE__),                       \
1412                               (__ADC_DATA__),                                  \
1413                               (__ADC_WIDTH__))
1414 
1415 /**
1416   * @brief  Helper macro to calculate the voltage (unit: mVolt)
1417   *         corresponding to a ADC conversion data (unit: digital value)
1418   *         in differential ended mode.
1419   * @param  __INPUT_VOLTAGE_RANGE__ Analog reference voltage (unit: mV)
1420   *         @arg @ref ADC_VIN_RANGE_3V6
1421   *         @arg @ref ADC_VIN_RANGE_2V4
1422   *         @arg @ref ADC_VIN_RANGE_1V2
1423   * @param  __ADC_DATA__ ADC conversion data (unit: digital value).
1424   * @param  __ADC_WIDTH__ This parameter can be one of the following values:
1425   *         @arg @ref ADC_DS_DATA_WIDTH_12_BIT
1426   *         @arg @ref ADC_DS_DATA_WIDTH_13_BIT
1427   *         @arg @ref ADC_DS_DATA_WIDTH_14_BIT
1428   *         @arg @ref ADC_DS_DATA_WIDTH_15_BIT
1429   *         @arg @ref ADC_DS_DATA_WIDTH_16_BIT
1430   * @retval ADC conversion data equivalent voltage value (unit: mVolt)
1431   */
1432 #define __HAL_ADC_CALC_DIFF_DATA_TO_VOLTAGE(__INPUT_VOLTAGE_RANGE__,\
1433                                             __ADC_DATA__,\
1434                                             __ADC_WIDTH__)\
1435 __LL_ADC_CALC_DIFF_DATA_TO_VOLTAGE((__INPUT_VOLTAGE_RANGE__),                  \
1436                                    (__ADC_DATA__),                             \
1437                                    (__ADC_WIDTH__))
1438 
1439 /**
1440   * @brief  Helper macro to calculate the temperature (unit: degree Celsius)
1441   *         from ADC conversion data of internal temperature sensor.
1442   * @note   Computation is using temperature sensor calibration values
1443   *         stored in system memory for each device during production.
1444   *         Caution: Calculation relevancy under reserve that calibration
1445   *                  parameters are correct (address and data).
1446   *                  To calculate temperature using temperature sensor
1447   *                  datasheet typical values (generic values less, therefore
1448   *                  less accurate than calibrated values),
1449   *                  use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().
1450   * @param  __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal
1451   *                                 temperature sensor (unit: digital value).
1452   * @param  __ADC_WIDTH__ This parameter can be one of the following values:
1453   *         @arg @ref ADC_DS_DATA_WIDTH_12_BIT
1454   *         @arg @ref ADC_DS_DATA_WIDTH_13_BIT
1455   *         @arg @ref ADC_DS_DATA_WIDTH_14_BIT
1456   *         @arg @ref ADC_DS_DATA_WIDTH_15_BIT
1457   *         @arg @ref ADC_DS_DATA_WIDTH_16_BIT
1458   * @retval Temperature (unit: degree Celsius)
1459   */
1460 #define __HAL_ADC_CALC_TEMPERATURE(__TEMPSENSOR_ADC_DATA__,\
1461                                    __ADC_WIDTH__)\
1462 __LL_ADC_CALC_TEMPERATURE((__TEMPSENSOR_ADC_DATA__),                           \
1463                           (__ADC_WIDTH__))
1464 
1465 /**
1466   * @brief  Helper macro to calculate the temperature (unit: degree Celsius)
1467   *         from ADC conversion data of internal temperature sensor.
1468   * @note   Computation is using temperature sensor typical values
1469   *         (refer to device datasheet).
1470   * @param  __TEMPSENSOR_ADC_DATA__      ADC conversion data of internal temperature sensor (unit: digital value).
1471   * @param  __ADC_WIDTH__ This parameter can be one of the following values:
1472   *         @arg @ref ADC_DS_DATA_WIDTH_12_BIT
1473   *         @arg @ref ADC_DS_DATA_WIDTH_13_BIT
1474   *         @arg @ref ADC_DS_DATA_WIDTH_14_BIT
1475   *         @arg @ref ADC_DS_DATA_WIDTH_15_BIT
1476   *         @arg @ref ADC_DS_DATA_WIDTH_16_BIT
1477   * @retval Temperature (unit: degree Celsius)
1478   */
1479 #define __HAL_ADC_CALC_TEMPERATURE_TYP_PARAMS(__TEMPSENSOR_ADC_DATA__,\
1480                                               __ADC_WIDTH__)\
1481 __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS((__TEMPSENSOR_ADC_DATA__),                \
1482                                      (__ADC_WIDTH__))
1483 
1484 /**
1485   * @}
1486   */
1487 
1488 /**
1489   * @}
1490   */
1491 
1492 /* Exported functions --------------------------------------------------------*/
1493 /** @addtogroup ADC_Exported_Functions
1494   * @{
1495   */
1496 
1497 /** @addtogroup ADC_Exported_Functions_Group1
1498   * @brief    Initialization and Configuration functions
1499   * @{
1500   */
1501 
1502 /* Initialization and de-initialization functions  ****************************/
1503 HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef *hadc);
1504 HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
1505 void              HAL_ADC_MspInit(ADC_HandleTypeDef *hadc);
1506 void              HAL_ADC_MspDeInit(ADC_HandleTypeDef *hadc);
1507 
1508 #if (USE_HAL_ADC_REGISTER_CALLBACKS == 1)
1509 /* Callbacks Register/UnRegister functions  ***********************************/
1510 HAL_StatusTypeDef HAL_ADC_RegisterCallback(ADC_HandleTypeDef *hadc, HAL_ADC_CallbackIDTypeDef CallbackID,
1511                                            pADC_CallbackTypeDef pCallback);
1512 HAL_StatusTypeDef HAL_ADC_UnRegisterCallback(ADC_HandleTypeDef *hadc, HAL_ADC_CallbackIDTypeDef CallbackID);
1513 #endif /* USE_HAL_ADC_REGISTER_CALLBACKS */
1514 
1515 /**
1516   * @}
1517   */
1518 
1519 /** @addtogroup ADC_Exported_Functions_Group2
1520   * @brief    IO operation functions
1521   * @{
1522   */
1523 
1524 /* IO operation functions  *****************************************************/
1525 
1526 /* Blocking mode: Polling */
1527 HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef *hadc);
1528 HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef *hadc);
1529 HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef *hadc, uint32_t Timeout);
1530 HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef *hadc, uint32_t EventType, uint32_t Timeout);
1531 
1532 /* Non-blocking mode: Interruption */
1533 HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef *hadc);
1534 HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef *hadc);
1535 
1536 /* Non-blocking mode: DMA */
1537 HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef *hadc, const uint32_t *pData, uint32_t Length);
1538 HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef *hadc);
1539 
1540 /* ADC retrieve conversion value intended to be used with polling or interruption */
1541 uint32_t HAL_ADC_GetValue(const ADC_HandleTypeDef *hadc);
1542 uint32_t HAL_ADC_GetValue_DF(const ADC_HandleTypeDef *hadc);
1543 
1544 /* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption and DMA) */
1545 void HAL_ADC_IRQHandler(ADC_HandleTypeDef *hadc);
1546 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef *hadc);
1547 void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef *hadc);
1548 void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef *hadc);
1549 void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
1550 
1551 /**
1552   * @}
1553   */
1554 
1555 /** @addtogroup ADC_Exported_Functions_Group3 Peripheral Control functions
1556   * @{
1557   */
1558 
1559 /* Peripheral Control functions ***********************************************/
1560 HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef *hadc, const ADC_ChannelConfTypeDef *ConfigChannel);
1561 HAL_StatusTypeDef HAL_ADC_DFConfig(ADC_HandleTypeDef *hadc, const ADC_DFConfTypeDef *ConfigDF);
1562 HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef *hadc, const ADC_AnalogWDGConfTypeDef *ConfigWatchdog);
1563 
1564 /**
1565   * @}
1566   */
1567 
1568 /** @addtogroup ADC_Exported_Functions_Group4 Microphone Interface Control functions
1569   * @{
1570   */
1571 HAL_StatusTypeDef HAL_ADC_SetMicrophoneChannel(ADC_HandleTypeDef *hadc, uint32_t MicrophoneChannel);
1572 
1573 HAL_StatusTypeDef HAL_ADC_PDMConfig(ADC_HandleTypeDef *hadc, const ADC_PDMConfTypeDef *ConfigPDM);
1574 HAL_StatusTypeDef HAL_ADC_PDMStart(ADC_HandleTypeDef *hadc);
1575 HAL_StatusTypeDef HAL_ADC_PDMStop(ADC_HandleTypeDef *hadc);
1576 
1577 HAL_StatusTypeDef HAL_ADC_PGAConfig(ADC_HandleTypeDef *hadc, const ADC_PGAConfTypeDef *ConfigPGA);
1578 /**
1579   * @}
1580   */
1581 
1582 /** @addtogroup ADC_Exported_Functions_Group5 Occasional Mode Control functions
1583   * @{
1584   */
1585 HAL_StatusTypeDef HAL_ADC_SetOccasionalSource(ADC_HandleTypeDef *hadc, uint32_t Source);
1586 
1587 HAL_StatusTypeDef HAL_ADC_StartOccasionalMode(ADC_HandleTypeDef *hadc);
1588 /**
1589   * @}
1590   */
1591 
1592 /**
1593   * @addtogroup ADC_Exported_Functions_Group6 Analog Timing Control functions
1594   * @{
1595   */
1596 HAL_StatusTypeDef HAL_ADC_SMPSSyncEnable(ADC_HandleTypeDef *hadc);
1597 HAL_StatusTypeDef HAL_ADC_SMPSSyncDisable(ADC_HandleTypeDef *hadc);
1598 
1599 HAL_StatusTypeDef HAL_ADC_VBiasPrechargeDelayConfig(ADC_HandleTypeDef *hadc, uint32_t Delay_us);
1600 HAL_StatusTypeDef HAL_ADC_LDODelayConfig(ADC_HandleTypeDef *hadc, uint32_t Delay_us);
1601 /**
1602   * @}
1603   */
1604 
1605 /* Peripheral State functions *************************************************/
1606 /** @addtogroup ADC_Exported_Functions_Group7
1607   * @{
1608   */
1609 
1610 uint32_t HAL_ADC_GetState(const ADC_HandleTypeDef *hadc);
1611 uint32_t HAL_ADC_GetError(const ADC_HandleTypeDef *hadc);
1612 
1613 /**
1614   * @}
1615   */
1616 
1617 /**
1618   * @}
1619   */
1620 
1621 /* Private functions ---------------------------------------------------------*/
1622 /** @addtogroup ADC_Private_Functions ADC Private Functions
1623   * @{
1624   */
1625 
1626 /**
1627   * @}
1628   */
1629 
1630 /**
1631   * @}
1632   */
1633 
1634 /**
1635   * @}
1636   */
1637 
1638 #ifdef __cplusplus
1639 }
1640 #endif
1641 
1642 
1643 #endif /* STM32WB0x_HAL_ADC_H */
1644