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 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> 10 * 11 * Redistribution and use in source and binary forms, with or without modification, 12 * are permitted provided that the following conditions are met: 13 * 1. Redistributions of source code must retain the above copyright notice, 14 * this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright notice, 16 * this list of conditions and the following disclaimer in the documentation 17 * and/or other materials provided with the distribution. 18 * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * 33 ****************************************************************************** 34 */ 35 36 /* Define to prevent recursive inclusion -------------------------------------*/ 37 #ifndef __STM32L0xx_HAL_ADC_EX_H 38 #define __STM32L0xx_HAL_ADC_EX_H 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /* Includes ------------------------------------------------------------------*/ 45 #include "stm32l0xx_hal_def.h" 46 47 /** @addtogroup STM32L0xx_HAL_Driver 48 * @{ 49 */ 50 51 /** @addtogroup ADCEx 52 * @{ 53 */ 54 55 /* Exported types ------------------------------------------------------------*/ 56 /* Exported constants --------------------------------------------------------*/ 57 58 /** @defgroup ADCEx_Exported_Constants ADC Extended Exported Constants 59 * @{ 60 */ 61 62 /** @defgroup ADCEx_Channel_Mode ADC Single Ended 63 * @{ 64 */ 65 #define ADC_SINGLE_ENDED (uint32_t)0x00000000U /* dummy value */ 66 /** 67 * @} 68 */ 69 70 /** @defgroup ADC_regular_external_trigger_source ADC External Trigger Source 71 * @{ 72 */ 73 #define ADC_EXTERNALTRIGCONV_T6_TRGO ((uint32_t)0x00000000U) 74 #define ADC_EXTERNALTRIGCONV_T21_CC2 (ADC_CFGR1_EXTSEL_0) 75 #define ADC_EXTERNALTRIGCONV_T2_TRGO (ADC_CFGR1_EXTSEL_1) 76 #define ADC_EXTERNALTRIGCONV_T2_CC4 (ADC_CFGR1_EXTSEL_1 | ADC_CFGR1_EXTSEL_0) 77 #define ADC_EXTERNALTRIGCONV_T22_TRGO (ADC_CFGR1_EXTSEL_2) 78 #define ADC_EXTERNALTRIGCONV_T3_TRGO (ADC_CFGR1_EXTSEL_2 | ADC_CFGR1_EXTSEL_1) 79 #define ADC_EXTERNALTRIGCONV_EXT_IT11 (ADC_CFGR1_EXTSEL_2 | ADC_CFGR1_EXTSEL_1 | ADC_CFGR1_EXTSEL_0) 80 #define ADC_SOFTWARE_START (ADC_CFGR1_EXTSEL + (uint32_t)1) 81 82 /* ADC group regular external trigger TIM21_TRGO available only on */ 83 /* STM32L0 devices categories: Cat.2, Cat.3, Cat.5 */ 84 #if defined (STM32L031xx) || defined (STM32L041xx) || \ 85 defined (STM32L051xx) || defined (STM32L052xx) || defined (STM32L053xx) || \ 86 defined (STM32L061xx) || defined (STM32L062xx) || defined (STM32L063xx) || \ 87 defined (STM32L071xx) || defined (STM32L072xx) || defined (STM32L073xx) || \ 88 defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx) 89 #define ADC_EXTERNALTRIGCONV_T21_TRGO (ADC_EXTERNALTRIGCONV_T22_TRGO) 90 #endif 91 92 /* ADC group regular external trigger TIM2_CC3 available only on */ 93 /* STM32L0 devices categories: Cat.1, Cat.2, Cat.5 */ 94 #if defined (STM32L011xx) || defined (STM32L021xx) || \ 95 defined (STM32L031xx) || defined (STM32L041xx) || \ 96 defined (STM32L071xx) || defined (STM32L072xx) || defined (STM32L073xx) || \ 97 defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx) 98 #define ADC_EXTERNALTRIGCONV_T2_CC3 (ADC_CFGR1_EXTSEL_2 | ADC_CFGR1_EXTSEL_0) 99 #endif 100 101 /** 102 * @} 103 */ 104 105 /** @defgroup ADC_SYSCFG_internal_paths_flags_definition ADC SYSCFG internal paths Flags Definition 106 * @{ 107 */ 108 #define ADC_FLAG_SENSOR SYSCFG_CFGR3_VREFINT_RDYF 109 #define ADC_FLAG_VREFINT SYSCFG_VREFINT_ADC_RDYF 110 /** 111 * @} 112 */ 113 114 /** 115 * @} 116 */ 117 118 /* Private macros ------------------------------------------------------------*/ 119 120 /** @defgroup ADCEx_Private_Macros ADCEx Private Macros 121 * @{ 122 */ 123 124 #define IS_ADC_SINGLE_DIFFERENTIAL(SING_DIFF) ((SING_DIFF) == ADC_SINGLE_ENDED) 125 126 /** @defgroup ADCEx_calibration_factor_length_verification ADC Calibration Factor Length Verification 127 * @{ 128 */ 129 /** 130 * @brief Calibration factor length verification (7 bits maximum) 131 * @param _Calibration_Factor_: Calibration factor value 132 * @retval None 133 */ 134 #define IS_ADC_CALFACT(_Calibration_Factor_) ((_Calibration_Factor_) <= ((uint32_t)0x7FU)) 135 /** 136 * @} 137 */ 138 139 /** @defgroup ADC_External_trigger_Source ADC External Trigger Source 140 * @{ 141 */ 142 #if defined (STM32L031xx) || defined (STM32L041xx) || \ 143 defined (STM32L071xx) || defined (STM32L072xx) || defined (STM32L073xx) || \ 144 defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx) 145 #define IS_ADC_EXTTRIG(CONV) (((CONV) == ADC_EXTERNALTRIGCONV_T6_TRGO ) || \ 146 ((CONV) == ADC_EXTERNALTRIGCONV_T21_CC2 ) || \ 147 ((CONV) == ADC_EXTERNALTRIGCONV_T2_TRGO ) || \ 148 ((CONV) == ADC_EXTERNALTRIGCONV_T2_CC4 ) || \ 149 ((CONV) == ADC_EXTERNALTRIGCONV_T22_TRGO ) || \ 150 ((CONV) == ADC_EXTERNALTRIGCONV_T21_TRGO ) || \ 151 ((CONV) == ADC_EXTERNALTRIGCONV_T2_CC3 ) || \ 152 ((CONV) == ADC_EXTERNALTRIGCONV_T3_TRGO ) || \ 153 ((CONV) == ADC_EXTERNALTRIGCONV_EXT_IT11 ) || \ 154 ((CONV) == ADC_SOFTWARE_START)) 155 #elif defined (STM32L011xx) || defined (STM32L021xx) 156 #define IS_ADC_EXTTRIG(CONV) (((CONV) == ADC_EXTERNALTRIGCONV_T6_TRGO ) || \ 157 ((CONV) == ADC_EXTERNALTRIGCONV_T21_CC2 ) || \ 158 ((CONV) == ADC_EXTERNALTRIGCONV_T2_TRGO ) || \ 159 ((CONV) == ADC_EXTERNALTRIGCONV_T2_CC4 ) || \ 160 ((CONV) == ADC_EXTERNALTRIGCONV_T22_TRGO ) || \ 161 ((CONV) == ADC_EXTERNALTRIGCONV_T2_CC3 ) || \ 162 ((CONV) == ADC_EXTERNALTRIGCONV_T3_TRGO ) || \ 163 ((CONV) == ADC_EXTERNALTRIGCONV_EXT_IT11 ) || \ 164 ((CONV) == ADC_SOFTWARE_START)) 165 #elif defined (STM32L051xx) || defined (STM32L052xx) || defined (STM32L053xx) || \ 166 defined (STM32L061xx) || defined (STM32L062xx) || defined (STM32L063xx) 167 #define IS_ADC_EXTTRIG(CONV) (((CONV) == ADC_EXTERNALTRIGCONV_T6_TRGO ) || \ 168 ((CONV) == ADC_EXTERNALTRIGCONV_T21_CC2 ) || \ 169 ((CONV) == ADC_EXTERNALTRIGCONV_T2_TRGO ) || \ 170 ((CONV) == ADC_EXTERNALTRIGCONV_T2_CC4 ) || \ 171 ((CONV) == ADC_EXTERNALTRIGCONV_T22_TRGO ) || \ 172 ((CONV) == ADC_EXTERNALTRIGCONV_T21_TRGO ) || \ 173 ((CONV) == ADC_EXTERNALTRIGCONV_T3_TRGO ) || \ 174 ((CONV) == ADC_EXTERNALTRIGCONV_EXT_IT11 ) || \ 175 ((CONV) == ADC_SOFTWARE_START)) 176 #endif 177 /** 178 * @} 179 */ 180 181 /** 182 * @} 183 */ 184 185 /* Exported functions --------------------------------------------------------*/ 186 /** @addtogroup ADCEx_Exported_Functions 187 * @{ 188 */ 189 190 /** @addtogroup ADCEx_Exported_Functions_Group1 191 * @{ 192 */ 193 /* IO operation functions *****************************************************/ 194 195 /* ADC calibration */ 196 HAL_StatusTypeDef HAL_ADCEx_Calibration_Start(ADC_HandleTypeDef* hadc, uint32_t SingleDiff); 197 uint32_t HAL_ADCEx_Calibration_GetValue(ADC_HandleTypeDef* hadc, uint32_t SingleDiff); 198 HAL_StatusTypeDef HAL_ADCEx_Calibration_SetValue(ADC_HandleTypeDef* hadc, uint32_t SingleDiff, uint32_t CalibrationFactor); 199 200 /* ADC VrefInt and Temperature sensor functions specific to this STM32 serie */ 201 HAL_StatusTypeDef HAL_ADCEx_EnableVREFINT(void); 202 void HAL_ADCEx_DisableVREFINT(void); 203 HAL_StatusTypeDef HAL_ADCEx_EnableVREFINTTempSensor(void); 204 void HAL_ADCEx_DisableVREFINTTempSensor(void); 205 /** 206 * @} 207 */ 208 209 /** 210 * @} 211 */ 212 213 214 /** 215 * @} 216 */ 217 218 /** 219 * @} 220 */ 221 222 #ifdef __cplusplus 223 } 224 #endif 225 226 #endif /*__STM32L0xx_HAL_ADC_EX_H */ 227 228 229 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 230