Subversion Repositories LedShow

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 mjames 1
/**
2
  ******************************************************************************
3
  * @file    stm32f1xx_hal_adc_ex.h
4
  * @author  MCD Application Team
5
  * @brief   Header file of ADC HAL extension module.
6
  ******************************************************************************
7
  * @attention
8
  *
9
  * <h2><center>&copy; 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 __STM32F1xx_HAL_ADC_EX_H
38
#define __STM32F1xx_HAL_ADC_EX_H
39
 
40
#ifdef __cplusplus
41
 extern "C" {
42
#endif
43
 
44
/* Includes ------------------------------------------------------------------*/
45
#include "stm32f1xx_hal_def.h"  
46
 
47
/** @addtogroup STM32F1xx_HAL_Driver
48
  * @{
49
  */
50
 
51
/** @addtogroup ADCEx
52
  * @{
53
  */
54
 
55
/* Exported types ------------------------------------------------------------*/
56
/** @defgroup ADCEx_Exported_Types ADCEx Exported Types
57
  * @{
58
  */
59
 
60
/**
61
  * @brief  ADC Configuration injected Channel structure definition
62
  * @note   Parameters of this structure are shared within 2 scopes:
63
  *          - Scope channel: InjectedChannel, InjectedRank, InjectedSamplingTime, InjectedOffset
64
  *          - Scope injected group (affects all channels of injected group): InjectedNbrOfConversion, InjectedDiscontinuousConvMode,
65
  *            AutoInjectedConv, ExternalTrigInjecConvEdge, ExternalTrigInjecConv.
66
  * @note   The setting of these parameters with function HAL_ADCEx_InjectedConfigChannel() is conditioned to ADC state.
67
  *         ADC state can be either:
68
  *          - For all parameters: ADC disabled (this is the only possible ADC state to modify parameter 'ExternalTrigInjecConv')
69
  *          - For all except parameters 'ExternalTrigInjecConv': ADC enabled without conversion on going on injected group.
70
  */
71
typedef struct
72
{
73
  uint32_t InjectedChannel;               /*!< Selection of ADC channel to configure
74
                                               This parameter can be a value of @ref ADC_channels
75
                                               Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability.
76
                                               Note: On STM32F1 devices with several ADC: Only ADC1 can access internal measurement channels (VrefInt/TempSensor)
77
                                               Note: On STM32F10xx8 and STM32F10xxB devices: A low-amplitude voltage glitch may be generated (on ADC input 0) on the PA0 pin, when the ADC is converting with injection trigger.
78
                                                     It is advised to distribute the analog channels so that Channel 0 is configured as an injected channel.
79
                                                     Refer to errata sheet of these devices for more details. */
80
  uint32_t InjectedRank;                  /*!< Rank in the injected group sequencer
81
                                               This parameter must be a value of @ref ADCEx_injected_rank
82
                                               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) */
83
  uint32_t InjectedSamplingTime;          /*!< Sampling time value to be set for the selected channel.
84
                                               Unit: ADC clock cycles
85
                                               Conversion time is the addition of sampling time and processing time (12.5 ADC clock cycles at ADC resolution 12 bits).
86
                                               This parameter can be a value of @ref ADC_sampling_times
87
                                               Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups.
88
                                                        If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting.
89
                                               Note: In case of usage of internal measurement channels (VrefInt/TempSensor),
90
                                                     sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
91
                                                     Refer to device datasheet for timings values, parameters TS_vrefint, TS_temp (values rough order: 5us to 17.1us min). */
92
  uint32_t InjectedOffset;                /*!< Defines the offset to be subtracted from the raw converted data (for channels set on injected group only).
93
                                               Offset value must be a positive number.
94
                                               Depending of ADC resolution selected (12, 10, 8 or 6 bits),
95
                                               this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF, 0x3FF, 0xFF or 0x3F respectively. */
96
  uint32_t InjectedNbrOfConversion;       /*!< Specifies the number of ranks that will be converted within the injected group sequencer.
97
                                               To use the injected group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
98
                                               This parameter must be a number between Min_Data = 1 and Max_Data = 4.
99
                                               Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
100
                                                        configure a channel on injected group can impact the configuration of other channels previously set. */
101
  uint32_t InjectedDiscontinuousConvMode; /*!< Specifies whether the conversions sequence of injected group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts).
102
                                               Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
103
                                               Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
104
                                               This parameter can be set to ENABLE or DISABLE.
105
                                               Note: For injected group, number of discontinuous ranks increment is fixed to one-by-one.
106
                                               Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
107
                                                        configure a channel on injected group can impact the configuration of other channels previously set. */
108
  uint32_t AutoInjectedConv;              /*!< Enables or disables the selected ADC automatic injected group conversion after regular one
109
                                               This parameter can be set to ENABLE or DISABLE.      
110
                                               Note: To use Automatic injected conversion, discontinuous mode must be disabled ('DiscontinuousConvMode' and 'InjectedDiscontinuousConvMode' set to DISABLE)
111
                                               Note: To use Automatic injected conversion, injected group external triggers must be disabled ('ExternalTrigInjecConv' set to ADC_SOFTWARE_START)
112
                                               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.
113
                                                     To maintain JAUTO always enabled, DMA must be configured in circular mode.
114
                                               Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
115
                                                        configure a channel on injected group can impact the configuration of other channels previously set. */
116
  uint32_t ExternalTrigInjecConv;         /*!< Selects the external event used to trigger the conversion start of injected group.
117
                                               If set to ADC_INJECTED_SOFTWARE_START, external triggers are disabled.
118
                                               If set to external trigger source, triggering is on event rising edge.
119
                                               This parameter can be a value of @ref ADCEx_External_trigger_source_Injected
120
                                               Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion).
121
                                                     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)
122
                                               Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
123
                                                        configure a channel on injected group can impact the configuration of other channels previously set. */
124
}ADC_InjectionConfTypeDef;
125
 
