1 /** 2 ****************************************************************************** 3 * @file stm32l0xx_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) 2016 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 __STM32L0xx_HAL_ADC_EX_H 21 #define __STM32L0xx_HAL_ADC_EX_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32l0xx_hal_def.h" 29 30 /** @addtogroup STM32L0xx_HAL_Driver 31 * @{ 32 */ 33 34 /** @addtogroup ADCEx 35 * @{ 36 */ 37 38 /* Exported types ------------------------------------------------------------*/ 39 /* Exported constants --------------------------------------------------------*/ 40 41 /** @defgroup ADCEx_Exported_Constants ADC Extended Exported Constants 42 * @{ 43 */ 44 45 /** @defgroup ADCEx_Channel_Mode ADC Single Ended 46 * @{ 47 */ 48 #define ADC_SINGLE_ENDED 0x00000000U /* dummy value */ 49 /** 50 * @} 51 */ 52 53 /** @defgroup ADC_regular_external_trigger_source ADC External Trigger Source 54 * @{ 55 */ 56 #define ADC_EXTERNALTRIGCONV_T6_TRGO (0x00000000U) 57 #define ADC_EXTERNALTRIGCONV_T21_CC2 (ADC_CFGR1_EXTSEL_0) 58 #define ADC_EXTERNALTRIGCONV_T2_TRGO (ADC_CFGR1_EXTSEL_1) 59 #define ADC_EXTERNALTRIGCONV_T2_CC4 (ADC_CFGR1_EXTSEL_1 | ADC_CFGR1_EXTSEL_0) 60 #define ADC_EXTERNALTRIGCONV_T22_TRGO (ADC_CFGR1_EXTSEL_2) 61 #define ADC_EXTERNALTRIGCONV_T3_TRGO (ADC_CFGR1_EXTSEL_2 | ADC_CFGR1_EXTSEL_1) 62 #define ADC_EXTERNALTRIGCONV_EXT_IT11 (ADC_CFGR1_EXTSEL_2 | ADC_CFGR1_EXTSEL_1 | ADC_CFGR1_EXTSEL_0) 63 #define ADC_SOFTWARE_START (ADC_CFGR1_EXTSEL + 1U) 64 65 /* ADC group regular external trigger TIM21_TRGO available only on */ 66 /* STM32L0 devices categories: Cat.2, Cat.3, Cat.5 */ 67 #if defined (STM32L031xx) || defined (STM32L041xx) || \ 68 defined (STM32L051xx) || defined (STM32L052xx) || defined (STM32L053xx) || \ 69 defined (STM32L062xx) || defined (STM32L063xx) || \ 70 defined (STM32L071xx) || defined (STM32L072xx) || defined (STM32L073xx) || \ 71 defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx) || \ 72 defined (STM32L010x6) || defined (STM32L010x8) || defined (STM32L010xB) 73 #define ADC_EXTERNALTRIGCONV_T21_TRGO (ADC_EXTERNALTRIGCONV_T22_TRGO) 74 #endif 75 76 /* ADC group regular external trigger TIM2_CC3 available only on */ 77 /* STM32L0 devices categories: Cat.1, Cat.2, Cat.5 */ 78 #if defined (STM32L011xx) || defined (STM32L021xx) || \ 79 defined (STM32L031xx) || defined (STM32L041xx) || \ 80 defined (STM32L071xx) || defined (STM32L072xx) || defined (STM32L073xx) || \ 81 defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx) || \ 82 defined (STM32L010x4) || defined (STM32L010x6) || defined (STM32L010x8) || defined (STM32L010xB) 83 #define ADC_EXTERNALTRIGCONV_T2_CC3 (ADC_CFGR1_EXTSEL_2 | ADC_CFGR1_EXTSEL_0) 84 #endif 85 86 /** 87 * @} 88 */ 89 90 /** @defgroup ADC_SYSCFG_internal_paths_flags_definition ADC SYSCFG internal paths Flags Definition 91 * @{ 92 */ 93 #define ADC_FLAG_SENSOR SYSCFG_CFGR3_VREFINT_RDYF 94 #define ADC_FLAG_VREFINT SYSCFG_VREFINT_ADC_RDYF 95 /** 96 * @} 97 */ 98 99 /** 100 * @} 101 */ 102 103 /* Private macros ------------------------------------------------------------*/ 104 105 /** @defgroup ADCEx_Private_Macros ADCEx Private Macros 106 * @{ 107 */ 108 109 #define IS_ADC_SINGLE_DIFFERENTIAL(SING_DIFF) ((SING_DIFF) == ADC_SINGLE_ENDED) 110 111 /** @defgroup ADCEx_calibration_factor_length_verification ADC Calibration Factor Length Verification 112 * @{ 113 */ 114 /** 115 * @brief Calibration factor length verification (7 bits maximum) 116 * @param _Calibration_Factor_: Calibration factor value 117 * @retval None 118 */ 119 #define IS_ADC_CALFACT(_Calibration_Factor_) ((_Calibration_Factor_) <= (0x7FU)) 120 /** 121 * @} 122 */ 123 124 /** @defgroup ADC_External_trigger_Source ADC External Trigger Source 125 * @{ 126 */ 127 #if defined (STM32L031xx) || defined (STM32L041xx) || \ 128 defined (STM32L071xx) || defined (STM32L072xx) || defined (STM32L073xx) || \ 129 defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx) || \ 130 defined (STM32L010x6) || defined (STM32L010x8) || defined (STM32L010xB) 131 #define IS_ADC_EXTTRIG(CONV) (((CONV) == ADC_EXTERNALTRIGCONV_T6_TRGO ) || \ 132 ((CONV) == ADC_EXTERNALTRIGCONV_T21_CC2 ) || \ 133 ((CONV) == ADC_EXTERNALTRIGCONV_T2_TRGO ) || \ 134 ((CONV) == ADC_EXTERNALTRIGCONV_T2_CC4 ) || \ 135 ((CONV) == ADC_EXTERNALTRIGCONV_T22_TRGO ) || \ 136 ((CONV) == ADC_EXTERNALTRIGCONV_T21_TRGO ) || \ 137 ((CONV) == ADC_EXTERNALTRIGCONV_T2_CC3 ) || \ 138 ((CONV) == ADC_EXTERNALTRIGCONV_T3_TRGO ) || \ 139 ((CONV) == ADC_EXTERNALTRIGCONV_EXT_IT11 ) || \ 140 ((CONV) == ADC_SOFTWARE_START)) 141 #elif defined (STM32L010x4) || defined (STM32L011xx) || defined (STM32L021xx) 142 #define IS_ADC_EXTTRIG(CONV) (((CONV) == ADC_EXTERNALTRIGCONV_T6_TRGO ) || \ 143 ((CONV) == ADC_EXTERNALTRIGCONV_T21_CC2 ) || \ 144 ((CONV) == ADC_EXTERNALTRIGCONV_T2_TRGO ) || \ 145 ((CONV) == ADC_EXTERNALTRIGCONV_T2_CC4 ) || \ 146 ((CONV) == ADC_EXTERNALTRIGCONV_T22_TRGO ) || \ 147 ((CONV) == ADC_EXTERNALTRIGCONV_T2_CC3 ) || \ 148 ((CONV) == ADC_EXTERNALTRIGCONV_T3_TRGO ) || \ 149 ((CONV) == ADC_EXTERNALTRIGCONV_EXT_IT11 ) || \ 150 ((CONV) == ADC_SOFTWARE_START)) 151 #elif defined (STM32L051xx) || defined (STM32L052xx) || defined (STM32L053xx) || \ 152 defined (STM32L062xx) || defined (STM32L063xx) 153 #define IS_ADC_EXTTRIG(CONV) (((CONV) == ADC_EXTERNALTRIGCONV_T6_TRGO ) || \ 154 ((CONV) == ADC_EXTERNALTRIGCONV_T21_CC2 ) || \ 155 ((CONV) == ADC_EXTERNALTRIGCONV_T2_TRGO ) || \ 156 ((CONV) == ADC_EXTERNALTRIGCONV_T2_CC4 ) || \ 157 ((CONV) == ADC_EXTERNALTRIGCONV_T22_TRGO ) || \ 158 ((CONV) == ADC_EXTERNALTRIGCONV_T21_TRGO ) || \ 159 ((CONV) == ADC_EXTERNALTRIGCONV_T3_TRGO ) || \ 160 ((CONV) == ADC_EXTERNALTRIGCONV_EXT_IT11 ) || \ 161 ((CONV) == ADC_SOFTWARE_START)) 162 #endif 163 /** 164 * @} 165 */ 166 167 /** 168 * @} 169 */ 170 171 /* Exported functions --------------------------------------------------------*/ 172 /** @addtogroup ADCEx_Exported_Functions 173 * @{ 174 */ 175 176 /** @addtogroup ADCEx_Exported_Functions_Group1 177 * @{ 178 */ 179 /* IO operation functions *****************************************************/ 180 181 /* ADC calibration */ 182 HAL_StatusTypeDef HAL_ADCEx_Calibration_Start(ADC_HandleTypeDef *hadc, uint32_t SingleDiff); 183 uint32_t HAL_ADCEx_Calibration_GetValue(ADC_HandleTypeDef *hadc, uint32_t SingleDiff); 184 HAL_StatusTypeDef HAL_ADCEx_Calibration_SetValue(ADC_HandleTypeDef *hadc, uint32_t SingleDiff, uint32_t CalibrationFactor); 185 186 /* ADC VrefInt and Temperature sensor functions specific to this STM32 series */ 187 HAL_StatusTypeDef HAL_ADCEx_EnableVREFINT(void); 188 void HAL_ADCEx_DisableVREFINT(void); 189 HAL_StatusTypeDef HAL_ADCEx_EnableVREFINTTempSensor(void); 190 void HAL_ADCEx_DisableVREFINTTempSensor(void); 191 /** 192 * @} 193 */ 194 195 /** 196 * @} 197 */ 198 199 200 /** 201 * @} 202 */ 203 204 /** 205 * @} 206 */ 207 208 #ifdef __cplusplus 209 } 210 #endif 211 212 #endif /*__STM32L0xx_HAL_ADC_EX_H */ 213 214