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:
Wed Feb 26 09:45:12 2014 +0000
Revision:
106:ced8cbb51063
Parent:
76:aeb1df146756
Synchronized with git revision 4222735eff5868389433f0e9271976b39c8115cd

Full URL: https://github.com/mbedmicro/mbed/commit/4222735eff5868389433f0e9271976b39c8115cd/

[NUCLEO_xxx] Update STM32CubeF4 driver V1.0.0 + update license

Who changed what in which revision?

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