126
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
127
/**
128
  * @brief  Structure definition of ADC multimode
129
  * @note   The setting of these parameters with function HAL_ADCEx_MultiModeConfigChannel() is conditioned to ADCs state (both ADCs of the common group).
130
  *         State of ADCs of the common group must be: disabled.
131
  */
132
typedef struct
133
{
134
  uint32_t Mode;              /*!< Configures the ADC to operate in independent or multi mode.
135
                                   This parameter can be a value of @ref ADCEx_Common_mode
136
                                   Note: In dual mode, a change of channel configuration generates a restart that can produce a loss of synchronization. It is recommended to disable dual mode before any configuration change.
137
                                   Note: In case of simultaneous mode used: Exactly the same sampling time should be configured for the 2 channels that will be sampled simultaneously by ACD1 and ADC2.
138
                                   Note: In case of interleaved mode used: To avoid overlap between conversions, maximum sampling time allowed is 7 ADC clock cycles for fast interleaved mode and 14 ADC clock cycles for slow interleaved mode.
139
                                   Note: Some multimode parameters are fixed on STM32F1 and can be configured on other STM32 devices with several ADC (multimode configuration structure can have additional parameters).
140
                                         The equivalences are:
141
                                           - Parameter 'DMAAccessMode': On STM32F1, this parameter is fixed to 1 DMA channel (one DMA channel for both ADC, DMA of ADC master). On other STM32 devices with several ADC, this is equivalent to parameter 'ADC_DMAACCESSMODE_12_10_BITS'.
142
                                           - Parameter 'TwoSamplingDelay': On STM32F1, this parameter is fixed to 7 or 14 ADC clock cycles depending on fast or slow interleaved mode selected. On other STM32 devices with several ADC, this is equivalent to parameter 'ADC_TWOSAMPLINGDELAY_7CYCLES' (for fast interleaved mode). */
143
 
144
 
145
}ADC_MultiModeTypeDef;                                                          
146
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
147
 
148
/**
149
  * @}
150
  */
151
 
152
 
153
/* Exported constants --------------------------------------------------------*/
154
 
155
/** @defgroup ADCEx_Exported_Constants ADCEx Exported Constants
156
  * @{
157
  */
158
 
159
/** @defgroup ADCEx_injected_rank ADCEx rank into injected group
160
  * @{
161
  */
162
#define ADC_INJECTED_RANK_1                           0x00000001U
163
#define ADC_INJECTED_RANK_2                           0x00000002U
164
#define ADC_INJECTED_RANK_3                           0x00000003U
165
#define ADC_INJECTED_RANK_4                           0x00000004U
166
/**
167
  * @}
168
  */
169
 
170
/** @defgroup ADCEx_External_trigger_edge_Injected ADCEx external trigger enable for injected group
171
  * @{
172
  */
173
#define ADC_EXTERNALTRIGINJECCONV_EDGE_NONE           0x00000000U
174
#define ADC_EXTERNALTRIGINJECCONV_EDGE_RISING         ((uint32_t)ADC_CR2_JEXTTRIG)
175
/**
176
  * @}
177
  */
178
 
179
/** @defgroup ADC_External_trigger_source_Regular ADC External trigger selection for regular group
180
  * @{
181
  */
182
/*!< List of external triggers with generic trigger name, independently of    */
183
/* ADC target, sorted by trigger name:                                        */
184
 
185
/*!< External triggers of regular group for ADC1&ADC2 only */
186
#define ADC_EXTERNALTRIGCONV_T1_CC1         ADC1_2_EXTERNALTRIG_T1_CC1
187
#define ADC_EXTERNALTRIGCONV_T1_CC2         ADC1_2_EXTERNALTRIG_T1_CC2
188
#define ADC_EXTERNALTRIGCONV_T2_CC2         ADC1_2_EXTERNALTRIG_T2_CC2
189
#define ADC_EXTERNALTRIGCONV_T3_TRGO        ADC1_2_EXTERNALTRIG_T3_TRGO
190
#define ADC_EXTERNALTRIGCONV_T4_CC4         ADC1_2_EXTERNALTRIG_T4_CC4
191
#define ADC_EXTERNALTRIGCONV_EXT_IT11       ADC1_2_EXTERNALTRIG_EXT_IT11
192
 
