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