STM32F439xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32f4xx_hal_adc_ex.h 00004 * @author MCD Application Team 00005 * @brief Header file of ADC HAL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> 00010 * 00011 * Redistribution and use in source and binary forms, with or without modification, 00012 * are permitted provided that the following conditions are met: 00013 * 1. Redistributions of source code must retain the above copyright notice, 00014 * this list of conditions and the following disclaimer. 00015 * 2. Redistributions in binary form must reproduce the above copyright notice, 00016 * this list of conditions and the following disclaimer in the documentation 00017 * and/or other materials provided with the distribution. 00018 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00019 * may be used to endorse or promote products derived from this software 00020 * without specific prior written permission. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00023 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00024 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00025 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00026 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00027 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00028 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00029 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00030 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00031 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00032 * 00033 ****************************************************************************** 00034 */ 00035 00036 /* Define to prevent recursive inclusion -------------------------------------*/ 00037 #ifndef __STM32F4xx_ADC_EX_H 00038 #define __STM32F4xx_ADC_EX_H 00039 00040 #ifdef __cplusplus 00041 extern "C" { 00042 #endif 00043 00044 /* Includes ------------------------------------------------------------------*/ 00045 #include "stm32f4xx_hal_def.h" 00046 00047 /** @addtogroup STM32F4xx_HAL_Driver 00048 * @{ 00049 */ 00050 00051 /** @addtogroup ADCEx 00052 * @{ 00053 */ 00054 00055 /* Exported types ------------------------------------------------------------*/ 00056 /** @defgroup ADCEx_Exported_Types ADC Exported Types 00057 * @{ 00058 */ 00059 00060 /** 00061 * @brief ADC Configuration injected Channel structure definition 00062 * @note Parameters of this structure are shared within 2 scopes: 00063 * - Scope channel: InjectedChannel, InjectedRank, InjectedSamplingTime, InjectedOffset 00064 * - Scope injected group (affects all channels of injected group): InjectedNbrOfConversion, InjectedDiscontinuousConvMode, 00065 * AutoInjectedConv, ExternalTrigInjecConvEdge, ExternalTrigInjecConv. 00066 * @note The setting of these parameters with function HAL_ADCEx_InjectedConfigChannel() is conditioned to ADC state. 00067 * ADC state can be either: 00068 * - For all parameters: ADC disabled 00069 * - For all except parameters 'InjectedDiscontinuousConvMode' and 'AutoInjectedConv': ADC enabled without conversion on going on injected group. 00070 * - For parameters 'ExternalTrigInjecConv' and 'ExternalTrigInjecConvEdge': ADC enabled, even with conversion on going on injected group. 00071 */ 00072 typedef struct 00073 { 00074 uint32_t InjectedChannel; /*!< Selection of ADC channel to configure 00075 This parameter can be a value of @ref ADC_channels 00076 Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability. */ 00077 uint32_t InjectedRank; /*!< Rank in the injected group sequencer 00078 This parameter must be a value of @ref ADCEx_injected_rank 00079 Note: In case of need to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by the new channel setting (or parameter number of conversions can be adjusted) */ 00080 uint32_t InjectedSamplingTime; /*!< Sampling time value to be set for the selected channel. 00081 Unit: ADC clock cycles 00082 Conversion time is the addition of sampling time and processing time (12 ADC clock cycles at ADC resolution 12 bits, 11 cycles at 10 bits, 9 cycles at 8 bits, 7 cycles at 6 bits). 00083 This parameter can be a value of @ref ADC_sampling_times 00084 Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups. 00085 If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting. 00086 Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor), 00087 sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting) 00088 Refer to device datasheet for timings values, parameters TS_vrefint, TS_temp (values rough order: 4us min). */ 00089 uint32_t InjectedOffset; /*!< Defines the offset to be subtracted from the raw converted data (for channels set on injected group only). 00090 Offset value must be a positive number. 00091 Depending of ADC resolution selected (12, 10, 8 or 6 bits), 00092 this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF, 0x3FF, 0xFF or 0x3F respectively. */ 00093 uint32_t InjectedNbrOfConversion; /*!< Specifies the number of ranks that will be converted within the injected group sequencer. 00094 To use the injected group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled. 00095 This parameter must be a number between Min_Data = 1 and Max_Data = 4. 00096 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to 00097 configure a channel on injected group can impact the configuration of other channels previously set. */ 00098 uint32_t InjectedDiscontinuousConvMode; /*!< Specifies whether the conversions sequence of injected group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts). 00099 Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded. 00100 Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded. 00101 This parameter can be set to ENABLE or DISABLE. 00102 Note: For injected group, number of discontinuous ranks increment is fixed to one-by-one. 00103 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to 00104 configure a channel on injected group can impact the configuration of other channels previously set. */ 00105 uint32_t AutoInjectedConv; /*!< Enables or disables the selected ADC automatic injected group conversion after regular one 00106 This parameter can be set to ENABLE or DISABLE. 00107 Note: To use Automatic injected conversion, discontinuous mode must be disabled ('DiscontinuousConvMode' and 'InjectedDiscontinuousConvMode' set to DISABLE) 00108 Note: To use Automatic injected conversion, injected group external triggers must be disabled ('ExternalTrigInjecConv' set to ADC_SOFTWARE_START) 00109 Note: In case of DMA used with regular group: if DMA configured in normal mode (single shot) JAUTO will be stopped upon DMA transfer complete. 00110 To maintain JAUTO always enabled, DMA must be configured in circular mode. 00111 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to 00112 configure a channel on injected group can impact the configuration of other channels previously set. */ 00113 uint32_t ExternalTrigInjecConv; /*!< Selects the external event used to trigger the conversion start of injected group. 00114 If set to ADC_INJECTED_SOFTWARE_START, external triggers are disabled. 00115 If set to external trigger source, triggering is on event rising edge. 00116 This parameter can be a value of @ref ADCEx_External_trigger_Source_Injected 00117 Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion). 00118 If ADC is enabled, this parameter setting is bypassed without error reporting (as it can be the expected behaviour in case of another parameter update on the fly) 00119 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to 00120 configure a channel on injected group can impact the configuration of other channels previously set. */ 00121 uint32_t ExternalTrigInjecConvEdge; /*!< Selects the external trigger edge of injected group. 00122 This parameter can be a value of @ref ADCEx_External_trigger_edge_Injected. 00123 If trigger is set to ADC_INJECTED_SOFTWARE_START, this parameter is discarded. 00124 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to 00125 configure a channel on injected group can impact the configuration of other channels previously set. */ 00126 }ADC_InjectionConfTypeDef; 00127 00128 /** 00129 * @brief ADC Configuration multi-mode structure definition 00130 */ 00131 typedef struct 00132 { 00133 uint32_t Mode; /*!< Configures the ADC to operate in independent or multi mode. 00134 This parameter can be a value of @ref ADCEx_Common_mode */ 00135 uint32_t DMAAccessMode; /*!< Configures the Direct memory access mode for multi ADC mode. 00136 This parameter can be a value of @ref ADCEx_Direct_memory_access_mode_for_multi_mode */ 00137 uint32_t TwoSamplingDelay; /*!< Configures the Delay between 2 sampling phases. 00138 This parameter can be a value of @ref ADC_delay_between_2_sampling_phases */ 00139 }ADC_MultiModeTypeDef; 00140 00141 /** 00142 * @} 00143 */ 00144 00145 /* Exported constants --------------------------------------------------------*/ 00146 /** @defgroup ADCEx_Exported_Constants ADC Exported Constants 00147 * @{ 00148 */ 00149 00150 /** @defgroup ADCEx_Common_mode ADC Common Mode 00151 * @{ 00152 */ 00153 #define ADC_MODE_INDEPENDENT 0x00000000U 00154 #define ADC_DUALMODE_REGSIMULT_INJECSIMULT ((uint32_t)ADC_CCR_MULTI_0) 00155 #define ADC_DUALMODE_REGSIMULT_ALTERTRIG ((uint32_t)ADC_CCR_MULTI_1) 00156 #define ADC_DUALMODE_INJECSIMULT ((uint32_t)(ADC_CCR_MULTI_2 | ADC_CCR_MULTI_0)) 00157 #define ADC_DUALMODE_REGSIMULT ((uint32_t)(ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1)) 00158 #define ADC_DUALMODE_INTERL ((uint32_t)(ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1 | ADC_CCR_MULTI_0)) 00159 #define ADC_DUALMODE_ALTERTRIG ((uint32_t)(ADC_CCR_MULTI_3 | ADC_CCR_MULTI_0)) 00160 #define ADC_TRIPLEMODE_REGSIMULT_INJECSIMULT ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_0)) 00161 #define ADC_TRIPLEMODE_REGSIMULT_AlterTrig ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_1)) 00162 #define ADC_TRIPLEMODE_INJECSIMULT ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_2 | ADC_CCR_MULTI_0)) 00163 #define ADC_TRIPLEMODE_REGSIMULT ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1)) 00164 #define ADC_TRIPLEMODE_INTERL ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_2 | ADC_CCR_MULTI_1 | ADC_CCR_MULTI_0)) 00165 #define ADC_TRIPLEMODE_ALTERTRIG ((uint32_t)(ADC_CCR_MULTI_4 | ADC_CCR_MULTI_3 | ADC_CCR_MULTI_0)) 00166 /** 00167 * @} 00168 */ 00169 00170 /** @defgroup ADCEx_Direct_memory_access_mode_for_multi_mode ADC Direct Memory Access Mode For Multi Mode 00171 * @{ 00172 */ 00173 #define ADC_DMAACCESSMODE_DISABLED 0x00000000U /*!< DMA mode disabled */ 00174 #define ADC_DMAACCESSMODE_1 ((uint32_t)ADC_CCR_DMA_0) /*!< DMA mode 1 enabled (2 / 3 half-words one by one - 1 then 2 then 3)*/ 00175 #define ADC_DMAACCESSMODE_2 ((uint32_t)ADC_CCR_DMA_1) /*!< DMA mode 2 enabled (2 / 3 half-words by pairs - 2&1 then 1&3 then 3&2)*/ 00176 #define ADC_DMAACCESSMODE_3 ((uint32_t)ADC_CCR_DMA) /*!< DMA mode 3 enabled (2 / 3 bytes by pairs - 2&1 then 1&3 then 3&2) */ 00177 /** 00178 * @} 00179 */ 00180 00181 /** @defgroup ADCEx_External_trigger_edge_Injected ADC External Trigger Edge Injected 00182 * @{ 00183 */ 00184 #define ADC_EXTERNALTRIGINJECCONVEDGE_NONE 0x00000000U 00185 #define ADC_EXTERNALTRIGINJECCONVEDGE_RISING ((uint32_t)ADC_CR2_JEXTEN_0) 00186 #define ADC_EXTERNALTRIGINJECCONVEDGE_FALLING ((uint32_t)ADC_CR2_JEXTEN_1) 00187 #define ADC_EXTERNALTRIGINJECCONVEDGE_RISINGFALLING ((uint32_t)ADC_CR2_JEXTEN) 00188 /** 00189 * @} 00190 */ 00191 00192 /** @defgroup ADCEx_External_trigger_Source_Injected ADC External Trigger Source Injected 00193 * @{ 00194 */ 00195 #define ADC_EXTERNALTRIGINJECCONV_T1_CC4 0x00000000U 00196 #define ADC_EXTERNALTRIGINJECCONV_T1_TRGO ((uint32_t)ADC_CR2_JEXTSEL_0) 00197 #define ADC_EXTERNALTRIGINJECCONV_T2_CC1 ((uint32_t)ADC_CR2_JEXTSEL_1) 00198 #define ADC_EXTERNALTRIGINJECCONV_T2_TRGO ((uint32_t)(ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0)) 00199 #define ADC_EXTERNALTRIGINJECCONV_T3_CC2 ((uint32_t)ADC_CR2_JEXTSEL_2) 00200 #define ADC_EXTERNALTRIGINJECCONV_T3_CC4 ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0)) 00201 #define ADC_EXTERNALTRIGINJECCONV_T4_CC1 ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1)) 00202 #define ADC_EXTERNALTRIGINJECCONV_T4_CC2 ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0)) 00203 #define ADC_EXTERNALTRIGINJECCONV_T4_CC3 ((uint32_t)ADC_CR2_JEXTSEL_3) 00204 #define ADC_EXTERNALTRIGINJECCONV_T4_TRGO ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_0)) 00205 #define ADC_EXTERNALTRIGINJECCONV_T5_CC4 ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_1)) 00206 #define ADC_EXTERNALTRIGINJECCONV_T5_TRGO ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0)) 00207 #define ADC_EXTERNALTRIGINJECCONV_T8_CC2 ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2)) 00208 #define ADC_EXTERNALTRIGINJECCONV_T8_CC3 ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0)) 00209 #define ADC_EXTERNALTRIGINJECCONV_T8_CC4 ((uint32_t)(ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1)) 00210 #define ADC_EXTERNALTRIGINJECCONV_EXT_IT15 ((uint32_t)ADC_CR2_JEXTSEL) 00211 #define ADC_INJECTED_SOFTWARE_START ((uint32_t)ADC_CR2_JEXTSEL + 1U) 00212 /** 00213 * @} 00214 */ 00215 00216 /** @defgroup ADCEx_injected_rank ADC Injected Rank 00217 * @{ 00218 */ 00219 #define ADC_INJECTED_RANK_1 0x00000001U 00220 #define ADC_INJECTED_RANK_2 0x00000002U 00221 #define ADC_INJECTED_RANK_3 0x00000003U 00222 #define ADC_INJECTED_RANK_4 0x00000004U 00223 /** 00224 * @} 00225 */ 00226 00227 /** @defgroup ADCEx_channels ADC Specific Channels 00228 * @{ 00229 */ 00230 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \ 00231 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) || \ 00232 defined(STM32F410Rx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) || \ 00233 defined(STM32F412Cx) 00234 #define ADC_CHANNEL_TEMPSENSOR ((uint32_t)ADC_CHANNEL_16) 00235 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F410xx || STM32F412Zx || 00236 STM32F412Vx || STM32F412Rx || STM32F412Cx */ 00237 00238 #if defined(STM32F413xx) || defined(STM32F423xx) 00239 #define ADC_CHANNEL_TEMPSENSOR ((uint32_t)ADC_CHANNEL_18) 00240 #endif /* STM32F413xx || STM32F423xx */ 00241 00242 #if defined(STM32F411xE) || defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \ 00243 defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) 00244 #define ADC_CHANNEL_DIFFERENCIATION_TEMPSENSOR_VBAT 0x10000000U /* Dummy bit for driver internal usage, not used in ADC channel setting registers CR1 or SQRx */ 00245 #define ADC_CHANNEL_TEMPSENSOR ((uint32_t)ADC_CHANNEL_18 | ADC_CHANNEL_DIFFERENCIATION_TEMPSENSOR_VBAT) 00246 #endif /* STM32F411xE || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */ 00247 /** 00248 * @} 00249 */ 00250 00251 00252 /** 00253 * @} 00254 */ 00255 00256 /* Exported macro ------------------------------------------------------------*/ 00257 /** @defgroup ADC_Exported_Macros ADC Exported Macros 00258 * @{ 00259 */ 00260 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) 00261 /** 00262 * @brief Disable internal path of ADC channel Vbat 00263 * @note Use case of this macro: 00264 * On devices STM32F42x and STM32F43x, ADC internal channels 00265 * Vbat and VrefInt share the same internal path, only 00266 * one of them can be enabled.This macro is to be used when ADC 00267 * channels Vbat and VrefInt are selected, and must be called 00268 * before starting conversion of ADC channel VrefInt in order 00269 * to disable ADC channel Vbat. 00270 * @retval None 00271 */ 00272 #define __HAL_ADC_PATH_INTERNAL_VBAT_DISABLE() (ADC->CCR &= ~(ADC_CCR_VBATE)) 00273 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */ 00274 /** 00275 * @} 00276 */ 00277 00278 /* Exported functions --------------------------------------------------------*/ 00279 /** @addtogroup ADCEx_Exported_Functions 00280 * @{ 00281 */ 00282 00283 /** @addtogroup ADCEx_Exported_Functions_Group1 00284 * @{ 00285 */ 00286 00287 /* I/O operation functions ******************************************************/ 00288 HAL_StatusTypeDef HAL_ADCEx_InjectedStart(ADC_HandleTypeDef* hadc); 00289 HAL_StatusTypeDef HAL_ADCEx_InjectedStop(ADC_HandleTypeDef* hadc); 00290 HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout); 00291 HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT(ADC_HandleTypeDef* hadc); 00292 HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT(ADC_HandleTypeDef* hadc); 00293 uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t InjectedRank); 00294 HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length); 00295 HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA(ADC_HandleTypeDef* hadc); 00296 uint32_t HAL_ADCEx_MultiModeGetValue(ADC_HandleTypeDef* hadc); 00297 void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc); 00298 00299 /* Peripheral Control functions *************************************************/ 00300 HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef* hadc,ADC_InjectionConfTypeDef* sConfigInjected); 00301 HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel(ADC_HandleTypeDef* hadc, ADC_MultiModeTypeDef* multimode); 00302 00303 /** 00304 * @} 00305 */ 00306 00307 /** 00308 * @} 00309 */ 00310 /* Private types -------------------------------------------------------------*/ 00311 /* Private variables ---------------------------------------------------------*/ 00312 /* Private constants ---------------------------------------------------------*/ 00313 /** @defgroup ADCEx_Private_Constants ADC Private Constants 00314 * @{ 00315 */ 00316 00317 /** 00318 * @} 00319 */ 00320 00321 /* Private macros ------------------------------------------------------------*/ 00322 /** @defgroup ADCEx_Private_Macros ADC Private Macros 00323 * @{ 00324 */ 00325 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \ 00326 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) || \ 00327 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F412Zx) || defined(STM32F412Vx) || \ 00328 defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) 00329 #define IS_ADC_CHANNEL(CHANNEL) ((CHANNEL) <= ADC_CHANNEL_18) 00330 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || 00331 STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */ 00332 00333 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \ 00334 defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) 00335 #define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) <= ADC_CHANNEL_18) || \ 00336 ((CHANNEL) == ADC_CHANNEL_TEMPSENSOR)) 00337 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */ 00338 00339 #define IS_ADC_MODE(MODE) (((MODE) == ADC_MODE_INDEPENDENT) || \ 00340 ((MODE) == ADC_DUALMODE_REGSIMULT_INJECSIMULT) || \ 00341 ((MODE) == ADC_DUALMODE_REGSIMULT_ALTERTRIG) || \ 00342 ((MODE) == ADC_DUALMODE_INJECSIMULT) || \ 00343 ((MODE) == ADC_DUALMODE_REGSIMULT) || \ 00344 ((MODE) == ADC_DUALMODE_INTERL) || \ 00345 ((MODE) == ADC_DUALMODE_ALTERTRIG) || \ 00346 ((MODE) == ADC_TRIPLEMODE_REGSIMULT_INJECSIMULT) || \ 00347 ((MODE) == ADC_TRIPLEMODE_REGSIMULT_AlterTrig) || \ 00348 ((MODE) == ADC_TRIPLEMODE_INJECSIMULT) || \ 00349 ((MODE) == ADC_TRIPLEMODE_REGSIMULT) || \ 00350 ((MODE) == ADC_TRIPLEMODE_INTERL) || \ 00351 ((MODE) == ADC_TRIPLEMODE_ALTERTRIG)) 00352 #define IS_ADC_DMA_ACCESS_MODE(MODE) (((MODE) == ADC_DMAACCESSMODE_DISABLED) || \ 00353 ((MODE) == ADC_DMAACCESSMODE_1) || \ 00354 ((MODE) == ADC_DMAACCESSMODE_2) || \ 00355 ((MODE) == ADC_DMAACCESSMODE_3)) 00356 #define IS_ADC_EXT_INJEC_TRIG_EDGE(EDGE) (((EDGE) == ADC_EXTERNALTRIGINJECCONVEDGE_NONE) || \ 00357 ((EDGE) == ADC_EXTERNALTRIGINJECCONVEDGE_RISING) || \ 00358 ((EDGE) == ADC_EXTERNALTRIGINJECCONVEDGE_FALLING) || \ 00359 ((EDGE) == ADC_EXTERNALTRIGINJECCONVEDGE_RISINGFALLING)) 00360 #define IS_ADC_EXT_INJEC_TRIG(INJTRIG) (((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4) || \ 00361 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO) || \ 00362 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1) || \ 00363 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO) || \ 00364 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC2) || \ 00365 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4) || \ 00366 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC1) || \ 00367 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC2) || \ 00368 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC3) || \ 00369 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO) || \ 00370 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T5_CC4) || \ 00371 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T5_TRGO) || \ 00372 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC2) || \ 00373 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC3) || \ 00374 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC4) || \ 00375 ((INJTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15)|| \ 00376 ((INJTRIG) == ADC_INJECTED_SOFTWARE_START)) 00377 #define IS_ADC_INJECTED_LENGTH(LENGTH) (((LENGTH) >= 1U) && ((LENGTH) <= 4U)) 00378 #define IS_ADC_INJECTED_RANK(RANK) (((RANK) >= 1U) && ((RANK) <= 4U)) 00379 00380 /** 00381 * @brief Set the selected injected Channel rank. 00382 * @param _CHANNELNB_ Channel number. 00383 * @param _RANKNB_ Rank number. 00384 * @param _JSQR_JL_ Sequence length. 00385 * @retval None 00386 */ 00387 #define ADC_JSQR(_CHANNELNB_, _RANKNB_, _JSQR_JL_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5U * (uint8_t)(((_RANKNB_) + 3U) - (_JSQR_JL_)))) 00388 00389 /** 00390 * @brief Defines if the selected ADC is within ADC common register ADC123 or ADC1 00391 * if available (ADC2, ADC3 availability depends on STM32 product) 00392 * @param __HANDLE__ ADC handle 00393 * @retval Common control register ADC123 or ADC1 00394 */ 00395 #if defined(STM32F405xx) || defined(STM32F407xx) || defined(STM32F415xx) || defined(STM32F417xx) || defined(STM32F427xx) || defined(STM32F429xx) || defined(STM32F437xx) || defined(STM32F439xx) || defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) 00396 #define ADC_COMMON_REGISTER(__HANDLE__) ADC123_COMMON 00397 #else 00398 #define ADC_COMMON_REGISTER(__HANDLE__) ADC1_COMMON 00399 #endif /* STM32F405xx || STM32F407xx || STM32F415xx || STM32F417xx || STM32F427xx || STM32F429xx || STM32F437xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */ 00400 /** 00401 * @} 00402 */ 00403 00404 /* Private functions ---------------------------------------------------------*/ 00405 /** @defgroup ADCEx_Private_Functions ADC Private Functions 00406 * @{ 00407 */ 00408 00409 /** 00410 * @} 00411 */ 00412 00413 /** 00414 * @} 00415 */ 00416 00417 /** 00418 * @} 00419 */ 00420 00421 #ifdef __cplusplus 00422 } 00423 #endif 00424 00425 #endif /*__STM32F4xx_ADC_EX_H */ 00426 00427 00428 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/