193
#if defined (STM32F103xE) || defined (STM32F103xG)
194
/*!< External triggers of regular group for ADC3 only */
195
#define ADC_EXTERNALTRIGCONV_T2_CC3         ADC3_EXTERNALTRIG_T2_CC3
196
#define ADC_EXTERNALTRIGCONV_T3_CC1         ADC3_EXTERNALTRIG_T3_CC1
197
#define ADC_EXTERNALTRIGCONV_T5_CC1         ADC3_EXTERNALTRIG_T5_CC1
198
#define ADC_EXTERNALTRIGCONV_T5_CC3         ADC3_EXTERNALTRIG_T5_CC3
199
#define ADC_EXTERNALTRIGCONV_T8_CC1         ADC3_EXTERNALTRIG_T8_CC1
200
#endif /* STM32F103xE || defined STM32F103xG */
201
 
202
/*!< External triggers of regular group for all ADC instances */
203
#define ADC_EXTERNALTRIGCONV_T1_CC3         ADC1_2_3_EXTERNALTRIG_T1_CC3
204
 
205
#if defined (STM32F101xE) || defined (STM32F103xE) || defined (STM32F103xG) || defined (STM32F105xC) || defined (STM32F107xC)
206
/*!< Note: TIM8_TRGO is available on ADC1 and ADC2 only in high-density and   */
207
/*         XL-density devices.                                                */
208
/*         To use it on ADC or ADC2, a remap of trigger must be done from     */
209
/*         EXTI line 11 to TIM8_TRGO with macro:                              */
210
/*           __HAL_AFIO_REMAP_ADC1_ETRGREG_ENABLE()                           */
211
/*           __HAL_AFIO_REMAP_ADC2_ETRGREG_ENABLE()                           */
212
 
213
/* Note for internal constant value management: If TIM8_TRGO is available,    */
214
/* its definition is set to value for ADC1&ADC2 by default and changed to     */
215
/* value for ADC3 by HAL ADC driver if ADC3 is selected.                      */
216
#define ADC_EXTERNALTRIGCONV_T8_TRGO        ADC1_2_EXTERNALTRIG_T8_TRGO
217
#endif /* STM32F101xE || STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
218
 
219
#define ADC_SOFTWARE_START                  ADC1_2_3_SWSTART
220
/**
221
  * @}
222
  */
223
 
224
/** @defgroup ADCEx_External_trigger_source_Injected ADCEx External trigger selection for injected group
225
  * @{
226
  */
227
/*!< List of external triggers with generic trigger name, independently of    */
228
/* ADC target, sorted by trigger name:                                        */
229
 
230
/*!< External triggers of injected group for ADC1&ADC2 only */
231
#define ADC_EXTERNALTRIGINJECCONV_T2_TRGO        ADC1_2_EXTERNALTRIGINJEC_T2_TRGO
232
#define ADC_EXTERNALTRIGINJECCONV_T2_CC1         ADC1_2_EXTERNALTRIGINJEC_T2_CC1
233
#define ADC_EXTERNALTRIGINJECCONV_T3_CC4         ADC1_2_EXTERNALTRIGINJEC_T3_CC4
234
#define ADC_EXTERNALTRIGINJECCONV_T4_TRGO        ADC1_2_EXTERNALTRIGINJEC_T4_TRGO 
235
#define ADC_EXTERNALTRIGINJECCONV_EXT_IT15       ADC1_2_EXTERNALTRIGINJEC_EXT_IT15
236
 
237
#if defined (STM32F103xE) || defined (STM32F103xG)
238
/*!< External triggers of injected group for ADC3 only */
239
#define ADC_EXTERNALTRIGINJECCONV_T4_CC3         ADC3_EXTERNALTRIGINJEC_T4_CC3
240
#define ADC_EXTERNALTRIGINJECCONV_T8_CC2         ADC3_EXTERNALTRIGINJEC_T8_CC2
241
#define ADC_EXTERNALTRIGINJECCONV_T5_TRGO        ADC3_EXTERNALTRIGINJEC_T5_TRGO
242
#define ADC_EXTERNALTRIGINJECCONV_T5_CC4         ADC3_EXTERNALTRIGINJEC_T5_CC4
243
#endif /* STM32F103xE || defined STM32F103xG */
244
 
245
/*!< External triggers of injected group for all ADC instances */
246
#define ADC_EXTERNALTRIGINJECCONV_T1_CC4         ADC1_2_3_EXTERNALTRIGINJEC_T1_CC4
247
#define ADC_EXTERNALTRIGINJECCONV_T1_TRGO        ADC1_2_3_EXTERNALTRIGINJEC_T1_TRGO
248
 
249
#if defined (STM32F101xE) || defined (STM32F103xE) || defined (STM32F103xG) || defined (STM32F105xC) || defined (STM32F107xC)
250
/*!< Note: TIM8_CC4 is available on ADC1 and ADC2 only in high-density and    */
251
/*         XL-density devices.                                                */
252
/*         To use it on ADC1 or ADC2, a remap of trigger must be done from    */
253
/*         EXTI line 11 to TIM8_CC4 with macro:                               */
254
/*           __HAL_AFIO_REMAP_ADC1_ETRGINJ_ENABLE()                           */
255
/*           __HAL_AFIO_REMAP_ADC2_ETRGINJ_ENABLE()                           */
256
 
257
/* Note for internal constant value management: If TIM8_CC4 is available,     */
258
/* its definition is set to value for ADC1&ADC2 by default and changed to     */
259
/* value for ADC3 by HAL ADC driver if ADC3 is selected.                      */
260
#define ADC_EXTERNALTRIGINJECCONV_T8_CC4         ADC1_2_EXTERNALTRIGINJEC_T8_CC4
261
#endif /* STM32F101xE || STM32F103xE || STM32F103xG || STM32F105xC || STM32F107xC */
262
 
