version_2.0

Dependents:   cc3000_ping_demo_try_2

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Wed Mar 19 18:28:32 2014 +0000
Revision:
81:7d30d6019079
Parent:
77:869cf507173a
Release 81 of the mbed library

Main changes:

- Updates and fixes for many targets
- LPC1768: serial interface code fixes
- nRF51822 targets now output a .hex file
- More exporters
- More flexible GPIO API

Who changed what in which revision?

UserRevisionLine numberNew contents of line
emilmont 77:869cf507173a 1 /**
emilmont 77:869cf507173a 2 ******************************************************************************
emilmont 77:869cf507173a 3 * @file stm32f0xx_adc.h
emilmont 77:869cf507173a 4 * @author MCD Application Team
emilmont 77:869cf507173a 5 * @version V1.3.0
emilmont 77:869cf507173a 6 * @date 16-January-2014
emilmont 77:869cf507173a 7 * @brief This file contains all the functions prototypes for the ADC firmware
emilmont 77:869cf507173a 8 * library
emilmont 77:869cf507173a 9 ******************************************************************************
emilmont 77:869cf507173a 10 * @attention
emilmont 77:869cf507173a 11 *
bogdanm 81:7d30d6019079 12 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
emilmont 77:869cf507173a 13 *
bogdanm 81:7d30d6019079 14 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 81:7d30d6019079 15 * are permitted provided that the following conditions are met:
bogdanm 81:7d30d6019079 16 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 81:7d30d6019079 17 * this list of conditions and the following disclaimer.
bogdanm 81:7d30d6019079 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 81:7d30d6019079 19 * this list of conditions and the following disclaimer in the documentation
bogdanm 81:7d30d6019079 20 * and/or other materials provided with the distribution.
bogdanm 81:7d30d6019079 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 81:7d30d6019079 22 * may be used to endorse or promote products derived from this software
bogdanm 81:7d30d6019079 23 * without specific prior written permission.
emilmont 77:869cf507173a 24 *
bogdanm 81:7d30d6019079 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 81:7d30d6019079 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 81:7d30d6019079 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 81:7d30d6019079 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 81:7d30d6019079 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 81:7d30d6019079 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 81:7d30d6019079 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 81:7d30d6019079 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 81:7d30d6019079 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 81:7d30d6019079 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
emilmont 77:869cf507173a 35 *
emilmont 77:869cf507173a 36 ******************************************************************************
emilmont 77:869cf507173a 37 */
emilmont 77:869cf507173a 38
emilmont 77:869cf507173a 39 /* Define to prevent recursive inclusion -------------------------------------*/
emilmont 77:869cf507173a 40 #ifndef __STM32F0XX_ADC_H
emilmont 77:869cf507173a 41 #define __STM32F0XX_ADC_H
emilmont 77:869cf507173a 42
emilmont 77:869cf507173a 43 #ifdef __cplusplus
emilmont 77:869cf507173a 44 extern "C" {
emilmont 77:869cf507173a 45 #endif
emilmont 77:869cf507173a 46
emilmont 77:869cf507173a 47 /* Includes ------------------------------------------------------------------*/
emilmont 77:869cf507173a 48 #include "stm32f0xx.h"
emilmont 77:869cf507173a 49
emilmont 77:869cf507173a 50 /** @addtogroup STM32F0xx_StdPeriph_Driver
emilmont 77:869cf507173a 51 * @{
emilmont 77:869cf507173a 52 */
emilmont 77:869cf507173a 53
emilmont 77:869cf507173a 54 /** @addtogroup ADC
emilmont 77:869cf507173a 55 * @{
emilmont 77:869cf507173a 56 */
emilmont 77:869cf507173a 57
emilmont 77:869cf507173a 58 /* Exported types ------------------------------------------------------------*/
emilmont 77:869cf507173a 59
emilmont 77:869cf507173a 60 /**
emilmont 77:869cf507173a 61 * @brief ADC Init structure definition
emilmont 77:869cf507173a 62 */
emilmont 77:869cf507173a 63
emilmont 77:869cf507173a 64 typedef struct
emilmont 77:869cf507173a 65 {
emilmont 77:869cf507173a 66 uint32_t ADC_Resolution; /*!< Selects the resolution of the conversion.
emilmont 77:869cf507173a 67 This parameter can be a value of @ref ADC_Resolution */
emilmont 77:869cf507173a 68
emilmont 77:869cf507173a 69 FunctionalState ADC_ContinuousConvMode; /*!< Specifies whether the conversion is performed in
emilmont 77:869cf507173a 70 Continuous or Single mode.
emilmont 77:869cf507173a 71 This parameter can be set to ENABLE or DISABLE. */
emilmont 77:869cf507173a 72
emilmont 77:869cf507173a 73 uint32_t ADC_ExternalTrigConvEdge; /*!< Selects the external trigger Edge and enables the
emilmont 77:869cf507173a 74 trigger of a regular group. This parameter can be a value
emilmont 77:869cf507173a 75 of @ref ADC_external_trigger_edge_conversion */
emilmont 77:869cf507173a 76
emilmont 77:869cf507173a 77 uint32_t ADC_ExternalTrigConv; /*!< Defines the external trigger used to start the analog
emilmont 77:869cf507173a 78 to digital conversion of regular channels. This parameter
emilmont 77:869cf507173a 79 can be a value of @ref ADC_external_trigger_sources_for_channels_conversion */
emilmont 77:869cf507173a 80
emilmont 77:869cf507173a 81 uint32_t ADC_DataAlign; /*!< Specifies whether the ADC data alignment is left or right.
emilmont 77:869cf507173a 82 This parameter can be a value of @ref ADC_data_align */
emilmont 77:869cf507173a 83
emilmont 77:869cf507173a 84 uint32_t ADC_ScanDirection; /*!< Specifies in which direction the channels will be scanned
emilmont 77:869cf507173a 85 in the sequence.
emilmont 77:869cf507173a 86 This parameter can be a value of @ref ADC_Scan_Direction */
emilmont 77:869cf507173a 87 }ADC_InitTypeDef;
emilmont 77:869cf507173a 88
emilmont 77:869cf507173a 89
emilmont 77:869cf507173a 90 /* Exported constants --------------------------------------------------------*/
emilmont 77:869cf507173a 91
emilmont 77:869cf507173a 92 /** @defgroup ADC_Exported_Constants
emilmont 77:869cf507173a 93 * @{
emilmont 77:869cf507173a 94 */
emilmont 77:869cf507173a 95 #define IS_ADC_ALL_PERIPH(PERIPH) ((PERIPH) == ADC1)
emilmont 77:869cf507173a 96
emilmont 77:869cf507173a 97 /** @defgroup ADC_JitterOff
emilmont 77:869cf507173a 98 * @{
emilmont 77:869cf507173a 99 */
emilmont 77:869cf507173a 100 /* These defines are obsolete and maintained for legacy purpose only. They are replaced by the ADC_ClockMode */
emilmont 77:869cf507173a 101 #define ADC_JitterOff_PCLKDiv2 ADC_CFGR2_JITOFFDIV2
emilmont 77:869cf507173a 102 #define ADC_JitterOff_PCLKDiv4 ADC_CFGR2_JITOFFDIV4
emilmont 77:869cf507173a 103
emilmont 77:869cf507173a 104 #define IS_ADC_JITTEROFF(JITTEROFF) (((JITTEROFF) & 0x3FFFFFFF) == (uint32_t)RESET)
emilmont 77:869cf507173a 105
emilmont 77:869cf507173a 106 /**
emilmont 77:869cf507173a 107 * @}
emilmont 77:869cf507173a 108 */
emilmont 77:869cf507173a 109
emilmont 77:869cf507173a 110 /** @defgroup ADC_ClockMode
emilmont 77:869cf507173a 111 * @{
emilmont 77:869cf507173a 112 */
emilmont 77:869cf507173a 113 #define ADC_ClockMode_AsynClk ((uint32_t)0x00000000) /*!< ADC Asynchronous clock mode */
emilmont 77:869cf507173a 114 #define ADC_ClockMode_SynClkDiv2 ADC_CFGR2_CKMODE_0 /*!< Synchronous clock mode divided by 2 */
emilmont 77:869cf507173a 115 #define ADC_ClockMode_SynClkDiv4 ADC_CFGR2_CKMODE_1 /*!< Synchronous clock mode divided by 4 */
emilmont 77:869cf507173a 116 #define IS_ADC_CLOCKMODE(CLOCK) (((CLOCK) == ADC_ClockMode_AsynClk) ||\
emilmont 77:869cf507173a 117 ((CLOCK) == ADC_ClockMode_SynClkDiv2) ||\
emilmont 77:869cf507173a 118 ((CLOCK) == ADC_ClockMode_SynClkDiv4))
emilmont 77:869cf507173a 119
emilmont 77:869cf507173a 120 /**
emilmont 77:869cf507173a 121 * @}
emilmont 77:869cf507173a 122 */
emilmont 77:869cf507173a 123
emilmont 77:869cf507173a 124 /** @defgroup ADC_Resolution
emilmont 77:869cf507173a 125 * @{
emilmont 77:869cf507173a 126 */
emilmont 77:869cf507173a 127 #define ADC_Resolution_12b ((uint32_t)0x00000000)
emilmont 77:869cf507173a 128 #define ADC_Resolution_10b ADC_CFGR1_RES_0
emilmont 77:869cf507173a 129 #define ADC_Resolution_8b ADC_CFGR1_RES_1
emilmont 77:869cf507173a 130 #define ADC_Resolution_6b ADC_CFGR1_RES
emilmont 77:869cf507173a 131
emilmont 77:869cf507173a 132 #define IS_ADC_RESOLUTION(RESOLUTION) (((RESOLUTION) == ADC_Resolution_12b) || \
emilmont 77:869cf507173a 133 ((RESOLUTION) == ADC_Resolution_10b) || \
emilmont 77:869cf507173a 134 ((RESOLUTION) == ADC_Resolution_8b) || \
emilmont 77:869cf507173a 135 ((RESOLUTION) == ADC_Resolution_6b))
emilmont 77:869cf507173a 136
emilmont 77:869cf507173a 137 /**
emilmont 77:869cf507173a 138 * @}
emilmont 77:869cf507173a 139 */
emilmont 77:869cf507173a 140
emilmont 77:869cf507173a 141 /** @defgroup ADC_external_trigger_edge_conversion
emilmont 77:869cf507173a 142 * @{
emilmont 77:869cf507173a 143 */
emilmont 77:869cf507173a 144 #define ADC_ExternalTrigConvEdge_None ((uint32_t)0x00000000)
emilmont 77:869cf507173a 145 #define ADC_ExternalTrigConvEdge_Rising ADC_CFGR1_EXTEN_0
emilmont 77:869cf507173a 146 #define ADC_ExternalTrigConvEdge_Falling ADC_CFGR1_EXTEN_1
emilmont 77:869cf507173a 147 #define ADC_ExternalTrigConvEdge_RisingFalling ADC_CFGR1_EXTEN
emilmont 77:869cf507173a 148
emilmont 77:869cf507173a 149 #define IS_ADC_EXT_TRIG_EDGE(EDGE) (((EDGE) == ADC_ExternalTrigConvEdge_None) || \
emilmont 77:869cf507173a 150 ((EDGE) == ADC_ExternalTrigConvEdge_Rising) || \
emilmont 77:869cf507173a 151 ((EDGE) == ADC_ExternalTrigConvEdge_Falling) || \
emilmont 77:869cf507173a 152 ((EDGE) == ADC_ExternalTrigConvEdge_RisingFalling))
emilmont 77:869cf507173a 153 /**
emilmont 77:869cf507173a 154 * @}
emilmont 77:869cf507173a 155 */
emilmont 77:869cf507173a 156
emilmont 77:869cf507173a 157 /** @defgroup ADC_external_trigger_sources_for_channels_conversion
emilmont 77:869cf507173a 158 * @{
emilmont 77:869cf507173a 159 */
emilmont 77:869cf507173a 160
emilmont 77:869cf507173a 161 /* TIM1 */
emilmont 77:869cf507173a 162 #define ADC_ExternalTrigConv_T1_TRGO ((uint32_t)0x00000000)
emilmont 77:869cf507173a 163 #define ADC_ExternalTrigConv_T1_CC4 ADC_CFGR1_EXTSEL_0
emilmont 77:869cf507173a 164
emilmont 77:869cf507173a 165 /* TIM2 */
emilmont 77:869cf507173a 166 #define ADC_ExternalTrigConv_T2_TRGO ADC_CFGR1_EXTSEL_1
emilmont 77:869cf507173a 167
emilmont 77:869cf507173a 168 /* TIM3 */
emilmont 77:869cf507173a 169 #define ADC_ExternalTrigConv_T3_TRGO ((uint32_t)(ADC_CFGR1_EXTSEL_0 | ADC_CFGR1_EXTSEL_1))
emilmont 77:869cf507173a 170
emilmont 77:869cf507173a 171 /* TIM15 */
emilmont 77:869cf507173a 172 #define ADC_ExternalTrigConv_T15_TRGO ADC_CFGR1_EXTSEL_2
emilmont 77:869cf507173a 173
emilmont 77:869cf507173a 174 #define IS_ADC_EXTERNAL_TRIG_CONV(CONV) (((CONV) == ADC_ExternalTrigConv_T1_TRGO) || \
emilmont 77:869cf507173a 175 ((CONV) == ADC_ExternalTrigConv_T1_CC4) || \
emilmont 77:869cf507173a 176 ((CONV) == ADC_ExternalTrigConv_T2_TRGO) || \
emilmont 77:869cf507173a 177 ((CONV) == ADC_ExternalTrigConv_T3_TRGO) || \
emilmont 77:869cf507173a 178 ((CONV) == ADC_ExternalTrigConv_T15_TRGO))
emilmont 77:869cf507173a 179 /**
emilmont 77:869cf507173a 180 * @}
emilmont 77:869cf507173a 181 */
emilmont 77:869cf507173a 182
emilmont 77:869cf507173a 183 /** @defgroup ADC_data_align
emilmont 77:869cf507173a 184 * @{
emilmont 77:869cf507173a 185 */
emilmont 77:869cf507173a 186
emilmont 77:869cf507173a 187 #define ADC_DataAlign_Right ((uint32_t)0x00000000)
emilmont 77:869cf507173a 188 #define ADC_DataAlign_Left ADC_CFGR1_ALIGN
emilmont 77:869cf507173a 189
emilmont 77:869cf507173a 190 #define IS_ADC_DATA_ALIGN(ALIGN) (((ALIGN) == ADC_DataAlign_Right) || \
emilmont 77:869cf507173a 191 ((ALIGN) == ADC_DataAlign_Left))
emilmont 77:869cf507173a 192 /**
emilmont 77:869cf507173a 193 * @}
emilmont 77:869cf507173a 194 */
emilmont 77:869cf507173a 195
emilmont 77:869cf507173a 196 /** @defgroup ADC_Scan_Direction
emilmont 77:869cf507173a 197 * @{
emilmont 77:869cf507173a 198 */
emilmont 77:869cf507173a 199
emilmont 77:869cf507173a 200 #define ADC_ScanDirection_Upward ((uint32_t)0x00000000)
emilmont 77:869cf507173a 201 #define ADC_ScanDirection_Backward ADC_CFGR1_SCANDIR
emilmont 77:869cf507173a 202
emilmont 77:869cf507173a 203 #define IS_ADC_SCAN_DIRECTION(DIRECTION) (((DIRECTION) == ADC_ScanDirection_Upward) || \
emilmont 77:869cf507173a 204 ((DIRECTION) == ADC_ScanDirection_Backward))
emilmont 77:869cf507173a 205 /**
emilmont 77:869cf507173a 206 * @}
emilmont 77:869cf507173a 207 */
emilmont 77:869cf507173a 208
emilmont 77:869cf507173a 209 /** @defgroup ADC_DMA_Mode
emilmont 77:869cf507173a 210 * @{
emilmont 77:869cf507173a 211 */
emilmont 77:869cf507173a 212
emilmont 77:869cf507173a 213 #define ADC_DMAMode_OneShot ((uint32_t)0x00000000)
emilmont 77:869cf507173a 214 #define ADC_DMAMode_Circular ADC_CFGR1_DMACFG
emilmont 77:869cf507173a 215
emilmont 77:869cf507173a 216 #define IS_ADC_DMA_MODE(MODE) (((MODE) == ADC_DMAMode_OneShot) || \
emilmont 77:869cf507173a 217 ((MODE) == ADC_DMAMode_Circular))
emilmont 77:869cf507173a 218 /**
emilmont 77:869cf507173a 219 * @}
emilmont 77:869cf507173a 220 */
emilmont 77:869cf507173a 221
emilmont 77:869cf507173a 222 /** @defgroup ADC_analog_watchdog_selection
emilmont 77:869cf507173a 223 * @{
emilmont 77:869cf507173a 224 */
emilmont 77:869cf507173a 225
emilmont 77:869cf507173a 226 #define ADC_AnalogWatchdog_Channel_0 ((uint32_t)0x00000000)
emilmont 77:869cf507173a 227 #define ADC_AnalogWatchdog_Channel_1 ((uint32_t)0x04000000)
emilmont 77:869cf507173a 228 #define ADC_AnalogWatchdog_Channel_2 ((uint32_t)0x08000000)
emilmont 77:869cf507173a 229 #define ADC_AnalogWatchdog_Channel_3 ((uint32_t)0x0C000000)
emilmont 77:869cf507173a 230 #define ADC_AnalogWatchdog_Channel_4 ((uint32_t)0x10000000)
emilmont 77:869cf507173a 231 #define ADC_AnalogWatchdog_Channel_5 ((uint32_t)0x14000000)
emilmont 77:869cf507173a 232 #define ADC_AnalogWatchdog_Channel_6 ((uint32_t)0x18000000)
emilmont 77:869cf507173a 233 #define ADC_AnalogWatchdog_Channel_7 ((uint32_t)0x1C000000)
emilmont 77:869cf507173a 234 #define ADC_AnalogWatchdog_Channel_8 ((uint32_t)0x20000000)
emilmont 77:869cf507173a 235 #define ADC_AnalogWatchdog_Channel_9 ((uint32_t)0x24000000)
emilmont 77:869cf507173a 236 #define ADC_AnalogWatchdog_Channel_10 ((uint32_t)0x28000000) /*!< Not available for STM32F031 devices */
emilmont 77:869cf507173a 237 #define ADC_AnalogWatchdog_Channel_11 ((uint32_t)0x2C000000) /*!< Not available for STM32F031 devices */
emilmont 77:869cf507173a 238 #define ADC_AnalogWatchdog_Channel_12 ((uint32_t)0x30000000) /*!< Not available for STM32F031 devices */
emilmont 77:869cf507173a 239 #define ADC_AnalogWatchdog_Channel_13 ((uint32_t)0x34000000) /*!< Not available for STM32F031 devices */
emilmont 77:869cf507173a 240 #define ADC_AnalogWatchdog_Channel_14 ((uint32_t)0x38000000) /*!< Not available for STM32F031 devices */
emilmont 77:869cf507173a 241 #define ADC_AnalogWatchdog_Channel_15 ((uint32_t)0x3C000000) /*!< Not available for STM32F031 devices */
emilmont 77:869cf507173a 242 #define ADC_AnalogWatchdog_Channel_16 ((uint32_t)0x40000000)
emilmont 77:869cf507173a 243 #define ADC_AnalogWatchdog_Channel_17 ((uint32_t)0x44000000)
emilmont 77:869cf507173a 244 #define ADC_AnalogWatchdog_Channel_18 ((uint32_t)0x48000000)
emilmont 77:869cf507173a 245
emilmont 77:869cf507173a 246
emilmont 77:869cf507173a 247 #define IS_ADC_ANALOG_WATCHDOG_CHANNEL(CHANNEL) (((CHANNEL) == ADC_AnalogWatchdog_Channel_0) || \
emilmont 77:869cf507173a 248 ((CHANNEL) == ADC_AnalogWatchdog_Channel_1) || \
emilmont 77:869cf507173a 249 ((CHANNEL) == ADC_AnalogWatchdog_Channel_2) || \
emilmont 77:869cf507173a 250 ((CHANNEL) == ADC_AnalogWatchdog_Channel_3) || \
emilmont 77:869cf507173a 251 ((CHANNEL) == ADC_AnalogWatchdog_Channel_4) || \
emilmont 77:869cf507173a 252 ((CHANNEL) == ADC_AnalogWatchdog_Channel_5) || \
emilmont 77:869cf507173a 253 ((CHANNEL) == ADC_AnalogWatchdog_Channel_6) || \
emilmont 77:869cf507173a 254 ((CHANNEL) == ADC_AnalogWatchdog_Channel_7) || \
emilmont 77:869cf507173a 255 ((CHANNEL) == ADC_AnalogWatchdog_Channel_8) || \
emilmont 77:869cf507173a 256 ((CHANNEL) == ADC_AnalogWatchdog_Channel_9) || \
emilmont 77:869cf507173a 257 ((CHANNEL) == ADC_AnalogWatchdog_Channel_10) || \
emilmont 77:869cf507173a 258 ((CHANNEL) == ADC_AnalogWatchdog_Channel_11) || \
emilmont 77:869cf507173a 259 ((CHANNEL) == ADC_AnalogWatchdog_Channel_12) || \
emilmont 77:869cf507173a 260 ((CHANNEL) == ADC_AnalogWatchdog_Channel_13) || \
emilmont 77:869cf507173a 261 ((CHANNEL) == ADC_AnalogWatchdog_Channel_14) || \
emilmont 77:869cf507173a 262 ((CHANNEL) == ADC_AnalogWatchdog_Channel_15) || \
emilmont 77:869cf507173a 263 ((CHANNEL) == ADC_AnalogWatchdog_Channel_16) || \
emilmont 77:869cf507173a 264 ((CHANNEL) == ADC_AnalogWatchdog_Channel_17) || \
emilmont 77:869cf507173a 265 ((CHANNEL) == ADC_AnalogWatchdog_Channel_18))
emilmont 77:869cf507173a 266 /**
emilmont 77:869cf507173a 267 * @}
emilmont 77:869cf507173a 268 */
emilmont 77:869cf507173a 269
emilmont 77:869cf507173a 270 /** @defgroup ADC_sampling_times
emilmont 77:869cf507173a 271 * @{
emilmont 77:869cf507173a 272 */
emilmont 77:869cf507173a 273
emilmont 77:869cf507173a 274 #define ADC_SampleTime_1_5Cycles ((uint32_t)0x00000000)
emilmont 77:869cf507173a 275 #define ADC_SampleTime_7_5Cycles ((uint32_t)0x00000001)
emilmont 77:869cf507173a 276 #define ADC_SampleTime_13_5Cycles ((uint32_t)0x00000002)
emilmont 77:869cf507173a 277 #define ADC_SampleTime_28_5Cycles ((uint32_t)0x00000003)
emilmont 77:869cf507173a 278 #define ADC_SampleTime_41_5Cycles ((uint32_t)0x00000004)
emilmont 77:869cf507173a 279 #define ADC_SampleTime_55_5Cycles ((uint32_t)0x00000005)
emilmont 77:869cf507173a 280 #define ADC_SampleTime_71_5Cycles ((uint32_t)0x00000006)
emilmont 77:869cf507173a 281 #define ADC_SampleTime_239_5Cycles ((uint32_t)0x00000007)
emilmont 77:869cf507173a 282
emilmont 77:869cf507173a 283 #define IS_ADC_SAMPLE_TIME(TIME) (((TIME) == ADC_SampleTime_1_5Cycles) || \
emilmont 77:869cf507173a 284 ((TIME) == ADC_SampleTime_7_5Cycles) || \
emilmont 77:869cf507173a 285 ((TIME) == ADC_SampleTime_13_5Cycles) || \
emilmont 77:869cf507173a 286 ((TIME) == ADC_SampleTime_28_5Cycles) || \
emilmont 77:869cf507173a 287 ((TIME) == ADC_SampleTime_41_5Cycles) || \
emilmont 77:869cf507173a 288 ((TIME) == ADC_SampleTime_55_5Cycles) || \
emilmont 77:869cf507173a 289 ((TIME) == ADC_SampleTime_71_5Cycles) || \
emilmont 77:869cf507173a 290 ((TIME) == ADC_SampleTime_239_5Cycles))
emilmont 77:869cf507173a 291 /**
emilmont 77:869cf507173a 292 * @}
emilmont 77:869cf507173a 293 */
emilmont 77:869cf507173a 294
emilmont 77:869cf507173a 295 /** @defgroup ADC_thresholds
emilmont 77:869cf507173a 296 * @{
emilmont 77:869cf507173a 297 */
emilmont 77:869cf507173a 298
emilmont 77:869cf507173a 299 #define IS_ADC_THRESHOLD(THRESHOLD) ((THRESHOLD) <= 0xFFF)
emilmont 77:869cf507173a 300
emilmont 77:869cf507173a 301 /**
emilmont 77:869cf507173a 302 * @}
emilmont 77:869cf507173a 303 */
emilmont 77:869cf507173a 304
emilmont 77:869cf507173a 305 /** @defgroup ADC_channels
emilmont 77:869cf507173a 306 * @{
emilmont 77:869cf507173a 307 */
emilmont 77:869cf507173a 308
emilmont 77:869cf507173a 309 #define ADC_Channel_0 ADC_CHSELR_CHSEL0
emilmont 77:869cf507173a 310 #define ADC_Channel_1 ADC_CHSELR_CHSEL1
emilmont 77:869cf507173a 311 #define ADC_Channel_2 ADC_CHSELR_CHSEL2
emilmont 77:869cf507173a 312 #define ADC_Channel_3 ADC_CHSELR_CHSEL3
emilmont 77:869cf507173a 313 #define ADC_Channel_4 ADC_CHSELR_CHSEL4
emilmont 77:869cf507173a 314 #define ADC_Channel_5 ADC_CHSELR_CHSEL5
emilmont 77:869cf507173a 315 #define ADC_Channel_6 ADC_CHSELR_CHSEL6
emilmont 77:869cf507173a 316 #define ADC_Channel_7 ADC_CHSELR_CHSEL7
emilmont 77:869cf507173a 317 #define ADC_Channel_8 ADC_CHSELR_CHSEL8
emilmont 77:869cf507173a 318 #define ADC_Channel_9 ADC_CHSELR_CHSEL9
emilmont 77:869cf507173a 319 #define ADC_Channel_10 ADC_CHSELR_CHSEL10 /*!< Not available for STM32F031 devices */
emilmont 77:869cf507173a 320 #define ADC_Channel_11 ADC_CHSELR_CHSEL11 /*!< Not available for STM32F031 devices */
emilmont 77:869cf507173a 321 #define ADC_Channel_12 ADC_CHSELR_CHSEL12 /*!< Not available for STM32F031 devices */
emilmont 77:869cf507173a 322 #define ADC_Channel_13 ADC_CHSELR_CHSEL13 /*!< Not available for STM32F031 devices */
emilmont 77:869cf507173a 323 #define ADC_Channel_14 ADC_CHSELR_CHSEL14 /*!< Not available for STM32F031 devices */
emilmont 77:869cf507173a 324 #define ADC_Channel_15 ADC_CHSELR_CHSEL15 /*!< Not available for STM32F031 devices */
emilmont 77:869cf507173a 325 #define ADC_Channel_16 ADC_CHSELR_CHSEL16
emilmont 77:869cf507173a 326 #define ADC_Channel_17 ADC_CHSELR_CHSEL17
emilmont 77:869cf507173a 327 #define ADC_Channel_18 ADC_CHSELR_CHSEL18 /*!< Not available for STM32F030 devices */
emilmont 77:869cf507173a 328
emilmont 77:869cf507173a 329 #define ADC_Channel_TempSensor ((uint32_t)ADC_Channel_16)
emilmont 77:869cf507173a 330 #define ADC_Channel_Vrefint ((uint32_t)ADC_Channel_17)
emilmont 77:869cf507173a 331 #define ADC_Channel_Vbat ((uint32_t)ADC_Channel_18) /*!< Not available for STM32F030 devices */
emilmont 77:869cf507173a 332
emilmont 77:869cf507173a 333 #define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) != (uint32_t)RESET) && (((CHANNEL) & 0xFFF80000) == (uint32_t)RESET))
emilmont 77:869cf507173a 334
emilmont 77:869cf507173a 335 /**
emilmont 77:869cf507173a 336 * @}
emilmont 77:869cf507173a 337 */
emilmont 77:869cf507173a 338
emilmont 77:869cf507173a 339 /** @defgroup ADC_interrupts_definition
emilmont 77:869cf507173a 340 * @{
emilmont 77:869cf507173a 341 */
emilmont 77:869cf507173a 342
emilmont 77:869cf507173a 343 #define ADC_IT_ADRDY ADC_IER_ADRDYIE
emilmont 77:869cf507173a 344 #define ADC_IT_EOSMP ADC_IER_EOSMPIE
emilmont 77:869cf507173a 345 #define ADC_IT_EOC ADC_IER_EOCIE
emilmont 77:869cf507173a 346 #define ADC_IT_EOSEQ ADC_IER_EOSEQIE
emilmont 77:869cf507173a 347 #define ADC_IT_OVR ADC_IER_OVRIE
emilmont 77:869cf507173a 348 #define ADC_IT_AWD ADC_IER_AWDIE
emilmont 77:869cf507173a 349
emilmont 77:869cf507173a 350 #define IS_ADC_CONFIG_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFFFF60) == (uint32_t)RESET))
emilmont 77:869cf507173a 351
emilmont 77:869cf507173a 352 #define IS_ADC_GET_IT(IT) (((IT) == ADC_IT_ADRDY) || ((IT) == ADC_IT_EOSMP) || \
emilmont 77:869cf507173a 353 ((IT) == ADC_IT_EOC) || ((IT) == ADC_IT_EOSEQ) || \
emilmont 77:869cf507173a 354 ((IT) == ADC_IT_OVR) || ((IT) == ADC_IT_AWD))
emilmont 77:869cf507173a 355
emilmont 77:869cf507173a 356 #define IS_ADC_CLEAR_IT(IT) (((IT) != (uint32_t)RESET) && (((IT) & 0xFFFFFF60) == (uint32_t)RESET))
emilmont 77:869cf507173a 357
emilmont 77:869cf507173a 358 /**
emilmont 77:869cf507173a 359 * @}
emilmont 77:869cf507173a 360 */
emilmont 77:869cf507173a 361
emilmont 77:869cf507173a 362 /** @defgroup ADC_flags_definition
emilmont 77:869cf507173a 363 * @{
emilmont 77:869cf507173a 364 */
emilmont 77:869cf507173a 365
emilmont 77:869cf507173a 366 #define ADC_FLAG_ADRDY ADC_ISR_ADRDY
emilmont 77:869cf507173a 367 #define ADC_FLAG_EOSMP ADC_ISR_EOSMP
emilmont 77:869cf507173a 368 #define ADC_FLAG_EOC ADC_ISR_EOC
emilmont 77:869cf507173a 369 #define ADC_FLAG_EOSEQ ADC_ISR_EOSEQ
emilmont 77:869cf507173a 370 #define ADC_FLAG_OVR ADC_ISR_OVR
emilmont 77:869cf507173a 371 #define ADC_FLAG_AWD ADC_ISR_AWD
emilmont 77:869cf507173a 372
emilmont 77:869cf507173a 373 #define ADC_FLAG_ADEN ((uint32_t)0x01000001)
emilmont 77:869cf507173a 374 #define ADC_FLAG_ADDIS ((uint32_t)0x01000002)
emilmont 77:869cf507173a 375 #define ADC_FLAG_ADSTART ((uint32_t)0x01000004)
emilmont 77:869cf507173a 376 #define ADC_FLAG_ADSTP ((uint32_t)0x01000010)
emilmont 77:869cf507173a 377 #define ADC_FLAG_ADCAL ((uint32_t)0x81000000)
emilmont 77:869cf507173a 378
emilmont 77:869cf507173a 379 #define IS_ADC_CLEAR_FLAG(FLAG) (((FLAG) != (uint32_t)RESET) && (((FLAG) & 0xFFFFFF60) == (uint32_t)RESET))
emilmont 77:869cf507173a 380
emilmont 77:869cf507173a 381 #define IS_ADC_GET_FLAG(FLAG) (((FLAG) == ADC_FLAG_ADRDY) || ((FLAG) == ADC_FLAG_EOSMP) || \
emilmont 77:869cf507173a 382 ((FLAG) == ADC_FLAG_EOC) || ((FLAG) == ADC_FLAG_EOSEQ) || \
emilmont 77:869cf507173a 383 ((FLAG) == ADC_FLAG_AWD) || ((FLAG) == ADC_FLAG_OVR) || \
emilmont 77:869cf507173a 384 ((FLAG) == ADC_FLAG_ADEN) || ((FLAG) == ADC_FLAG_ADDIS) || \
emilmont 77:869cf507173a 385 ((FLAG) == ADC_FLAG_ADSTART) || ((FLAG) == ADC_FLAG_ADSTP) || \
emilmont 77:869cf507173a 386 ((FLAG) == ADC_FLAG_ADCAL))
emilmont 77:869cf507173a 387 /**
emilmont 77:869cf507173a 388 * @}
emilmont 77:869cf507173a 389 */
emilmont 77:869cf507173a 390
emilmont 77:869cf507173a 391 /**
emilmont 77:869cf507173a 392 * @}
emilmont 77:869cf507173a 393 */
emilmont 77:869cf507173a 394
emilmont 77:869cf507173a 395 /* Exported macro ------------------------------------------------------------*/
emilmont 77:869cf507173a 396 /* Exported functions ------------------------------------------------------- */
emilmont 77:869cf507173a 397
emilmont 77:869cf507173a 398 /* Function used to set the ADC configuration to the default reset state *****/
emilmont 77:869cf507173a 399 void ADC_DeInit(ADC_TypeDef* ADCx);
emilmont 77:869cf507173a 400
emilmont 77:869cf507173a 401 /* Initialization and Configuration functions *********************************/
emilmont 77:869cf507173a 402 void ADC_Init(ADC_TypeDef* ADCx, ADC_InitTypeDef* ADC_InitStruct);
emilmont 77:869cf507173a 403 void ADC_StructInit(ADC_InitTypeDef* ADC_InitStruct);
emilmont 77:869cf507173a 404 void ADC_ClockModeConfig(ADC_TypeDef* ADCx, uint32_t ADC_ClockMode);
emilmont 77:869cf507173a 405 void ADC_Cmd(ADC_TypeDef* ADCx, FunctionalState NewState);
emilmont 77:869cf507173a 406 /* This Function is obsolete and maintained for legacy purpose only.
emilmont 77:869cf507173a 407 ADC_ClockModeConfig() function should be used instead */
emilmont 77:869cf507173a 408 void ADC_JitterCmd(ADC_TypeDef* ADCx, uint32_t ADC_JitterOff, FunctionalState NewState);
emilmont 77:869cf507173a 409
emilmont 77:869cf507173a 410 /* Power saving functions *****************************************************/
emilmont 77:869cf507173a 411 void ADC_AutoPowerOffCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
emilmont 77:869cf507173a 412 void ADC_WaitModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
emilmont 77:869cf507173a 413
emilmont 77:869cf507173a 414 /* Analog Watchdog configuration functions ************************************/
emilmont 77:869cf507173a 415 void ADC_AnalogWatchdogCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
emilmont 77:869cf507173a 416 void ADC_AnalogWatchdogThresholdsConfig(ADC_TypeDef* ADCx, uint16_t HighThreshold,uint16_t LowThreshold);
emilmont 77:869cf507173a 417 void ADC_AnalogWatchdogSingleChannelConfig(ADC_TypeDef* ADCx, uint32_t ADC_AnalogWatchdog_Channel);
emilmont 77:869cf507173a 418 void ADC_AnalogWatchdogSingleChannelCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
emilmont 77:869cf507173a 419
emilmont 77:869cf507173a 420 /* Temperature Sensor , Vrefint and Vbat management function ******************/
emilmont 77:869cf507173a 421 void ADC_TempSensorCmd(FunctionalState NewState);
emilmont 77:869cf507173a 422 void ADC_VrefintCmd(FunctionalState NewState);
emilmont 77:869cf507173a 423 void ADC_VbatCmd(FunctionalState NewState); /*!< Not applicable for STM32F030 devices */
emilmont 77:869cf507173a 424
emilmont 77:869cf507173a 425 /* Channels Configuration functions *******************************************/
emilmont 77:869cf507173a 426 void ADC_ChannelConfig(ADC_TypeDef* ADCx, uint32_t ADC_Channel, uint32_t ADC_SampleTime);
emilmont 77:869cf507173a 427 void ADC_ContinuousModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
emilmont 77:869cf507173a 428 void ADC_DiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
emilmont 77:869cf507173a 429 void ADC_OverrunModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
emilmont 77:869cf507173a 430 uint32_t ADC_GetCalibrationFactor(ADC_TypeDef* ADCx);
emilmont 77:869cf507173a 431 void ADC_StopOfConversion(ADC_TypeDef* ADCx);
emilmont 77:869cf507173a 432 void ADC_StartOfConversion(ADC_TypeDef* ADCx);
emilmont 77:869cf507173a 433 uint16_t ADC_GetConversionValue(ADC_TypeDef* ADCx);
emilmont 77:869cf507173a 434
emilmont 77:869cf507173a 435 /* Regular Channels DMA Configuration functions *******************************/
emilmont 77:869cf507173a 436 void ADC_DMACmd(ADC_TypeDef* ADCx, FunctionalState NewState);
emilmont 77:869cf507173a 437 void ADC_DMARequestModeConfig(ADC_TypeDef* ADCx, uint32_t ADC_DMARequestMode);
emilmont 77:869cf507173a 438
emilmont 77:869cf507173a 439 /* Interrupts and flags management functions **********************************/
emilmont 77:869cf507173a 440 void ADC_ITConfig(ADC_TypeDef* ADCx, uint32_t ADC_IT, FunctionalState NewState);
emilmont 77:869cf507173a 441 FlagStatus ADC_GetFlagStatus(ADC_TypeDef* ADCx, uint32_t ADC_FLAG);
emilmont 77:869cf507173a 442 void ADC_ClearFlag(ADC_TypeDef* ADCx, uint32_t ADC_FLAG);
emilmont 77:869cf507173a 443 ITStatus ADC_GetITStatus(ADC_TypeDef* ADCx, uint32_t ADC_IT);
emilmont 77:869cf507173a 444 void ADC_ClearITPendingBit(ADC_TypeDef* ADCx, uint32_t ADC_IT);
emilmont 77:869cf507173a 445
emilmont 77:869cf507173a 446 #ifdef __cplusplus
emilmont 77:869cf507173a 447 }
emilmont 77:869cf507173a 448 #endif
emilmont 77:869cf507173a 449
emilmont 77:869cf507173a 450 #endif /*__STM32F0XX_ADC_H */
emilmont 77:869cf507173a 451
emilmont 77:869cf507173a 452 /**
emilmont 77:869cf507173a 453 * @}
emilmont 77:869cf507173a 454 */
emilmont 77:869cf507173a 455
emilmont 77:869cf507173a 456 /**
emilmont 77:869cf507173a 457 * @}
emilmont 77:869cf507173a 458 */
emilmont 77:869cf507173a 459
emilmont 77:869cf507173a 460 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/