mbed library with additional peripherals for ST F401 board

Fork of mbed-src by mbed official

This mbed LIB has additional peripherals for ST F401 board

  • UART2 : PA_3 rx, PA_2 tx
  • UART3 : PC_7 rx, PC_6 tx
  • I2C2 : PB_3 SDA, PB_10 SCL
  • I2C3 : PB_4 SDA, PA_8 SCL
Committer:
mbed_official
Date:
Tue Jan 07 11:00:05 2014 +0000
Revision:
70:c1fbde68b492
Parent:
52:a51c77007319
Child:
84:f54042cbc282
Synchronized with git revision 3f438a307904431f2782db3c8fa49946b9fc1d85

Full URL: https://github.com/mbedmicro/mbed/commit/3f438a307904431f2782db3c8fa49946b9fc1d85/

[NUCLEO_F103RB] license text changed + sleep hal updated

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