263
#define ADC_INJECTED_SOFTWARE_START              ADC1_2_3_JSWSTART
264
/**
265
  * @}
266
  */
267
 
268
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
269
/** @defgroup ADCEx_Common_mode ADC Extended Dual ADC Mode
270
  * @{
271
  */
272
#define ADC_MODE_INDEPENDENT                              0x00000000U                                                                     /*!< ADC dual mode disabled (ADC independent mode) */
273
#define ADC_DUALMODE_REGSIMULT_INJECSIMULT    ((uint32_t)(                                                            ADC_CR1_DUALMOD_0)) /*!< ADC dual mode enabled: Combined regular simultaneous + injected simultaneous mode, on groups regular and injected */
274
#define ADC_DUALMODE_REGSIMULT_ALTERTRIG      ((uint32_t)(                                        ADC_CR1_DUALMOD_1                    )) /*!< ADC dual mode enabled: Combined regular simultaneous + alternate trigger mode, on groups regular and injected */
275
#define ADC_DUALMODE_INJECSIMULT_INTERLFAST   ((uint32_t)(                                        ADC_CR1_DUALMOD_1 | ADC_CR1_DUALMOD_0)) /*!< ADC dual mode enabled: Combined injected simultaneous + fast interleaved mode, on groups regular and injected (delay between ADC sampling phases: 7 ADC clock cycles (equivalent to parameter "TwoSamplingDelay" set to "ADC_TWOSAMPLINGDELAY_7CYCLES" on other STM32 devices)) */
276
#define ADC_DUALMODE_INJECSIMULT_INTERLSLOW   ((uint32_t)(                    ADC_CR1_DUALMOD_2                                        )) /*!< ADC dual mode enabled: Combined injected simultaneous + slow Interleaved mode, on groups regular and injected (delay between ADC sampling phases: 14 ADC clock cycles (equivalent to parameter "TwoSamplingDelay" set to "ADC_TWOSAMPLINGDELAY_7CYCLES" on other STM32 devices)) */
277
#define ADC_DUALMODE_INJECSIMULT              ((uint32_t)(                    ADC_CR1_DUALMOD_2 |                     ADC_CR1_DUALMOD_0)) /*!< ADC dual mode enabled: Injected simultaneous mode, on group injected */
278
#define ADC_DUALMODE_REGSIMULT                ((uint32_t)(                    ADC_CR1_DUALMOD_2 | ADC_CR1_DUALMOD_1                    )) /*!< ADC dual mode enabled: Regular simultaneous mode, on group regular */
279
#define ADC_DUALMODE_INTERLFAST               ((uint32_t)(                    ADC_CR1_DUALMOD_2 | ADC_CR1_DUALMOD_1 | ADC_CR1_DUALMOD_0)) /*!< ADC dual mode enabled: Fast interleaved mode, on group regular (delay between ADC sampling phases: 7 ADC clock cycles (equivalent to parameter "TwoSamplingDelay" set to "ADC_TWOSAMPLINGDELAY_7CYCLES" on other STM32 devices)) */
280
#define ADC_DUALMODE_INTERLSLOW               ((uint32_t)(ADC_CR1_DUALMOD_3                                                            )) /*!< ADC dual mode enabled: Slow interleaved mode, on group regular (delay between ADC sampling phases: 14 ADC clock cycles (equivalent to parameter "TwoSamplingDelay" set to "ADC_TWOSAMPLINGDELAY_7CYCLES" on other STM32 devices)) */
281
#define ADC_DUALMODE_ALTERTRIG                ((uint32_t)(ADC_CR1_DUALMOD_3 |                                         ADC_CR1_DUALMOD_0)) /*!< ADC dual mode enabled: Alternate trigger mode, on group injected */
282
/**
283
  * @}
284
  */
285
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
286
 
287
/**
288
  * @}
289
  */
290
 
291
 
292
/* Private constants ---------------------------------------------------------*/
293
 
294
/** @addtogroup ADCEx_Private_Constants ADCEx Private Constants
295
  * @{
296
  */
297
 
298
/** @defgroup ADCEx_Internal_HAL_driver_Ext_trig_src_Regular ADC Extended Internal HAL driver trigger selection for regular group
299
  * @{
300
  */
301
/* List of external triggers of regular group for ADC1, ADC2, ADC3 (if ADC    */
302
/* instance is available on the selected device).                             */
303
/* (used internally by HAL driver. To not use into HAL structure parameters)  */
304
 
305
/* External triggers of regular group for ADC1&ADC2 (if ADCx available) */
306
#define ADC1_2_EXTERNALTRIG_T1_CC1                       0x00000000U
307
#define ADC1_2_EXTERNALTRIG_T1_CC2           ((uint32_t)(                                      ADC_CR2_EXTSEL_0))
308
#define ADC1_2_EXTERNALTRIG_T2_CC2           ((uint32_t)(                   ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
309
#define ADC1_2_EXTERNALTRIG_T3_TRGO          ((uint32_t)(ADC_CR2_EXTSEL_2                                      ))
310
#define ADC1_2_EXTERNALTRIG_T4_CC4           ((uint32_t)(ADC_CR2_EXTSEL_2 |                    ADC_CR2_EXTSEL_0))
311
#define ADC1_2_EXTERNALTRIG_EXT_IT11         ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1                   ))
312
#if defined (STM32F101xE) || defined (STM32F103xE) || defined (STM32F103xG)
313
/* Note: TIM8_TRGO is available on ADC1 and ADC2 only in high-density and     */
314
/* XL-density devices.                                                        */
315
#define ADC1_2_EXTERNALTRIG_T8_TRGO          ADC1_2_EXTERNALTRIG_EXT_IT11
316
#endif
317
 
