1 /**
2   ******************************************************************************
3   * @file    stm32g0xx_hal_adc_ex.h
4   * @author  MCD Application Team
5   * @brief   Header file of ADC HAL extended module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2018 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 STM32G0xx_HAL_ADC_EX_H
21 #define STM32G0xx_HAL_ADC_EX_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32g0xx_hal_def.h"
29 
30 /** @addtogroup STM32G0xx_HAL_Driver
31   * @{
32   */
33 
34 /** @addtogroup ADCEx
35   * @{
36   */
37 
38 /* Exported types ------------------------------------------------------------*/
39 /** @defgroup ADCEx_Exported_Types ADC Extended Exported Types
40   * @{
41   */
42 
43 /**
44   * @}
45   */
46 
47 /* Exported constants --------------------------------------------------------*/
48 
49 /** @defgroup ADCEx_Exported_Constants ADC Extended Exported Constants
50   * @{
51   */
52 
53 /** @defgroup ADC_HAL_EC_GROUPS  ADC instance - Groups
54   * @{
55   */
56 #define ADC_REGULAR_GROUP                  (LL_ADC_GROUP_REGULAR)          /*!< ADC group regular (available on
57                                                                                 all STM32 devices) */
58 /**
59   * @}
60   */
61 
62 /**
63   * @}
64   */
65 
66 /* Exported macros -----------------------------------------------------------*/
67 
68 /* Private macros ------------------------------------------------------------*/
69 
70 /** @defgroup ADCEx_Private_Macro_internal_HAL_driver ADC Extended Private Macros
71   * @{
72   */
73 /* Macro reserved for internal HAL driver usage, not intended to be used in   */
74 /* code of final user.                                                        */
75 
76 /**
77   * @brief Check whether or not ADC is independent.
78   * @param __HANDLE__ ADC handle.
79   * @note  When multimode feature is not available, the macro always returns SET.
80   * @retval SET (ADC is independent) or RESET (ADC is not).
81   */
82 #define ADC_IS_INDEPENDENT(__HANDLE__)   (SET)
83 
84 
85 /**
86   * @brief Calibration factor size verification (7 bits maximum).
87   * @param __CALIBRATION_FACTOR__ Calibration factor value.
88   * @retval SET (__CALIBRATION_FACTOR__ is within the authorized size) or RESET (__CALIBRATION_FACTOR__ is too large)
89   */
90 #define IS_ADC_CALFACT(__CALIBRATION_FACTOR__) ((__CALIBRATION_FACTOR__) <= (0x7FU))
91 
92 /**
93   * @brief Verify the ADC oversampling ratio.
94   * @param __RATIO__ programmed ADC oversampling ratio.
95   * @retval SET (__RATIO__ is a valid value) or RESET (__RATIO__ is invalid)
96   */
97 #define IS_ADC_OVERSAMPLING_RATIO(__RATIO__)      (((__RATIO__) == ADC_OVERSAMPLING_RATIO_2   ) || \
98                                                    ((__RATIO__) == ADC_OVERSAMPLING_RATIO_4   ) || \
99                                                    ((__RATIO__) == ADC_OVERSAMPLING_RATIO_8   ) || \
100                                                    ((__RATIO__) == ADC_OVERSAMPLING_RATIO_16  ) || \
101                                                    ((__RATIO__) == ADC_OVERSAMPLING_RATIO_32  ) || \
102                                                    ((__RATIO__) == ADC_OVERSAMPLING_RATIO_64  ) || \
103                                                    ((__RATIO__) == ADC_OVERSAMPLING_RATIO_128 ) || \
104                                                    ((__RATIO__) == ADC_OVERSAMPLING_RATIO_256 ))
105 
106 /**
107   * @brief Verify the ADC oversampling shift.
108   * @param __SHIFT__ programmed ADC oversampling shift.
109   * @retval SET (__SHIFT__ is a valid value) or RESET (__SHIFT__ is invalid)
110   */
111 #define IS_ADC_RIGHT_BIT_SHIFT(__SHIFT__)        (((__SHIFT__) == ADC_RIGHTBITSHIFT_NONE) || \
112                                                   ((__SHIFT__) == ADC_RIGHTBITSHIFT_1   ) || \
113                                                   ((__SHIFT__) == ADC_RIGHTBITSHIFT_2   ) || \
114                                                   ((__SHIFT__) == ADC_RIGHTBITSHIFT_3   ) || \
115                                                   ((__SHIFT__) == ADC_RIGHTBITSHIFT_4   ) || \
116                                                   ((__SHIFT__) == ADC_RIGHTBITSHIFT_5   ) || \
117                                                   ((__SHIFT__) == ADC_RIGHTBITSHIFT_6   ) || \
118                                                   ((__SHIFT__) == ADC_RIGHTBITSHIFT_7   ) || \
119                                                   ((__SHIFT__) == ADC_RIGHTBITSHIFT_8   ))
120 
121 /**
122   * @brief Verify the ADC oversampling triggered mode.
123   * @param __MODE__ programmed ADC oversampling triggered mode.
124   * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
125   */
126 #define IS_ADC_TRIGGERED_OVERSAMPLING_MODE(__MODE__) (((__MODE__) == ADC_TRIGGEREDMODE_SINGLE_TRIGGER) || \
127                                                       ((__MODE__) == ADC_TRIGGEREDMODE_MULTI_TRIGGER) )
128 
129 
130 /**
131   * @}
132   */
133 
134 
135 /* Exported functions --------------------------------------------------------*/
136 /** @addtogroup ADCEx_Exported_Functions
137   * @{
138   */
139 
140 /** @addtogroup ADCEx_Exported_Functions_Group1
141   * @{
142   */
143 /* IO operation functions *****************************************************/
144 
145 /* ADC calibration */
146 HAL_StatusTypeDef       HAL_ADCEx_Calibration_Start(ADC_HandleTypeDef *hadc);
147 uint32_t                HAL_ADCEx_Calibration_GetValue(ADC_HandleTypeDef *hadc);
148 HAL_StatusTypeDef       HAL_ADCEx_Calibration_SetValue(ADC_HandleTypeDef *hadc, uint32_t CalibrationFactor);
149 
150 /* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption) */
151 void                    HAL_ADCEx_LevelOutOfWindow2Callback(ADC_HandleTypeDef *hadc);
152 void                    HAL_ADCEx_LevelOutOfWindow3Callback(ADC_HandleTypeDef *hadc);
153 void                    HAL_ADCEx_EndOfSamplingCallback(ADC_HandleTypeDef *hadc);
154 void                    HAL_ADCEx_ChannelConfigReadyCallback(ADC_HandleTypeDef *hadc);
155 
156 /**
157   * @}
158   */
159 
160 /** @addtogroup ADCEx_Exported_Functions_Group2
161   * @{
162   */
163 /* Peripheral Control functions ***********************************************/
164 HAL_StatusTypeDef       HAL_ADCEx_DisableVoltageRegulator(ADC_HandleTypeDef *hadc);
165 
166 /**
167   * @}
168   */
169 
170 /**
171   * @}
172   */
173 
174 /**
175   * @}
176   */
177 
178 /**
179   * @}
180   */
181 
182 #ifdef __cplusplus
183 }
184 #endif
185 
186 #endif /* STM32G0xx_HAL_ADC_EX_H */
187