mbed library sources

Dependents:   frdm_kl05z_gpio_test

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Mon Dec 02 11:30:05 2013 +0000
Revision:
52:a51c77007319
Child:
70:c1fbde68b492
Synchronized with git revision 49df530ae72ce97ccc773d1f2c13b38e868e6abd

Full URL: https://github.com/mbedmicro/mbed/commit/49df530ae72ce97ccc773d1f2c13b38e868e6abd/

Add STMicroelectronics NUCLEO_F103RB target

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 52:a51c77007319 1 /**
mbed_official 52:a51c77007319 2 ******************************************************************************
mbed_official 52:a51c77007319 3 * @file stm32f10x_adc.h
mbed_official 52:a51c77007319 4 * @author MCD Application Team
mbed_official 52:a51c77007319 5 * @version V3.5.0
mbed_official 52:a51c77007319 6 * @date 11-March-2011
mbed_official 52:a51c77007319 7 * @brief This file contains all the functions prototypes for the ADC firmware
mbed_official 52:a51c77007319 8 * library.
mbed_official 52:a51c77007319 9 ******************************************************************************
mbed_official 52:a51c77007319 10 * @attention
mbed_official 52:a51c77007319 11 *
mbed_official 52:a51c77007319 12 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
mbed_official 52:a51c77007319 13 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
mbed_official 52:a51c77007319 14 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
mbed_official 52:a51c77007319 15 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
mbed_official 52:a51c77007319 16 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
mbed_official 52:a51c77007319 17 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
mbed_official 52:a51c77007319 18 *
mbed_official 52:a51c77007319 19 * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
mbed_official 52:a51c77007319 20 ******************************************************************************
mbed_official 52:a51c77007319 21 */
mbed_official 52:a51c77007319 22
mbed_official 52:a51c77007319 23 /* Define to prevent recursive inclusion -------------------------------------*/
mbed_official 52:a51c77007319 24 #ifndef __STM32F10x_ADC_H
mbed_official 52:a51c77007319 25 #define __STM32F10x_ADC_H
mbed_official 52:a51c77007319 26
mbed_official 52:a51c77007319 27 #ifdef __cplusplus
mbed_official 52:a51c77007319 28 extern "C" {
mbed_official 52:a51c77007319 29 #endif
mbed_official 52:a51c77007319 30
mbed_official 52:a51c77007319 31 /* Includes ------------------------------------------------------------------*/
mbed_official 52:a51c77007319 32 #include "stm32f10x.h"
mbed_official 52:a51c77007319 33
mbed_official 52:a51c77007319 34 /** @addtogroup STM32F10x_StdPeriph_Driver
mbed_official 52:a51c77007319 35 * @{
mbed_official 52:a51c77007319 36 */
mbed_official 52:a51c77007319 37
mbed_official 52:a51c77007319 38 /** @addtogroup ADC
mbed_official 52:a51c77007319 39 * @{
mbed_official 52:a51c77007319 40 */
mbed_official 52:a51c77007319 41
mbed_official 52:a51c77007319 42 /** @defgroup ADC_Exported_Types
mbed_official 52:a51c77007319 43 * @{
mbed_official 52:a51c77007319 44 */
mbed_official 52:a51c77007319 45
mbed_official 52:a51c77007319 46 /**
mbed_official 52:a51c77007319 47 * @brief ADC Init structure definition
mbed_official 52:a51c77007319 48 */
mbed_official 52:a51c77007319 49
mbed_official 52:a51c77007319 50 typedef struct
mbed_official 52:a51c77007319 51 {
mbed_official 52:a51c77007319 52 uint32_t ADC_Mode; /*!< Configures the ADC to operate in independent or
mbed_official 52:a51c77007319 53 dual mode.
mbed_official 52:a51c77007319 54 This parameter can be a value of @ref ADC_mode */
mbed_official 52:a51c77007319 55
mbed_official 52:a51c77007319 56 FunctionalState ADC_ScanConvMode; /*!< Specifies whether the conversion is performed in
mbed_official 52:a51c77007319 57 Scan (multichannels) or Single (one channel) mode.
mbed_official 52:a51c77007319 58 This parameter can be set to ENABLE or DISABLE */
mbed_official 52:a51c77007319 59
mbed_official 52:a51c77007319 60 FunctionalState ADC_ContinuousConvMode; /*!< Specifies whether the conversion is performed in
mbed_official 52:a51c77007319 61 Continuous or Single mode.
mbed_official 52:a51c77007319 62 This parameter can be set to ENABLE or DISABLE. */
mbed_official 52:a51c77007319 63
mbed_official 52:a51c77007319 64 uint32_t ADC_ExternalTrigConv; /*!< Defines the external trigger used to start the analog
mbed_official 52:a51c77007319 65 to digital conversion of regular channels. This parameter
mbed_official 52:a51c77007319 66 can be a value of @ref ADC_external_trigger_sources_for_regular_channels_conversion */
mbed_official 52:a51c77007319 67
mbed_official 52:a51c77007319 68 uint32_t ADC_DataAlign; /*!< Specifies whether the ADC data alignment is left or right.
mbed_official 52:a51c77007319 69 This parameter can be a value of @ref ADC_data_align */
mbed_official 52:a51c77007319 70
mbed_official 52:a51c77007319 71 uint8_t ADC_NbrOfChannel; /*!< Specifies the number of ADC channels that will be converted
mbed_official 52:a51c77007319 72 using the sequencer for regular channel group.
mbed_official 52:a51c77007319 73 This parameter must range from 1 to 16. */
mbed_official 52:a51c77007319 74 }ADC_InitTypeDef;
mbed_official 52:a51c77007319 75 /**
mbed_official 52:a51c77007319 76 * @}
mbed_official 52:a51c77007319 77 */
mbed_official 52:a51c77007319 78
mbed_official 52:a51c77007319 79 /** @defgroup ADC_Exported_Constants
mbed_official 52:a51c77007319 80 * @{
mbed_official 52:a51c77007319 81 */
mbed_official 52:a51c77007319 82
mbed_official 52:a51c77007319 83 #define IS_ADC_ALL_PERIPH(PERIPH) (((PERIPH) == ADC1) || \
mbed_official 52:a51c77007319 84 ((PERIPH) == ADC2) || \
mbed_official 52:a51c77007319 85 ((PERIPH) == ADC3))
mbed_official 52:a51c77007319 86
mbed_official 52:a51c77007319 87 #define IS_ADC_DMA_PERIPH(PERIPH) (((PERIPH) == ADC1) || \
mbed_official 52:a51c77007319 88 ((PERIPH) == ADC3))
mbed_official 52:a51c77007319 89
mbed_official 52:a51c77007319 90 /** @defgroup ADC_mode
mbed_official 52:a51c77007319 91 * @{
mbed_official 52:a51c77007319 92 */
mbed_official 52:a51c77007319 93
mbed_official 52:a51c77007319 94 #define ADC_Mode_Independent ((uint32_t)0x00000000)
mbed_official 52:a51c77007319 95 #define ADC_Mode_RegInjecSimult ((uint32_t)0x00010000)
mbed_official 52:a51c77007319 96 #define ADC_Mode_RegSimult_AlterTrig ((uint32_t)0x00020000)
mbed_official 52:a51c77007319 97 #define ADC_Mode_InjecSimult_FastInterl ((uint32_t)0x00030000)
mbed_official 52:a51c77007319 98 #define ADC_Mode_InjecSimult_SlowInterl ((uint32_t)0x00040000)
mbed_official 52:a51c77007319 99 #define ADC_Mode_InjecSimult ((uint32_t)0x00050000)
mbed_official 52:a51c77007319 100 #define ADC_Mode_RegSimult ((uint32_t)0x00060000)
mbed_official 52:a51c77007319 101 #define ADC_Mode_FastInterl ((uint32_t)0x00070000)
mbed_official 52:a51c77007319 102 #define ADC_Mode_SlowInterl ((uint32_t)0x00080000)
mbed_official 52:a51c77007319 103 #define ADC_Mode_AlterTrig ((uint32_t)0x00090000)
mbed_official 52:a51c77007319 104
mbed_official 52:a51c77007319 105 #define IS_ADC_MODE(MODE) (((MODE) == ADC_Mode_Independent) || \
mbed_official 52:a51c77007319 106 ((MODE) == ADC_Mode_RegInjecSimult) || \
mbed_official 52:a51c77007319 107 ((MODE) == ADC_Mode_RegSimult_AlterTrig) || \
mbed_official 52:a51c77007319 108 ((MODE) == ADC_Mode_InjecSimult_FastInterl) || \
mbed_official 52:a51c77007319 109 ((MODE) == ADC_Mode_InjecSimult_SlowInterl) || \
mbed_official 52:a51c77007319 110 ((MODE) == ADC_Mode_InjecSimult) || \
mbed_official 52:a51c77007319 111 ((MODE) == ADC_Mode_RegSimult) || \
mbed_official 52:a51c77007319 112 ((MODE) == ADC_Mode_FastInterl) || \
mbed_official 52:a51c77007319 113 ((MODE) == ADC_Mode_SlowInterl) || \
mbed_official 52:a51c77007319 114 ((MODE) == ADC_Mode_AlterTrig))
mbed_official 52:a51c77007319 115 /**
mbed_official 52:a51c77007319 116 * @}
mbed_official 52:a51c77007319 117 */
mbed_official 52:a51c77007319 118
mbed_official 52:a51c77007319 119 /** @defgroup ADC_external_trigger_sources_for_regular_channels_conversion
mbed_official 52:a51c77007319 120 * @{
mbed_official 52:a51c77007319 121 */
mbed_official 52:a51c77007319 122
mbed_official 52:a51c77007319 123 #define ADC_ExternalTrigConv_T1_CC1 ((uint32_t)0x00000000) /*!< For ADC1 and ADC2 */
mbed_official 52:a51c77007319 124 #define ADC_ExternalTrigConv_T1_CC2 ((uint32_t)0x00020000) /*!< For ADC1 and ADC2 */
mbed_official 52:a51c77007319 125 #define ADC_ExternalTrigConv_T2_CC2 ((uint32_t)0x00060000) /*!< For ADC1 and ADC2 */
mbed_official 52:a51c77007319 126 #define ADC_ExternalTrigConv_T3_TRGO ((uint32_t)0x00080000) /*!< For ADC1 and ADC2 */
mbed_official 52:a51c77007319 127 #define ADC_ExternalTrigConv_T4_CC4 ((uint32_t)0x000A0000) /*!< For ADC1 and ADC2 */
mbed_official 52:a51c77007319 128 #define ADC_ExternalTrigConv_Ext_IT11_TIM8_TRGO ((uint32_t)0x000C0000) /*!< For ADC1 and ADC2 */
mbed_official 52:a51c77007319 129
mbed_official 52:a51c77007319 130 #define ADC_ExternalTrigConv_T1_CC3 ((uint32_t)0x00040000) /*!< For ADC1, ADC2 and ADC3 */
mbed_official 52:a51c77007319 131 #define ADC_ExternalTrigConv_None ((uint32_t)0x000E0000) /*!< For ADC1, ADC2 and ADC3 */
mbed_official 52:a51c77007319 132
mbed_official 52:a51c77007319 133 #define ADC_ExternalTrigConv_T3_CC1 ((uint32_t)0x00000000) /*!< For ADC3 only */
mbed_official 52:a51c77007319 134 #define ADC_ExternalTrigConv_T2_CC3 ((uint32_t)0x00020000) /*!< For ADC3 only */
mbed_official 52:a51c77007319 135 #define ADC_ExternalTrigConv_T8_CC1 ((uint32_t)0x00060000) /*!< For ADC3 only */
mbed_official 52:a51c77007319 136 #define ADC_ExternalTrigConv_T8_TRGO ((uint32_t)0x00080000) /*!< For ADC3 only */
mbed_official 52:a51c77007319 137 #define ADC_ExternalTrigConv_T5_CC1 ((uint32_t)0x000A0000) /*!< For ADC3 only */
mbed_official 52:a51c77007319 138 #define ADC_ExternalTrigConv_T5_CC3 ((uint32_t)0x000C0000) /*!< For ADC3 only */
mbed_official 52:a51c77007319 139
mbed_official 52:a51c77007319 140 #define IS_ADC_EXT_TRIG(REGTRIG) (((REGTRIG) == ADC_ExternalTrigConv_T1_CC1) || \
mbed_official 52:a51c77007319 141 ((REGTRIG) == ADC_ExternalTrigConv_T1_CC2) || \
mbed_official 52:a51c77007319 142 ((REGTRIG) == ADC_ExternalTrigConv_T1_CC3) || \
mbed_official 52:a51c77007319 143 ((REGTRIG) == ADC_ExternalTrigConv_T2_CC2) || \
mbed_official 52:a51c77007319 144 ((REGTRIG) == ADC_ExternalTrigConv_T3_TRGO) || \
mbed_official 52:a51c77007319 145 ((REGTRIG) == ADC_ExternalTrigConv_T4_CC4) || \
mbed_official 52:a51c77007319 146 ((REGTRIG) == ADC_ExternalTrigConv_Ext_IT11_TIM8_TRGO) || \
mbed_official 52:a51c77007319 147 ((REGTRIG) == ADC_ExternalTrigConv_None) || \
mbed_official 52:a51c77007319 148 ((REGTRIG) == ADC_ExternalTrigConv_T3_CC1) || \
mbed_official 52:a51c77007319 149 ((REGTRIG) == ADC_ExternalTrigConv_T2_CC3) || \
mbed_official 52:a51c77007319 150 ((REGTRIG) == ADC_ExternalTrigConv_T8_CC1) || \
mbed_official 52:a51c77007319 151 ((REGTRIG) == ADC_ExternalTrigConv_T8_TRGO) || \
mbed_official 52:a51c77007319 152 ((REGTRIG) == ADC_ExternalTrigConv_T5_CC1) || \
mbed_official 52:a51c77007319 153 ((REGTRIG) == ADC_ExternalTrigConv_T5_CC3))
mbed_official 52:a51c77007319 154 /**
mbed_official 52:a51c77007319 155 * @}
mbed_official 52:a51c77007319 156 */
mbed_official 52:a51c77007319 157
mbed_official 52:a51c77007319 158 /** @defgroup ADC_data_align
mbed_official 52:a51c77007319 159 * @{
mbed_official 52:a51c77007319 160 */
mbed_official 52:a51c77007319 161
mbed_official 52:a51c77007319 162 #define ADC_DataAlign_Right ((uint32_t)0x00000000)
mbed_official 52:a51c77007319 163 #define ADC_DataAlign_Left ((uint32_t)0x00000800)
mbed_official 52:a51c77007319 164 #define IS_ADC_DATA_ALIGN(ALIGN) (((ALIGN) == ADC_DataAlign_Right) || \
mbed_official 52:a51c77007319 165 ((ALIGN) == ADC_DataAlign_Left))
mbed_official 52:a51c77007319 166 /**
mbed_official 52:a51c77007319 167 * @}
mbed_official 52:a51c77007319 168 */
mbed_official 52:a51c77007319 169
mbed_official 52:a51c77007319 170 /** @defgroup ADC_channels
mbed_official 52:a51c77007319 171 * @{
mbed_official 52:a51c77007319 172 */
mbed_official 52:a51c77007319 173
mbed_official 52:a51c77007319 174 #define ADC_Channel_0 ((uint8_t)0x00)
mbed_official 52:a51c77007319 175 #define ADC_Channel_1 ((uint8_t)0x01)
mbed_official 52:a51c77007319 176 #define ADC_Channel_2 ((uint8_t)0x02)
mbed_official 52:a51c77007319 177 #define ADC_Channel_3 ((uint8_t)0x03)
mbed_official 52:a51c77007319 178 #define ADC_Channel_4 ((uint8_t)0x04)
mbed_official 52:a51c77007319 179 #define ADC_Channel_5 ((uint8_t)0x05)
mbed_official 52:a51c77007319 180 #define ADC_Channel_6 ((uint8_t)0x06)
mbed_official 52:a51c77007319 181 #define ADC_Channel_7 ((uint8_t)0x07)
mbed_official 52:a51c77007319 182 #define ADC_Channel_8 ((uint8_t)0x08)
mbed_official 52:a51c77007319 183 #define ADC_Channel_9 ((uint8_t)0x09)
mbed_official 52:a51c77007319 184 #define ADC_Channel_10 ((uint8_t)0x0A)
mbed_official 52:a51c77007319 185 #define ADC_Channel_11 ((uint8_t)0x0B)
mbed_official 52:a51c77007319 186 #define ADC_Channel_12 ((uint8_t)0x0C)
mbed_official 52:a51c77007319 187 #define ADC_Channel_13 ((uint8_t)0x0D)
mbed_official 52:a51c77007319 188 #define ADC_Channel_14 ((uint8_t)0x0E)
mbed_official 52:a51c77007319 189 #define ADC_Channel_15 ((uint8_t)0x0F)
mbed_official 52:a51c77007319 190 #define ADC_Channel_16 ((uint8_t)0x10)
mbed_official 52:a51c77007319 191 #define ADC_Channel_17 ((uint8_t)0x11)
mbed_official 52:a51c77007319 192
mbed_official 52:a51c77007319 193 #define ADC_Channel_TempSensor ((uint8_t)ADC_Channel_16)
mbed_official 52:a51c77007319 194 #define ADC_Channel_Vrefint ((uint8_t)ADC_Channel_17)
mbed_official 52:a51c77007319 195
mbed_official 52:a51c77007319 196 #define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) == ADC_Channel_0) || ((CHANNEL) == ADC_Channel_1) || \
mbed_official 52:a51c77007319 197 ((CHANNEL) == ADC_Channel_2) || ((CHANNEL) == ADC_Channel_3) || \
mbed_official 52:a51c77007319 198 ((CHANNEL) == ADC_Channel_4) || ((CHANNEL) == ADC_Channel_5) || \
mbed_official 52:a51c77007319 199 ((CHANNEL) == ADC_Channel_6) || ((CHANNEL) == ADC_Channel_7) || \
mbed_official 52:a51c77007319 200 ((CHANNEL) == ADC_Channel_8) || ((CHANNEL) == ADC_Channel_9) || \
mbed_official 52:a51c77007319 201 ((CHANNEL) == ADC_Channel_10) || ((CHANNEL) == ADC_Channel_11) || \
mbed_official 52:a51c77007319 202 ((CHANNEL) == ADC_Channel_12) || ((CHANNEL) == ADC_Channel_13) || \
mbed_official 52:a51c77007319 203 ((CHANNEL) == ADC_Channel_14) || ((CHANNEL) == ADC_Channel_15) || \
mbed_official 52:a51c77007319 204 ((CHANNEL) == ADC_Channel_16) || ((CHANNEL) == ADC_Channel_17))
mbed_official 52:a51c77007319 205 /**
mbed_official 52:a51c77007319 206 * @}
mbed_official 52:a51c77007319 207 */
mbed_official 52:a51c77007319 208
mbed_official 52:a51c77007319 209 /** @defgroup ADC_sampling_time
mbed_official 52:a51c77007319 210 * @{
mbed_official 52:a51c77007319 211 */
mbed_official 52:a51c77007319 212
mbed_official 52:a51c77007319 213 #define ADC_SampleTime_1Cycles5 ((uint8_t)0x00)
mbed_official 52:a51c77007319 214 #define ADC_SampleTime_7Cycles5 ((uint8_t)0x01)
mbed_official 52:a51c77007319 215 #define ADC_SampleTime_13Cycles5 ((uint8_t)0x02)
mbed_official 52:a51c77007319 216 #define ADC_SampleTime_28Cycles5 ((uint8_t)0x03)
mbed_official 52:a51c77007319 217 #define ADC_SampleTime_41Cycles5 ((uint8_t)0x04)
mbed_official 52:a51c77007319 218 #define ADC_SampleTime_55Cycles5 ((uint8_t)0x05)
mbed_official 52:a51c77007319 219 #define ADC_SampleTime_71Cycles5 ((uint8_t)0x06)
mbed_official 52:a51c77007319 220 #define ADC_SampleTime_239Cycles5 ((uint8_t)0x07)
mbed_official 52:a51c77007319 221 #define IS_ADC_SAMPLE_TIME(TIME) (((TIME) == ADC_SampleTime_1Cycles5) || \
mbed_official 52:a51c77007319 222 ((TIME) == ADC_SampleTime_7Cycles5) || \
mbed_official 52:a51c77007319 223 ((TIME) == ADC_SampleTime_13Cycles5) || \
mbed_official 52:a51c77007319 224 ((TIME) == ADC_SampleTime_28Cycles5) || \
mbed_official 52:a51c77007319 225 ((TIME) == ADC_SampleTime_41Cycles5) || \
mbed_official 52:a51c77007319 226 ((TIME) == ADC_SampleTime_55Cycles5) || \
mbed_official 52:a51c77007319 227 ((TIME) == ADC_SampleTime_71Cycles5) || \
mbed_official 52:a51c77007319 228 ((TIME) == ADC_SampleTime_239Cycles5))
mbed_official 52:a51c77007319 229 /**
mbed_official 52:a51c77007319 230 * @}
mbed_official 52:a51c77007319 231 */
mbed_official 52:a51c77007319 232
mbed_official 52:a51c77007319 233 /** @defgroup ADC_external_trigger_sources_for_injected_channels_conversion
mbed_official 52:a51c77007319 234 * @{
mbed_official 52:a51c77007319 235 */
mbed_official 52:a51c77007319 236
mbed_official 52:a51c77007319 237 #define ADC_ExternalTrigInjecConv_T2_TRGO ((uint32_t)0x00002000) /*!< For ADC1 and ADC2 */
mbed_official 52:a51c77007319 238 #define ADC_ExternalTrigInjecConv_T2_CC1 ((uint32_t)0x00003000) /*!< For ADC1 and ADC2 */
mbed_official 52:a51c77007319 239 #define ADC_ExternalTrigInjecConv_T3_CC4 ((uint32_t)0x00004000) /*!< For ADC1 and ADC2 */
mbed_official 52:a51c77007319 240 #define ADC_ExternalTrigInjecConv_T4_TRGO ((uint32_t)0x00005000) /*!< For ADC1 and ADC2 */
mbed_official 52:a51c77007319 241 #define ADC_ExternalTrigInjecConv_Ext_IT15_TIM8_CC4 ((uint32_t)0x00006000) /*!< For ADC1 and ADC2 */
mbed_official 52:a51c77007319 242
mbed_official 52:a51c77007319 243 #define ADC_ExternalTrigInjecConv_T1_TRGO ((uint32_t)0x00000000) /*!< For ADC1, ADC2 and ADC3 */
mbed_official 52:a51c77007319 244 #define ADC_ExternalTrigInjecConv_T1_CC4 ((uint32_t)0x00001000) /*!< For ADC1, ADC2 and ADC3 */
mbed_official 52:a51c77007319 245 #define ADC_ExternalTrigInjecConv_None ((uint32_t)0x00007000) /*!< For ADC1, ADC2 and ADC3 */
mbed_official 52:a51c77007319 246
mbed_official 52:a51c77007319 247 #define ADC_ExternalTrigInjecConv_T4_CC3 ((uint32_t)0x00002000) /*!< For ADC3 only */
mbed_official 52:a51c77007319 248 #define ADC_ExternalTrigInjecConv_T8_CC2 ((uint32_t)0x00003000) /*!< For ADC3 only */
mbed_official 52:a51c77007319 249 #define ADC_ExternalTrigInjecConv_T8_CC4 ((uint32_t)0x00004000) /*!< For ADC3 only */
mbed_official 52:a51c77007319 250 #define ADC_ExternalTrigInjecConv_T5_TRGO ((uint32_t)0x00005000) /*!< For ADC3 only */
mbed_official 52:a51c77007319 251 #define ADC_ExternalTrigInjecConv_T5_CC4 ((uint32_t)0x00006000) /*!< For ADC3 only */
mbed_official 52:a51c77007319 252
mbed_official 52:a51c77007319 253 #define IS_ADC_EXT_INJEC_TRIG(INJTRIG) (((INJTRIG) == ADC_ExternalTrigInjecConv_T1_TRGO) || \
mbed_official 52:a51c77007319 254 ((INJTRIG) == ADC_ExternalTrigInjecConv_T1_CC4) || \
mbed_official 52:a51c77007319 255 ((INJTRIG) == ADC_ExternalTrigInjecConv_T2_TRGO) || \
mbed_official 52:a51c77007319 256 ((INJTRIG) == ADC_ExternalTrigInjecConv_T2_CC1) || \
mbed_official 52:a51c77007319 257 ((INJTRIG) == ADC_ExternalTrigInjecConv_T3_CC4) || \
mbed_official 52:a51c77007319 258 ((INJTRIG) == ADC_ExternalTrigInjecConv_T4_TRGO) || \
mbed_official 52:a51c77007319 259 ((INJTRIG) == ADC_ExternalTrigInjecConv_Ext_IT15_TIM8_CC4) || \
mbed_official 52:a51c77007319 260 ((INJTRIG) == ADC_ExternalTrigInjecConv_None) || \
mbed_official 52:a51c77007319 261 ((INJTRIG) == ADC_ExternalTrigInjecConv_T4_CC3) || \
mbed_official 52:a51c77007319 262 ((INJTRIG) == ADC_ExternalTrigInjecConv_T8_CC2) || \
mbed_official 52:a51c77007319 263 ((INJTRIG) == ADC_ExternalTrigInjecConv_T8_CC4) || \
mbed_official 52:a51c77007319 264 ((INJTRIG) == ADC_ExternalTrigInjecConv_T5_TRGO) || \
mbed_official 52:a51c77007319 265 ((INJTRIG) == ADC_ExternalTrigInjecConv_T5_CC4))
mbed_official 52:a51c77007319 266 /**
mbed_official 52:a51c77007319 267 * @}
mbed_official 52:a51c77007319 268 */
mbed_official 52:a51c77007319 269
mbed_official 52:a51c77007319 270 /** @defgroup ADC_injected_channel_selection
mbed_official 52:a51c77007319 271 * @{
mbed_official 52:a51c77007319 272 */
mbed_official 52:a51c77007319 273
mbed_official 52:a51c77007319 274 #define ADC_InjectedChannel_1 ((uint8_t)0x14)
mbed_official 52:a51c77007319 275 #define ADC_InjectedChannel_2 ((uint8_t)0x18)
mbed_official 52:a51c77007319 276 #define ADC_InjectedChannel_3 ((uint8_t)0x1C)
mbed_official 52:a51c77007319 277 #define ADC_InjectedChannel_4 ((uint8_t)0x20)
mbed_official 52:a51c77007319 278 #define IS_ADC_INJECTED_CHANNEL(CHANNEL) (((CHANNEL) == ADC_InjectedChannel_1) || \
mbed_official 52:a51c77007319 279 ((CHANNEL) == ADC_InjectedChannel_2) || \
mbed_official 52:a51c77007319 280 ((CHANNEL) == ADC_InjectedChannel_3) || \
mbed_official 52:a51c77007319 281 ((CHANNEL) == ADC_InjectedChannel_4))
mbed_official 52:a51c77007319 282 /**
mbed_official 52:a51c77007319 283 * @}
mbed_official 52:a51c77007319 284 */
mbed_official 52:a51c77007319 285
mbed_official 52:a51c77007319 286 /** @defgroup ADC_analog_watchdog_selection
mbed_official 52:a51c77007319 287 * @{
mbed_official 52:a51c77007319 288 */
mbed_official 52:a51c77007319 289
mbed_official 52:a51c77007319 290 #define ADC_AnalogWatchdog_SingleRegEnable ((uint32_t)0x00800200)
mbed_official 52:a51c77007319 291 #define ADC_AnalogWatchdog_SingleInjecEnable ((uint32_t)0x00400200)
mbed_official 52:a51c77007319 292 #define ADC_AnalogWatchdog_SingleRegOrInjecEnable ((uint32_t)0x00C00200)
mbed_official 52:a51c77007319 293 #define ADC_AnalogWatchdog_AllRegEnable ((uint32_t)0x00800000)
mbed_official 52:a51c77007319 294 #define ADC_AnalogWatchdog_AllInjecEnable ((uint32_t)0x00400000)
mbed_official 52:a51c77007319 295 #define ADC_AnalogWatchdog_AllRegAllInjecEnable ((uint32_t)0x00C00000)
mbed_official 52:a51c77007319 296 #define ADC_AnalogWatchdog_None ((uint32_t)0x00000000)
mbed_official 52:a51c77007319 297
mbed_official 52:a51c77007319 298 #define IS_ADC_ANALOG_WATCHDOG(WATCHDOG) (((WATCHDOG) == ADC_AnalogWatchdog_SingleRegEnable) || \
mbed_official 52:a51c77007319 299 ((WATCHDOG) == ADC_AnalogWatchdog_SingleInjecEnable) || \
mbed_official 52:a51c77007319 300 ((WATCHDOG) == ADC_AnalogWatchdog_SingleRegOrInjecEnable) || \
mbed_official 52:a51c77007319 301 ((WATCHDOG) == ADC_AnalogWatchdog_AllRegEnable) || \
mbed_official 52:a51c77007319 302 ((WATCHDOG) == ADC_AnalogWatchdog_AllInjecEnable) || \
mbed_official 52:a51c77007319 303 ((WATCHDOG) == ADC_AnalogWatchdog_AllRegAllInjecEnable) || \
mbed_official 52:a51c77007319 304 ((WATCHDOG) == ADC_AnalogWatchdog_None))
mbed_official 52:a51c77007319 305 /**
mbed_official 52:a51c77007319 306 * @}
mbed_official 52:a51c77007319 307 */
mbed_official 52:a51c77007319 308
mbed_official 52:a51c77007319 309 /** @defgroup ADC_interrupts_definition
mbed_official 52:a51c77007319 310 * @{
mbed_official 52:a51c77007319 311 */
mbed_official 52:a51c77007319 312
mbed_official 52:a51c77007319 313 #define ADC_IT_EOC ((uint16_t)0x0220)
mbed_official 52:a51c77007319 314 #define ADC_IT_AWD ((uint16_t)0x0140)
mbed_official 52:a51c77007319 315 #define ADC_IT_JEOC ((uint16_t)0x0480)
mbed_official 52:a51c77007319 316
mbed_official 52:a51c77007319 317 #define IS_ADC_IT(IT) ((((IT) & (uint16_t)0xF81F) == 0x00) && ((IT) != 0x00))
mbed_official 52:a51c77007319 318
mbed_official 52:a51c77007319 319 #define IS_ADC_GET_IT(IT) (((IT) == ADC_IT_EOC) || ((IT) == ADC_IT_AWD) || \
mbed_official 52:a51c77007319 320 ((IT) == ADC_IT_JEOC))
mbed_official 52:a51c77007319 321 /**
mbed_official 52:a51c77007319 322 * @}
mbed_official 52:a51c77007319 323 */
mbed_official 52:a51c77007319 324
mbed_official 52:a51c77007319 325 /** @defgroup ADC_flags_definition
mbed_official 52:a51c77007319 326 * @{
mbed_official 52:a51c77007319 327 */
mbed_official 52:a51c77007319 328
mbed_official 52:a51c77007319 329 #define ADC_FLAG_AWD ((uint8_t)0x01)
mbed_official 52:a51c77007319 330 #define ADC_FLAG_EOC ((uint8_t)0x02)
mbed_official 52:a51c77007319 331 #define ADC_FLAG_JEOC ((uint8_t)0x04)
mbed_official 52:a51c77007319 332 #define ADC_FLAG_JSTRT ((uint8_t)0x08)
mbed_official 52:a51c77007319 333 #define ADC_FLAG_STRT ((uint8_t)0x10)
mbed_official 52:a51c77007319 334 #define IS_ADC_CLEAR_FLAG(FLAG) ((((FLAG) & (uint8_t)0xE0) == 0x00) && ((FLAG) != 0x00))
mbed_official 52:a51c77007319 335 #define IS_ADC_GET_FLAG(FLAG) (((FLAG) == ADC_FLAG_AWD) || ((FLAG) == ADC_FLAG_EOC) || \
mbed_official 52:a51c77007319 336 ((FLAG) == ADC_FLAG_JEOC) || ((FLAG)== ADC_FLAG_JSTRT) || \
mbed_official 52:a51c77007319 337 ((FLAG) == ADC_FLAG_STRT))
mbed_official 52:a51c77007319 338 /**
mbed_official 52:a51c77007319 339 * @}
mbed_official 52:a51c77007319 340 */
mbed_official 52:a51c77007319 341
mbed_official 52:a51c77007319 342 /** @defgroup ADC_thresholds
mbed_official 52:a51c77007319 343 * @{
mbed_official 52:a51c77007319 344 */
mbed_official 52:a51c77007319 345
mbed_official 52:a51c77007319 346 #define IS_ADC_THRESHOLD(THRESHOLD) ((THRESHOLD) <= 0xFFF)
mbed_official 52:a51c77007319 347
mbed_official 52:a51c77007319 348 /**
mbed_official 52:a51c77007319 349 * @}
mbed_official 52:a51c77007319 350 */
mbed_official 52:a51c77007319 351
mbed_official 52:a51c77007319 352 /** @defgroup ADC_injected_offset
mbed_official 52:a51c77007319 353 * @{
mbed_official 52:a51c77007319 354 */
mbed_official 52:a51c77007319 355
mbed_official 52:a51c77007319 356 #define IS_ADC_OFFSET(OFFSET) ((OFFSET) <= 0xFFF)
mbed_official 52:a51c77007319 357
mbed_official 52:a51c77007319 358 /**
mbed_official 52:a51c77007319 359 * @}
mbed_official 52:a51c77007319 360 */
mbed_official 52:a51c77007319 361
mbed_official 52:a51c77007319 362 /** @defgroup ADC_injected_length
mbed_official 52:a51c77007319 363 * @{
mbed_official 52:a51c77007319 364 */
mbed_official 52:a51c77007319 365
mbed_official 52:a51c77007319 366 #define IS_ADC_INJECTED_LENGTH(LENGTH) (((LENGTH) >= 0x1) && ((LENGTH) <= 0x4))
mbed_official 52:a51c77007319 367
mbed_official 52:a51c77007319 368 /**
mbed_official 52:a51c77007319 369 * @}
mbed_official 52:a51c77007319 370 */
mbed_official 52:a51c77007319 371
mbed_official 52:a51c77007319 372 /** @defgroup ADC_injected_rank
mbed_official 52:a51c77007319 373 * @{
mbed_official 52:a51c77007319 374 */
mbed_official 52:a51c77007319 375
mbed_official 52:a51c77007319 376 #define IS_ADC_INJECTED_RANK(RANK) (((RANK) >= 0x1) && ((RANK) <= 0x4))
mbed_official 52:a51c77007319 377
mbed_official 52:a51c77007319 378 /**
mbed_official 52:a51c77007319 379 * @}
mbed_official 52:a51c77007319 380 */
mbed_official 52:a51c77007319 381
mbed_official 52:a51c77007319 382
mbed_official 52:a51c77007319 383 /** @defgroup ADC_regular_length
mbed_official 52:a51c77007319 384 * @{
mbed_official 52:a51c77007319 385 */
mbed_official 52:a51c77007319 386
mbed_official 52:a51c77007319 387 #define IS_ADC_REGULAR_LENGTH(LENGTH) (((LENGTH) >= 0x1) && ((LENGTH) <= 0x10))
mbed_official 52:a51c77007319 388 /**
mbed_official 52:a51c77007319 389 * @}
mbed_official 52:a51c77007319 390 */
mbed_official 52:a51c77007319 391
mbed_official 52:a51c77007319 392 /** @defgroup ADC_regular_rank
mbed_official 52:a51c77007319 393 * @{
mbed_official 52:a51c77007319 394 */
mbed_official 52:a51c77007319 395
mbed_official 52:a51c77007319 396 #define IS_ADC_REGULAR_RANK(RANK) (((RANK) >= 0x1) && ((RANK) <= 0x10))
mbed_official 52:a51c77007319 397
mbed_official 52:a51c77007319 398 /**
mbed_official 52:a51c77007319 399 * @}
mbed_official 52:a51c77007319 400 */
mbed_official 52:a51c77007319 401
mbed_official 52:a51c77007319 402 /** @defgroup ADC_regular_discontinuous_mode_number
mbed_official 52:a51c77007319 403 * @{
mbed_official 52:a51c77007319 404 */
mbed_official 52:a51c77007319 405
mbed_official 52:a51c77007319 406 #define IS_ADC_REGULAR_DISC_NUMBER(NUMBER) (((NUMBER) >= 0x1) && ((NUMBER) <= 0x8))
mbed_official 52:a51c77007319 407
mbed_official 52:a51c77007319 408 /**
mbed_official 52:a51c77007319 409 * @}
mbed_official 52:a51c77007319 410 */
mbed_official 52:a51c77007319 411
mbed_official 52:a51c77007319 412 /**
mbed_official 52:a51c77007319 413 * @}
mbed_official 52:a51c77007319 414 */
mbed_official 52:a51c77007319 415
mbed_official 52:a51c77007319 416 /** @defgroup ADC_Exported_Macros
mbed_official 52:a51c77007319 417 * @{
mbed_official 52:a51c77007319 418 */
mbed_official 52:a51c77007319 419
mbed_official 52:a51c77007319 420 /**
mbed_official 52:a51c77007319 421 * @}
mbed_official 52:a51c77007319 422 */
mbed_official 52:a51c77007319 423
mbed_official 52:a51c77007319 424 /** @defgroup ADC_Exported_Functions
mbed_official 52:a51c77007319 425 * @{
mbed_official 52:a51c77007319 426 */
mbed_official 52:a51c77007319 427
mbed_official 52:a51c77007319 428 void ADC_DeInit(ADC_TypeDef* ADCx);
mbed_official 52:a51c77007319 429 void ADC_Init(ADC_TypeDef* ADCx, ADC_InitTypeDef* ADC_InitStruct);
mbed_official 52:a51c77007319 430 void ADC_StructInit(ADC_InitTypeDef* ADC_InitStruct);
mbed_official 52:a51c77007319 431 void ADC_Cmd(ADC_TypeDef* ADCx, FunctionalState NewState);
mbed_official 52:a51c77007319 432 void ADC_DMACmd(ADC_TypeDef* ADCx, FunctionalState NewState);
mbed_official 52:a51c77007319 433 void ADC_ITConfig(ADC_TypeDef* ADCx, uint16_t ADC_IT, FunctionalState NewState);
mbed_official 52:a51c77007319 434 void ADC_ResetCalibration(ADC_TypeDef* ADCx);
mbed_official 52:a51c77007319 435 FlagStatus ADC_GetResetCalibrationStatus(ADC_TypeDef* ADCx);
mbed_official 52:a51c77007319 436 void ADC_StartCalibration(ADC_TypeDef* ADCx);
mbed_official 52:a51c77007319 437 FlagStatus ADC_GetCalibrationStatus(ADC_TypeDef* ADCx);
mbed_official 52:a51c77007319 438 void ADC_SoftwareStartConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
mbed_official 52:a51c77007319 439 FlagStatus ADC_GetSoftwareStartConvStatus(ADC_TypeDef* ADCx);
mbed_official 52:a51c77007319 440 void ADC_DiscModeChannelCountConfig(ADC_TypeDef* ADCx, uint8_t Number);
mbed_official 52:a51c77007319 441 void ADC_DiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
mbed_official 52:a51c77007319 442 void ADC_RegularChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime);
mbed_official 52:a51c77007319 443 void ADC_ExternalTrigConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
mbed_official 52:a51c77007319 444 uint16_t ADC_GetConversionValue(ADC_TypeDef* ADCx);
mbed_official 52:a51c77007319 445 uint32_t ADC_GetDualModeConversionValue(void);
mbed_official 52:a51c77007319 446 void ADC_AutoInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
mbed_official 52:a51c77007319 447 void ADC_InjectedDiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
mbed_official 52:a51c77007319 448 void ADC_ExternalTrigInjectedConvConfig(ADC_TypeDef* ADCx, uint32_t ADC_ExternalTrigInjecConv);
mbed_official 52:a51c77007319 449 void ADC_ExternalTrigInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
mbed_official 52:a51c77007319 450 void ADC_SoftwareStartInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState);
mbed_official 52:a51c77007319 451 FlagStatus ADC_GetSoftwareStartInjectedConvCmdStatus(ADC_TypeDef* ADCx);
mbed_official 52:a51c77007319 452 void ADC_InjectedChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime);
mbed_official 52:a51c77007319 453 void ADC_InjectedSequencerLengthConfig(ADC_TypeDef* ADCx, uint8_t Length);
mbed_official 52:a51c77007319 454 void ADC_SetInjectedOffset(ADC_TypeDef* ADCx, uint8_t ADC_InjectedChannel, uint16_t Offset);
mbed_official 52:a51c77007319 455 uint16_t ADC_GetInjectedConversionValue(ADC_TypeDef* ADCx, uint8_t ADC_InjectedChannel);
mbed_official 52:a51c77007319 456 void ADC_AnalogWatchdogCmd(ADC_TypeDef* ADCx, uint32_t ADC_AnalogWatchdog);
mbed_official 52:a51c77007319 457 void ADC_AnalogWatchdogThresholdsConfig(ADC_TypeDef* ADCx, uint16_t HighThreshold, uint16_t LowThreshold);
mbed_official 52:a51c77007319 458 void ADC_AnalogWatchdogSingleChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel);
mbed_official 52:a51c77007319 459 void ADC_TempSensorVrefintCmd(FunctionalState NewState);
mbed_official 52:a51c77007319 460 FlagStatus ADC_GetFlagStatus(ADC_TypeDef* ADCx, uint8_t ADC_FLAG);
mbed_official 52:a51c77007319 461 void ADC_ClearFlag(ADC_TypeDef* ADCx, uint8_t ADC_FLAG);
mbed_official 52:a51c77007319 462 ITStatus ADC_GetITStatus(ADC_TypeDef* ADCx, uint16_t ADC_IT);
mbed_official 52:a51c77007319 463 void ADC_ClearITPendingBit(ADC_TypeDef* ADCx, uint16_t ADC_IT);
mbed_official 52:a51c77007319 464
mbed_official 52:a51c77007319 465 #ifdef __cplusplus
mbed_official 52:a51c77007319 466 }
mbed_official 52:a51c77007319 467 #endif
mbed_official 52:a51c77007319 468
mbed_official 52:a51c77007319 469 #endif /*__STM32F10x_ADC_H */
mbed_official 52:a51c77007319 470
mbed_official 52:a51c77007319 471 /**
mbed_official 52:a51c77007319 472 * @}
mbed_official 52:a51c77007319 473 */
mbed_official 52:a51c77007319 474
mbed_official 52:a51c77007319 475 /**
mbed_official 52:a51c77007319 476 * @}
mbed_official 52:a51c77007319 477 */
mbed_official 52:a51c77007319 478
mbed_official 52:a51c77007319 479 /**
mbed_official 52:a51c77007319 480 * @}
mbed_official 52:a51c77007319 481 */
mbed_official 52:a51c77007319 482
mbed_official 52:a51c77007319 483 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/