318
#if defined (STM32F103xE) || defined (STM32F103xG)
319
/* External triggers of regular group for ADC3 */
320
#define ADC3_EXTERNALTRIG_T3_CC1             ADC1_2_EXTERNALTRIG_T1_CC1
321
#define ADC3_EXTERNALTRIG_T2_CC3             ADC1_2_EXTERNALTRIG_T1_CC2
322
#define ADC3_EXTERNALTRIG_T8_CC1             ADC1_2_EXTERNALTRIG_T2_CC2
323
#define ADC3_EXTERNALTRIG_T8_TRGO            ADC1_2_EXTERNALTRIG_T3_TRGO
324
#define ADC3_EXTERNALTRIG_T5_CC1             ADC1_2_EXTERNALTRIG_T4_CC4
325
#define ADC3_EXTERNALTRIG_T5_CC3             ADC1_2_EXTERNALTRIG_EXT_IT11
326
#endif
327
 
328
/* External triggers of regular group for ADC1&ADC2&ADC3 (if ADCx available) */
329
#define ADC1_2_3_EXTERNALTRIG_T1_CC3         ((uint32_t)(                   ADC_CR2_EXTSEL_1                   ))
330
#define ADC1_2_3_SWSTART                     ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
331
/**
332
  * @}
333
  */
334
 
335
/** @defgroup ADCEx_Internal_HAL_driver_Ext_trig_src_Injected ADC Extended Internal HAL driver trigger selection for injected group
336
  * @{
337
  */
338
/* List of external triggers of injected group for ADC1, ADC2, ADC3 (if ADC    */
339
/* instance is available on the selected device).                             */
340
/* (used internally by HAL driver. To not use into HAL structure parameters)  */
341
 
342
/* External triggers of injected group for ADC1&ADC2 (if ADCx available) */
343
#define ADC1_2_EXTERNALTRIGINJEC_T2_TRGO          ((uint32_t)(                    ADC_CR2_JEXTSEL_1                    ))
344
#define ADC1_2_EXTERNALTRIGINJEC_T2_CC1           ((uint32_t)(                    ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0))
345
#define ADC1_2_EXTERNALTRIGINJEC_T3_CC4           ((uint32_t)(ADC_CR2_JEXTSEL_2                                        ))
346
#define ADC1_2_EXTERNALTRIGINJEC_T4_TRGO          ((uint32_t)(ADC_CR2_JEXTSEL_2 |                     ADC_CR2_JEXTSEL_0))
347
#define ADC1_2_EXTERNALTRIGINJEC_EXT_IT15         ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1                    ))
348
#if defined (STM32F101xE) || defined (STM32F103xE) || defined (STM32F103xG)
349
/* Note: TIM8_CC4 is available on ADC1 and ADC2 only in high-density and      */
350
/* XL-density devices.                                                        */
351
#define ADC1_2_EXTERNALTRIGINJEC_T8_CC4           ADC1_2_EXTERNALTRIGINJEC_EXT_IT15
352
#endif
353
 
354
#if defined (STM32F103xE) || defined (STM32F103xG)
355
/* External triggers of injected group for ADC3 */
356
#define ADC3_EXTERNALTRIGINJEC_T4_CC3             ADC1_2_EXTERNALTRIGINJEC_T2_TRGO
357
#define ADC3_EXTERNALTRIGINJEC_T8_CC2             ADC1_2_EXTERNALTRIGINJEC_T2_CC1
358
#define ADC3_EXTERNALTRIGINJEC_T8_CC4             ADC1_2_EXTERNALTRIGINJEC_T3_CC4
359
#define ADC3_EXTERNALTRIGINJEC_T5_TRGO            ADC1_2_EXTERNALTRIGINJEC_T4_TRGO
360
#define ADC3_EXTERNALTRIGINJEC_T5_CC4             ADC1_2_EXTERNALTRIGINJEC_EXT_IT15
361
#endif /* STM32F103xE || defined STM32F103xG */
362
 
363
/* External triggers of injected group for ADC1&ADC2&ADC3 (if ADCx available) */
364
#define ADC1_2_3_EXTERNALTRIGINJEC_T1_TRGO                    0x00000000U
365
#define ADC1_2_3_EXTERNALTRIGINJEC_T1_CC4         ((uint32_t)(                                        ADC_CR2_JEXTSEL_0))
366
#define ADC1_2_3_JSWSTART                         ((uint32_t)(ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0))
367
/**
368
  * @}
369
  */
370
 
371
/**
372
  * @}
373
  */
374
 
375
 
376
/* Exported macro ------------------------------------------------------------*/
377
 
378
/* Private macro -------------------------------------------------------------*/
379
 
