2 ******************************************************************************
\r
3 * @file stm32l1xx_adc.h
\r
4 * @author MCD Application Team
\r
6 * @date 05-March-2012
\r
7 * @brief This file contains all the functions prototypes for the ADC firmware
\r
9 ******************************************************************************
\r
12 * <h2><center>© COPYRIGHT 2012 STMicroelectronics</center></h2>
\r
14 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
\r
15 * You may not use this file except in compliance with the License.
\r
16 * You may obtain a copy of the License at:
\r
18 * http://www.st.com/software_license_agreement_liberty_v2
\r
20 * Unless required by applicable law or agreed to in writing, software
\r
21 * distributed under the License is distributed on an "AS IS" BASIS,
\r
22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
23 * See the License for the specific language governing permissions and
\r
24 * limitations under the License.
\r
26 ******************************************************************************
\r
29 /* Define to prevent recursive inclusion -------------------------------------*/
\r
30 #ifndef __STM32L1xx_ADC_H
\r
31 #define __STM32L1xx_ADC_H
\r
37 /* Includes ------------------------------------------------------------------*/
\r
38 #include "stm32l1xx.h"
\r
40 /** @addtogroup STM32L1xx_StdPeriph_Driver
\r
48 /* Exported types ------------------------------------------------------------*/
\r
51 * @brief ADC Init structure definition
\r
56 uint32_t ADC_Resolution; /*!< Selects the resolution of the conversion.
\r
57 This parameter can be a value of @ref ADC_Resolution */
\r
59 FunctionalState ADC_ScanConvMode; /*!< Specifies whether the conversion is performed in
\r
60 Scan (multichannel) or Single (one channel) mode.
\r
61 This parameter can be set to ENABLE or DISABLE */
\r
63 FunctionalState ADC_ContinuousConvMode; /*!< Specifies whether the conversion is performed in
\r
64 Continuous or Single mode.
\r
65 This parameter can be set to ENABLE or DISABLE. */
\r
67 uint32_t ADC_ExternalTrigConvEdge; /*!< Selects the external trigger Edge and enables the
\r
68 trigger of a regular group. This parameter can be a value
\r
69 of @ref ADC_external_trigger_edge_for_regular_channels_conversion */
\r
71 uint32_t ADC_ExternalTrigConv; /*!< Defines the external trigger used to start the analog
\r
72 to digital conversion of regular channels. This parameter
\r
73 can be a value of @ref ADC_external_trigger_sources_for_regular_channels_conversion */
\r
75 uint32_t ADC_DataAlign; /*!< Specifies whether the ADC data alignment is left or right.
\r
76 This parameter can be a value of @ref ADC_data_align */
\r
78 uint8_t ADC_NbrOfConversion; /*!< Specifies the number of ADC conversions that will be done
\r
79 using the sequencer for regular channel group.
\r
80 This parameter must range from 1 to 27. */
\r
85 uint32_t ADC_Prescaler; /*!< Selects the ADC prescaler.
\r
86 This parameter can be a value
\r
87 of @ref ADC_Prescaler */
\r
88 }ADC_CommonInitTypeDef;
\r
90 /* Exported constants --------------------------------------------------------*/
\r
92 /** @defgroup ADC_Exported_Constants
\r
95 #define IS_ADC_ALL_PERIPH(PERIPH) ((PERIPH) == ADC1)
\r
96 #define IS_ADC_DMA_PERIPH(PERIPH) ((PERIPH) == ADC1)
\r
98 /** @defgroup ADC_Power_down_during_Idle_and_or_Delay_phase
\r
101 #define ADC_PowerDown_Delay ((uint32_t)0x00010000)
\r
102 #define ADC_PowerDown_Idle ((uint32_t)0x00020000)
\r
103 #define ADC_PowerDown_Idle_Delay ((uint32_t)0x00030000)
\r
105 #define IS_ADC_POWER_DOWN(DWON) (((DWON) == ADC_PowerDown_Delay) || \
\r
106 ((DWON) == ADC_PowerDown_Idle) || \
\r
107 ((DWON) == ADC_PowerDown_Idle_Delay))
\r
113 /** @defgroup ADC_Prescaler
\r
116 #define ADC_Prescaler_Div1 ((uint32_t)0x00000000)
\r
117 #define ADC_Prescaler_Div2 ((uint32_t)0x00010000)
\r
118 #define ADC_Prescaler_Div4 ((uint32_t)0x00020000)
\r
120 #define IS_ADC_PRESCALER(PRESCALER) (((PRESCALER) == ADC_Prescaler_Div1) || \
\r
121 ((PRESCALER) == ADC_Prescaler_Div2) || \
\r
122 ((PRESCALER) == ADC_Prescaler_Div4))
\r
129 /** @defgroup ADC_Resolution
\r
132 #define ADC_Resolution_12b ((uint32_t)0x00000000)
\r
133 #define ADC_Resolution_10b ((uint32_t)0x01000000)
\r
134 #define ADC_Resolution_8b ((uint32_t)0x02000000)
\r
135 #define ADC_Resolution_6b ((uint32_t)0x03000000)
\r
137 #define IS_ADC_RESOLUTION(RESOLUTION) (((RESOLUTION) == ADC_Resolution_12b) || \
\r
138 ((RESOLUTION) == ADC_Resolution_10b) || \
\r
139 ((RESOLUTION) == ADC_Resolution_8b) || \
\r
140 ((RESOLUTION) == ADC_Resolution_6b))
\r
146 /** @defgroup ADC_external_trigger_edge_for_regular_channels_conversion
\r
149 #define ADC_ExternalTrigConvEdge_None ((uint32_t)0x00000000)
\r
150 #define ADC_ExternalTrigConvEdge_Rising ((uint32_t)0x10000000)
\r
151 #define ADC_ExternalTrigConvEdge_Falling ((uint32_t)0x20000000)
\r
152 #define ADC_ExternalTrigConvEdge_RisingFalling ((uint32_t)0x30000000)
\r
154 #define IS_ADC_EXT_TRIG_EDGE(EDGE) (((EDGE) == ADC_ExternalTrigConvEdge_None) || \
\r
155 ((EDGE) == ADC_ExternalTrigConvEdge_Rising) || \
\r
156 ((EDGE) == ADC_ExternalTrigConvEdge_Falling) || \
\r
157 ((EDGE) == ADC_ExternalTrigConvEdge_RisingFalling))
\r
162 /** @defgroup ADC_external_trigger_sources_for_regular_channels_conversion
\r
167 #define ADC_ExternalTrigConv_T2_CC3 ((uint32_t)0x02000000)
\r
168 #define ADC_ExternalTrigConv_T2_CC2 ((uint32_t)0x03000000)
\r
169 #define ADC_ExternalTrigConv_T2_TRGO ((uint32_t)0x06000000)
\r
172 #define ADC_ExternalTrigConv_T3_CC1 ((uint32_t)0x07000000)
\r
173 #define ADC_ExternalTrigConv_T3_CC3 ((uint32_t)0x08000000)
\r
174 #define ADC_ExternalTrigConv_T3_TRGO ((uint32_t)0x04000000)
\r
177 #define ADC_ExternalTrigConv_T4_CC4 ((uint32_t)0x05000000)
\r
178 #define ADC_ExternalTrigConv_T4_TRGO ((uint32_t)0x09000000)
\r
181 #define ADC_ExternalTrigConv_T6_TRGO ((uint32_t)0x0A000000)
\r
184 #define ADC_ExternalTrigConv_T9_CC2 ((uint32_t)0x00000000)
\r
185 #define ADC_ExternalTrigConv_T9_TRGO ((uint32_t)0x01000000)
\r
188 #define ADC_ExternalTrigConv_Ext_IT11 ((uint32_t)0x0F000000)
\r
190 #define IS_ADC_EXT_TRIG(REGTRIG) (((REGTRIG) == ADC_ExternalTrigConv_T9_CC2) || \
\r
191 ((REGTRIG) == ADC_ExternalTrigConv_T9_TRGO) || \
\r
192 ((REGTRIG) == ADC_ExternalTrigConv_T2_CC3) || \
\r
193 ((REGTRIG) == ADC_ExternalTrigConv_T2_CC2) || \
\r
194 ((REGTRIG) == ADC_ExternalTrigConv_T3_TRGO) || \
\r
195 ((REGTRIG) == ADC_ExternalTrigConv_T4_CC4) || \
\r
196 ((REGTRIG) == ADC_ExternalTrigConv_T2_TRGO) || \
\r
197 ((REGTRIG) == ADC_ExternalTrigConv_T3_CC1) || \
\r
198 ((REGTRIG) == ADC_ExternalTrigConv_T3_CC3) || \
\r
199 ((REGTRIG) == ADC_ExternalTrigConv_T4_TRGO) || \
\r
200 ((REGTRIG) == ADC_ExternalTrigConv_T6_TRGO) || \
\r
201 ((REGTRIG) == ADC_ExternalTrigConv_Ext_IT11))
\r
206 /** @defgroup ADC_data_align
\r
210 #define ADC_DataAlign_Right ((uint32_t)0x00000000)
\r
211 #define ADC_DataAlign_Left ((uint32_t)0x00000800)
\r
213 #define IS_ADC_DATA_ALIGN(ALIGN) (((ALIGN) == ADC_DataAlign_Right) || \
\r
214 ((ALIGN) == ADC_DataAlign_Left))
\r
219 /** @defgroup ADC_channels
\r
222 /* ADC Bank A Channels -------------------------------------------------------*/
\r
223 #define ADC_Channel_0 ((uint8_t)0x00)
\r
224 #define ADC_Channel_1 ((uint8_t)0x01)
\r
225 #define ADC_Channel_2 ((uint8_t)0x02)
\r
226 #define ADC_Channel_3 ((uint8_t)0x03)
\r
228 #define ADC_Channel_6 ((uint8_t)0x06)
\r
229 #define ADC_Channel_7 ((uint8_t)0x07)
\r
230 #define ADC_Channel_8 ((uint8_t)0x08)
\r
231 #define ADC_Channel_9 ((uint8_t)0x09)
\r
232 #define ADC_Channel_10 ((uint8_t)0x0A)
\r
233 #define ADC_Channel_11 ((uint8_t)0x0B)
\r
234 #define ADC_Channel_12 ((uint8_t)0x0C)
\r
237 /* ADC Bank B Channels -------------------------------------------------------*/
\r
238 #define ADC_Channel_0b ADC_Channel_0
\r
239 #define ADC_Channel_1b ADC_Channel_1
\r
240 #define ADC_Channel_2b ADC_Channel_2
\r
241 #define ADC_Channel_3b ADC_Channel_3
\r
243 #define ADC_Channel_6b ADC_Channel_6
\r
244 #define ADC_Channel_7b ADC_Channel_7
\r
245 #define ADC_Channel_8b ADC_Channel_8
\r
246 #define ADC_Channel_9b ADC_Channel_9
\r
247 #define ADC_Channel_10b ADC_Channel_10
\r
248 #define ADC_Channel_11b ADC_Channel_11
\r
249 #define ADC_Channel_12b ADC_Channel_12
\r
251 /* ADC Common Channels (ADC Bank A and B) ------------------------------------*/
\r
252 #define ADC_Channel_4 ((uint8_t)0x04)
\r
253 #define ADC_Channel_5 ((uint8_t)0x05)
\r
255 #define ADC_Channel_13 ((uint8_t)0x0D)
\r
256 #define ADC_Channel_14 ((uint8_t)0x0E)
\r
257 #define ADC_Channel_15 ((uint8_t)0x0F)
\r
258 #define ADC_Channel_16 ((uint8_t)0x10)
\r
259 #define ADC_Channel_17 ((uint8_t)0x11)
\r
260 #define ADC_Channel_18 ((uint8_t)0x12)
\r
261 #define ADC_Channel_19 ((uint8_t)0x13)
\r
262 #define ADC_Channel_20 ((uint8_t)0x14)
\r
263 #define ADC_Channel_21 ((uint8_t)0x15)
\r
264 #define ADC_Channel_22 ((uint8_t)0x16)
\r
265 #define ADC_Channel_23 ((uint8_t)0x17)
\r
266 #define ADC_Channel_24 ((uint8_t)0x18)
\r
267 #define ADC_Channel_25 ((uint8_t)0x19)
\r
269 #define ADC_Channel_27 ((uint8_t)0x1B)
\r
270 #define ADC_Channel_28 ((uint8_t)0x1C)
\r
271 #define ADC_Channel_29 ((uint8_t)0x1D)
\r
272 #define ADC_Channel_30 ((uint8_t)0x1E)
\r
273 #define ADC_Channel_31 ((uint8_t)0x1F)
\r
275 #define ADC_Channel_TempSensor ((uint8_t)ADC_Channel_16)
\r
276 #define ADC_Channel_Vrefint ((uint8_t)ADC_Channel_17)
\r
278 #define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) == ADC_Channel_0) || ((CHANNEL) == ADC_Channel_1) || \
\r
279 ((CHANNEL) == ADC_Channel_2) || ((CHANNEL) == ADC_Channel_3) || \
\r
280 ((CHANNEL) == ADC_Channel_4) || ((CHANNEL) == ADC_Channel_5) || \
\r
281 ((CHANNEL) == ADC_Channel_6) || ((CHANNEL) == ADC_Channel_7) || \
\r
282 ((CHANNEL) == ADC_Channel_8) || ((CHANNEL) == ADC_Channel_9) || \
\r
283 ((CHANNEL) == ADC_Channel_10) || ((CHANNEL) == ADC_Channel_11) || \
\r
284 ((CHANNEL) == ADC_Channel_12) || ((CHANNEL) == ADC_Channel_13) || \
\r
285 ((CHANNEL) == ADC_Channel_14) || ((CHANNEL) == ADC_Channel_15) || \
\r
286 ((CHANNEL) == ADC_Channel_16) || ((CHANNEL) == ADC_Channel_17) || \
\r
287 ((CHANNEL) == ADC_Channel_18) || ((CHANNEL) == ADC_Channel_19) || \
\r
288 ((CHANNEL) == ADC_Channel_20) || ((CHANNEL) == ADC_Channel_21) || \
\r
289 ((CHANNEL) == ADC_Channel_22) || ((CHANNEL) == ADC_Channel_23) || \
\r
290 ((CHANNEL) == ADC_Channel_24) || ((CHANNEL) == ADC_Channel_25) || \
\r
291 ((CHANNEL) == ADC_Channel_27) || ((CHANNEL) == ADC_Channel_28) || \
\r
292 ((CHANNEL) == ADC_Channel_29) || ((CHANNEL) == ADC_Channel_30) || \
\r
293 ((CHANNEL) == ADC_Channel_31))
\r
298 /** @defgroup ADC_sampling_times
\r
302 #define ADC_SampleTime_4Cycles ((uint8_t)0x00)
\r
303 #define ADC_SampleTime_9Cycles ((uint8_t)0x01)
\r
304 #define ADC_SampleTime_16Cycles ((uint8_t)0x02)
\r
305 #define ADC_SampleTime_24Cycles ((uint8_t)0x03)
\r
306 #define ADC_SampleTime_48Cycles ((uint8_t)0x04)
\r
307 #define ADC_SampleTime_96Cycles ((uint8_t)0x05)
\r
308 #define ADC_SampleTime_192Cycles ((uint8_t)0x06)
\r
309 #define ADC_SampleTime_384Cycles ((uint8_t)0x07)
\r
311 #define IS_ADC_SAMPLE_TIME(TIME) (((TIME) == ADC_SampleTime_4Cycles) || \
\r
312 ((TIME) == ADC_SampleTime_9Cycles) || \
\r
313 ((TIME) == ADC_SampleTime_16Cycles) || \
\r
314 ((TIME) == ADC_SampleTime_24Cycles) || \
\r
315 ((TIME) == ADC_SampleTime_48Cycles) || \
\r
316 ((TIME) == ADC_SampleTime_96Cycles) || \
\r
317 ((TIME) == ADC_SampleTime_192Cycles) || \
\r
318 ((TIME) == ADC_SampleTime_384Cycles))
\r
323 /** @defgroup ADC_Delay_length
\r
327 #define ADC_DelayLength_None ((uint8_t)0x00)
\r
328 #define ADC_DelayLength_Freeze ((uint8_t)0x10)
\r
329 #define ADC_DelayLength_7Cycles ((uint8_t)0x20)
\r
330 #define ADC_DelayLength_15Cycles ((uint8_t)0x30)
\r
331 #define ADC_DelayLength_31Cycles ((uint8_t)0x40)
\r
332 #define ADC_DelayLength_63Cycles ((uint8_t)0x50)
\r
333 #define ADC_DelayLength_127Cycles ((uint8_t)0x60)
\r
334 #define ADC_DelayLength_255Cycles ((uint8_t)0x70)
\r
336 #define IS_ADC_DELAY_LENGTH(LENGTH) (((LENGTH) == ADC_DelayLength_None) || \
\r
337 ((LENGTH) == ADC_DelayLength_Freeze) || \
\r
338 ((LENGTH) == ADC_DelayLength_7Cycles) || \
\r
339 ((LENGTH) == ADC_DelayLength_15Cycles) || \
\r
340 ((LENGTH) == ADC_DelayLength_31Cycles) || \
\r
341 ((LENGTH) == ADC_DelayLength_63Cycles) || \
\r
342 ((LENGTH) == ADC_DelayLength_127Cycles) || \
\r
343 ((LENGTH) == ADC_DelayLength_255Cycles))
\r
349 /** @defgroup ADC_external_trigger_edge_for_injected_channels_conversion
\r
352 #define ADC_ExternalTrigInjecConvEdge_None ((uint32_t)0x00000000)
\r
353 #define ADC_ExternalTrigInjecConvEdge_Rising ((uint32_t)0x00100000)
\r
354 #define ADC_ExternalTrigInjecConvEdge_Falling ((uint32_t)0x00200000)
\r
355 #define ADC_ExternalTrigInjecConvEdge_RisingFalling ((uint32_t)0x00300000)
\r
357 #define IS_ADC_EXT_INJEC_TRIG_EDGE(EDGE) (((EDGE) == ADC_ExternalTrigInjecConvEdge_None) || \
\r
358 ((EDGE) == ADC_ExternalTrigInjecConvEdge_Rising) || \
\r
359 ((EDGE) == ADC_ExternalTrigInjecConvEdge_Falling) || \
\r
360 ((EDGE) == ADC_ExternalTrigInjecConvEdge_RisingFalling))
\r
366 /** @defgroup ADC_external_trigger_sources_for_injected_channels_conversion
\r
372 #define ADC_ExternalTrigInjecConv_T2_TRGO ((uint32_t)0x00020000)
\r
373 #define ADC_ExternalTrigInjecConv_T2_CC1 ((uint32_t)0x00030000)
\r
376 #define ADC_ExternalTrigInjecConv_T3_CC4 ((uint32_t)0x00040000)
\r
379 #define ADC_ExternalTrigInjecConv_T4_TRGO ((uint32_t)0x00050000)
\r
380 #define ADC_ExternalTrigInjecConv_T4_CC1 ((uint32_t)0x00060000)
\r
381 #define ADC_ExternalTrigInjecConv_T4_CC2 ((uint32_t)0x00070000)
\r
382 #define ADC_ExternalTrigInjecConv_T4_CC3 ((uint32_t)0x00080000)
\r
385 #define ADC_ExternalTrigInjecConv_T7_TRGO ((uint32_t)0x000A0000)
\r
388 #define ADC_ExternalTrigInjecConv_T9_CC1 ((uint32_t)0x00000000)
\r
389 #define ADC_ExternalTrigInjecConv_T9_TRGO ((uint32_t)0x00010000)
\r
392 #define ADC_ExternalTrigInjecConv_T10_CC1 ((uint32_t)0x00090000)
\r
395 #define ADC_ExternalTrigInjecConv_Ext_IT15 ((uint32_t)0x000F0000)
\r
397 #define IS_ADC_EXT_INJEC_TRIG(INJTRIG) (((INJTRIG) == ADC_ExternalTrigInjecConv_T9_CC1) || \
\r
398 ((INJTRIG) == ADC_ExternalTrigInjecConv_T9_TRGO) || \
\r
399 ((INJTRIG) == ADC_ExternalTrigInjecConv_T2_TRGO) || \
\r
400 ((INJTRIG) == ADC_ExternalTrigInjecConv_T2_CC1) || \
\r
401 ((INJTRIG) == ADC_ExternalTrigInjecConv_T3_CC4) || \
\r
402 ((INJTRIG) == ADC_ExternalTrigInjecConv_T4_TRGO) || \
\r
403 ((INJTRIG) == ADC_ExternalTrigInjecConv_T4_CC1) || \
\r
404 ((INJTRIG) == ADC_ExternalTrigInjecConv_T4_CC2) || \
\r
405 ((INJTRIG) == ADC_ExternalTrigInjecConv_T4_CC3) || \
\r
406 ((INJTRIG) == ADC_ExternalTrigInjecConv_T10_CC1) || \
\r
407 ((INJTRIG) == ADC_ExternalTrigInjecConv_T7_TRGO) || \
\r
408 ((INJTRIG) == ADC_ExternalTrigInjecConv_Ext_IT15))
\r
413 /** @defgroup ADC_injected_channel_selection
\r
416 #define ADC_InjectedChannel_1 ((uint8_t)0x18)
\r
417 #define ADC_InjectedChannel_2 ((uint8_t)0x1C)
\r
418 #define ADC_InjectedChannel_3 ((uint8_t)0x20)
\r
419 #define ADC_InjectedChannel_4 ((uint8_t)0x24)
\r
421 #define IS_ADC_INJECTED_CHANNEL(CHANNEL) (((CHANNEL) == ADC_InjectedChannel_1) || \
\r
422 ((CHANNEL) == ADC_InjectedChannel_2) || \
\r
423 ((CHANNEL) == ADC_InjectedChannel_3) || \
\r
424 ((CHANNEL) == ADC_InjectedChannel_4))
\r
429 /** @defgroup ADC_analog_watchdog_selection
\r
433 #define ADC_AnalogWatchdog_SingleRegEnable ((uint32_t)0x00800200)
\r
434 #define ADC_AnalogWatchdog_SingleInjecEnable ((uint32_t)0x00400200)
\r
435 #define ADC_AnalogWatchdog_SingleRegOrInjecEnable ((uint32_t)0x00C00200)
\r
436 #define ADC_AnalogWatchdog_AllRegEnable ((uint32_t)0x00800000)
\r
437 #define ADC_AnalogWatchdog_AllInjecEnable ((uint32_t)0x00400000)
\r
438 #define ADC_AnalogWatchdog_AllRegAllInjecEnable ((uint32_t)0x00C00000)
\r
439 #define ADC_AnalogWatchdog_None ((uint32_t)0x00000000)
\r
441 #define IS_ADC_ANALOG_WATCHDOG(WATCHDOG) (((WATCHDOG) == ADC_AnalogWatchdog_SingleRegEnable) || \
\r
442 ((WATCHDOG) == ADC_AnalogWatchdog_SingleInjecEnable) || \
\r
443 ((WATCHDOG) == ADC_AnalogWatchdog_SingleRegOrInjecEnable) || \
\r
444 ((WATCHDOG) == ADC_AnalogWatchdog_AllRegEnable) || \
\r
445 ((WATCHDOG) == ADC_AnalogWatchdog_AllInjecEnable) || \
\r
446 ((WATCHDOG) == ADC_AnalogWatchdog_AllRegAllInjecEnable) || \
\r
447 ((WATCHDOG) == ADC_AnalogWatchdog_None))
\r
452 /** @defgroup ADC_interrupts_definition
\r
456 #define ADC_IT_AWD ((uint16_t)0x0106)
\r
457 #define ADC_IT_EOC ((uint16_t)0x0205)
\r
458 #define ADC_IT_JEOC ((uint16_t)0x0407)
\r
459 #define ADC_IT_OVR ((uint16_t)0x201A)
\r
461 #define IS_ADC_IT(IT) (((IT) == ADC_IT_AWD) || ((IT) == ADC_IT_EOC) || \
\r
462 ((IT) == ADC_IT_JEOC)|| ((IT) == ADC_IT_OVR))
\r
467 /** @defgroup ADC_flags_definition
\r
471 #define ADC_FLAG_AWD ((uint16_t)0x0001)
\r
472 #define ADC_FLAG_EOC ((uint16_t)0x0002)
\r
473 #define ADC_FLAG_JEOC ((uint16_t)0x0004)
\r
474 #define ADC_FLAG_JSTRT ((uint16_t)0x0008)
\r
475 #define ADC_FLAG_STRT ((uint16_t)0x0010)
\r
476 #define ADC_FLAG_OVR ((uint16_t)0x0020)
\r
477 #define ADC_FLAG_ADONS ((uint16_t)0x0040)
\r
478 #define ADC_FLAG_RCNR ((uint16_t)0x0100)
\r
479 #define ADC_FLAG_JCNR ((uint16_t)0x0200)
\r
481 #define IS_ADC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint16_t)0xFFC0) == 0x00) && ((FLAG) != 0x00))
\r
483 #define IS_ADC_GET_FLAG(FLAG) (((FLAG) == ADC_FLAG_AWD) || ((FLAG) == ADC_FLAG_EOC) || \
\r
484 ((FLAG) == ADC_FLAG_JEOC) || ((FLAG)== ADC_FLAG_JSTRT) || \
\r
485 ((FLAG) == ADC_FLAG_STRT) || ((FLAG)== ADC_FLAG_OVR) || \
\r
486 ((FLAG) == ADC_FLAG_ADONS) || ((FLAG)== ADC_FLAG_RCNR) || \
\r
487 ((FLAG) == ADC_FLAG_JCNR))
\r
492 /** @defgroup ADC_thresholds
\r
496 #define IS_ADC_THRESHOLD(THRESHOLD) ((THRESHOLD) <= 0xFFF)
\r
502 /** @defgroup ADC_injected_offset
\r
506 #define IS_ADC_OFFSET(OFFSET) ((OFFSET) <= 0xFFF)
\r
512 /** @defgroup ADC_injected_length
\r
516 #define IS_ADC_INJECTED_LENGTH(LENGTH) (((LENGTH) >= 0x1) && ((LENGTH) <= 0x4))
\r
522 /** @defgroup ADC_injected_rank
\r
526 #define IS_ADC_INJECTED_RANK(RANK) (((RANK) >= 0x1) && ((RANK) <= 0x4))
\r
532 /** @defgroup ADC_regular_length
\r
536 #define IS_ADC_REGULAR_LENGTH(LENGTH) (((LENGTH) >= 1) && ((LENGTH) <= 28))
\r
542 /** @defgroup ADC_regular_rank
\r
546 #define IS_ADC_REGULAR_RANK(RANK) (((RANK) >= 1) && ((RANK) <= 28))
\r
552 /** @defgroup ADC_regular_discontinuous_mode_number
\r
556 #define IS_ADC_REGULAR_DISC_NUMBER(NUMBER) (((NUMBER) >= 0x1) && ((NUMBER) <= 0x8))
\r
562 /** @defgroup ADC_Bank_Selection
\r
565 #define ADC_Bank_A ((uint8_t)0x00)
\r
566 #define ADC_Bank_B ((uint8_t)0x01)
\r
567 #define IS_ADC_BANK(BANK) (((BANK) == ADC_Bank_A) || ((BANK) == ADC_Bank_B))
\r
577 /* Exported macro ------------------------------------------------------------*/
\r
578 /* Exported functions ------------------------------------------------------- */
\r
580 /* Function used to set the ADC configuration to the default reset state *****/
\r
581 void ADC_DeInit(ADC_TypeDef* ADCx);
\r
583 /* Initialization and Configuration functions *********************************/
\r
584 void ADC_Init(ADC_TypeDef* ADCx, ADC_InitTypeDef* ADC_InitStruct);
\r
585 void ADC_StructInit(ADC_InitTypeDef* ADC_InitStruct);
\r
586 void ADC_CommonInit(ADC_CommonInitTypeDef* ADC_CommonInitStruct);
\r
587 void ADC_CommonStructInit(ADC_CommonInitTypeDef* ADC_CommonInitStruct);
\r
588 void ADC_Cmd(ADC_TypeDef* ADCx, FunctionalState NewState);
\r
589 void ADC_BankSelection(ADC_TypeDef* ADCx, uint8_t ADC_Bank);
\r
591 /* Power saving functions *****************************************************/
\r
592 void ADC_PowerDownCmd(ADC_TypeDef* ADCx, uint32_t ADC_PowerDown, FunctionalState NewState);
\r
593 void ADC_DelaySelectionConfig(ADC_TypeDef* ADCx, uint8_t ADC_DelayLength);
\r
595 /* Analog Watchdog configuration functions ************************************/
\r
596 void ADC_AnalogWatchdogCmd(ADC_TypeDef* ADCx, uint32_t ADC_AnalogWatchdog);
\r
597 void ADC_AnalogWatchdogThresholdsConfig(ADC_TypeDef* ADCx, uint16_t HighThreshold,uint16_t LowThreshold);
\r
598 void ADC_AnalogWatchdogSingleChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel);
\r
600 /* Temperature Sensor & Vrefint (Voltage Reference internal) management function */
\r
601 void ADC_TempSensorVrefintCmd(FunctionalState NewState);
\r
603 /* Regular Channels Configuration functions ***********************************/
\r
604 void ADC_RegularChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime);
\r
605 void ADC_SoftwareStartConv(ADC_TypeDef* ADCx);
\r
606 FlagStatus ADC_GetSoftwareStartConvStatus(ADC_TypeDef* ADCx);
\r
607 void ADC_EOCOnEachRegularChannelCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
\r
608 void ADC_ContinuousModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
\r
609 void ADC_DiscModeChannelCountConfig(ADC_TypeDef* ADCx, uint8_t Number);
\r
610 void ADC_DiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
\r
611 uint16_t ADC_GetConversionValue(ADC_TypeDef* ADCx);
\r
613 /* Regular Channels DMA Configuration functions *******************************/
\r
614 void ADC_DMACmd(ADC_TypeDef* ADCx, FunctionalState NewState);
\r
615 void ADC_DMARequestAfterLastTransferCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
\r
617 /* Injected channels Configuration functions **********************************/
\r
618 void ADC_InjectedChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime);
\r
619 void ADC_InjectedSequencerLengthConfig(ADC_TypeDef* ADCx, uint8_t Length);
\r
620 void ADC_SetInjectedOffset(ADC_TypeDef* ADCx, uint8_t ADC_InjectedChannel, uint16_t Offset);
\r
621 void ADC_ExternalTrigInjectedConvConfig(ADC_TypeDef* ADCx, uint32_t ADC_ExternalTrigInjecConv);
\r
622 void ADC_ExternalTrigInjectedConvEdgeConfig(ADC_TypeDef* ADCx, uint32_t ADC_ExternalTrigInjecConvEdge);
\r
623 void ADC_SoftwareStartInjectedConv(ADC_TypeDef* ADCx);
\r
624 FlagStatus ADC_GetSoftwareStartInjectedConvCmdStatus(ADC_TypeDef* ADCx);
\r
625 void ADC_AutoInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
\r
626 void ADC_InjectedDiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
\r
627 uint16_t ADC_GetInjectedConversionValue(ADC_TypeDef* ADCx, uint8_t ADC_InjectedChannel);
\r
629 /* Interrupts and flags management functions **********************************/
\r
630 void ADC_ITConfig(ADC_TypeDef* ADCx, uint16_t ADC_IT, FunctionalState NewState);
\r
631 FlagStatus ADC_GetFlagStatus(ADC_TypeDef* ADCx, uint16_t ADC_FLAG);
\r
632 void ADC_ClearFlag(ADC_TypeDef* ADCx, uint16_t ADC_FLAG);
\r
633 ITStatus ADC_GetITStatus(ADC_TypeDef* ADCx, uint16_t ADC_IT);
\r
634 void ADC_ClearITPendingBit(ADC_TypeDef* ADCx, uint16_t ADC_IT);
\r
640 #endif /*__STM32L1xx_ADC_H */
\r
650 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r