380
/** @defgroup ADCEx_Private_Macro ADCEx Private Macro
381
  * @{
382
  */
383
/* Macro reserved for internal HAL driver usage, not intended to be used in   */
384
/* code of final user.                                                        */
385
 
386
 
387
/**
388
  * @brief For devices with 3 ADCs: Defines the external trigger source
389
  *        for regular group according to ADC into common group ADC1&ADC2 or
390
  *        ADC3 (some triggers with same source have different value to
391
  *        be programmed into ADC EXTSEL bits of CR2 register).
392
  *        For devices with 2 ADCs or less: this macro makes no change.
393
  * @param __HANDLE__: ADC handle
394
  * @param __EXT_TRIG_CONV__: External trigger selected for regular group.
395
  * @retval External trigger to be programmed into EXTSEL bits of CR2 register
396
  */
397
#if defined (STM32F103xE) || defined (STM32F103xG)
398
#define ADC_CFGR_EXTSEL(__HANDLE__, __EXT_TRIG_CONV__)                         \
399
 (( (((__HANDLE__)->Instance) == ADC3)                                         \
400
  )?                                                                           \
401
   ( ( (__EXT_TRIG_CONV__) == ADC_EXTERNALTRIGCONV_T8_TRGO                     \
402
     )?                                                                        \
403
      (ADC3_EXTERNALTRIG_T8_TRGO)                                              \
404
      :                                                                        \
405
      (__EXT_TRIG_CONV__)                                                      \
406
   )                                                                           \
407
   :                                                                           \
408
   (__EXT_TRIG_CONV__)                                                         \
409
 )
410
#else
411
#define ADC_CFGR_EXTSEL(__HANDLE__, __EXT_TRIG_CONV__)                         \
412
  (__EXT_TRIG_CONV__)
413
#endif /* STM32F103xE || STM32F103xG */
414
 
415
/**
416
  * @brief For devices with 3 ADCs: Defines the external trigger source
417
  *        for injected group according to ADC into common group ADC1&ADC2 or
418
  *        ADC3 (some triggers with same source have different value to
419
  *        be programmed into ADC JEXTSEL bits of CR2 register).
420
  *        For devices with 2 ADCs or less: this macro makes no change.
421
  * @param __HANDLE__: ADC handle
422
  * @param __EXT_TRIG_INJECTCONV__: External trigger selected for injected group.
423
  * @retval External trigger to be programmed into JEXTSEL bits of CR2 register
424
  */
425
#if defined (STM32F103xE) || defined (STM32F103xG)
426
#define ADC_CFGR_JEXTSEL(__HANDLE__, __EXT_TRIG_INJECTCONV__)                  \
427
 (( (((__HANDLE__)->Instance) == ADC3)                                         \
428
  )?                                                                           \
429
   ( ( (__EXT_TRIG_INJECTCONV__) == ADC_EXTERNALTRIGINJECCONV_T8_CC4           \
430
     )?                                                                        \
431
      (ADC3_EXTERNALTRIGINJEC_T8_CC4)                                          \
432
      :                                                                        \
433
      (__EXT_TRIG_INJECTCONV__)                                                \
434
   )                                                                           \
435
   :                                                                           \
436
   (__EXT_TRIG_INJECTCONV__)                                                   \
437
 )
438
#else
439
#define ADC_CFGR_JEXTSEL(__HANDLE__, __EXT_TRIG_INJECTCONV__)                  \
440
   (__EXT_TRIG_INJECTCONV__)
441
#endif /* STM32F103xE || STM32F103xG */
442
 
443
 
444
/**
445
  * @brief Verification if multimode is enabled for the selected ADC (multimode ADC master or ADC slave) (applicable for devices with several ADCs)
446
  * @param __HANDLE__: ADC handle
447
  * @retval Multimode state: RESET if multimode is disabled, other value if multimode is enabled
448
  */
449
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
450
#define ADC_MULTIMODE_IS_ENABLE(__HANDLE__)                                    \
451
 (( (((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC2)   \
452
  )?                                                                           \
453
   (ADC1->CR1 & ADC_CR1_DUALMOD)                                               \
454
   :                                                                           \
455
   (RESET)                                                                     \
456
 )
457
#else
458
#define ADC_MULTIMODE_IS_ENABLE(__HANDLE__)                                    \
459
  (RESET)
460
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
461
 
462
/**
463
  * @brief Verification of condition for ADC start conversion: ADC must be in non-multimode, or multimode with handle of ADC master (applicable for devices with several ADCs)
464
  * @param __HANDLE__: ADC handle
465
  * @retval None
466
  */
467
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
468
#define ADC_NONMULTIMODE_OR_MULTIMODEMASTER(__HANDLE__)                        \
469
  (( (((__HANDLE__)->Instance) == ADC2)                                        \
470
   )?                                                                          \
471
    ((ADC1->CR1 & ADC_CR1_DUALMOD) == RESET)                                   \
472
    :                                                                          \
473
    (!RESET)                                                                   \
474
  )
475
#else
476
#define ADC_NONMULTIMODE_OR_MULTIMODEMASTER(__HANDLE__)                        \
477
  (!RESET)
478
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
479
 
480
/**
481
  * @brief Check ADC multimode setting: In case of multimode, check whether ADC master of the selected ADC has feature auto-injection enabled (applicable for devices with several ADCs)
482
  * @param __HANDLE__: ADC handle
483
  * @retval None
484
  */
485
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
486
#define ADC_MULTIMODE_AUTO_INJECTED(__HANDLE__)                                \
487
  (( (((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC2)  \
488
   )?                                                                          \
489
    (ADC1->CR1 & ADC_CR1_JAUTO)                                                \
490
    :                                                                          \
491
    (RESET)                                                                    \
492
  )
493
#else
494
#define ADC_MULTIMODE_AUTO_INJECTED(__HANDLE__)                                \
495
  (RESET)
496
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
497
 
498
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
499
/**
500
  * @brief Set handle of the other ADC sharing the common multimode settings
501
  * @param __HANDLE__: ADC handle
502
  * @param __HANDLE_OTHER_ADC__: other ADC handle
503
  * @retval None
504
  */
505
#define ADC_COMMON_ADC_OTHER(__HANDLE__, __HANDLE_OTHER_ADC__)                 \
506
  ((__HANDLE_OTHER_ADC__)->Instance = ADC2)
507
 
508
/**
509
  * @brief Set handle of the ADC slave associated to the ADC master
510
  * On STM32F1 devices, ADC slave is always ADC2 (this can be different
511
  * on other STM32 devices)
512
  * @param __HANDLE_MASTER__: ADC master handle
513
  * @param __HANDLE_SLAVE__: ADC slave handle
514
  * @retval None
515
  */
516
#define ADC_MULTI_SLAVE(__HANDLE_MASTER__, __HANDLE_SLAVE__)                   \
517
  ((__HANDLE_SLAVE__)->Instance = ADC2)
518
 
519
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
520
 
521
#define IS_ADC_INJECTED_RANK(CHANNEL) (((CHANNEL) == ADC_INJECTED_RANK_1) || \
522
                                       ((CHANNEL) == ADC_INJECTED_RANK_2) || \
523
                                       ((CHANNEL) == ADC_INJECTED_RANK_3) || \
524
                                       ((CHANNEL) == ADC_INJECTED_RANK_4))
525
 
526
#define IS_ADC_EXTTRIGINJEC_EDGE(EDGE) (((EDGE) == ADC_EXTERNALTRIGINJECCONV_EDGE_NONE)  || \
527
                                        ((EDGE) == ADC_EXTERNALTRIGINJECCONV_EDGE_RISING))
528
 
529
/** @defgroup ADCEx_injected_nb_conv_verification ADCEx injected nb conv verification
530
  * @{
531
  */
532
#define IS_ADC_INJECTED_NB_CONV(LENGTH)  (((LENGTH) >= 1U) && ((LENGTH) <= 4U))
533
/**
534
  * @}
535
  */
536
 
537
#if defined (STM32F100xB) || defined (STM32F100xE) || defined (STM32F101x6) || defined (STM32F101xB) || defined (STM32F102x6) || defined (STM32F102xB) || defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC)
538
#define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1)    || \
539
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2)    || \
540
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2)    || \
541
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO)   || \
542
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4)    || \
543
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11)  || \
544
                                 ((REGTRIG) == ADC_SOFTWARE_START))
545
#endif
546
#if defined (STM32F101xE)
547
#define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1)    || \
548
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2)    || \
549
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2)    || \
550
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO)   || \
551
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4)    || \
552
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11)  || \
553
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_TRGO)   || \
554
                                 ((REGTRIG) == ADC_SOFTWARE_START))
555
#endif
556
#if defined (STM32F101xG)
557
#define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1)    || \
558
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2)    || \
559
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2)    || \
560
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO)   || \
561
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4)    || \
562
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11)  || \
563
                                 ((REGTRIG) == ADC_SOFTWARE_START))
564
#endif
565
#if defined (STM32F103xE) || defined (STM32F103xG)
566
#define IS_ADC_EXTTRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1)    || \
567
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2)    || \
568
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2)    || \
569
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO)   || \
570
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4)    || \
571
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_EXT_IT11)  || \
572
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_CC1)    || \
573
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC3)    || \
574
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_CC1)    || \
575
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T5_CC1)    || \
576
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T5_CC3)    || \
577
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC3)    || \
578
                                 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_TRGO)   || \
579
                                 ((REGTRIG) == ADC_SOFTWARE_START))
580
#endif
581
 
582
#if defined (STM32F100xB) || defined (STM32F100xE) || defined (STM32F101x6) || defined (STM32F101xB) || defined (STM32F102x6) || defined (STM32F102xB) || defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC)
583
#define IS_ADC_EXTTRIGINJEC(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO)  || \
584
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1)   || \
585
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4)   || \
586
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO)  || \
587
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
588
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4)   || \
589
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO)  || \
590
                                      ((REGTRIG) == ADC_INJECTED_SOFTWARE_START))
591
#endif
592
#if defined (STM32F101xE)
593
#define IS_ADC_EXTTRIGINJEC(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO)  || \
594
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1)   || \
595
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4)   || \
596
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO)  || \
597
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
598
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4)   || \
599
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO)  || \
600
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC4)   || \
601
                                      ((REGTRIG) == ADC_INJECTED_SOFTWARE_START))
602
#endif
603
#if defined (STM32F101xG)
604
#define IS_ADC_EXTTRIGINJEC(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO)  || \
605
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1)   || \
606
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4)   || \
607
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO)  || \
608
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
609
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4)   || \
610
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO)  || \
611
                                      ((REGTRIG) == ADC_INJECTED_SOFTWARE_START))
612
#endif
613
#if defined (STM32F103xE) || defined (STM32F103xG)
614
#define IS_ADC_EXTTRIGINJEC(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_TRGO)  || \
615
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T2_CC1)   || \
616
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T3_CC4)   || \
617
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_TRGO)  || \
618
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T5_CC4)   || \
619
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_EXT_IT15) || \
620
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T4_CC3)   || \
621
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC2)   || \
622
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T5_TRGO)  || \
623
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T5_CC4)   || \
624
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_CC4)   || \
625
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T1_TRGO)  || \
626
                                      ((REGTRIG) == ADC_EXTERNALTRIGINJECCONV_T8_CC4)   || \
627
                                      ((REGTRIG) == ADC_INJECTED_SOFTWARE_START))
628
#endif
629
 
630
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
631
#define IS_ADC_MODE(MODE) (((MODE) == ADC_MODE_INDEPENDENT)                || \
632
                           ((MODE) == ADC_DUALMODE_REGSIMULT_INJECSIMULT)  || \
633
                           ((MODE) == ADC_DUALMODE_REGSIMULT_ALTERTRIG)    || \
634
                           ((MODE) == ADC_DUALMODE_INJECSIMULT_INTERLFAST) || \
635
                           ((MODE) == ADC_DUALMODE_INJECSIMULT_INTERLSLOW) || \
636
                           ((MODE) == ADC_DUALMODE_INJECSIMULT)            || \
637
                           ((MODE) == ADC_DUALMODE_REGSIMULT)              || \
638
                           ((MODE) == ADC_DUALMODE_INTERLFAST)             || \
639
                           ((MODE) == ADC_DUALMODE_INTERLSLOW)             || \
640
                           ((MODE) == ADC_DUALMODE_ALTERTRIG) )
641
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
642
 
643
/**
644
  * @}
645
  */      
646
 
647
 
648
 
649
 
650
 
651
 
652
/* Exported functions --------------------------------------------------------*/
653
/** @addtogroup ADCEx_Exported_Functions
654
  * @{
655
  */
656
 
657
/* IO operation functions  *****************************************************/
658
/** @addtogroup ADCEx_Exported_Functions_Group1
659
  * @{
660
  */
661
 
662
/* ADC calibration */
663
HAL_StatusTypeDef       HAL_ADCEx_Calibration_Start(ADC_HandleTypeDef* hadc);
664
 
665
/* Blocking mode: Polling */
666
HAL_StatusTypeDef       HAL_ADCEx_InjectedStart(ADC_HandleTypeDef* hadc);
667
HAL_StatusTypeDef       HAL_ADCEx_InjectedStop(ADC_HandleTypeDef* hadc);
668
HAL_StatusTypeDef       HAL_ADCEx_InjectedPollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
669
 
670
/* Non-blocking mode: Interruption */
671
HAL_StatusTypeDef       HAL_ADCEx_InjectedStart_IT(ADC_HandleTypeDef* hadc);
672
HAL_StatusTypeDef       HAL_ADCEx_InjectedStop_IT(ADC_HandleTypeDef* hadc);
673
 
674
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
675
/* ADC multimode */
676
HAL_StatusTypeDef       HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef *hadc, uint32_t *pData, uint32_t Length);
677
HAL_StatusTypeDef       HAL_ADCEx_MultiModeStop_DMA(ADC_HandleTypeDef *hadc);
678
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
679
 
680
/* ADC retrieve conversion value intended to be used with polling or interruption */
681
uint32_t                HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t InjectedRank);
682
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
683
uint32_t                HAL_ADCEx_MultiModeGetValue(ADC_HandleTypeDef *hadc);
684
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
685
 
686
/* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption) */
687
void                    HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc);
688
/**
689
  * @}
690
  */
691
 
692
 
693
/* Peripheral Control functions ***********************************************/
694
/** @addtogroup ADCEx_Exported_Functions_Group2
695
  * @{
696
  */
697
HAL_StatusTypeDef       HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef* hadc,ADC_InjectionConfTypeDef* sConfigInjected);
698
#if defined (STM32F103x6) || defined (STM32F103xB) || defined (STM32F105xC) || defined (STM32F107xC) || defined (STM32F103xE) || defined (STM32F103xG)
699
HAL_StatusTypeDef       HAL_ADCEx_MultiModeConfigChannel(ADC_HandleTypeDef *hadc, ADC_MultiModeTypeDef *multimode);
700
#endif /* defined STM32F103x6 || defined STM32F103xB || defined STM32F105xC || defined STM32F107xC || defined STM32F103xE || defined STM32F103xG */
701
/**
702
  * @}
703
  */
704
 
705
 
706
/**
707
  * @}
708
  */
709
 
710
 
711
/**
712
  * @}
713
  */
714
 
715
/**
716
  * @}
717
  */
718
 
719
#ifdef __cplusplus
720
}
721
#endif
722
 
723
#endif /* __STM32F1xx_HAL_ADC_EX_H */
724
 
725
 
726
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/