mbed library sources

Dependents:   bare

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Wed Mar 19 10:15:22 2014 +0000
Revision:
125:23cc3068a9e4
Synchronized with git revision ace35dfba3748c7cdc102eb38ec6b9e1067c3252

Full URL: https://github.com/mbedmicro/mbed/commit/ace35dfba3748c7cdc102eb38ec6b9e1067c3252/

[NUCLEO_F302R8] Add cmsis and hal files + change F401RE clock to 84MHz

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 125:23cc3068a9e4 1 /**
mbed_official 125:23cc3068a9e4 2 ******************************************************************************
mbed_official 125:23cc3068a9e4 3 * @file stm32f30x_adc.c
mbed_official 125:23cc3068a9e4 4 * @author MCD Application Team
mbed_official 125:23cc3068a9e4 5 * @version V1.1.0
mbed_official 125:23cc3068a9e4 6 * @date 27-February-2014
mbed_official 125:23cc3068a9e4 7 * @brief This file provides firmware functions to manage the following
mbed_official 125:23cc3068a9e4 8 * functionalities of the Analog to Digital Convertor (ADC) peripheral:
mbed_official 125:23cc3068a9e4 9 * + Initialization and Configuration
mbed_official 125:23cc3068a9e4 10 * + Analog Watchdog configuration
mbed_official 125:23cc3068a9e4 11 * + Temperature Sensor, Vbat & Vrefint (Internal Reference Voltage) management
mbed_official 125:23cc3068a9e4 12 * + Regular Channels Configuration
mbed_official 125:23cc3068a9e4 13 * + Regular Channels DMA Configuration
mbed_official 125:23cc3068a9e4 14 * + Injected channels Configuration
mbed_official 125:23cc3068a9e4 15 * + Interrupts and flags management
mbed_official 125:23cc3068a9e4 16 * + Dual mode configuration
mbed_official 125:23cc3068a9e4 17 *
mbed_official 125:23cc3068a9e4 18 @verbatim
mbed_official 125:23cc3068a9e4 19 ==============================================================================
mbed_official 125:23cc3068a9e4 20 ##### How to use this driver #####
mbed_official 125:23cc3068a9e4 21 ==============================================================================
mbed_official 125:23cc3068a9e4 22 [..]
mbed_official 125:23cc3068a9e4 23 (#) select the ADC clock using the function RCC_ADCCLKConfig()
mbed_official 125:23cc3068a9e4 24 (#) Enable the ADC interface clock using RCC_AHBPeriphClockCmd();
mbed_official 125:23cc3068a9e4 25 (#) ADC pins configuration
mbed_official 125:23cc3068a9e4 26 (++) Enable the clock for the ADC GPIOs using the following function:
mbed_official 125:23cc3068a9e4 27 RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOx, ENABLE);
mbed_official 125:23cc3068a9e4 28 (++) Configure these ADC pins in analog mode using GPIO_Init();
mbed_official 125:23cc3068a9e4 29 (#) Configure the ADC conversion resolution, data alignment, external
mbed_official 125:23cc3068a9e4 30 trigger and edge, sequencer lenght and Enable/Disable the continuous mode
mbed_official 125:23cc3068a9e4 31 using the ADC_Init() function.
mbed_official 125:23cc3068a9e4 32 (#) Activate the ADC peripheral using ADC_Cmd() function.
mbed_official 125:23cc3068a9e4 33
mbed_official 125:23cc3068a9e4 34 *** ADC channels group configuration ***
mbed_official 125:23cc3068a9e4 35 ========================================
mbed_official 125:23cc3068a9e4 36 [..]
mbed_official 125:23cc3068a9e4 37 (+) To configure the ADC channels features, use ADC_Init(), ADC_InjectedInit()
mbed_official 125:23cc3068a9e4 38 and/or ADC_RegularChannelConfig() functions.
mbed_official 125:23cc3068a9e4 39 (+) To activate the continuous mode, use the ADC_ContinuousModeCmd()
mbed_official 125:23cc3068a9e4 40 function.
mbed_official 125:23cc3068a9e4 41 (+) To activate the Discontinuous mode, use the ADC_DiscModeCmd() functions.
mbed_official 125:23cc3068a9e4 42 (+) To activate the overrun mode, use the ADC_OverrunModeCmd() functions.
mbed_official 125:23cc3068a9e4 43 (+) To activate the calibration mode, use the ADC_StartCalibration() functions.
mbed_official 125:23cc3068a9e4 44 (+) To read the ADC converted values, use the ADC_GetConversionValue()
mbed_official 125:23cc3068a9e4 45 function.
mbed_official 125:23cc3068a9e4 46
mbed_official 125:23cc3068a9e4 47 *** DMA for ADC channels features configuration ***
mbed_official 125:23cc3068a9e4 48 ===================================================
mbed_official 125:23cc3068a9e4 49 [..]
mbed_official 125:23cc3068a9e4 50 (+) To enable the DMA mode for ADC channels group, use the ADC_DMACmd() function.
mbed_official 125:23cc3068a9e4 51 (+) To configure the DMA transfer request, use ADC_DMAConfig() function.
mbed_official 125:23cc3068a9e4 52
mbed_official 125:23cc3068a9e4 53 @endverbatim
mbed_official 125:23cc3068a9e4 54 *
mbed_official 125:23cc3068a9e4 55 ******************************************************************************
mbed_official 125:23cc3068a9e4 56 * @attention
mbed_official 125:23cc3068a9e4 57 *
mbed_official 125:23cc3068a9e4 58 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 125:23cc3068a9e4 59 *
mbed_official 125:23cc3068a9e4 60 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 125:23cc3068a9e4 61 * are permitted provided that the following conditions are met:
mbed_official 125:23cc3068a9e4 62 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 125:23cc3068a9e4 63 * this list of conditions and the following disclaimer.
mbed_official 125:23cc3068a9e4 64 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 125:23cc3068a9e4 65 * this list of conditions and the following disclaimer in the documentation
mbed_official 125:23cc3068a9e4 66 * and/or other materials provided with the distribution.
mbed_official 125:23cc3068a9e4 67 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 125:23cc3068a9e4 68 * may be used to endorse or promote products derived from this software
mbed_official 125:23cc3068a9e4 69 * without specific prior written permission.
mbed_official 125:23cc3068a9e4 70 *
mbed_official 125:23cc3068a9e4 71 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 125:23cc3068a9e4 72 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 125:23cc3068a9e4 73 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 125:23cc3068a9e4 74 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 125:23cc3068a9e4 75 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 125:23cc3068a9e4 76 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 125:23cc3068a9e4 77 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 125:23cc3068a9e4 78 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 125:23cc3068a9e4 79 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 125:23cc3068a9e4 80 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 125:23cc3068a9e4 81 *
mbed_official 125:23cc3068a9e4 82 ******************************************************************************
mbed_official 125:23cc3068a9e4 83 */
mbed_official 125:23cc3068a9e4 84
mbed_official 125:23cc3068a9e4 85 /* Includes ------------------------------------------------------------------*/
mbed_official 125:23cc3068a9e4 86 #include "stm32f30x_adc.h"
mbed_official 125:23cc3068a9e4 87 #include "stm32f30x_rcc.h"
mbed_official 125:23cc3068a9e4 88
mbed_official 125:23cc3068a9e4 89 /** @addtogroup STM32F30x_StdPeriph_Driver
mbed_official 125:23cc3068a9e4 90 * @{
mbed_official 125:23cc3068a9e4 91 */
mbed_official 125:23cc3068a9e4 92
mbed_official 125:23cc3068a9e4 93 /** @defgroup ADC
mbed_official 125:23cc3068a9e4 94 * @brief ADC driver modules
mbed_official 125:23cc3068a9e4 95 * @{
mbed_official 125:23cc3068a9e4 96 */
mbed_official 125:23cc3068a9e4 97
mbed_official 125:23cc3068a9e4 98 /* Private typedef -----------------------------------------------------------*/
mbed_official 125:23cc3068a9e4 99 /* Private define ------------------------------------------------------------*/
mbed_official 125:23cc3068a9e4 100
mbed_official 125:23cc3068a9e4 101 /* CFGR register Mask */
mbed_official 125:23cc3068a9e4 102 #define CFGR_CLEAR_Mask ((uint32_t)0xFDFFC007)
mbed_official 125:23cc3068a9e4 103
mbed_official 125:23cc3068a9e4 104 /* JSQR register Mask */
mbed_official 125:23cc3068a9e4 105 #define JSQR_CLEAR_Mask ((uint32_t)0x00000000)
mbed_official 125:23cc3068a9e4 106
mbed_official 125:23cc3068a9e4 107 /* ADC ADON mask */
mbed_official 125:23cc3068a9e4 108 #define CCR_CLEAR_MASK ((uint32_t)0xFFFC10E0)
mbed_official 125:23cc3068a9e4 109
mbed_official 125:23cc3068a9e4 110 /* ADC JDRx registers offset */
mbed_official 125:23cc3068a9e4 111 #define JDR_Offset ((uint8_t)0x80)
mbed_official 125:23cc3068a9e4 112
mbed_official 125:23cc3068a9e4 113 /* Private macro -------------------------------------------------------------*/
mbed_official 125:23cc3068a9e4 114 /* Private variables ---------------------------------------------------------*/
mbed_official 125:23cc3068a9e4 115 /* Private function prototypes -----------------------------------------------*/
mbed_official 125:23cc3068a9e4 116 /* Private functions ---------------------------------------------------------*/
mbed_official 125:23cc3068a9e4 117
mbed_official 125:23cc3068a9e4 118 /** @defgroup ADC_Private_Functions
mbed_official 125:23cc3068a9e4 119 * @{
mbed_official 125:23cc3068a9e4 120 */
mbed_official 125:23cc3068a9e4 121
mbed_official 125:23cc3068a9e4 122 /** @defgroup ADC_Group1 Initialization and Configuration functions
mbed_official 125:23cc3068a9e4 123 * @brief Initialization and Configuration functions
mbed_official 125:23cc3068a9e4 124 *
mbed_official 125:23cc3068a9e4 125 @verbatim
mbed_official 125:23cc3068a9e4 126 ===============================================================================
mbed_official 125:23cc3068a9e4 127 ##### Initialization and Configuration functions #####
mbed_official 125:23cc3068a9e4 128 ===============================================================================
mbed_official 125:23cc3068a9e4 129 [..]
mbed_official 125:23cc3068a9e4 130 This section provides functions allowing to:
mbed_official 125:23cc3068a9e4 131 (#) Initialize and configure the ADC injected and/or regular channels and dual mode.
mbed_official 125:23cc3068a9e4 132 (#) Management of the calibration process
mbed_official 125:23cc3068a9e4 133 (#) ADC Power-on Power-off
mbed_official 125:23cc3068a9e4 134 (#) Single ended or differential mode
mbed_official 125:23cc3068a9e4 135 (#) Enabling the queue of context and the auto delay mode
mbed_official 125:23cc3068a9e4 136 (#) The number of ADC conversions that will be done using the sequencer for regular
mbed_official 125:23cc3068a9e4 137 channel group
mbed_official 125:23cc3068a9e4 138 (#) Enable or disable the ADC peripheral
mbed_official 125:23cc3068a9e4 139
mbed_official 125:23cc3068a9e4 140 @endverbatim
mbed_official 125:23cc3068a9e4 141 * @{
mbed_official 125:23cc3068a9e4 142 */
mbed_official 125:23cc3068a9e4 143
mbed_official 125:23cc3068a9e4 144 /**
mbed_official 125:23cc3068a9e4 145 * @brief Deinitializes the ADCx peripheral registers to their default reset values.
mbed_official 125:23cc3068a9e4 146 * @param ADCx: where x can be 1, 2,3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 147 * @retval None
mbed_official 125:23cc3068a9e4 148 */
mbed_official 125:23cc3068a9e4 149 void ADC_DeInit(ADC_TypeDef* ADCx)
mbed_official 125:23cc3068a9e4 150 {
mbed_official 125:23cc3068a9e4 151 /* Check the parameters */
mbed_official 125:23cc3068a9e4 152 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 153
mbed_official 125:23cc3068a9e4 154
mbed_official 125:23cc3068a9e4 155 if((ADCx == ADC1) || (ADCx == ADC2))
mbed_official 125:23cc3068a9e4 156 {
mbed_official 125:23cc3068a9e4 157 /* Enable ADC1/ADC2 reset state */
mbed_official 125:23cc3068a9e4 158 RCC_AHBPeriphResetCmd(RCC_AHBPeriph_ADC12, ENABLE);
mbed_official 125:23cc3068a9e4 159 /* Release ADC1/ADC2 from reset state */
mbed_official 125:23cc3068a9e4 160 RCC_AHBPeriphResetCmd(RCC_AHBPeriph_ADC12, DISABLE);
mbed_official 125:23cc3068a9e4 161 }
mbed_official 125:23cc3068a9e4 162 else if((ADCx == ADC3) || (ADCx == ADC4))
mbed_official 125:23cc3068a9e4 163 {
mbed_official 125:23cc3068a9e4 164 /* Enable ADC3/ADC4 reset state */
mbed_official 125:23cc3068a9e4 165 RCC_AHBPeriphResetCmd(RCC_AHBPeriph_ADC34, ENABLE);
mbed_official 125:23cc3068a9e4 166 /* Release ADC3/ADC4 from reset state */
mbed_official 125:23cc3068a9e4 167 RCC_AHBPeriphResetCmd(RCC_AHBPeriph_ADC34, DISABLE);
mbed_official 125:23cc3068a9e4 168 }
mbed_official 125:23cc3068a9e4 169 }
mbed_official 125:23cc3068a9e4 170 /**
mbed_official 125:23cc3068a9e4 171 * @brief Initializes the ADCx peripheral according to the specified parameters
mbed_official 125:23cc3068a9e4 172 * in the ADC_InitStruct.
mbed_official 125:23cc3068a9e4 173 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 174 * @param ADC_InitStruct: pointer to an ADC_InitTypeDef structure that contains
mbed_official 125:23cc3068a9e4 175 * the configuration information for the specified ADC peripheral.
mbed_official 125:23cc3068a9e4 176 * @retval None
mbed_official 125:23cc3068a9e4 177 */
mbed_official 125:23cc3068a9e4 178 void ADC_Init(ADC_TypeDef* ADCx, ADC_InitTypeDef* ADC_InitStruct)
mbed_official 125:23cc3068a9e4 179 {
mbed_official 125:23cc3068a9e4 180 uint32_t tmpreg1 = 0;
mbed_official 125:23cc3068a9e4 181 /* Check the parameters */
mbed_official 125:23cc3068a9e4 182 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 183 assert_param(IS_ADC_CONVMODE(ADC_InitStruct->ADC_ContinuousConvMode));
mbed_official 125:23cc3068a9e4 184 assert_param(IS_ADC_RESOLUTION(ADC_InitStruct->ADC_Resolution));
mbed_official 125:23cc3068a9e4 185 assert_param(IS_ADC_EXT_TRIG(ADC_InitStruct->ADC_ExternalTrigConvEvent));
mbed_official 125:23cc3068a9e4 186 assert_param(IS_EXTERNALTRIG_EDGE(ADC_InitStruct->ADC_ExternalTrigEventEdge));
mbed_official 125:23cc3068a9e4 187 assert_param(IS_ADC_DATA_ALIGN(ADC_InitStruct->ADC_DataAlign));
mbed_official 125:23cc3068a9e4 188 assert_param(IS_ADC_OVRUNMODE(ADC_InitStruct->ADC_OverrunMode));
mbed_official 125:23cc3068a9e4 189 assert_param(IS_ADC_AUTOINJECMODE(ADC_InitStruct->ADC_AutoInjMode));
mbed_official 125:23cc3068a9e4 190 assert_param(IS_ADC_REGULAR_LENGTH(ADC_InitStruct->ADC_NbrOfRegChannel));
mbed_official 125:23cc3068a9e4 191
mbed_official 125:23cc3068a9e4 192 /*---------------------------- ADCx CFGR Configuration -----------------*/
mbed_official 125:23cc3068a9e4 193 /* Get the ADCx CFGR value */
mbed_official 125:23cc3068a9e4 194 tmpreg1 = ADCx->CFGR;
mbed_official 125:23cc3068a9e4 195 /* Clear SCAN bit */
mbed_official 125:23cc3068a9e4 196 tmpreg1 &= CFGR_CLEAR_Mask;
mbed_official 125:23cc3068a9e4 197 /* Configure ADCx: scan conversion mode */
mbed_official 125:23cc3068a9e4 198 /* Set SCAN bit according to ADC_ScanConvMode value */
mbed_official 125:23cc3068a9e4 199 tmpreg1 |= (uint32_t)ADC_InitStruct->ADC_ContinuousConvMode |
mbed_official 125:23cc3068a9e4 200 ADC_InitStruct->ADC_Resolution|
mbed_official 125:23cc3068a9e4 201 ADC_InitStruct->ADC_ExternalTrigConvEvent|
mbed_official 125:23cc3068a9e4 202 ADC_InitStruct->ADC_ExternalTrigEventEdge|
mbed_official 125:23cc3068a9e4 203 ADC_InitStruct->ADC_DataAlign|
mbed_official 125:23cc3068a9e4 204 ADC_InitStruct->ADC_OverrunMode|
mbed_official 125:23cc3068a9e4 205 ADC_InitStruct->ADC_AutoInjMode;
mbed_official 125:23cc3068a9e4 206
mbed_official 125:23cc3068a9e4 207 /* Write to ADCx CFGR */
mbed_official 125:23cc3068a9e4 208 ADCx->CFGR = tmpreg1;
mbed_official 125:23cc3068a9e4 209
mbed_official 125:23cc3068a9e4 210 /*---------------------------- ADCx SQR1 Configuration -----------------*/
mbed_official 125:23cc3068a9e4 211 /* Get the ADCx SQR1 value */
mbed_official 125:23cc3068a9e4 212 tmpreg1 = ADCx->SQR1;
mbed_official 125:23cc3068a9e4 213 /* Clear L bits */
mbed_official 125:23cc3068a9e4 214 tmpreg1 &= ~(uint32_t)(ADC_SQR1_L);
mbed_official 125:23cc3068a9e4 215 /* Configure ADCx: regular channel sequence length */
mbed_official 125:23cc3068a9e4 216 /* Set L bits according to ADC_NbrOfRegChannel value */
mbed_official 125:23cc3068a9e4 217 tmpreg1 |= (uint32_t) (ADC_InitStruct->ADC_NbrOfRegChannel - 1);
mbed_official 125:23cc3068a9e4 218 /* Write to ADCx SQR1 */
mbed_official 125:23cc3068a9e4 219 ADCx->SQR1 = tmpreg1;
mbed_official 125:23cc3068a9e4 220
mbed_official 125:23cc3068a9e4 221 }
mbed_official 125:23cc3068a9e4 222
mbed_official 125:23cc3068a9e4 223 /**
mbed_official 125:23cc3068a9e4 224 * @brief Fills each ADC_InitStruct member with its default value.
mbed_official 125:23cc3068a9e4 225 * @param ADC_InitStruct : pointer to an ADC_InitTypeDef structure which will be initialized.
mbed_official 125:23cc3068a9e4 226 * @retval None
mbed_official 125:23cc3068a9e4 227 */
mbed_official 125:23cc3068a9e4 228 void ADC_StructInit(ADC_InitTypeDef* ADC_InitStruct)
mbed_official 125:23cc3068a9e4 229 {
mbed_official 125:23cc3068a9e4 230 /* Reset ADC init structure parameters values */
mbed_official 125:23cc3068a9e4 231 ADC_InitStruct->ADC_ContinuousConvMode = DISABLE;
mbed_official 125:23cc3068a9e4 232 ADC_InitStruct->ADC_Resolution = ADC_Resolution_12b;
mbed_official 125:23cc3068a9e4 233 ADC_InitStruct->ADC_ExternalTrigConvEvent = ADC_ExternalTrigConvEvent_0;
mbed_official 125:23cc3068a9e4 234 ADC_InitStruct->ADC_ExternalTrigEventEdge = ADC_ExternalTrigEventEdge_None;
mbed_official 125:23cc3068a9e4 235 ADC_InitStruct->ADC_DataAlign = ADC_DataAlign_Right;
mbed_official 125:23cc3068a9e4 236 ADC_InitStruct->ADC_OverrunMode = DISABLE;
mbed_official 125:23cc3068a9e4 237 ADC_InitStruct->ADC_AutoInjMode = DISABLE;
mbed_official 125:23cc3068a9e4 238 ADC_InitStruct->ADC_NbrOfRegChannel = 1;
mbed_official 125:23cc3068a9e4 239 }
mbed_official 125:23cc3068a9e4 240
mbed_official 125:23cc3068a9e4 241 /**
mbed_official 125:23cc3068a9e4 242 * @brief Initializes the ADCx peripheral according to the specified parameters
mbed_official 125:23cc3068a9e4 243 * in the ADC_InitStruct.
mbed_official 125:23cc3068a9e4 244 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 245 * @param ADC_InjectInitStruct: pointer to an ADC_InjecInitTypeDef structure that contains
mbed_official 125:23cc3068a9e4 246 * the configuration information for the specified ADC injected channel.
mbed_official 125:23cc3068a9e4 247 * @retval None
mbed_official 125:23cc3068a9e4 248 */
mbed_official 125:23cc3068a9e4 249 void ADC_InjectedInit(ADC_TypeDef* ADCx, ADC_InjectedInitTypeDef* ADC_InjectedInitStruct)
mbed_official 125:23cc3068a9e4 250 {
mbed_official 125:23cc3068a9e4 251 uint32_t tmpreg1 = 0;
mbed_official 125:23cc3068a9e4 252 /* Check the parameters */
mbed_official 125:23cc3068a9e4 253 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 254 assert_param(IS_ADC_EXT_INJEC_TRIG(ADC_InjectedInitStruct->ADC_ExternalTrigInjecConvEvent));
mbed_official 125:23cc3068a9e4 255 assert_param(IS_EXTERNALTRIGINJ_EDGE(ADC_InjectedInitStruct->ADC_ExternalTrigInjecEventEdge));
mbed_official 125:23cc3068a9e4 256 assert_param(IS_ADC_INJECTED_LENGTH(ADC_InjectedInitStruct->ADC_NbrOfInjecChannel));
mbed_official 125:23cc3068a9e4 257 assert_param(IS_ADC_INJECTED_CHANNEL(ADC_InjectedInitStruct->ADC_InjecSequence1));
mbed_official 125:23cc3068a9e4 258 assert_param(IS_ADC_INJECTED_CHANNEL(ADC_InjectedInitStruct->ADC_InjecSequence2));
mbed_official 125:23cc3068a9e4 259 assert_param(IS_ADC_INJECTED_CHANNEL(ADC_InjectedInitStruct->ADC_InjecSequence3));
mbed_official 125:23cc3068a9e4 260 assert_param(IS_ADC_INJECTED_CHANNEL(ADC_InjectedInitStruct->ADC_InjecSequence4));
mbed_official 125:23cc3068a9e4 261
mbed_official 125:23cc3068a9e4 262 /*---------------------------- ADCx JSQR Configuration -----------------*/
mbed_official 125:23cc3068a9e4 263 /* Get the ADCx JSQR value */
mbed_official 125:23cc3068a9e4 264 tmpreg1 = ADCx->JSQR;
mbed_official 125:23cc3068a9e4 265 /* Clear L bits */
mbed_official 125:23cc3068a9e4 266 tmpreg1 &= JSQR_CLEAR_Mask;
mbed_official 125:23cc3068a9e4 267 /* Configure ADCx: Injected channel sequence length, external trigger,
mbed_official 125:23cc3068a9e4 268 external trigger edge and sequences
mbed_official 125:23cc3068a9e4 269 */
mbed_official 125:23cc3068a9e4 270 tmpreg1 = (uint32_t) ((ADC_InjectedInitStruct->ADC_NbrOfInjecChannel - (uint8_t)1) |
mbed_official 125:23cc3068a9e4 271 ADC_InjectedInitStruct->ADC_ExternalTrigInjecConvEvent |
mbed_official 125:23cc3068a9e4 272 ADC_InjectedInitStruct->ADC_ExternalTrigInjecEventEdge |
mbed_official 125:23cc3068a9e4 273 (uint32_t)((ADC_InjectedInitStruct->ADC_InjecSequence1) << 8) |
mbed_official 125:23cc3068a9e4 274 (uint32_t)((ADC_InjectedInitStruct->ADC_InjecSequence2) << 14) |
mbed_official 125:23cc3068a9e4 275 (uint32_t)((ADC_InjectedInitStruct->ADC_InjecSequence3) << 20) |
mbed_official 125:23cc3068a9e4 276 (uint32_t)((ADC_InjectedInitStruct->ADC_InjecSequence4) << 26));
mbed_official 125:23cc3068a9e4 277 /* Write to ADCx SQR1 */
mbed_official 125:23cc3068a9e4 278 ADCx->JSQR = tmpreg1;
mbed_official 125:23cc3068a9e4 279 }
mbed_official 125:23cc3068a9e4 280
mbed_official 125:23cc3068a9e4 281 /**
mbed_official 125:23cc3068a9e4 282 * @brief Fills each ADC_InjectedInitStruct member with its default value.
mbed_official 125:23cc3068a9e4 283 * @param ADC_InjectedInitStruct : pointer to an ADC_InjectedInitTypeDef structure which will be initialized.
mbed_official 125:23cc3068a9e4 284 * @retval None
mbed_official 125:23cc3068a9e4 285 */
mbed_official 125:23cc3068a9e4 286 void ADC_InjectedStructInit(ADC_InjectedInitTypeDef* ADC_InjectedInitStruct)
mbed_official 125:23cc3068a9e4 287 {
mbed_official 125:23cc3068a9e4 288 ADC_InjectedInitStruct->ADC_ExternalTrigInjecConvEvent = ADC_ExternalTrigInjecConvEvent_0;
mbed_official 125:23cc3068a9e4 289 ADC_InjectedInitStruct->ADC_ExternalTrigInjecEventEdge = ADC_ExternalTrigInjecEventEdge_None;
mbed_official 125:23cc3068a9e4 290 ADC_InjectedInitStruct->ADC_NbrOfInjecChannel = 1;
mbed_official 125:23cc3068a9e4 291 ADC_InjectedInitStruct->ADC_InjecSequence1 = ADC_InjectedChannel_1;
mbed_official 125:23cc3068a9e4 292 ADC_InjectedInitStruct->ADC_InjecSequence2 = ADC_InjectedChannel_1;
mbed_official 125:23cc3068a9e4 293 ADC_InjectedInitStruct->ADC_InjecSequence3 = ADC_InjectedChannel_1;
mbed_official 125:23cc3068a9e4 294 ADC_InjectedInitStruct->ADC_InjecSequence4 = ADC_InjectedChannel_1;
mbed_official 125:23cc3068a9e4 295 }
mbed_official 125:23cc3068a9e4 296
mbed_official 125:23cc3068a9e4 297 /**
mbed_official 125:23cc3068a9e4 298 * @brief Initializes the ADCs peripherals according to the specified parameters
mbed_official 125:23cc3068a9e4 299 * in the ADC_CommonInitStruct.
mbed_official 125:23cc3068a9e4 300 * @param ADCx: where x can be 1 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 301 * @param ADC_CommonInitStruct: pointer to an ADC_CommonInitTypeDef structure
mbed_official 125:23cc3068a9e4 302 * that contains the configuration information for All ADCs peripherals.
mbed_official 125:23cc3068a9e4 303 * @retval None
mbed_official 125:23cc3068a9e4 304 */
mbed_official 125:23cc3068a9e4 305 void ADC_CommonInit(ADC_TypeDef* ADCx, ADC_CommonInitTypeDef* ADC_CommonInitStruct)
mbed_official 125:23cc3068a9e4 306 {
mbed_official 125:23cc3068a9e4 307 uint32_t tmpreg1 = 0;
mbed_official 125:23cc3068a9e4 308 /* Check the parameters */
mbed_official 125:23cc3068a9e4 309 assert_param(IS_ADC_MODE(ADC_CommonInitStruct->ADC_Mode));
mbed_official 125:23cc3068a9e4 310 assert_param(IS_ADC_CLOCKMODE(ADC_CommonInitStruct->ADC_Clock));
mbed_official 125:23cc3068a9e4 311 assert_param(IS_ADC_DMA_MODE(ADC_CommonInitStruct->ADC_DMAMode));
mbed_official 125:23cc3068a9e4 312 assert_param(IS_ADC_DMA_ACCESS_MODE(ADC_CommonInitStruct->ADC_DMAAccessMode));
mbed_official 125:23cc3068a9e4 313 assert_param(IS_ADC_TWOSAMPLING_DELAY(ADC_CommonInitStruct->ADC_TwoSamplingDelay));
mbed_official 125:23cc3068a9e4 314
mbed_official 125:23cc3068a9e4 315 if((ADCx == ADC1) || (ADCx == ADC2))
mbed_official 125:23cc3068a9e4 316 {
mbed_official 125:23cc3068a9e4 317 /* Get the ADC CCR value */
mbed_official 125:23cc3068a9e4 318 tmpreg1 = ADC1_2->CCR;
mbed_official 125:23cc3068a9e4 319
mbed_official 125:23cc3068a9e4 320 /* Clear MULTI, DELAY, DMA and ADCPRE bits */
mbed_official 125:23cc3068a9e4 321 tmpreg1 &= CCR_CLEAR_MASK;
mbed_official 125:23cc3068a9e4 322 }
mbed_official 125:23cc3068a9e4 323 else
mbed_official 125:23cc3068a9e4 324 {
mbed_official 125:23cc3068a9e4 325 /* Get the ADC CCR value */
mbed_official 125:23cc3068a9e4 326 tmpreg1 = ADC3_4->CCR;
mbed_official 125:23cc3068a9e4 327
mbed_official 125:23cc3068a9e4 328 /* Clear MULTI, DELAY, DMA and ADCPRE bits */
mbed_official 125:23cc3068a9e4 329 tmpreg1 &= CCR_CLEAR_MASK;
mbed_official 125:23cc3068a9e4 330 }
mbed_official 125:23cc3068a9e4 331 /*---------------------------- ADC CCR Configuration -----------------*/
mbed_official 125:23cc3068a9e4 332 /* Configure ADCx: Multi mode, Delay between two sampling time, ADC clock, DMA mode
mbed_official 125:23cc3068a9e4 333 and DMA access mode for dual mode */
mbed_official 125:23cc3068a9e4 334 /* Set MULTI bits according to ADC_Mode value */
mbed_official 125:23cc3068a9e4 335 /* Set CKMODE bits according to ADC_Clock value */
mbed_official 125:23cc3068a9e4 336 /* Set MDMA bits according to ADC_DMAAccessMode value */
mbed_official 125:23cc3068a9e4 337 /* Set DMACFG bits according to ADC_DMAMode value */
mbed_official 125:23cc3068a9e4 338 /* Set DELAY bits according to ADC_TwoSamplingDelay value */
mbed_official 125:23cc3068a9e4 339 tmpreg1 |= (uint32_t)(ADC_CommonInitStruct->ADC_Mode |
mbed_official 125:23cc3068a9e4 340 ADC_CommonInitStruct->ADC_Clock |
mbed_official 125:23cc3068a9e4 341 ADC_CommonInitStruct->ADC_DMAAccessMode |
mbed_official 125:23cc3068a9e4 342 (uint32_t)(ADC_CommonInitStruct->ADC_DMAMode << 12) |
mbed_official 125:23cc3068a9e4 343 (uint32_t)((uint32_t)ADC_CommonInitStruct->ADC_TwoSamplingDelay << 8));
mbed_official 125:23cc3068a9e4 344
mbed_official 125:23cc3068a9e4 345 if((ADCx == ADC1) || (ADCx == ADC2))
mbed_official 125:23cc3068a9e4 346 {
mbed_official 125:23cc3068a9e4 347 /* Write to ADC CCR */
mbed_official 125:23cc3068a9e4 348 ADC1_2->CCR = tmpreg1;
mbed_official 125:23cc3068a9e4 349 }
mbed_official 125:23cc3068a9e4 350 else
mbed_official 125:23cc3068a9e4 351 {
mbed_official 125:23cc3068a9e4 352 /* Write to ADC CCR */
mbed_official 125:23cc3068a9e4 353 ADC3_4->CCR = tmpreg1;
mbed_official 125:23cc3068a9e4 354 }
mbed_official 125:23cc3068a9e4 355 }
mbed_official 125:23cc3068a9e4 356
mbed_official 125:23cc3068a9e4 357 /**
mbed_official 125:23cc3068a9e4 358 * @brief Fills each ADC_CommonInitStruct member with its default value.
mbed_official 125:23cc3068a9e4 359 * @param ADC_CommonInitStruct: pointer to an ADC_CommonInitTypeDef structure
mbed_official 125:23cc3068a9e4 360 * which will be initialized.
mbed_official 125:23cc3068a9e4 361 * @retval None
mbed_official 125:23cc3068a9e4 362 */
mbed_official 125:23cc3068a9e4 363 void ADC_CommonStructInit(ADC_CommonInitTypeDef* ADC_CommonInitStruct)
mbed_official 125:23cc3068a9e4 364 {
mbed_official 125:23cc3068a9e4 365 /* Initialize the ADC_Mode member */
mbed_official 125:23cc3068a9e4 366 ADC_CommonInitStruct->ADC_Mode = ADC_Mode_Independent;
mbed_official 125:23cc3068a9e4 367
mbed_official 125:23cc3068a9e4 368 /* initialize the ADC_Clock member */
mbed_official 125:23cc3068a9e4 369 ADC_CommonInitStruct->ADC_Clock = ADC_Clock_AsynClkMode;
mbed_official 125:23cc3068a9e4 370
mbed_official 125:23cc3068a9e4 371 /* Initialize the ADC_DMAAccessMode member */
mbed_official 125:23cc3068a9e4 372 ADC_CommonInitStruct->ADC_DMAAccessMode = ADC_DMAAccessMode_Disabled;
mbed_official 125:23cc3068a9e4 373
mbed_official 125:23cc3068a9e4 374 /* Initialize the ADC_DMAMode member */
mbed_official 125:23cc3068a9e4 375 ADC_CommonInitStruct->ADC_DMAMode = ADC_DMAMode_OneShot;
mbed_official 125:23cc3068a9e4 376
mbed_official 125:23cc3068a9e4 377 /* Initialize the ADC_TwoSamplingDelay member */
mbed_official 125:23cc3068a9e4 378 ADC_CommonInitStruct->ADC_TwoSamplingDelay = 0;
mbed_official 125:23cc3068a9e4 379
mbed_official 125:23cc3068a9e4 380 }
mbed_official 125:23cc3068a9e4 381
mbed_official 125:23cc3068a9e4 382 /**
mbed_official 125:23cc3068a9e4 383 * @brief Enables or disables the specified ADC peripheral.
mbed_official 125:23cc3068a9e4 384 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 385 * @param NewState: new state of the ADCx peripheral.
mbed_official 125:23cc3068a9e4 386 * This parameter can be: ENABLE or DISABLE.
mbed_official 125:23cc3068a9e4 387 * @retval None
mbed_official 125:23cc3068a9e4 388 */
mbed_official 125:23cc3068a9e4 389 void ADC_Cmd(ADC_TypeDef* ADCx, FunctionalState NewState)
mbed_official 125:23cc3068a9e4 390 {
mbed_official 125:23cc3068a9e4 391 /* Check the parameters */
mbed_official 125:23cc3068a9e4 392 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 393 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 125:23cc3068a9e4 394
mbed_official 125:23cc3068a9e4 395 if (NewState != DISABLE)
mbed_official 125:23cc3068a9e4 396 {
mbed_official 125:23cc3068a9e4 397 /* Set the ADEN bit */
mbed_official 125:23cc3068a9e4 398 ADCx->CR |= ADC_CR_ADEN;
mbed_official 125:23cc3068a9e4 399 }
mbed_official 125:23cc3068a9e4 400 else
mbed_official 125:23cc3068a9e4 401 {
mbed_official 125:23cc3068a9e4 402 /* Disable the selected ADC peripheral: Set the ADDIS bit */
mbed_official 125:23cc3068a9e4 403 ADCx->CR |= ADC_CR_ADDIS;
mbed_official 125:23cc3068a9e4 404 }
mbed_official 125:23cc3068a9e4 405 }
mbed_official 125:23cc3068a9e4 406
mbed_official 125:23cc3068a9e4 407 /**
mbed_official 125:23cc3068a9e4 408 * @brief Starts the selected ADC calibration process.
mbed_official 125:23cc3068a9e4 409 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 410 * @retval None
mbed_official 125:23cc3068a9e4 411 */
mbed_official 125:23cc3068a9e4 412 void ADC_StartCalibration(ADC_TypeDef* ADCx)
mbed_official 125:23cc3068a9e4 413 {
mbed_official 125:23cc3068a9e4 414 /* Check the parameters */
mbed_official 125:23cc3068a9e4 415 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 416
mbed_official 125:23cc3068a9e4 417 /* Set the ADCAL bit */
mbed_official 125:23cc3068a9e4 418 ADCx->CR |= ADC_CR_ADCAL;
mbed_official 125:23cc3068a9e4 419 }
mbed_official 125:23cc3068a9e4 420
mbed_official 125:23cc3068a9e4 421 /**
mbed_official 125:23cc3068a9e4 422 * @brief Returns the ADCx calibration value.
mbed_official 125:23cc3068a9e4 423 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 424 * @retval None
mbed_official 125:23cc3068a9e4 425 */
mbed_official 125:23cc3068a9e4 426 uint32_t ADC_GetCalibrationValue(ADC_TypeDef* ADCx)
mbed_official 125:23cc3068a9e4 427 {
mbed_official 125:23cc3068a9e4 428 /* Check the parameters */
mbed_official 125:23cc3068a9e4 429 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 430
mbed_official 125:23cc3068a9e4 431 /* Return the selected ADC calibration value */
mbed_official 125:23cc3068a9e4 432 return (uint32_t)ADCx->CALFACT;
mbed_official 125:23cc3068a9e4 433 }
mbed_official 125:23cc3068a9e4 434
mbed_official 125:23cc3068a9e4 435 /**
mbed_official 125:23cc3068a9e4 436 * @brief Sets the ADCx calibration register.
mbed_official 125:23cc3068a9e4 437 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 438 * @retval None
mbed_official 125:23cc3068a9e4 439 */
mbed_official 125:23cc3068a9e4 440 void ADC_SetCalibrationValue(ADC_TypeDef* ADCx, uint32_t ADC_Calibration)
mbed_official 125:23cc3068a9e4 441 {
mbed_official 125:23cc3068a9e4 442 /* Check the parameters */
mbed_official 125:23cc3068a9e4 443 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 444
mbed_official 125:23cc3068a9e4 445 /* Set the ADC calibration register value */
mbed_official 125:23cc3068a9e4 446 ADCx->CALFACT = ADC_Calibration;
mbed_official 125:23cc3068a9e4 447 }
mbed_official 125:23cc3068a9e4 448
mbed_official 125:23cc3068a9e4 449 /**
mbed_official 125:23cc3068a9e4 450 * @brief Select the ADC calibration mode.
mbed_official 125:23cc3068a9e4 451 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 452 * @param ADC_CalibrationMode: the ADC calibration mode.
mbed_official 125:23cc3068a9e4 453 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 454 * @arg ADC_CalibrationMode_Single: to select the calibration for single channel
mbed_official 125:23cc3068a9e4 455 * @arg ADC_CalibrationMode_Differential: to select the calibration for differential channel
mbed_official 125:23cc3068a9e4 456 * @retval None
mbed_official 125:23cc3068a9e4 457 */
mbed_official 125:23cc3068a9e4 458 void ADC_SelectCalibrationMode(ADC_TypeDef* ADCx, uint32_t ADC_CalibrationMode)
mbed_official 125:23cc3068a9e4 459 {
mbed_official 125:23cc3068a9e4 460 /* Check the parameters */
mbed_official 125:23cc3068a9e4 461 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 462 assert_param(IS_ADC_CALIBRATION_MODE(ADC_CalibrationMode));
mbed_official 125:23cc3068a9e4 463 /* Set or Reset the ADCALDIF bit */
mbed_official 125:23cc3068a9e4 464 ADCx->CR &= (~ADC_CR_ADCALDIF);
mbed_official 125:23cc3068a9e4 465 ADCx->CR |= ADC_CalibrationMode;
mbed_official 125:23cc3068a9e4 466
mbed_official 125:23cc3068a9e4 467 }
mbed_official 125:23cc3068a9e4 468
mbed_official 125:23cc3068a9e4 469 /**
mbed_official 125:23cc3068a9e4 470 * @brief Gets the selected ADC calibration status.
mbed_official 125:23cc3068a9e4 471 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 472 * @retval The new state of ADC calibration (SET or RESET).
mbed_official 125:23cc3068a9e4 473 */
mbed_official 125:23cc3068a9e4 474 FlagStatus ADC_GetCalibrationStatus(ADC_TypeDef* ADCx)
mbed_official 125:23cc3068a9e4 475 {
mbed_official 125:23cc3068a9e4 476 FlagStatus bitstatus = RESET;
mbed_official 125:23cc3068a9e4 477 /* Check the parameters */
mbed_official 125:23cc3068a9e4 478 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 479 /* Check the status of CAL bit */
mbed_official 125:23cc3068a9e4 480 if ((ADCx->CR & ADC_CR_ADCAL) != (uint32_t)RESET)
mbed_official 125:23cc3068a9e4 481 {
mbed_official 125:23cc3068a9e4 482 /* CAL bit is set: calibration on going */
mbed_official 125:23cc3068a9e4 483 bitstatus = SET;
mbed_official 125:23cc3068a9e4 484 }
mbed_official 125:23cc3068a9e4 485 else
mbed_official 125:23cc3068a9e4 486 {
mbed_official 125:23cc3068a9e4 487 /* CAL bit is reset: end of calibration */
mbed_official 125:23cc3068a9e4 488 bitstatus = RESET;
mbed_official 125:23cc3068a9e4 489 }
mbed_official 125:23cc3068a9e4 490 /* Return the CAL bit status */
mbed_official 125:23cc3068a9e4 491 return bitstatus;
mbed_official 125:23cc3068a9e4 492 }
mbed_official 125:23cc3068a9e4 493
mbed_official 125:23cc3068a9e4 494 /**
mbed_official 125:23cc3068a9e4 495 * @brief ADC Disable Command.
mbed_official 125:23cc3068a9e4 496 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 497 * @retval None
mbed_official 125:23cc3068a9e4 498 */
mbed_official 125:23cc3068a9e4 499 void ADC_DisableCmd(ADC_TypeDef* ADCx)
mbed_official 125:23cc3068a9e4 500 {
mbed_official 125:23cc3068a9e4 501 /* Check the parameters */
mbed_official 125:23cc3068a9e4 502 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 503
mbed_official 125:23cc3068a9e4 504 /* Set the ADDIS bit */
mbed_official 125:23cc3068a9e4 505 ADCx->CR |= ADC_CR_ADDIS;
mbed_official 125:23cc3068a9e4 506 }
mbed_official 125:23cc3068a9e4 507
mbed_official 125:23cc3068a9e4 508
mbed_official 125:23cc3068a9e4 509 /**
mbed_official 125:23cc3068a9e4 510 * @brief Gets the selected ADC disable command Status.
mbed_official 125:23cc3068a9e4 511 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 512 * @retval The new state of ADC ADC disable command (SET or RESET).
mbed_official 125:23cc3068a9e4 513 */
mbed_official 125:23cc3068a9e4 514 FlagStatus ADC_GetDisableCmdStatus(ADC_TypeDef* ADCx)
mbed_official 125:23cc3068a9e4 515 {
mbed_official 125:23cc3068a9e4 516 FlagStatus bitstatus = RESET;
mbed_official 125:23cc3068a9e4 517 /* Check the parameters */
mbed_official 125:23cc3068a9e4 518 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 519
mbed_official 125:23cc3068a9e4 520 /* Check the status of ADDIS bit */
mbed_official 125:23cc3068a9e4 521 if ((ADCx->CR & ADC_CR_ADDIS) != (uint32_t)RESET)
mbed_official 125:23cc3068a9e4 522 {
mbed_official 125:23cc3068a9e4 523 /* ADDIS bit is set */
mbed_official 125:23cc3068a9e4 524 bitstatus = SET;
mbed_official 125:23cc3068a9e4 525 }
mbed_official 125:23cc3068a9e4 526 else
mbed_official 125:23cc3068a9e4 527 {
mbed_official 125:23cc3068a9e4 528 /* ADDIS bit is reset */
mbed_official 125:23cc3068a9e4 529 bitstatus = RESET;
mbed_official 125:23cc3068a9e4 530 }
mbed_official 125:23cc3068a9e4 531 /* Return the ADDIS bit status */
mbed_official 125:23cc3068a9e4 532 return bitstatus;
mbed_official 125:23cc3068a9e4 533 }
mbed_official 125:23cc3068a9e4 534
mbed_official 125:23cc3068a9e4 535 /**
mbed_official 125:23cc3068a9e4 536 * @brief Enables or disables the specified ADC Voltage Regulator.
mbed_official 125:23cc3068a9e4 537 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 538 * @param NewState: new state of the ADCx Voltage Regulator.
mbed_official 125:23cc3068a9e4 539 * This parameter can be: ENABLE or DISABLE.
mbed_official 125:23cc3068a9e4 540 * @retval None
mbed_official 125:23cc3068a9e4 541 */
mbed_official 125:23cc3068a9e4 542 void ADC_VoltageRegulatorCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
mbed_official 125:23cc3068a9e4 543 {
mbed_official 125:23cc3068a9e4 544 /* Check the parameters */
mbed_official 125:23cc3068a9e4 545 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 546 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 125:23cc3068a9e4 547
mbed_official 125:23cc3068a9e4 548 /* set the intermediate state before moving the ADC voltage regulator
mbed_official 125:23cc3068a9e4 549 from enable state to disable state or from disable state to enable state */
mbed_official 125:23cc3068a9e4 550 ADCx->CR &= ~(ADC_CR_ADVREGEN);
mbed_official 125:23cc3068a9e4 551
mbed_official 125:23cc3068a9e4 552 if (NewState != DISABLE)
mbed_official 125:23cc3068a9e4 553 {
mbed_official 125:23cc3068a9e4 554 /* Set the ADVREGEN bit 0 */
mbed_official 125:23cc3068a9e4 555 ADCx->CR |= ADC_CR_ADVREGEN_0;
mbed_official 125:23cc3068a9e4 556 }
mbed_official 125:23cc3068a9e4 557 else
mbed_official 125:23cc3068a9e4 558 {
mbed_official 125:23cc3068a9e4 559 /* Set the ADVREGEN bit 1 */
mbed_official 125:23cc3068a9e4 560 ADCx->CR |=ADC_CR_ADVREGEN_1;
mbed_official 125:23cc3068a9e4 561 }
mbed_official 125:23cc3068a9e4 562 }
mbed_official 125:23cc3068a9e4 563
mbed_official 125:23cc3068a9e4 564 /**
mbed_official 125:23cc3068a9e4 565 * @brief Selectes the differential mode for a specific channel
mbed_official 125:23cc3068a9e4 566 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 567 * @param ADC_Channel: the ADC channel to configure for the analog watchdog.
mbed_official 125:23cc3068a9e4 568 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 569 * @arg ADC_Channel_1: ADC Channel1 selected
mbed_official 125:23cc3068a9e4 570 * @arg ADC_Channel_2: ADC Channel2 selected
mbed_official 125:23cc3068a9e4 571 * @arg ADC_Channel_3: ADC Channel3 selected
mbed_official 125:23cc3068a9e4 572 * @arg ADC_Channel_4: ADC Channel4 selected
mbed_official 125:23cc3068a9e4 573 * @arg ADC_Channel_5: ADC Channel5 selected
mbed_official 125:23cc3068a9e4 574 * @arg ADC_Channel_6: ADC Channel6 selected
mbed_official 125:23cc3068a9e4 575 * @arg ADC_Channel_7: ADC Channel7 selected
mbed_official 125:23cc3068a9e4 576 * @arg ADC_Channel_8: ADC Channel8 selected
mbed_official 125:23cc3068a9e4 577 * @arg ADC_Channel_9: ADC Channel9 selected
mbed_official 125:23cc3068a9e4 578 * @arg ADC_Channel_10: ADC Channel10 selected
mbed_official 125:23cc3068a9e4 579 * @arg ADC_Channel_11: ADC Channel11 selected
mbed_official 125:23cc3068a9e4 580 * @arg ADC_Channel_12: ADC Channel12 selected
mbed_official 125:23cc3068a9e4 581 * @arg ADC_Channel_13: ADC Channel13 selected
mbed_official 125:23cc3068a9e4 582 * @arg ADC_Channel_14: ADC Channel14 selected
mbed_official 125:23cc3068a9e4 583 * @note : Channel 15, 16 and 17 are fixed to single-ended inputs mode.
mbed_official 125:23cc3068a9e4 584 * @retval None
mbed_official 125:23cc3068a9e4 585 */
mbed_official 125:23cc3068a9e4 586 void ADC_SelectDifferentialMode(ADC_TypeDef* ADCx, uint8_t ADC_Channel, FunctionalState NewState)
mbed_official 125:23cc3068a9e4 587 {
mbed_official 125:23cc3068a9e4 588 /* Check the parameters */
mbed_official 125:23cc3068a9e4 589 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 590 assert_param(IS_ADC_DIFFCHANNEL(ADC_Channel));
mbed_official 125:23cc3068a9e4 591 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 125:23cc3068a9e4 592
mbed_official 125:23cc3068a9e4 593 if (NewState != DISABLE)
mbed_official 125:23cc3068a9e4 594 {
mbed_official 125:23cc3068a9e4 595 /* Set the DIFSEL bit */
mbed_official 125:23cc3068a9e4 596 ADCx->DIFSEL |= (uint32_t)(1 << ADC_Channel );
mbed_official 125:23cc3068a9e4 597 }
mbed_official 125:23cc3068a9e4 598 else
mbed_official 125:23cc3068a9e4 599 {
mbed_official 125:23cc3068a9e4 600 /* Reset the DIFSEL bit */
mbed_official 125:23cc3068a9e4 601 ADCx->DIFSEL &= ~(uint32_t)(1 << ADC_Channel);
mbed_official 125:23cc3068a9e4 602 }
mbed_official 125:23cc3068a9e4 603 }
mbed_official 125:23cc3068a9e4 604
mbed_official 125:23cc3068a9e4 605 /**
mbed_official 125:23cc3068a9e4 606 * @brief Selects the Queue Of Context Mode for injected channels.
mbed_official 125:23cc3068a9e4 607 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 608 * @param NewState: new state of the Queue Of Context Mode.
mbed_official 125:23cc3068a9e4 609 * This parameter can be: ENABLE or DISABLE.
mbed_official 125:23cc3068a9e4 610 * @retval None
mbed_official 125:23cc3068a9e4 611 */
mbed_official 125:23cc3068a9e4 612 void ADC_SelectQueueOfContextMode(ADC_TypeDef* ADCx, FunctionalState NewState)
mbed_official 125:23cc3068a9e4 613 {
mbed_official 125:23cc3068a9e4 614 /* Check the parameters */
mbed_official 125:23cc3068a9e4 615 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 616 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 125:23cc3068a9e4 617
mbed_official 125:23cc3068a9e4 618 if (NewState != DISABLE)
mbed_official 125:23cc3068a9e4 619 {
mbed_official 125:23cc3068a9e4 620 /* Set the JQM bit */
mbed_official 125:23cc3068a9e4 621 ADCx->CFGR |= (uint32_t)(ADC_CFGR_JQM );
mbed_official 125:23cc3068a9e4 622 }
mbed_official 125:23cc3068a9e4 623 else
mbed_official 125:23cc3068a9e4 624 {
mbed_official 125:23cc3068a9e4 625 /* Reset the JQM bit */
mbed_official 125:23cc3068a9e4 626 ADCx->CFGR &= ~(uint32_t)(ADC_CFGR_JQM);
mbed_official 125:23cc3068a9e4 627 }
mbed_official 125:23cc3068a9e4 628 }
mbed_official 125:23cc3068a9e4 629
mbed_official 125:23cc3068a9e4 630 /**
mbed_official 125:23cc3068a9e4 631 * @brief Selects the ADC Delayed Conversion Mode.
mbed_official 125:23cc3068a9e4 632 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 633 * @param NewState: new state of the ADC Delayed Conversion Mode.
mbed_official 125:23cc3068a9e4 634 * This parameter can be: ENABLE or DISABLE.
mbed_official 125:23cc3068a9e4 635 * @retval None
mbed_official 125:23cc3068a9e4 636 */
mbed_official 125:23cc3068a9e4 637 void ADC_AutoDelayCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
mbed_official 125:23cc3068a9e4 638 {
mbed_official 125:23cc3068a9e4 639 /* Check the parameters */
mbed_official 125:23cc3068a9e4 640 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 641 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 125:23cc3068a9e4 642
mbed_official 125:23cc3068a9e4 643 if (NewState != DISABLE)
mbed_official 125:23cc3068a9e4 644 {
mbed_official 125:23cc3068a9e4 645 /* Set the AUTDLY bit */
mbed_official 125:23cc3068a9e4 646 ADCx->CFGR |= (uint32_t)(ADC_CFGR_AUTDLY );
mbed_official 125:23cc3068a9e4 647 }
mbed_official 125:23cc3068a9e4 648 else
mbed_official 125:23cc3068a9e4 649 {
mbed_official 125:23cc3068a9e4 650 /* Reset the AUTDLY bit */
mbed_official 125:23cc3068a9e4 651 ADCx->CFGR &= ~(uint32_t)(ADC_CFGR_AUTDLY);
mbed_official 125:23cc3068a9e4 652 }
mbed_official 125:23cc3068a9e4 653 }
mbed_official 125:23cc3068a9e4 654
mbed_official 125:23cc3068a9e4 655 /**
mbed_official 125:23cc3068a9e4 656 * @}
mbed_official 125:23cc3068a9e4 657 */
mbed_official 125:23cc3068a9e4 658
mbed_official 125:23cc3068a9e4 659 /** @defgroup ADC_Group2 Analog Watchdog configuration functions
mbed_official 125:23cc3068a9e4 660 * @brief Analog Watchdog configuration functions
mbed_official 125:23cc3068a9e4 661 *
mbed_official 125:23cc3068a9e4 662 @verbatim
mbed_official 125:23cc3068a9e4 663 ===============================================================================
mbed_official 125:23cc3068a9e4 664 ##### Analog Watchdog configuration functions #####
mbed_official 125:23cc3068a9e4 665 ===============================================================================
mbed_official 125:23cc3068a9e4 666
mbed_official 125:23cc3068a9e4 667 [..] This section provides functions allowing to configure the 3 Analog Watchdogs
mbed_official 125:23cc3068a9e4 668 (AWDG1, AWDG2 and AWDG3) in the ADC.
mbed_official 125:23cc3068a9e4 669
mbed_official 125:23cc3068a9e4 670 [..] A typical configuration Analog Watchdog is done following these steps :
mbed_official 125:23cc3068a9e4 671 (#) The ADC guarded channel(s) is (are) selected using the functions:
mbed_official 125:23cc3068a9e4 672 (++) ADC_AnalogWatchdog1SingleChannelConfig().
mbed_official 125:23cc3068a9e4 673 (++) ADC_AnalogWatchdog2SingleChannelConfig().
mbed_official 125:23cc3068a9e4 674 (++) ADC_AnalogWatchdog3SingleChannelConfig().
mbed_official 125:23cc3068a9e4 675
mbed_official 125:23cc3068a9e4 676 (#) The Analog watchdog lower and higher threshold are configured using the functions:
mbed_official 125:23cc3068a9e4 677 (++) ADC_AnalogWatchdog1ThresholdsConfig().
mbed_official 125:23cc3068a9e4 678 (++) ADC_AnalogWatchdog2ThresholdsConfig().
mbed_official 125:23cc3068a9e4 679 (++) ADC_AnalogWatchdog3ThresholdsConfig().
mbed_official 125:23cc3068a9e4 680
mbed_official 125:23cc3068a9e4 681 (#) The Analog watchdog is enabled and configured to enable the check, on one
mbed_official 125:23cc3068a9e4 682 or more channels, using the function:
mbed_official 125:23cc3068a9e4 683 (++) ADC_AnalogWatchdogCmd().
mbed_official 125:23cc3068a9e4 684
mbed_official 125:23cc3068a9e4 685 @endverbatim
mbed_official 125:23cc3068a9e4 686 * @{
mbed_official 125:23cc3068a9e4 687 */
mbed_official 125:23cc3068a9e4 688
mbed_official 125:23cc3068a9e4 689 /**
mbed_official 125:23cc3068a9e4 690 * @brief Enables or disables the analog watchdog on single/all regular
mbed_official 125:23cc3068a9e4 691 * or injected channels
mbed_official 125:23cc3068a9e4 692 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 693 * @param ADC_AnalogWatchdog: the ADC analog watchdog configuration.
mbed_official 125:23cc3068a9e4 694 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 695 * @arg ADC_AnalogWatchdog_SingleRegEnable: Analog watchdog on a single regular channel
mbed_official 125:23cc3068a9e4 696 * @arg ADC_AnalogWatchdog_SingleInjecEnable: Analog watchdog on a single injected channel
mbed_official 125:23cc3068a9e4 697 * @arg ADC_AnalogWatchdog_SingleRegOrInjecEnable: Analog watchdog on a single regular or injected channel
mbed_official 125:23cc3068a9e4 698 * @arg ADC_AnalogWatchdog_AllRegEnable: Analog watchdog on all regular channel
mbed_official 125:23cc3068a9e4 699 * @arg ADC_AnalogWatchdog_AllInjecEnable: Analog watchdog on all injected channel
mbed_official 125:23cc3068a9e4 700 * @arg ADC_AnalogWatchdog_AllRegAllInjecEnable: Analog watchdog on all regular and injected channels
mbed_official 125:23cc3068a9e4 701 * @arg ADC_AnalogWatchdog_None: No channel guarded by the analog watchdog
mbed_official 125:23cc3068a9e4 702 * @retval None
mbed_official 125:23cc3068a9e4 703 */
mbed_official 125:23cc3068a9e4 704 void ADC_AnalogWatchdogCmd(ADC_TypeDef* ADCx, uint32_t ADC_AnalogWatchdog)
mbed_official 125:23cc3068a9e4 705 {
mbed_official 125:23cc3068a9e4 706 uint32_t tmpreg = 0;
mbed_official 125:23cc3068a9e4 707 /* Check the parameters */
mbed_official 125:23cc3068a9e4 708 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 709 assert_param(IS_ADC_ANALOG_WATCHDOG(ADC_AnalogWatchdog));
mbed_official 125:23cc3068a9e4 710 /* Get the old register value */
mbed_official 125:23cc3068a9e4 711 tmpreg = ADCx->CFGR;
mbed_official 125:23cc3068a9e4 712 /* Clear AWDEN, AWDENJ and AWDSGL bits */
mbed_official 125:23cc3068a9e4 713 tmpreg &= ~(uint32_t)(ADC_CFGR_AWD1SGL|ADC_CFGR_AWD1EN|ADC_CFGR_JAWD1EN);
mbed_official 125:23cc3068a9e4 714 /* Set the analog watchdog enable mode */
mbed_official 125:23cc3068a9e4 715 tmpreg |= ADC_AnalogWatchdog;
mbed_official 125:23cc3068a9e4 716 /* Store the new register value */
mbed_official 125:23cc3068a9e4 717 ADCx->CFGR = tmpreg;
mbed_official 125:23cc3068a9e4 718 }
mbed_official 125:23cc3068a9e4 719
mbed_official 125:23cc3068a9e4 720 /**
mbed_official 125:23cc3068a9e4 721 * @brief Configures the high and low thresholds of the analog watchdog1.
mbed_official 125:23cc3068a9e4 722 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 723 * @param HighThreshold: the ADC analog watchdog High threshold value.
mbed_official 125:23cc3068a9e4 724 * This parameter must be a 12bit value.
mbed_official 125:23cc3068a9e4 725 * @param LowThreshold: the ADC analog watchdog Low threshold value.
mbed_official 125:23cc3068a9e4 726 * This parameter must be a 12bit value.
mbed_official 125:23cc3068a9e4 727 * @retval None
mbed_official 125:23cc3068a9e4 728 */
mbed_official 125:23cc3068a9e4 729 void ADC_AnalogWatchdog1ThresholdsConfig(ADC_TypeDef* ADCx, uint16_t HighThreshold,
mbed_official 125:23cc3068a9e4 730 uint16_t LowThreshold)
mbed_official 125:23cc3068a9e4 731 {
mbed_official 125:23cc3068a9e4 732 /* Check the parameters */
mbed_official 125:23cc3068a9e4 733 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 734 assert_param(IS_ADC_THRESHOLD(HighThreshold));
mbed_official 125:23cc3068a9e4 735 assert_param(IS_ADC_THRESHOLD(LowThreshold));
mbed_official 125:23cc3068a9e4 736 /* Set the ADCx high threshold */
mbed_official 125:23cc3068a9e4 737 ADCx->TR1 &= ~(uint32_t)ADC_TR1_HT1;
mbed_official 125:23cc3068a9e4 738 ADCx->TR1 |= (uint32_t)((uint32_t)HighThreshold << 16);
mbed_official 125:23cc3068a9e4 739
mbed_official 125:23cc3068a9e4 740 /* Set the ADCx low threshold */
mbed_official 125:23cc3068a9e4 741 ADCx->TR1 &= ~(uint32_t)ADC_TR1_LT1;
mbed_official 125:23cc3068a9e4 742 ADCx->TR1 |= LowThreshold;
mbed_official 125:23cc3068a9e4 743 }
mbed_official 125:23cc3068a9e4 744
mbed_official 125:23cc3068a9e4 745 /**
mbed_official 125:23cc3068a9e4 746 * @brief Configures the high and low thresholds of the analog watchdog2.
mbed_official 125:23cc3068a9e4 747 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 748 * @param HighThreshold: the ADC analog watchdog High threshold value.
mbed_official 125:23cc3068a9e4 749 * This parameter must be a 8bit value.
mbed_official 125:23cc3068a9e4 750 * @param LowThreshold: the ADC analog watchdog Low threshold value.
mbed_official 125:23cc3068a9e4 751 * This parameter must be a 8bit value.
mbed_official 125:23cc3068a9e4 752 * @retval None
mbed_official 125:23cc3068a9e4 753 */
mbed_official 125:23cc3068a9e4 754 void ADC_AnalogWatchdog2ThresholdsConfig(ADC_TypeDef* ADCx, uint8_t HighThreshold,
mbed_official 125:23cc3068a9e4 755 uint8_t LowThreshold)
mbed_official 125:23cc3068a9e4 756 {
mbed_official 125:23cc3068a9e4 757 /* Check the parameters */
mbed_official 125:23cc3068a9e4 758 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 759
mbed_official 125:23cc3068a9e4 760 /* Set the ADCx high threshold */
mbed_official 125:23cc3068a9e4 761 ADCx->TR2 &= ~(uint32_t)ADC_TR2_HT2;
mbed_official 125:23cc3068a9e4 762 ADCx->TR2 |= (uint32_t)((uint32_t)HighThreshold << 16);
mbed_official 125:23cc3068a9e4 763
mbed_official 125:23cc3068a9e4 764 /* Set the ADCx low threshold */
mbed_official 125:23cc3068a9e4 765 ADCx->TR2 &= ~(uint32_t)ADC_TR2_LT2;
mbed_official 125:23cc3068a9e4 766 ADCx->TR2 |= LowThreshold;
mbed_official 125:23cc3068a9e4 767 }
mbed_official 125:23cc3068a9e4 768
mbed_official 125:23cc3068a9e4 769 /**
mbed_official 125:23cc3068a9e4 770 * @brief Configures the high and low thresholds of the analog watchdog3.
mbed_official 125:23cc3068a9e4 771 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 772 * @param HighThreshold: the ADC analog watchdog High threshold value.
mbed_official 125:23cc3068a9e4 773 * This parameter must be a 8bit value.
mbed_official 125:23cc3068a9e4 774 * @param LowThreshold: the ADC analog watchdog Low threshold value.
mbed_official 125:23cc3068a9e4 775 * This parameter must be a 8bit value.
mbed_official 125:23cc3068a9e4 776 * @retval None
mbed_official 125:23cc3068a9e4 777 */
mbed_official 125:23cc3068a9e4 778 void ADC_AnalogWatchdog3ThresholdsConfig(ADC_TypeDef* ADCx, uint8_t HighThreshold,
mbed_official 125:23cc3068a9e4 779 uint8_t LowThreshold)
mbed_official 125:23cc3068a9e4 780 {
mbed_official 125:23cc3068a9e4 781 /* Check the parameters */
mbed_official 125:23cc3068a9e4 782 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 783
mbed_official 125:23cc3068a9e4 784 /* Set the ADCx high threshold */
mbed_official 125:23cc3068a9e4 785 ADCx->TR3 &= ~(uint32_t)ADC_TR3_HT3;
mbed_official 125:23cc3068a9e4 786 ADCx->TR3 |= (uint32_t)((uint32_t)HighThreshold << 16);
mbed_official 125:23cc3068a9e4 787
mbed_official 125:23cc3068a9e4 788 /* Set the ADCx low threshold */
mbed_official 125:23cc3068a9e4 789 ADCx->TR3 &= ~(uint32_t)ADC_TR3_LT3;
mbed_official 125:23cc3068a9e4 790 ADCx->TR3 |= LowThreshold;
mbed_official 125:23cc3068a9e4 791 }
mbed_official 125:23cc3068a9e4 792
mbed_official 125:23cc3068a9e4 793 /**
mbed_official 125:23cc3068a9e4 794 * @brief Configures the analog watchdog 2 guarded single channel
mbed_official 125:23cc3068a9e4 795 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 796 * @param ADC_Channel: the ADC channel to configure for the analog watchdog.
mbed_official 125:23cc3068a9e4 797 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 798 * @arg ADC_Channel_1: ADC Channel1 selected
mbed_official 125:23cc3068a9e4 799 * @arg ADC_Channel_2: ADC Channel2 selected
mbed_official 125:23cc3068a9e4 800 * @arg ADC_Channel_3: ADC Channel3 selected
mbed_official 125:23cc3068a9e4 801 * @arg ADC_Channel_4: ADC Channel4 selected
mbed_official 125:23cc3068a9e4 802 * @arg ADC_Channel_5: ADC Channel5 selected
mbed_official 125:23cc3068a9e4 803 * @arg ADC_Channel_6: ADC Channel6 selected
mbed_official 125:23cc3068a9e4 804 * @arg ADC_Channel_7: ADC Channel7 selected
mbed_official 125:23cc3068a9e4 805 * @arg ADC_Channel_8: ADC Channel8 selected
mbed_official 125:23cc3068a9e4 806 * @arg ADC_Channel_9: ADC Channel9 selected
mbed_official 125:23cc3068a9e4 807 * @arg ADC_Channel_10: ADC Channel10 selected
mbed_official 125:23cc3068a9e4 808 * @arg ADC_Channel_11: ADC Channel11 selected
mbed_official 125:23cc3068a9e4 809 * @arg ADC_Channel_12: ADC Channel12 selected
mbed_official 125:23cc3068a9e4 810 * @arg ADC_Channel_13: ADC Channel13 selected
mbed_official 125:23cc3068a9e4 811 * @arg ADC_Channel_14: ADC Channel14 selected
mbed_official 125:23cc3068a9e4 812 * @arg ADC_Channel_15: ADC Channel15 selected
mbed_official 125:23cc3068a9e4 813 * @arg ADC_Channel_16: ADC Channel16 selected
mbed_official 125:23cc3068a9e4 814 * @arg ADC_Channel_17: ADC Channel17 selected
mbed_official 125:23cc3068a9e4 815 * @arg ADC_Channel_18: ADC Channel18 selected
mbed_official 125:23cc3068a9e4 816 * @retval None
mbed_official 125:23cc3068a9e4 817 */
mbed_official 125:23cc3068a9e4 818 void ADC_AnalogWatchdog1SingleChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel)
mbed_official 125:23cc3068a9e4 819 {
mbed_official 125:23cc3068a9e4 820 uint32_t tmpreg = 0;
mbed_official 125:23cc3068a9e4 821 /* Check the parameters */
mbed_official 125:23cc3068a9e4 822 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 823 assert_param(IS_ADC_CHANNEL(ADC_Channel));
mbed_official 125:23cc3068a9e4 824 /* Get the old register value */
mbed_official 125:23cc3068a9e4 825 tmpreg = ADCx->CFGR;
mbed_official 125:23cc3068a9e4 826 /* Clear the Analog watchdog channel select bits */
mbed_official 125:23cc3068a9e4 827 tmpreg &= ~(uint32_t)ADC_CFGR_AWD1CH;
mbed_official 125:23cc3068a9e4 828 /* Set the Analog watchdog channel */
mbed_official 125:23cc3068a9e4 829 tmpreg |= (uint32_t)((uint32_t)ADC_Channel << 26);
mbed_official 125:23cc3068a9e4 830 /* Store the new register value */
mbed_official 125:23cc3068a9e4 831 ADCx->CFGR = tmpreg;
mbed_official 125:23cc3068a9e4 832 }
mbed_official 125:23cc3068a9e4 833
mbed_official 125:23cc3068a9e4 834 /**
mbed_official 125:23cc3068a9e4 835 * @brief Configures the analog watchdog 2 guarded single channel
mbed_official 125:23cc3068a9e4 836 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 837 * @param ADC_Channel: the ADC channel to configure for the analog watchdog.
mbed_official 125:23cc3068a9e4 838 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 839 * @arg ADC_Channel_1: ADC Channel1 selected
mbed_official 125:23cc3068a9e4 840 * @arg ADC_Channel_2: ADC Channel2 selected
mbed_official 125:23cc3068a9e4 841 * @arg ADC_Channel_3: ADC Channel3 selected
mbed_official 125:23cc3068a9e4 842 * @arg ADC_Channel_4: ADC Channel4 selected
mbed_official 125:23cc3068a9e4 843 * @arg ADC_Channel_5: ADC Channel5 selected
mbed_official 125:23cc3068a9e4 844 * @arg ADC_Channel_6: ADC Channel6 selected
mbed_official 125:23cc3068a9e4 845 * @arg ADC_Channel_7: ADC Channel7 selected
mbed_official 125:23cc3068a9e4 846 * @arg ADC_Channel_8: ADC Channel8 selected
mbed_official 125:23cc3068a9e4 847 * @arg ADC_Channel_9: ADC Channel9 selected
mbed_official 125:23cc3068a9e4 848 * @arg ADC_Channel_10: ADC Channel10 selected
mbed_official 125:23cc3068a9e4 849 * @arg ADC_Channel_11: ADC Channel11 selected
mbed_official 125:23cc3068a9e4 850 * @arg ADC_Channel_12: ADC Channel12 selected
mbed_official 125:23cc3068a9e4 851 * @arg ADC_Channel_13: ADC Channel13 selected
mbed_official 125:23cc3068a9e4 852 * @arg ADC_Channel_14: ADC Channel14 selected
mbed_official 125:23cc3068a9e4 853 * @arg ADC_Channel_15: ADC Channel15 selected
mbed_official 125:23cc3068a9e4 854 * @arg ADC_Channel_16: ADC Channel16 selected
mbed_official 125:23cc3068a9e4 855 * @arg ADC_Channel_17: ADC Channel17 selected
mbed_official 125:23cc3068a9e4 856 * @arg ADC_Channel_18: ADC Channel18 selected
mbed_official 125:23cc3068a9e4 857 * @retval None
mbed_official 125:23cc3068a9e4 858 */
mbed_official 125:23cc3068a9e4 859 void ADC_AnalogWatchdog2SingleChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel)
mbed_official 125:23cc3068a9e4 860 {
mbed_official 125:23cc3068a9e4 861 uint32_t tmpreg = 0;
mbed_official 125:23cc3068a9e4 862 /* Check the parameters */
mbed_official 125:23cc3068a9e4 863 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 864 assert_param(IS_ADC_CHANNEL(ADC_Channel));
mbed_official 125:23cc3068a9e4 865 /* Get the old register value */
mbed_official 125:23cc3068a9e4 866 tmpreg = ADCx->AWD2CR;
mbed_official 125:23cc3068a9e4 867 /* Clear the Analog watchdog channel select bits */
mbed_official 125:23cc3068a9e4 868 tmpreg &= ~(uint32_t)ADC_AWD2CR_AWD2CH;
mbed_official 125:23cc3068a9e4 869 /* Set the Analog watchdog channel */
mbed_official 125:23cc3068a9e4 870 tmpreg |= (uint32_t)1 << (ADC_Channel);
mbed_official 125:23cc3068a9e4 871 /* Store the new register value */
mbed_official 125:23cc3068a9e4 872 ADCx->AWD2CR |= tmpreg;
mbed_official 125:23cc3068a9e4 873 }
mbed_official 125:23cc3068a9e4 874
mbed_official 125:23cc3068a9e4 875 /**
mbed_official 125:23cc3068a9e4 876 * @brief Configures the analog watchdog 3 guarded single channel
mbed_official 125:23cc3068a9e4 877 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 878 * @param ADC_Channel: the ADC channel to configure for the analog watchdog.
mbed_official 125:23cc3068a9e4 879 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 880 * @arg ADC_Channel_1: ADC Channel1 selected
mbed_official 125:23cc3068a9e4 881 * @arg ADC_Channel_2: ADC Channel2 selected
mbed_official 125:23cc3068a9e4 882 * @arg ADC_Channel_3: ADC Channel3 selected
mbed_official 125:23cc3068a9e4 883 * @arg ADC_Channel_4: ADC Channel4 selected
mbed_official 125:23cc3068a9e4 884 * @arg ADC_Channel_5: ADC Channel5 selected
mbed_official 125:23cc3068a9e4 885 * @arg ADC_Channel_6: ADC Channel6 selected
mbed_official 125:23cc3068a9e4 886 * @arg ADC_Channel_7: ADC Channel7 selected
mbed_official 125:23cc3068a9e4 887 * @arg ADC_Channel_8: ADC Channel8 selected
mbed_official 125:23cc3068a9e4 888 * @arg ADC_Channel_9: ADC Channel9 selected
mbed_official 125:23cc3068a9e4 889 * @arg ADC_Channel_10: ADC Channel10 selected
mbed_official 125:23cc3068a9e4 890 * @arg ADC_Channel_11: ADC Channel11 selected
mbed_official 125:23cc3068a9e4 891 * @arg ADC_Channel_12: ADC Channel12 selected
mbed_official 125:23cc3068a9e4 892 * @arg ADC_Channel_13: ADC Channel13 selected
mbed_official 125:23cc3068a9e4 893 * @arg ADC_Channel_14: ADC Channel14 selected
mbed_official 125:23cc3068a9e4 894 * @arg ADC_Channel_15: ADC Channel15 selected
mbed_official 125:23cc3068a9e4 895 * @arg ADC_Channel_16: ADC Channel16 selected
mbed_official 125:23cc3068a9e4 896 * @arg ADC_Channel_17: ADC Channel17 selected
mbed_official 125:23cc3068a9e4 897 * @arg ADC_Channel_18: ADC Channel18 selected
mbed_official 125:23cc3068a9e4 898 * @retval None
mbed_official 125:23cc3068a9e4 899 */
mbed_official 125:23cc3068a9e4 900 void ADC_AnalogWatchdog3SingleChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel)
mbed_official 125:23cc3068a9e4 901 {
mbed_official 125:23cc3068a9e4 902 uint32_t tmpreg = 0;
mbed_official 125:23cc3068a9e4 903 /* Check the parameters */
mbed_official 125:23cc3068a9e4 904 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 905 assert_param(IS_ADC_CHANNEL(ADC_Channel));
mbed_official 125:23cc3068a9e4 906 /* Get the old register value */
mbed_official 125:23cc3068a9e4 907 tmpreg = ADCx->AWD3CR;
mbed_official 125:23cc3068a9e4 908 /* Clear the Analog watchdog channel select bits */
mbed_official 125:23cc3068a9e4 909 tmpreg &= ~(uint32_t)ADC_AWD3CR_AWD3CH;
mbed_official 125:23cc3068a9e4 910 /* Set the Analog watchdog channel */
mbed_official 125:23cc3068a9e4 911 tmpreg |= (uint32_t)1 << (ADC_Channel);
mbed_official 125:23cc3068a9e4 912 /* Store the new register value */
mbed_official 125:23cc3068a9e4 913 ADCx->AWD3CR |= tmpreg;
mbed_official 125:23cc3068a9e4 914 }
mbed_official 125:23cc3068a9e4 915
mbed_official 125:23cc3068a9e4 916 /**
mbed_official 125:23cc3068a9e4 917 * @}
mbed_official 125:23cc3068a9e4 918 */
mbed_official 125:23cc3068a9e4 919
mbed_official 125:23cc3068a9e4 920 /** @defgroup ADC_Group3 Temperature Sensor - Vrefint (Internal Reference Voltage) and VBAT management functions
mbed_official 125:23cc3068a9e4 921 * @brief Vbat, Temperature Sensor & Vrefint (Internal Reference Voltage) management function
mbed_official 125:23cc3068a9e4 922 *
mbed_official 125:23cc3068a9e4 923 @verbatim
mbed_official 125:23cc3068a9e4 924 ====================================================================================================
mbed_official 125:23cc3068a9e4 925 ##### Temperature Sensor - Vrefint (Internal Reference Voltage) and VBAT management functions #####
mbed_official 125:23cc3068a9e4 926 ====================================================================================================
mbed_official 125:23cc3068a9e4 927
mbed_official 125:23cc3068a9e4 928 [..] This section provides a function allowing to enable/ disable the internal
mbed_official 125:23cc3068a9e4 929 connections between the ADC and the Vbat/2, Temperature Sensor and the Vrefint source.
mbed_official 125:23cc3068a9e4 930
mbed_official 125:23cc3068a9e4 931 [..] A typical configuration to get the Temperature sensor and Vrefint channels
mbed_official 125:23cc3068a9e4 932 voltages is done following these steps :
mbed_official 125:23cc3068a9e4 933 (#) Enable the internal connection of Vbat/2, Temperature sensor and Vrefint sources
mbed_official 125:23cc3068a9e4 934 with the ADC channels using:
mbed_official 125:23cc3068a9e4 935 (++) ADC_TempSensorCmd()
mbed_official 125:23cc3068a9e4 936 (++) ADC_VrefintCmd()
mbed_official 125:23cc3068a9e4 937 (++) ADC_VbatCmd()
mbed_official 125:23cc3068a9e4 938
mbed_official 125:23cc3068a9e4 939 (#) select the ADC_Channel_TempSensor and/or ADC_Channel_Vrefint and/or ADC_Channel_Vbat using
mbed_official 125:23cc3068a9e4 940 (++) ADC_RegularChannelConfig() or
mbed_official 125:23cc3068a9e4 941 (++) ADC_InjectedInit() functions
mbed_official 125:23cc3068a9e4 942
mbed_official 125:23cc3068a9e4 943 (#) Get the voltage values, using:
mbed_official 125:23cc3068a9e4 944 (++) ADC_GetConversionValue() or
mbed_official 125:23cc3068a9e4 945 (++) ADC_GetInjectedConversionValue().
mbed_official 125:23cc3068a9e4 946
mbed_official 125:23cc3068a9e4 947 @endverbatim
mbed_official 125:23cc3068a9e4 948 * @{
mbed_official 125:23cc3068a9e4 949 */
mbed_official 125:23cc3068a9e4 950
mbed_official 125:23cc3068a9e4 951 /**
mbed_official 125:23cc3068a9e4 952 * @brief Enables or disables the temperature sensor channel.
mbed_official 125:23cc3068a9e4 953 * @param ADCx: where x can be 1 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 954 * @param NewState: new state of the temperature sensor.
mbed_official 125:23cc3068a9e4 955 * This parameter can be: ENABLE or DISABLE.
mbed_official 125:23cc3068a9e4 956 * @retval None
mbed_official 125:23cc3068a9e4 957 */
mbed_official 125:23cc3068a9e4 958 void ADC_TempSensorCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
mbed_official 125:23cc3068a9e4 959 {
mbed_official 125:23cc3068a9e4 960 /* Check the parameters */
mbed_official 125:23cc3068a9e4 961 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 125:23cc3068a9e4 962
mbed_official 125:23cc3068a9e4 963 if (NewState != DISABLE)
mbed_official 125:23cc3068a9e4 964 {
mbed_official 125:23cc3068a9e4 965 /* Enable the temperature sensor channel*/
mbed_official 125:23cc3068a9e4 966 ADC1_2->CCR |= ADC12_CCR_TSEN;
mbed_official 125:23cc3068a9e4 967 }
mbed_official 125:23cc3068a9e4 968 else
mbed_official 125:23cc3068a9e4 969 {
mbed_official 125:23cc3068a9e4 970 /* Disable the temperature sensor channel*/
mbed_official 125:23cc3068a9e4 971 ADC1_2->CCR &= ~(uint32_t)ADC12_CCR_TSEN;
mbed_official 125:23cc3068a9e4 972 }
mbed_official 125:23cc3068a9e4 973 }
mbed_official 125:23cc3068a9e4 974
mbed_official 125:23cc3068a9e4 975 /**
mbed_official 125:23cc3068a9e4 976 * @brief Enables or disables the Vrefint channel.
mbed_official 125:23cc3068a9e4 977 * @param ADCx: where x can be 1 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 978 * @param NewState: new state of the Vrefint.
mbed_official 125:23cc3068a9e4 979 * This parameter can be: ENABLE or DISABLE.
mbed_official 125:23cc3068a9e4 980 * @retval None
mbed_official 125:23cc3068a9e4 981 */
mbed_official 125:23cc3068a9e4 982 void ADC_VrefintCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
mbed_official 125:23cc3068a9e4 983 {
mbed_official 125:23cc3068a9e4 984 /* Check the parameters */
mbed_official 125:23cc3068a9e4 985 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 986 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 125:23cc3068a9e4 987
mbed_official 125:23cc3068a9e4 988 if((ADCx == ADC1) || (ADCx == ADC2))
mbed_official 125:23cc3068a9e4 989 {
mbed_official 125:23cc3068a9e4 990 if (NewState != DISABLE)
mbed_official 125:23cc3068a9e4 991 {
mbed_official 125:23cc3068a9e4 992 /* Enable the Vrefint channel*/
mbed_official 125:23cc3068a9e4 993 ADC1_2->CCR |= ADC12_CCR_VREFEN;
mbed_official 125:23cc3068a9e4 994 }
mbed_official 125:23cc3068a9e4 995 else
mbed_official 125:23cc3068a9e4 996 {
mbed_official 125:23cc3068a9e4 997 /* Disable the Vrefint channel*/
mbed_official 125:23cc3068a9e4 998 ADC1_2->CCR &= ~(uint32_t)ADC12_CCR_VREFEN;
mbed_official 125:23cc3068a9e4 999 }
mbed_official 125:23cc3068a9e4 1000 }
mbed_official 125:23cc3068a9e4 1001 else
mbed_official 125:23cc3068a9e4 1002 {
mbed_official 125:23cc3068a9e4 1003 if (NewState != DISABLE)
mbed_official 125:23cc3068a9e4 1004 {
mbed_official 125:23cc3068a9e4 1005 /* Enable the Vrefint channel*/
mbed_official 125:23cc3068a9e4 1006 ADC3_4->CCR |= ADC34_CCR_VREFEN;
mbed_official 125:23cc3068a9e4 1007 }
mbed_official 125:23cc3068a9e4 1008 else
mbed_official 125:23cc3068a9e4 1009 {
mbed_official 125:23cc3068a9e4 1010 /* Disable the Vrefint channel*/
mbed_official 125:23cc3068a9e4 1011 ADC3_4->CCR &= ~(uint32_t)ADC34_CCR_VREFEN;
mbed_official 125:23cc3068a9e4 1012 }
mbed_official 125:23cc3068a9e4 1013 }
mbed_official 125:23cc3068a9e4 1014 }
mbed_official 125:23cc3068a9e4 1015
mbed_official 125:23cc3068a9e4 1016 /**
mbed_official 125:23cc3068a9e4 1017 * @brief Enables or disables the Vbat channel.
mbed_official 125:23cc3068a9e4 1018 * @param ADCx: where x can be 1 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1019 * @param NewState: new state of the Vbat.
mbed_official 125:23cc3068a9e4 1020 * This parameter can be: ENABLE or DISABLE.
mbed_official 125:23cc3068a9e4 1021 * @retval None
mbed_official 125:23cc3068a9e4 1022 */
mbed_official 125:23cc3068a9e4 1023 void ADC_VbatCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
mbed_official 125:23cc3068a9e4 1024 {
mbed_official 125:23cc3068a9e4 1025 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1026 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 125:23cc3068a9e4 1027
mbed_official 125:23cc3068a9e4 1028 if (NewState != DISABLE)
mbed_official 125:23cc3068a9e4 1029 {
mbed_official 125:23cc3068a9e4 1030 /* Enable the Vbat channel*/
mbed_official 125:23cc3068a9e4 1031 ADC1_2->CCR |= ADC12_CCR_VBATEN;
mbed_official 125:23cc3068a9e4 1032 }
mbed_official 125:23cc3068a9e4 1033 else
mbed_official 125:23cc3068a9e4 1034 {
mbed_official 125:23cc3068a9e4 1035 /* Disable the Vbat channel*/
mbed_official 125:23cc3068a9e4 1036 ADC1_2->CCR &= ~(uint32_t)ADC12_CCR_VBATEN;
mbed_official 125:23cc3068a9e4 1037 }
mbed_official 125:23cc3068a9e4 1038 }
mbed_official 125:23cc3068a9e4 1039
mbed_official 125:23cc3068a9e4 1040 /**
mbed_official 125:23cc3068a9e4 1041 * @}
mbed_official 125:23cc3068a9e4 1042 */
mbed_official 125:23cc3068a9e4 1043
mbed_official 125:23cc3068a9e4 1044 /** @defgroup ADC_Group4 Regular Channels Configuration functions
mbed_official 125:23cc3068a9e4 1045 * @brief Regular Channels Configuration functions
mbed_official 125:23cc3068a9e4 1046 *
mbed_official 125:23cc3068a9e4 1047 @verbatim
mbed_official 125:23cc3068a9e4 1048 ===============================================================================
mbed_official 125:23cc3068a9e4 1049 ##### Channels Configuration functions #####
mbed_official 125:23cc3068a9e4 1050 ===============================================================================
mbed_official 125:23cc3068a9e4 1051
mbed_official 125:23cc3068a9e4 1052 [..] This section provides functions allowing to manage the ADC regular channels.
mbed_official 125:23cc3068a9e4 1053
mbed_official 125:23cc3068a9e4 1054 [..] To configure a regular sequence of channels use:
mbed_official 125:23cc3068a9e4 1055 (#) ADC_RegularChannelConfig()
mbed_official 125:23cc3068a9e4 1056 this fuction allows:
mbed_official 125:23cc3068a9e4 1057 (++) Configure the rank in the regular group sequencer for each channel
mbed_official 125:23cc3068a9e4 1058 (++) Configure the sampling time for each channel
mbed_official 125:23cc3068a9e4 1059
mbed_official 125:23cc3068a9e4 1060 (#) ADC_RegularChannelSequencerLengthConfig() to set the length of the regular sequencer
mbed_official 125:23cc3068a9e4 1061
mbed_official 125:23cc3068a9e4 1062 [..] The regular trigger is configured using the following functions:
mbed_official 125:23cc3068a9e4 1063 (#) ADC_SelectExternalTrigger()
mbed_official 125:23cc3068a9e4 1064 (#) ADC_ExternalTriggerPolarityConfig()
mbed_official 125:23cc3068a9e4 1065
mbed_official 125:23cc3068a9e4 1066 [..] The start and the stop conversion are controlled by:
mbed_official 125:23cc3068a9e4 1067 (#) ADC_StartConversion()
mbed_official 125:23cc3068a9e4 1068 (#) ADC_StopConversion()
mbed_official 125:23cc3068a9e4 1069
mbed_official 125:23cc3068a9e4 1070 [..]
mbed_official 125:23cc3068a9e4 1071 (@)Please Note that the following features for regular channels are configurated
mbed_official 125:23cc3068a9e4 1072 using the ADC_Init() function :
mbed_official 125:23cc3068a9e4 1073 (++) continuous mode activation
mbed_official 125:23cc3068a9e4 1074 (++) Resolution
mbed_official 125:23cc3068a9e4 1075 (++) Data Alignement
mbed_official 125:23cc3068a9e4 1076 (++) Overrun Mode.
mbed_official 125:23cc3068a9e4 1077
mbed_official 125:23cc3068a9e4 1078 [..] Get the conversion data: This subsection provides an important function in
mbed_official 125:23cc3068a9e4 1079 the ADC peripheral since it returns the converted data of the current
mbed_official 125:23cc3068a9e4 1080 regular channel. When the Conversion value is read, the EOC Flag is
mbed_official 125:23cc3068a9e4 1081 automatically cleared.
mbed_official 125:23cc3068a9e4 1082
mbed_official 125:23cc3068a9e4 1083 [..] To configure the discontinous mode, the following functions should be used:
mbed_official 125:23cc3068a9e4 1084 (#) ADC_DiscModeChannelCountConfig() to configure the number of discontinuous channel to be converted.
mbed_official 125:23cc3068a9e4 1085 (#) ADC_DiscModeCmd() to enable the discontinuous mode.
mbed_official 125:23cc3068a9e4 1086
mbed_official 125:23cc3068a9e4 1087 [..] To configure and enable/disable the Channel offset use the functions:
mbed_official 125:23cc3068a9e4 1088 (++) ADC_SetChannelOffset1()
mbed_official 125:23cc3068a9e4 1089 (++) ADC_SetChannelOffset2()
mbed_official 125:23cc3068a9e4 1090 (++) ADC_SetChannelOffset3()
mbed_official 125:23cc3068a9e4 1091 (++) ADC_SetChannelOffset4()
mbed_official 125:23cc3068a9e4 1092 (++) ADC_ChannelOffset1Cmd()
mbed_official 125:23cc3068a9e4 1093 (++) ADC_ChannelOffset2Cmd()
mbed_official 125:23cc3068a9e4 1094 (++) ADC_ChannelOffset3Cmd()
mbed_official 125:23cc3068a9e4 1095 (++) ADC_ChannelOffset4Cmd()
mbed_official 125:23cc3068a9e4 1096
mbed_official 125:23cc3068a9e4 1097 @endverbatim
mbed_official 125:23cc3068a9e4 1098 * @{
mbed_official 125:23cc3068a9e4 1099 */
mbed_official 125:23cc3068a9e4 1100
mbed_official 125:23cc3068a9e4 1101 /**
mbed_official 125:23cc3068a9e4 1102 * @brief Configures for the selected ADC regular channel its corresponding
mbed_official 125:23cc3068a9e4 1103 * rank in the sequencer and its sample time.
mbed_official 125:23cc3068a9e4 1104 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1105 * @param ADC_Channel: the ADC channel to configure.
mbed_official 125:23cc3068a9e4 1106 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 1107 * @arg ADC_Channel_1: ADC Channel1 selected
mbed_official 125:23cc3068a9e4 1108 * @arg ADC_Channel_2: ADC Channel2 selected
mbed_official 125:23cc3068a9e4 1109 * @arg ADC_Channel_3: ADC Channel3 selected
mbed_official 125:23cc3068a9e4 1110 * @arg ADC_Channel_4: ADC Channel4 selected
mbed_official 125:23cc3068a9e4 1111 * @arg ADC_Channel_5: ADC Channel5 selected
mbed_official 125:23cc3068a9e4 1112 * @arg ADC_Channel_6: ADC Channel6 selected
mbed_official 125:23cc3068a9e4 1113 * @arg ADC_Channel_7: ADC Channel7 selected
mbed_official 125:23cc3068a9e4 1114 * @arg ADC_Channel_8: ADC Channel8 selected
mbed_official 125:23cc3068a9e4 1115 * @arg ADC_Channel_9: ADC Channel9 selected
mbed_official 125:23cc3068a9e4 1116 * @arg ADC_Channel_10: ADC Channel10 selected
mbed_official 125:23cc3068a9e4 1117 * @arg ADC_Channel_11: ADC Channel11 selected
mbed_official 125:23cc3068a9e4 1118 * @arg ADC_Channel_12: ADC Channel12 selected
mbed_official 125:23cc3068a9e4 1119 * @arg ADC_Channel_13: ADC Channel13 selected
mbed_official 125:23cc3068a9e4 1120 * @arg ADC_Channel_14: ADC Channel14 selected
mbed_official 125:23cc3068a9e4 1121 * @arg ADC_Channel_15: ADC Channel15 selected
mbed_official 125:23cc3068a9e4 1122 * @arg ADC_Channel_16: ADC Channel16 selected
mbed_official 125:23cc3068a9e4 1123 * @arg ADC_Channel_17: ADC Channel17 selected
mbed_official 125:23cc3068a9e4 1124 * @arg ADC_Channel_18: ADC Channel18 selected
mbed_official 125:23cc3068a9e4 1125 * @param Rank: The rank in the regular group sequencer. This parameter must be between 1 to 16.
mbed_official 125:23cc3068a9e4 1126 * @param ADC_SampleTime: The sample time value to be set for the selected channel.
mbed_official 125:23cc3068a9e4 1127 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 1128 * @arg ADC_SampleTime_1Cycles5: Sample time equal to 1.5 cycles
mbed_official 125:23cc3068a9e4 1129 * @arg ADC_SampleTime_2Cycles5: Sample time equal to 2.5 cycles
mbed_official 125:23cc3068a9e4 1130 * @arg ADC_SampleTime_4Cycles5: Sample time equal to 4.5 cycles
mbed_official 125:23cc3068a9e4 1131 * @arg ADC_SampleTime_7Cycles5: Sample time equal to 7.5 cycles
mbed_official 125:23cc3068a9e4 1132 * @arg ADC_SampleTime_19Cycles5: Sample time equal to 19.5 cycles
mbed_official 125:23cc3068a9e4 1133 * @arg ADC_SampleTime_61Cycles5: Sample time equal to 61.5 cycles
mbed_official 125:23cc3068a9e4 1134 * @arg ADC_SampleTime_181Cycles5: Sample time equal to 181.5 cycles
mbed_official 125:23cc3068a9e4 1135 * @arg ADC_SampleTime_601Cycles5: Sample time equal to 601.5 cycles
mbed_official 125:23cc3068a9e4 1136 * @retval None
mbed_official 125:23cc3068a9e4 1137 */
mbed_official 125:23cc3068a9e4 1138 void ADC_RegularChannelConfig(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint8_t Rank, uint8_t ADC_SampleTime)
mbed_official 125:23cc3068a9e4 1139 {
mbed_official 125:23cc3068a9e4 1140 uint32_t tmpreg1 = 0, tmpreg2 = 0;
mbed_official 125:23cc3068a9e4 1141 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1142 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1143 assert_param(IS_ADC_CHANNEL(ADC_Channel));
mbed_official 125:23cc3068a9e4 1144 assert_param(IS_ADC_SAMPLE_TIME(ADC_SampleTime));
mbed_official 125:23cc3068a9e4 1145
mbed_official 125:23cc3068a9e4 1146 /* Regular sequence configuration */
mbed_official 125:23cc3068a9e4 1147 /* For Rank 1 to 4 */
mbed_official 125:23cc3068a9e4 1148 if (Rank < 5)
mbed_official 125:23cc3068a9e4 1149 {
mbed_official 125:23cc3068a9e4 1150 /* Get the old register value */
mbed_official 125:23cc3068a9e4 1151 tmpreg1 = ADCx->SQR1;
mbed_official 125:23cc3068a9e4 1152 /* Calculate the mask to clear */
mbed_official 125:23cc3068a9e4 1153 tmpreg2 = 0x1F << (6 * (Rank ));
mbed_official 125:23cc3068a9e4 1154 /* Clear the old SQx bits for the selected rank */
mbed_official 125:23cc3068a9e4 1155 tmpreg1 &= ~tmpreg2;
mbed_official 125:23cc3068a9e4 1156 /* Calculate the mask to set */
mbed_official 125:23cc3068a9e4 1157 tmpreg2 = (uint32_t)(ADC_Channel) << (6 * (Rank));
mbed_official 125:23cc3068a9e4 1158 /* Set the SQx bits for the selected rank */
mbed_official 125:23cc3068a9e4 1159 tmpreg1 |= tmpreg2;
mbed_official 125:23cc3068a9e4 1160 /* Store the new register value */
mbed_official 125:23cc3068a9e4 1161 ADCx->SQR1 = tmpreg1;
mbed_official 125:23cc3068a9e4 1162 }
mbed_official 125:23cc3068a9e4 1163 /* For Rank 5 to 9 */
mbed_official 125:23cc3068a9e4 1164 else if (Rank < 10)
mbed_official 125:23cc3068a9e4 1165 {
mbed_official 125:23cc3068a9e4 1166 /* Get the old register value */
mbed_official 125:23cc3068a9e4 1167 tmpreg1 = ADCx->SQR2;
mbed_official 125:23cc3068a9e4 1168 /* Calculate the mask to clear */
mbed_official 125:23cc3068a9e4 1169 tmpreg2 = ADC_SQR2_SQ5 << (6 * (Rank - 5));
mbed_official 125:23cc3068a9e4 1170 /* Clear the old SQx bits for the selected rank */
mbed_official 125:23cc3068a9e4 1171 tmpreg1 &= ~tmpreg2;
mbed_official 125:23cc3068a9e4 1172 /* Calculate the mask to set */
mbed_official 125:23cc3068a9e4 1173 tmpreg2 = (uint32_t)(ADC_Channel) << (6 * (Rank - 5));
mbed_official 125:23cc3068a9e4 1174 /* Set the SQx bits for the selected rank */
mbed_official 125:23cc3068a9e4 1175 tmpreg1 |= tmpreg2;
mbed_official 125:23cc3068a9e4 1176 /* Store the new register value */
mbed_official 125:23cc3068a9e4 1177 ADCx->SQR2 = tmpreg1;
mbed_official 125:23cc3068a9e4 1178 }
mbed_official 125:23cc3068a9e4 1179 /* For Rank 10 to 14 */
mbed_official 125:23cc3068a9e4 1180 else if (Rank < 15)
mbed_official 125:23cc3068a9e4 1181 {
mbed_official 125:23cc3068a9e4 1182 /* Get the old register value */
mbed_official 125:23cc3068a9e4 1183 tmpreg1 = ADCx->SQR3;
mbed_official 125:23cc3068a9e4 1184 /* Calculate the mask to clear */
mbed_official 125:23cc3068a9e4 1185 tmpreg2 = ADC_SQR3_SQ10 << (6 * (Rank - 10));
mbed_official 125:23cc3068a9e4 1186 /* Clear the old SQx bits for the selected rank */
mbed_official 125:23cc3068a9e4 1187 tmpreg1 &= ~tmpreg2;
mbed_official 125:23cc3068a9e4 1188 /* Calculate the mask to set */
mbed_official 125:23cc3068a9e4 1189 tmpreg2 = (uint32_t)(ADC_Channel) << (6 * (Rank - 10));
mbed_official 125:23cc3068a9e4 1190 /* Set the SQx bits for the selected rank */
mbed_official 125:23cc3068a9e4 1191 tmpreg1 |= tmpreg2;
mbed_official 125:23cc3068a9e4 1192 /* Store the new register value */
mbed_official 125:23cc3068a9e4 1193 ADCx->SQR3 = tmpreg1;
mbed_official 125:23cc3068a9e4 1194 }
mbed_official 125:23cc3068a9e4 1195 else
mbed_official 125:23cc3068a9e4 1196 {
mbed_official 125:23cc3068a9e4 1197 /* Get the old register value */
mbed_official 125:23cc3068a9e4 1198 tmpreg1 = ADCx->SQR4;
mbed_official 125:23cc3068a9e4 1199 /* Calculate the mask to clear */
mbed_official 125:23cc3068a9e4 1200 tmpreg2 = ADC_SQR3_SQ15 << (6 * (Rank - 15));
mbed_official 125:23cc3068a9e4 1201 /* Clear the old SQx bits for the selected rank */
mbed_official 125:23cc3068a9e4 1202 tmpreg1 &= ~tmpreg2;
mbed_official 125:23cc3068a9e4 1203 /* Calculate the mask to set */
mbed_official 125:23cc3068a9e4 1204 tmpreg2 = (uint32_t)(ADC_Channel) << (6 * (Rank - 15));
mbed_official 125:23cc3068a9e4 1205 /* Set the SQx bits for the selected rank */
mbed_official 125:23cc3068a9e4 1206 tmpreg1 |= tmpreg2;
mbed_official 125:23cc3068a9e4 1207 /* Store the new register value */
mbed_official 125:23cc3068a9e4 1208 ADCx->SQR4 = tmpreg1;
mbed_official 125:23cc3068a9e4 1209 }
mbed_official 125:23cc3068a9e4 1210
mbed_official 125:23cc3068a9e4 1211 /* Channel sampling configuration */
mbed_official 125:23cc3068a9e4 1212 /* if ADC_Channel_10 ... ADC_Channel_18 is selected */
mbed_official 125:23cc3068a9e4 1213 if (ADC_Channel > ADC_Channel_9)
mbed_official 125:23cc3068a9e4 1214 {
mbed_official 125:23cc3068a9e4 1215 /* Get the old register value */
mbed_official 125:23cc3068a9e4 1216 tmpreg1 = ADCx->SMPR2;
mbed_official 125:23cc3068a9e4 1217 /* Calculate the mask to clear */
mbed_official 125:23cc3068a9e4 1218 tmpreg2 = ADC_SMPR2_SMP10 << (3 * (ADC_Channel - 10));
mbed_official 125:23cc3068a9e4 1219 /* Clear the old channel sample time */
mbed_official 125:23cc3068a9e4 1220 ADCx->SMPR2 &= ~tmpreg2;
mbed_official 125:23cc3068a9e4 1221 /* Calculate the mask to set */
mbed_official 125:23cc3068a9e4 1222 ADCx->SMPR2 |= (uint32_t)ADC_SampleTime << (3 * (ADC_Channel - 10));
mbed_official 125:23cc3068a9e4 1223
mbed_official 125:23cc3068a9e4 1224 }
mbed_official 125:23cc3068a9e4 1225 else /* ADC_Channel include in ADC_Channel_[0..9] */
mbed_official 125:23cc3068a9e4 1226 {
mbed_official 125:23cc3068a9e4 1227 /* Get the old register value */
mbed_official 125:23cc3068a9e4 1228 tmpreg1 = ADCx->SMPR1;
mbed_official 125:23cc3068a9e4 1229 /* Calculate the mask to clear */
mbed_official 125:23cc3068a9e4 1230 tmpreg2 = ADC_SMPR1_SMP1 << (3 * (ADC_Channel - 1));
mbed_official 125:23cc3068a9e4 1231 /* Clear the old channel sample time */
mbed_official 125:23cc3068a9e4 1232 ADCx->SMPR1 &= ~tmpreg2;
mbed_official 125:23cc3068a9e4 1233 /* Calculate the mask to set */
mbed_official 125:23cc3068a9e4 1234 ADCx->SMPR1 |= (uint32_t)ADC_SampleTime << (3 * (ADC_Channel));
mbed_official 125:23cc3068a9e4 1235 }
mbed_official 125:23cc3068a9e4 1236 }
mbed_official 125:23cc3068a9e4 1237
mbed_official 125:23cc3068a9e4 1238 /**
mbed_official 125:23cc3068a9e4 1239 * @brief Sets the ADC regular channel sequence lenght.
mbed_official 125:23cc3068a9e4 1240 * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1241 * @param SequenceLength: The Regular sequence length. This parameter must be between 1 to 16.
mbed_official 125:23cc3068a9e4 1242 * This parameter can be: ENABLE or DISABLE.
mbed_official 125:23cc3068a9e4 1243 * @retval None
mbed_official 125:23cc3068a9e4 1244 */
mbed_official 125:23cc3068a9e4 1245 void ADC_RegularChannelSequencerLengthConfig(ADC_TypeDef* ADCx, uint8_t SequencerLength)
mbed_official 125:23cc3068a9e4 1246 {
mbed_official 125:23cc3068a9e4 1247 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1248 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1249
mbed_official 125:23cc3068a9e4 1250 /* Configure the ADC sequence lenght */
mbed_official 125:23cc3068a9e4 1251 ADCx->SQR1 &= ~(uint32_t)ADC_SQR1_L;
mbed_official 125:23cc3068a9e4 1252 ADCx->SQR1 |= (uint32_t)(SequencerLength - 1);
mbed_official 125:23cc3068a9e4 1253 }
mbed_official 125:23cc3068a9e4 1254
mbed_official 125:23cc3068a9e4 1255 /**
mbed_official 125:23cc3068a9e4 1256 * @brief External Trigger Enable and Polarity Selection for regular channels.
mbed_official 125:23cc3068a9e4 1257 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1258 * @param ADC_ExternalTrigConvEvent: ADC external Trigger source.
mbed_official 125:23cc3068a9e4 1259 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 1260 * @arg ADC_ExternalTrigger_Event0: External trigger event 0
mbed_official 125:23cc3068a9e4 1261 * @arg ADC_ExternalTrigger_Event1: External trigger event 1
mbed_official 125:23cc3068a9e4 1262 * @arg ADC_ExternalTrigger_Event2: External trigger event 2
mbed_official 125:23cc3068a9e4 1263 * @arg ADC_ExternalTrigger_Event3: External trigger event 3
mbed_official 125:23cc3068a9e4 1264 * @arg ADC_ExternalTrigger_Event4: External trigger event 4
mbed_official 125:23cc3068a9e4 1265 * @arg ADC_ExternalTrigger_Event5: External trigger event 5
mbed_official 125:23cc3068a9e4 1266 * @arg ADC_ExternalTrigger_Event6: External trigger event 6
mbed_official 125:23cc3068a9e4 1267 * @arg ADC_ExternalTrigger_Event7: External trigger event 7
mbed_official 125:23cc3068a9e4 1268 * @arg ADC_ExternalTrigger_Event8: External trigger event 8
mbed_official 125:23cc3068a9e4 1269 * @arg ADC_ExternalTrigger_Event9: External trigger event 9
mbed_official 125:23cc3068a9e4 1270 * @arg ADC_ExternalTrigger_Event10: External trigger event 10
mbed_official 125:23cc3068a9e4 1271 * @arg ADC_ExternalTrigger_Event11: External trigger event 11
mbed_official 125:23cc3068a9e4 1272 * @arg ADC_ExternalTrigger_Event12: External trigger event 12
mbed_official 125:23cc3068a9e4 1273 * @arg ADC_ExternalTrigger_Event13: External trigger event 13
mbed_official 125:23cc3068a9e4 1274 * @arg ADC_ExternalTrigger_Event14: External trigger event 14
mbed_official 125:23cc3068a9e4 1275 * @arg ADC_ExternalTrigger_Event15: External trigger event 15
mbed_official 125:23cc3068a9e4 1276 * @param ADC_ExternalTrigEventEdge: ADC external Trigger Polarity.
mbed_official 125:23cc3068a9e4 1277 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 1278 * @arg ADC_ExternalTrigEventEdge_OFF: Hardware trigger detection disabled
mbed_official 125:23cc3068a9e4 1279 * (conversions can be launched by software)
mbed_official 125:23cc3068a9e4 1280 * @arg ADC_ExternalTrigEventEdge_RisingEdge: Hardware trigger detection on the rising edge
mbed_official 125:23cc3068a9e4 1281 * @arg ADC_ExternalTrigEventEdge_FallingEdge: Hardware trigger detection on the falling edge
mbed_official 125:23cc3068a9e4 1282 * @arg ADC_ExternalTrigEventEdge_BothEdge: Hardware trigger detection on both the rising and falling edges
mbed_official 125:23cc3068a9e4 1283 * @retval None
mbed_official 125:23cc3068a9e4 1284 */
mbed_official 125:23cc3068a9e4 1285 void ADC_ExternalTriggerConfig(ADC_TypeDef* ADCx, uint16_t ADC_ExternalTrigConvEvent, uint16_t ADC_ExternalTrigEventEdge)
mbed_official 125:23cc3068a9e4 1286 {
mbed_official 125:23cc3068a9e4 1287 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1288 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1289 assert_param(IS_ADC_EXT_TRIG(ADC_ExternalTrigConvEvent));
mbed_official 125:23cc3068a9e4 1290 assert_param(IS_EXTERNALTRIG_EDGE(ADC_ExternalTrigEventEdge));
mbed_official 125:23cc3068a9e4 1291
mbed_official 125:23cc3068a9e4 1292 /* Disable the selected ADC conversion on external event */
mbed_official 125:23cc3068a9e4 1293 ADCx->CFGR &= ~(ADC_CFGR_EXTEN | ADC_CFGR_EXTSEL);
mbed_official 125:23cc3068a9e4 1294 ADCx->CFGR |= (uint32_t)(ADC_ExternalTrigEventEdge | ADC_ExternalTrigConvEvent);
mbed_official 125:23cc3068a9e4 1295 }
mbed_official 125:23cc3068a9e4 1296
mbed_official 125:23cc3068a9e4 1297 /**
mbed_official 125:23cc3068a9e4 1298 * @brief Enables or disables the selected ADC start conversion .
mbed_official 125:23cc3068a9e4 1299 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1300 * @retval None
mbed_official 125:23cc3068a9e4 1301 */
mbed_official 125:23cc3068a9e4 1302 void ADC_StartConversion(ADC_TypeDef* ADCx)
mbed_official 125:23cc3068a9e4 1303 {
mbed_official 125:23cc3068a9e4 1304 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1305 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1306
mbed_official 125:23cc3068a9e4 1307 /* Set the ADSTART bit */
mbed_official 125:23cc3068a9e4 1308 ADCx->CR |= ADC_CR_ADSTART;
mbed_official 125:23cc3068a9e4 1309 }
mbed_official 125:23cc3068a9e4 1310
mbed_official 125:23cc3068a9e4 1311 /**
mbed_official 125:23cc3068a9e4 1312 * @brief Gets the selected ADC start conversion Status.
mbed_official 125:23cc3068a9e4 1313 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1314 * @retval The new state of ADC start conversion (SET or RESET).
mbed_official 125:23cc3068a9e4 1315 */
mbed_official 125:23cc3068a9e4 1316 FlagStatus ADC_GetStartConversionStatus(ADC_TypeDef* ADCx)
mbed_official 125:23cc3068a9e4 1317 {
mbed_official 125:23cc3068a9e4 1318 FlagStatus bitstatus = RESET;
mbed_official 125:23cc3068a9e4 1319 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1320 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1321 /* Check the status of ADSTART bit */
mbed_official 125:23cc3068a9e4 1322 if ((ADCx->CR & ADC_CR_ADSTART) != (uint32_t)RESET)
mbed_official 125:23cc3068a9e4 1323 {
mbed_official 125:23cc3068a9e4 1324 /* ADSTART bit is set */
mbed_official 125:23cc3068a9e4 1325 bitstatus = SET;
mbed_official 125:23cc3068a9e4 1326 }
mbed_official 125:23cc3068a9e4 1327 else
mbed_official 125:23cc3068a9e4 1328 {
mbed_official 125:23cc3068a9e4 1329 /* ADSTART bit is reset */
mbed_official 125:23cc3068a9e4 1330 bitstatus = RESET;
mbed_official 125:23cc3068a9e4 1331 }
mbed_official 125:23cc3068a9e4 1332 /* Return the ADSTART bit status */
mbed_official 125:23cc3068a9e4 1333 return bitstatus;
mbed_official 125:23cc3068a9e4 1334 }
mbed_official 125:23cc3068a9e4 1335
mbed_official 125:23cc3068a9e4 1336 /**
mbed_official 125:23cc3068a9e4 1337 * @brief Stops the selected ADC ongoing conversion.
mbed_official 125:23cc3068a9e4 1338 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1339 * @retval None
mbed_official 125:23cc3068a9e4 1340 */
mbed_official 125:23cc3068a9e4 1341 void ADC_StopConversion(ADC_TypeDef* ADCx)
mbed_official 125:23cc3068a9e4 1342 {
mbed_official 125:23cc3068a9e4 1343 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1344 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1345
mbed_official 125:23cc3068a9e4 1346 /* Set the ADSTP bit */
mbed_official 125:23cc3068a9e4 1347 ADCx->CR |= ADC_CR_ADSTP;
mbed_official 125:23cc3068a9e4 1348 }
mbed_official 125:23cc3068a9e4 1349
mbed_official 125:23cc3068a9e4 1350
mbed_official 125:23cc3068a9e4 1351 /**
mbed_official 125:23cc3068a9e4 1352 * @brief Configures the discontinuous mode for the selected ADC regular
mbed_official 125:23cc3068a9e4 1353 * group channel.
mbed_official 125:23cc3068a9e4 1354 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1355 * @param Number: specifies the discontinuous mode regular channel
mbed_official 125:23cc3068a9e4 1356 * count value. This number must be between 1 and 8.
mbed_official 125:23cc3068a9e4 1357 * @retval None
mbed_official 125:23cc3068a9e4 1358 */
mbed_official 125:23cc3068a9e4 1359 void ADC_DiscModeChannelCountConfig(ADC_TypeDef* ADCx, uint8_t Number)
mbed_official 125:23cc3068a9e4 1360 {
mbed_official 125:23cc3068a9e4 1361 uint32_t tmpreg1 = 0;
mbed_official 125:23cc3068a9e4 1362 uint32_t tmpreg2 = 0;
mbed_official 125:23cc3068a9e4 1363 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1364 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1365 assert_param(IS_ADC_REGULAR_DISC_NUMBER(Number));
mbed_official 125:23cc3068a9e4 1366 /* Get the old register value */
mbed_official 125:23cc3068a9e4 1367 tmpreg1 = ADCx->CFGR;
mbed_official 125:23cc3068a9e4 1368 /* Clear the old discontinuous mode channel count */
mbed_official 125:23cc3068a9e4 1369 tmpreg1 &= ~(uint32_t)(ADC_CFGR_DISCNUM);
mbed_official 125:23cc3068a9e4 1370 /* Set the discontinuous mode channel count */
mbed_official 125:23cc3068a9e4 1371 tmpreg2 = Number - 1;
mbed_official 125:23cc3068a9e4 1372 tmpreg1 |= tmpreg2 << 17;
mbed_official 125:23cc3068a9e4 1373 /* Store the new register value */
mbed_official 125:23cc3068a9e4 1374 ADCx->CFGR = tmpreg1;
mbed_official 125:23cc3068a9e4 1375 }
mbed_official 125:23cc3068a9e4 1376
mbed_official 125:23cc3068a9e4 1377 /**
mbed_official 125:23cc3068a9e4 1378 * @brief Enables or disables the discontinuous mode on regular group
mbed_official 125:23cc3068a9e4 1379 * channel for the specified ADC
mbed_official 125:23cc3068a9e4 1380 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1381 * @param NewState: new state of the selected ADC discontinuous mode
mbed_official 125:23cc3068a9e4 1382 * on regular group channel.
mbed_official 125:23cc3068a9e4 1383 * This parameter can be: ENABLE or DISABLE.
mbed_official 125:23cc3068a9e4 1384 * @retval None
mbed_official 125:23cc3068a9e4 1385 */
mbed_official 125:23cc3068a9e4 1386 void ADC_DiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
mbed_official 125:23cc3068a9e4 1387 {
mbed_official 125:23cc3068a9e4 1388 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1389 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1390 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 125:23cc3068a9e4 1391 if (NewState != DISABLE)
mbed_official 125:23cc3068a9e4 1392 {
mbed_official 125:23cc3068a9e4 1393 /* Enable the selected ADC regular discontinuous mode */
mbed_official 125:23cc3068a9e4 1394 ADCx->CFGR |= ADC_CFGR_DISCEN;
mbed_official 125:23cc3068a9e4 1395 }
mbed_official 125:23cc3068a9e4 1396 else
mbed_official 125:23cc3068a9e4 1397 {
mbed_official 125:23cc3068a9e4 1398 /* Disable the selected ADC regular discontinuous mode */
mbed_official 125:23cc3068a9e4 1399 ADCx->CFGR &= ~(uint32_t)(ADC_CFGR_DISCEN);
mbed_official 125:23cc3068a9e4 1400 }
mbed_official 125:23cc3068a9e4 1401 }
mbed_official 125:23cc3068a9e4 1402
mbed_official 125:23cc3068a9e4 1403 /**
mbed_official 125:23cc3068a9e4 1404 * @brief Returns the last ADCx conversion result data for regular channel.
mbed_official 125:23cc3068a9e4 1405 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1406 * @retval The Data conversion value.
mbed_official 125:23cc3068a9e4 1407 */
mbed_official 125:23cc3068a9e4 1408 uint16_t ADC_GetConversionValue(ADC_TypeDef* ADCx)
mbed_official 125:23cc3068a9e4 1409 {
mbed_official 125:23cc3068a9e4 1410 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1411 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1412 /* Return the selected ADC conversion value */
mbed_official 125:23cc3068a9e4 1413 return (uint16_t) ADCx->DR;
mbed_official 125:23cc3068a9e4 1414 }
mbed_official 125:23cc3068a9e4 1415
mbed_official 125:23cc3068a9e4 1416 /**
mbed_official 125:23cc3068a9e4 1417 * @brief Returns the last ADC1, ADC2, ADC3 and ADC4 regular conversions results
mbed_official 125:23cc3068a9e4 1418 * data in the selected dual mode.
mbed_official 125:23cc3068a9e4 1419 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1420 * @retval The Data conversion value.
mbed_official 125:23cc3068a9e4 1421 * @note In dual mode, the value returned by this function is as following
mbed_official 125:23cc3068a9e4 1422 * Data[15:0] : these bits contain the regular data of the Master ADC.
mbed_official 125:23cc3068a9e4 1423 * Data[31:16]: these bits contain the regular data of the Slave ADC.
mbed_official 125:23cc3068a9e4 1424 */
mbed_official 125:23cc3068a9e4 1425 uint32_t ADC_GetDualModeConversionValue(ADC_TypeDef* ADCx)
mbed_official 125:23cc3068a9e4 1426 {
mbed_official 125:23cc3068a9e4 1427 uint32_t tmpreg1 = 0;
mbed_official 125:23cc3068a9e4 1428
mbed_official 125:23cc3068a9e4 1429 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1430 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1431
mbed_official 125:23cc3068a9e4 1432 if((ADCx == ADC1) || (ADCx== ADC2))
mbed_official 125:23cc3068a9e4 1433 {
mbed_official 125:23cc3068a9e4 1434 /* Get the dual mode conversion value */
mbed_official 125:23cc3068a9e4 1435 tmpreg1 = ADC1_2->CDR;
mbed_official 125:23cc3068a9e4 1436 }
mbed_official 125:23cc3068a9e4 1437 else
mbed_official 125:23cc3068a9e4 1438 {
mbed_official 125:23cc3068a9e4 1439 /* Get the dual mode conversion value */
mbed_official 125:23cc3068a9e4 1440 tmpreg1 = ADC3_4->CDR;
mbed_official 125:23cc3068a9e4 1441 }
mbed_official 125:23cc3068a9e4 1442 /* Return the dual mode conversion value */
mbed_official 125:23cc3068a9e4 1443 return (uint32_t) tmpreg1;
mbed_official 125:23cc3068a9e4 1444 }
mbed_official 125:23cc3068a9e4 1445
mbed_official 125:23cc3068a9e4 1446 /**
mbed_official 125:23cc3068a9e4 1447 * @brief Set the ADC channels conversion value offset1
mbed_official 125:23cc3068a9e4 1448 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1449 * @param ADC_Channel: the ADC channel to configure.
mbed_official 125:23cc3068a9e4 1450 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 1451 * @arg ADC_Channel_1: ADC Channel1 selected
mbed_official 125:23cc3068a9e4 1452 * @arg ADC_Channel_2: ADC Channel2 selected
mbed_official 125:23cc3068a9e4 1453 * @arg ADC_Channel_3: ADC Channel3 selected
mbed_official 125:23cc3068a9e4 1454 * @arg ADC_Channel_4: ADC Channel4 selected
mbed_official 125:23cc3068a9e4 1455 * @arg ADC_Channel_5: ADC Channel5 selected
mbed_official 125:23cc3068a9e4 1456 * @arg ADC_Channel_6: ADC Channel6 selected
mbed_official 125:23cc3068a9e4 1457 * @arg ADC_Channel_7: ADC Channel7 selected
mbed_official 125:23cc3068a9e4 1458 * @arg ADC_Channel_8: ADC Channel8 selected
mbed_official 125:23cc3068a9e4 1459 * @arg ADC_Channel_9: ADC Channel9 selected
mbed_official 125:23cc3068a9e4 1460 * @arg ADC_Channel_10: ADC Channel10 selected
mbed_official 125:23cc3068a9e4 1461 * @arg ADC_Channel_11: ADC Channel11 selected
mbed_official 125:23cc3068a9e4 1462 * @arg ADC_Channel_12: ADC Channel12 selected
mbed_official 125:23cc3068a9e4 1463 * @arg ADC_Channel_13: ADC Channel13 selected
mbed_official 125:23cc3068a9e4 1464 * @arg ADC_Channel_14: ADC Channel14 selected
mbed_official 125:23cc3068a9e4 1465 * @arg ADC_Channel_15: ADC Channel15 selected
mbed_official 125:23cc3068a9e4 1466 * @arg ADC_Channel_16: ADC Channel16 selected
mbed_official 125:23cc3068a9e4 1467 * @arg ADC_Channel_17: ADC Channel17 selected
mbed_official 125:23cc3068a9e4 1468 * @arg ADC_Channel_18: ADC Channel18 selected
mbed_official 125:23cc3068a9e4 1469 * @param Offset: the offset value for the selected ADC Channel
mbed_official 125:23cc3068a9e4 1470 * This parameter must be a 12bit value.
mbed_official 125:23cc3068a9e4 1471 * @retval None
mbed_official 125:23cc3068a9e4 1472 */
mbed_official 125:23cc3068a9e4 1473 void ADC_SetChannelOffset1(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint16_t Offset)
mbed_official 125:23cc3068a9e4 1474 {
mbed_official 125:23cc3068a9e4 1475 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1476 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1477 assert_param(IS_ADC_CHANNEL(ADC_Channel));
mbed_official 125:23cc3068a9e4 1478 assert_param(IS_ADC_OFFSET(Offset));
mbed_official 125:23cc3068a9e4 1479
mbed_official 125:23cc3068a9e4 1480 /* Select the Channel */
mbed_official 125:23cc3068a9e4 1481 ADCx->OFR1 &= ~ (uint32_t) ADC_OFR1_OFFSET1_CH;
mbed_official 125:23cc3068a9e4 1482 ADCx->OFR1 |= (uint32_t)((uint32_t)ADC_Channel << 26);
mbed_official 125:23cc3068a9e4 1483
mbed_official 125:23cc3068a9e4 1484 /* Set the data offset */
mbed_official 125:23cc3068a9e4 1485 ADCx->OFR1 &= ~ (uint32_t) ADC_OFR1_OFFSET1;
mbed_official 125:23cc3068a9e4 1486 ADCx->OFR1 |= (uint32_t)Offset;
mbed_official 125:23cc3068a9e4 1487 }
mbed_official 125:23cc3068a9e4 1488
mbed_official 125:23cc3068a9e4 1489 /**
mbed_official 125:23cc3068a9e4 1490 * @brief Set the ADC channels conversion value offset2
mbed_official 125:23cc3068a9e4 1491 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1492 * @param ADC_Channel: the ADC channel to configure.
mbed_official 125:23cc3068a9e4 1493 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 1494 * @arg ADC_Channel_1: ADC Channel1 selected
mbed_official 125:23cc3068a9e4 1495 * @arg ADC_Channel_2: ADC Channel2 selected
mbed_official 125:23cc3068a9e4 1496 * @arg ADC_Channel_3: ADC Channel3 selected
mbed_official 125:23cc3068a9e4 1497 * @arg ADC_Channel_4: ADC Channel4 selected
mbed_official 125:23cc3068a9e4 1498 * @arg ADC_Channel_5: ADC Channel5 selected
mbed_official 125:23cc3068a9e4 1499 * @arg ADC_Channel_6: ADC Channel6 selected
mbed_official 125:23cc3068a9e4 1500 * @arg ADC_Channel_7: ADC Channel7 selected
mbed_official 125:23cc3068a9e4 1501 * @arg ADC_Channel_8: ADC Channel8 selected
mbed_official 125:23cc3068a9e4 1502 * @arg ADC_Channel_9: ADC Channel9 selected
mbed_official 125:23cc3068a9e4 1503 * @arg ADC_Channel_10: ADC Channel10 selected
mbed_official 125:23cc3068a9e4 1504 * @arg ADC_Channel_11: ADC Channel11 selected
mbed_official 125:23cc3068a9e4 1505 * @arg ADC_Channel_12: ADC Channel12 selected
mbed_official 125:23cc3068a9e4 1506 * @arg ADC_Channel_13: ADC Channel13 selected
mbed_official 125:23cc3068a9e4 1507 * @arg ADC_Channel_14: ADC Channel14 selected
mbed_official 125:23cc3068a9e4 1508 * @arg ADC_Channel_15: ADC Channel15 selected
mbed_official 125:23cc3068a9e4 1509 * @arg ADC_Channel_16: ADC Channel16 selected
mbed_official 125:23cc3068a9e4 1510 * @arg ADC_Channel_17: ADC Channel17 selected
mbed_official 125:23cc3068a9e4 1511 * @arg ADC_Channel_18: ADC Channel18 selected
mbed_official 125:23cc3068a9e4 1512 * @param Offset: the offset value for the selected ADC Channel
mbed_official 125:23cc3068a9e4 1513 * This parameter must be a 12bit value.
mbed_official 125:23cc3068a9e4 1514 * @retval None
mbed_official 125:23cc3068a9e4 1515 */
mbed_official 125:23cc3068a9e4 1516 void ADC_SetChannelOffset2(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint16_t Offset)
mbed_official 125:23cc3068a9e4 1517 {
mbed_official 125:23cc3068a9e4 1518 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1519 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1520 assert_param(IS_ADC_CHANNEL(ADC_Channel));
mbed_official 125:23cc3068a9e4 1521 assert_param(IS_ADC_OFFSET(Offset));
mbed_official 125:23cc3068a9e4 1522
mbed_official 125:23cc3068a9e4 1523 /* Select the Channel */
mbed_official 125:23cc3068a9e4 1524 ADCx->OFR2 &= ~ (uint32_t) ADC_OFR2_OFFSET2_CH;
mbed_official 125:23cc3068a9e4 1525 ADCx->OFR2 |= (uint32_t)((uint32_t)ADC_Channel << 26);
mbed_official 125:23cc3068a9e4 1526
mbed_official 125:23cc3068a9e4 1527 /* Set the data offset */
mbed_official 125:23cc3068a9e4 1528 ADCx->OFR2 &= ~ (uint32_t) ADC_OFR2_OFFSET2;
mbed_official 125:23cc3068a9e4 1529 ADCx->OFR2 |= (uint32_t)Offset;
mbed_official 125:23cc3068a9e4 1530 }
mbed_official 125:23cc3068a9e4 1531
mbed_official 125:23cc3068a9e4 1532 /**
mbed_official 125:23cc3068a9e4 1533 * @brief Set the ADC channels conversion value offset3
mbed_official 125:23cc3068a9e4 1534 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1535 * @param ADC_Channel: the ADC channel to configure.
mbed_official 125:23cc3068a9e4 1536 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 1537 * @arg ADC_Channel_1: ADC Channel1 selected
mbed_official 125:23cc3068a9e4 1538 * @arg ADC_Channel_2: ADC Channel2 selected
mbed_official 125:23cc3068a9e4 1539 * @arg ADC_Channel_3: ADC Channel3 selected
mbed_official 125:23cc3068a9e4 1540 * @arg ADC_Channel_4: ADC Channel4 selected
mbed_official 125:23cc3068a9e4 1541 * @arg ADC_Channel_5: ADC Channel5 selected
mbed_official 125:23cc3068a9e4 1542 * @arg ADC_Channel_6: ADC Channel6 selected
mbed_official 125:23cc3068a9e4 1543 * @arg ADC_Channel_7: ADC Channel7 selected
mbed_official 125:23cc3068a9e4 1544 * @arg ADC_Channel_8: ADC Channel8 selected
mbed_official 125:23cc3068a9e4 1545 * @arg ADC_Channel_9: ADC Channel9 selected
mbed_official 125:23cc3068a9e4 1546 * @arg ADC_Channel_10: ADC Channel10 selected
mbed_official 125:23cc3068a9e4 1547 * @arg ADC_Channel_11: ADC Channel11 selected
mbed_official 125:23cc3068a9e4 1548 * @arg ADC_Channel_12: ADC Channel12 selected
mbed_official 125:23cc3068a9e4 1549 * @arg ADC_Channel_13: ADC Channel13 selected
mbed_official 125:23cc3068a9e4 1550 * @arg ADC_Channel_14: ADC Channel14 selected
mbed_official 125:23cc3068a9e4 1551 * @arg ADC_Channel_15: ADC Channel15 selected
mbed_official 125:23cc3068a9e4 1552 * @arg ADC_Channel_16: ADC Channel16 selected
mbed_official 125:23cc3068a9e4 1553 * @arg ADC_Channel_17: ADC Channel17 selected
mbed_official 125:23cc3068a9e4 1554 * @arg ADC_Channel_18: ADC Channel18 selected
mbed_official 125:23cc3068a9e4 1555 * @param Offset: the offset value for the selected ADC Channel
mbed_official 125:23cc3068a9e4 1556 * This parameter must be a 12bit value.
mbed_official 125:23cc3068a9e4 1557 * @retval None
mbed_official 125:23cc3068a9e4 1558 */
mbed_official 125:23cc3068a9e4 1559 void ADC_SetChannelOffset3(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint16_t Offset)
mbed_official 125:23cc3068a9e4 1560 {
mbed_official 125:23cc3068a9e4 1561 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1562 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1563 assert_param(IS_ADC_CHANNEL(ADC_Channel));
mbed_official 125:23cc3068a9e4 1564 assert_param(IS_ADC_OFFSET(Offset));
mbed_official 125:23cc3068a9e4 1565
mbed_official 125:23cc3068a9e4 1566 /* Select the Channel */
mbed_official 125:23cc3068a9e4 1567 ADCx->OFR3 &= ~ (uint32_t) ADC_OFR3_OFFSET3_CH;
mbed_official 125:23cc3068a9e4 1568 ADCx->OFR3 |= (uint32_t)((uint32_t)ADC_Channel << 26);
mbed_official 125:23cc3068a9e4 1569
mbed_official 125:23cc3068a9e4 1570 /* Set the data offset */
mbed_official 125:23cc3068a9e4 1571 ADCx->OFR3 &= ~ (uint32_t) ADC_OFR3_OFFSET3;
mbed_official 125:23cc3068a9e4 1572 ADCx->OFR3 |= (uint32_t)Offset;
mbed_official 125:23cc3068a9e4 1573 }
mbed_official 125:23cc3068a9e4 1574
mbed_official 125:23cc3068a9e4 1575 /**
mbed_official 125:23cc3068a9e4 1576 * @brief Set the ADC channels conversion value offset4
mbed_official 125:23cc3068a9e4 1577 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1578 * @param ADC_Channel: the ADC channel to configure.
mbed_official 125:23cc3068a9e4 1579 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 1580 * @arg ADC_Channel_1: ADC Channel1 selected
mbed_official 125:23cc3068a9e4 1581 * @arg ADC_Channel_2: ADC Channel2 selected
mbed_official 125:23cc3068a9e4 1582 * @arg ADC_Channel_3: ADC Channel3 selected
mbed_official 125:23cc3068a9e4 1583 * @arg ADC_Channel_4: ADC Channel4 selected
mbed_official 125:23cc3068a9e4 1584 * @arg ADC_Channel_5: ADC Channel5 selected
mbed_official 125:23cc3068a9e4 1585 * @arg ADC_Channel_6: ADC Channel6 selected
mbed_official 125:23cc3068a9e4 1586 * @arg ADC_Channel_7: ADC Channel7 selected
mbed_official 125:23cc3068a9e4 1587 * @arg ADC_Channel_8: ADC Channel8 selected
mbed_official 125:23cc3068a9e4 1588 * @arg ADC_Channel_9: ADC Channel9 selected
mbed_official 125:23cc3068a9e4 1589 * @arg ADC_Channel_10: ADC Channel10 selected
mbed_official 125:23cc3068a9e4 1590 * @arg ADC_Channel_11: ADC Channel11 selected
mbed_official 125:23cc3068a9e4 1591 * @arg ADC_Channel_12: ADC Channel12 selected
mbed_official 125:23cc3068a9e4 1592 * @arg ADC_Channel_13: ADC Channel13 selected
mbed_official 125:23cc3068a9e4 1593 * @arg ADC_Channel_14: ADC Channel14 selected
mbed_official 125:23cc3068a9e4 1594 * @arg ADC_Channel_15: ADC Channel15 selected
mbed_official 125:23cc3068a9e4 1595 * @arg ADC_Channel_16: ADC Channel16 selected
mbed_official 125:23cc3068a9e4 1596 * @arg ADC_Channel_17: ADC Channel17 selected
mbed_official 125:23cc3068a9e4 1597 * @arg ADC_Channel_18: ADC Channel18 selected
mbed_official 125:23cc3068a9e4 1598 * @param Offset: the offset value for the selected ADC Channel
mbed_official 125:23cc3068a9e4 1599 * This parameter must be a 12bit value.
mbed_official 125:23cc3068a9e4 1600 * @retval None
mbed_official 125:23cc3068a9e4 1601 */
mbed_official 125:23cc3068a9e4 1602 void ADC_SetChannelOffset4(ADC_TypeDef* ADCx, uint8_t ADC_Channel, uint16_t Offset)
mbed_official 125:23cc3068a9e4 1603 {
mbed_official 125:23cc3068a9e4 1604 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1605 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1606 assert_param(IS_ADC_CHANNEL(ADC_Channel));
mbed_official 125:23cc3068a9e4 1607 assert_param(IS_ADC_OFFSET(Offset));
mbed_official 125:23cc3068a9e4 1608
mbed_official 125:23cc3068a9e4 1609 /* Select the Channel */
mbed_official 125:23cc3068a9e4 1610 ADCx->OFR4 &= ~ (uint32_t) ADC_OFR4_OFFSET4_CH;
mbed_official 125:23cc3068a9e4 1611 ADCx->OFR4 |= (uint32_t)((uint32_t)ADC_Channel << 26);
mbed_official 125:23cc3068a9e4 1612
mbed_official 125:23cc3068a9e4 1613 /* Set the data offset */
mbed_official 125:23cc3068a9e4 1614 ADCx->OFR4 &= ~ (uint32_t) ADC_OFR4_OFFSET4;
mbed_official 125:23cc3068a9e4 1615 ADCx->OFR4 |= (uint32_t)Offset;
mbed_official 125:23cc3068a9e4 1616 }
mbed_official 125:23cc3068a9e4 1617
mbed_official 125:23cc3068a9e4 1618 /**
mbed_official 125:23cc3068a9e4 1619 * @brief Enables or disables the Offset1.
mbed_official 125:23cc3068a9e4 1620 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1621 * @param NewState: new state of the ADCx offset1.
mbed_official 125:23cc3068a9e4 1622 * This parameter can be: ENABLE or DISABLE.
mbed_official 125:23cc3068a9e4 1623 * @retval None
mbed_official 125:23cc3068a9e4 1624 */
mbed_official 125:23cc3068a9e4 1625 void ADC_ChannelOffset1Cmd(ADC_TypeDef* ADCx, FunctionalState NewState)
mbed_official 125:23cc3068a9e4 1626 {
mbed_official 125:23cc3068a9e4 1627 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1628 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1629 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 125:23cc3068a9e4 1630
mbed_official 125:23cc3068a9e4 1631 if (NewState != DISABLE)
mbed_official 125:23cc3068a9e4 1632 {
mbed_official 125:23cc3068a9e4 1633 /* Set the OFFSET1_EN bit */
mbed_official 125:23cc3068a9e4 1634 ADCx->OFR1 |= ADC_OFR1_OFFSET1_EN;
mbed_official 125:23cc3068a9e4 1635 }
mbed_official 125:23cc3068a9e4 1636 else
mbed_official 125:23cc3068a9e4 1637 {
mbed_official 125:23cc3068a9e4 1638 /* Reset the OFFSET1_EN bit */
mbed_official 125:23cc3068a9e4 1639 ADCx->OFR1 &= ~(ADC_OFR1_OFFSET1_EN);
mbed_official 125:23cc3068a9e4 1640 }
mbed_official 125:23cc3068a9e4 1641 }
mbed_official 125:23cc3068a9e4 1642
mbed_official 125:23cc3068a9e4 1643 /**
mbed_official 125:23cc3068a9e4 1644 * @brief Enables or disables the Offset2.
mbed_official 125:23cc3068a9e4 1645 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1646 * @param NewState: new state of the ADCx offset2.
mbed_official 125:23cc3068a9e4 1647 * This parameter can be: ENABLE or DISABLE.
mbed_official 125:23cc3068a9e4 1648 * @retval None
mbed_official 125:23cc3068a9e4 1649 */
mbed_official 125:23cc3068a9e4 1650 void ADC_ChannelOffset2Cmd(ADC_TypeDef* ADCx, FunctionalState NewState)
mbed_official 125:23cc3068a9e4 1651 {
mbed_official 125:23cc3068a9e4 1652 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1653 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1654 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 125:23cc3068a9e4 1655
mbed_official 125:23cc3068a9e4 1656 if (NewState != DISABLE)
mbed_official 125:23cc3068a9e4 1657 {
mbed_official 125:23cc3068a9e4 1658 /* Set the OFFSET1_EN bit */
mbed_official 125:23cc3068a9e4 1659 ADCx->OFR2 |= ADC_OFR2_OFFSET2_EN;
mbed_official 125:23cc3068a9e4 1660 }
mbed_official 125:23cc3068a9e4 1661 else
mbed_official 125:23cc3068a9e4 1662 {
mbed_official 125:23cc3068a9e4 1663 /* Reset the OFFSET1_EN bit */
mbed_official 125:23cc3068a9e4 1664 ADCx->OFR2 &= ~(ADC_OFR2_OFFSET2_EN);
mbed_official 125:23cc3068a9e4 1665 }
mbed_official 125:23cc3068a9e4 1666 }
mbed_official 125:23cc3068a9e4 1667
mbed_official 125:23cc3068a9e4 1668 /**
mbed_official 125:23cc3068a9e4 1669 * @brief Enables or disables the Offset3.
mbed_official 125:23cc3068a9e4 1670 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1671 * @param NewState: new state of the ADCx offset3.
mbed_official 125:23cc3068a9e4 1672 * This parameter can be: ENABLE or DISABLE.
mbed_official 125:23cc3068a9e4 1673 * @retval None
mbed_official 125:23cc3068a9e4 1674 */
mbed_official 125:23cc3068a9e4 1675 void ADC_ChannelOffset3Cmd(ADC_TypeDef* ADCx, FunctionalState NewState)
mbed_official 125:23cc3068a9e4 1676 {
mbed_official 125:23cc3068a9e4 1677 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1678 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1679 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 125:23cc3068a9e4 1680
mbed_official 125:23cc3068a9e4 1681 if (NewState != DISABLE)
mbed_official 125:23cc3068a9e4 1682 {
mbed_official 125:23cc3068a9e4 1683 /* Set the OFFSET1_EN bit */
mbed_official 125:23cc3068a9e4 1684 ADCx->OFR3 |= ADC_OFR3_OFFSET3_EN;
mbed_official 125:23cc3068a9e4 1685 }
mbed_official 125:23cc3068a9e4 1686 else
mbed_official 125:23cc3068a9e4 1687 {
mbed_official 125:23cc3068a9e4 1688 /* Reset the OFFSET1_EN bit */
mbed_official 125:23cc3068a9e4 1689 ADCx->OFR3 &= ~(ADC_OFR3_OFFSET3_EN);
mbed_official 125:23cc3068a9e4 1690 }
mbed_official 125:23cc3068a9e4 1691 }
mbed_official 125:23cc3068a9e4 1692
mbed_official 125:23cc3068a9e4 1693 /**
mbed_official 125:23cc3068a9e4 1694 * @brief Enables or disables the Offset4.
mbed_official 125:23cc3068a9e4 1695 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1696 * @param NewState: new state of the ADCx offset4.
mbed_official 125:23cc3068a9e4 1697 * This parameter can be: ENABLE or DISABLE.
mbed_official 125:23cc3068a9e4 1698 * @retval None
mbed_official 125:23cc3068a9e4 1699 */
mbed_official 125:23cc3068a9e4 1700 void ADC_ChannelOffset4Cmd(ADC_TypeDef* ADCx, FunctionalState NewState)
mbed_official 125:23cc3068a9e4 1701 {
mbed_official 125:23cc3068a9e4 1702 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1703 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1704 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 125:23cc3068a9e4 1705
mbed_official 125:23cc3068a9e4 1706 if (NewState != DISABLE)
mbed_official 125:23cc3068a9e4 1707 {
mbed_official 125:23cc3068a9e4 1708 /* Set the OFFSET1_EN bit */
mbed_official 125:23cc3068a9e4 1709 ADCx->OFR4 |= ADC_OFR4_OFFSET4_EN;
mbed_official 125:23cc3068a9e4 1710 }
mbed_official 125:23cc3068a9e4 1711 else
mbed_official 125:23cc3068a9e4 1712 {
mbed_official 125:23cc3068a9e4 1713 /* Reset the OFFSET1_EN bit */
mbed_official 125:23cc3068a9e4 1714 ADCx->OFR4 &= ~(ADC_OFR4_OFFSET4_EN);
mbed_official 125:23cc3068a9e4 1715 }
mbed_official 125:23cc3068a9e4 1716 }
mbed_official 125:23cc3068a9e4 1717
mbed_official 125:23cc3068a9e4 1718 /**
mbed_official 125:23cc3068a9e4 1719 * @}
mbed_official 125:23cc3068a9e4 1720 */
mbed_official 125:23cc3068a9e4 1721
mbed_official 125:23cc3068a9e4 1722 /** @defgroup ADC_Group5 Regular Channels DMA Configuration functions
mbed_official 125:23cc3068a9e4 1723 * @brief Regular Channels DMA Configuration functions
mbed_official 125:23cc3068a9e4 1724 *
mbed_official 125:23cc3068a9e4 1725 @verbatim
mbed_official 125:23cc3068a9e4 1726 ===============================================================================
mbed_official 125:23cc3068a9e4 1727 ##### Regular Channels DMA Configuration functions #####
mbed_official 125:23cc3068a9e4 1728 ===============================================================================
mbed_official 125:23cc3068a9e4 1729
mbed_official 125:23cc3068a9e4 1730 [..] This section provides functions allowing to configure the DMA for ADC regular
mbed_official 125:23cc3068a9e4 1731 channels. Since converted regular channel values are stored into a unique data register,
mbed_official 125:23cc3068a9e4 1732 it is useful to use DMA for conversion of more than one regular channel. This
mbed_official 125:23cc3068a9e4 1733 avoids the loss of the data already stored in the ADC Data register.
mbed_official 125:23cc3068a9e4 1734
mbed_official 125:23cc3068a9e4 1735 (#) ADC_DMACmd() function is used to enable the ADC DMA mode, after each
mbed_official 125:23cc3068a9e4 1736 conversion of a regular channel, a DMA request is generated.
mbed_official 125:23cc3068a9e4 1737 (#) ADC_DMAConfig() function is used to select between the one shot DMA mode
mbed_official 125:23cc3068a9e4 1738 or the circular DMA mode
mbed_official 125:23cc3068a9e4 1739
mbed_official 125:23cc3068a9e4 1740 @endverbatim
mbed_official 125:23cc3068a9e4 1741 * @{
mbed_official 125:23cc3068a9e4 1742 */
mbed_official 125:23cc3068a9e4 1743
mbed_official 125:23cc3068a9e4 1744 /**
mbed_official 125:23cc3068a9e4 1745 * @brief Enables or disables the specified ADC DMA request.
mbed_official 125:23cc3068a9e4 1746 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1747 * @param NewState: new state of the selected ADC DMA transfer.
mbed_official 125:23cc3068a9e4 1748 * This parameter can be: ENABLE or DISABLE.
mbed_official 125:23cc3068a9e4 1749 * @retval None
mbed_official 125:23cc3068a9e4 1750 */
mbed_official 125:23cc3068a9e4 1751 void ADC_DMACmd(ADC_TypeDef* ADCx, FunctionalState NewState)
mbed_official 125:23cc3068a9e4 1752 {
mbed_official 125:23cc3068a9e4 1753 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1754 assert_param(IS_ADC_DMA_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1755 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 125:23cc3068a9e4 1756 if (NewState != DISABLE)
mbed_official 125:23cc3068a9e4 1757 {
mbed_official 125:23cc3068a9e4 1758 /* Enable the selected ADC DMA request */
mbed_official 125:23cc3068a9e4 1759 ADCx->CFGR |= ADC_CFGR_DMAEN;
mbed_official 125:23cc3068a9e4 1760 }
mbed_official 125:23cc3068a9e4 1761 else
mbed_official 125:23cc3068a9e4 1762 {
mbed_official 125:23cc3068a9e4 1763 /* Disable the selected ADC DMA request */
mbed_official 125:23cc3068a9e4 1764 ADCx->CFGR &= ~(uint32_t)ADC_CFGR_DMAEN;
mbed_official 125:23cc3068a9e4 1765 }
mbed_official 125:23cc3068a9e4 1766 }
mbed_official 125:23cc3068a9e4 1767
mbed_official 125:23cc3068a9e4 1768 /**
mbed_official 125:23cc3068a9e4 1769 * @brief Configure ADC DMA mode.
mbed_official 125:23cc3068a9e4 1770 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1771 * @param ADC_DMAMode: select the ADC DMA mode.
mbed_official 125:23cc3068a9e4 1772 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 1773 * @arg ADC_DMAMode_OneShot: ADC DMA Oneshot mode
mbed_official 125:23cc3068a9e4 1774 * @arg ADC_DMAMode_Circular: ADC DMA circular mode
mbed_official 125:23cc3068a9e4 1775 * @retval None
mbed_official 125:23cc3068a9e4 1776 */
mbed_official 125:23cc3068a9e4 1777 void ADC_DMAConfig(ADC_TypeDef* ADCx, uint32_t ADC_DMAMode)
mbed_official 125:23cc3068a9e4 1778 {
mbed_official 125:23cc3068a9e4 1779 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1780 assert_param(IS_ADC_DMA_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1781 assert_param(IS_ADC_DMA_MODE(ADC_DMAMode));
mbed_official 125:23cc3068a9e4 1782
mbed_official 125:23cc3068a9e4 1783 /* Set or reset the DMACFG bit */
mbed_official 125:23cc3068a9e4 1784 ADCx->CFGR &= ~(uint32_t)ADC_CFGR_DMACFG;
mbed_official 125:23cc3068a9e4 1785 ADCx->CFGR |= ADC_DMAMode;
mbed_official 125:23cc3068a9e4 1786 }
mbed_official 125:23cc3068a9e4 1787
mbed_official 125:23cc3068a9e4 1788 /**
mbed_official 125:23cc3068a9e4 1789 * @}
mbed_official 125:23cc3068a9e4 1790 */
mbed_official 125:23cc3068a9e4 1791
mbed_official 125:23cc3068a9e4 1792 /** @defgroup ADC_Group6 Injected channels Configuration functions
mbed_official 125:23cc3068a9e4 1793 * @brief Injected channels Configuration functions
mbed_official 125:23cc3068a9e4 1794 *
mbed_official 125:23cc3068a9e4 1795 @verbatim
mbed_official 125:23cc3068a9e4 1796 ===============================================================================
mbed_official 125:23cc3068a9e4 1797 ##### Injected channels Configuration functions #####
mbed_official 125:23cc3068a9e4 1798 ===============================================================================
mbed_official 125:23cc3068a9e4 1799
mbed_official 125:23cc3068a9e4 1800 [..] This section provide functions allowing to manage the ADC Injected channels,
mbed_official 125:23cc3068a9e4 1801 it is composed of :
mbed_official 125:23cc3068a9e4 1802
mbed_official 125:23cc3068a9e4 1803 (#) Configuration functions for Injected channels sample time
mbed_official 125:23cc3068a9e4 1804 (#) Functions to start and stop the injected conversion
mbed_official 125:23cc3068a9e4 1805 (#) unction to select the discontinuous mode
mbed_official 125:23cc3068a9e4 1806 (#) Function to get the Specified Injected channel conversion data: This subsection
mbed_official 125:23cc3068a9e4 1807 provides an important function in the ADC peripheral since it returns the
mbed_official 125:23cc3068a9e4 1808 converted data of the specific injected channel.
mbed_official 125:23cc3068a9e4 1809
mbed_official 125:23cc3068a9e4 1810 @endverbatim
mbed_official 125:23cc3068a9e4 1811 * @{
mbed_official 125:23cc3068a9e4 1812 */
mbed_official 125:23cc3068a9e4 1813
mbed_official 125:23cc3068a9e4 1814 /**
mbed_official 125:23cc3068a9e4 1815 * @brief Configures for the selected ADC injected channel its corresponding
mbed_official 125:23cc3068a9e4 1816 * sample time.
mbed_official 125:23cc3068a9e4 1817 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1818 * @param ADC_Channel: the ADC channel to configure.
mbed_official 125:23cc3068a9e4 1819 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 1820 * @arg ADC_InjectedChannel_1: ADC Channel1 selected
mbed_official 125:23cc3068a9e4 1821 * @arg ADC_InjectedChannel_2: ADC Channel2 selected
mbed_official 125:23cc3068a9e4 1822 * @arg ADC_InjectedChannel_3: ADC Channel3 selected
mbed_official 125:23cc3068a9e4 1823 * @arg ADC_InjectedChannel_4: ADC Channel4 selected
mbed_official 125:23cc3068a9e4 1824 * @arg ADC_InjectedChannel_5: ADC Channel5 selected
mbed_official 125:23cc3068a9e4 1825 * @arg ADC_InjectedChannel_6: ADC Channel6 selected
mbed_official 125:23cc3068a9e4 1826 * @arg ADC_InjectedChannel_7: ADC Channel7 selected
mbed_official 125:23cc3068a9e4 1827 * @arg ADC_InjectedChannel_8: ADC Channel8 selected
mbed_official 125:23cc3068a9e4 1828 * @arg ADC_InjectedChannel_9: ADC Channel9 selected
mbed_official 125:23cc3068a9e4 1829 * @arg ADC_InjectedChannel_10: ADC Channel10 selected
mbed_official 125:23cc3068a9e4 1830 * @arg ADC_InjectedChannel_11: ADC Channel11 selected
mbed_official 125:23cc3068a9e4 1831 * @arg ADC_InjectedChannel_12: ADC Channel12 selected
mbed_official 125:23cc3068a9e4 1832 * @arg ADC_InjectedChannel_13: ADC Channel13 selected
mbed_official 125:23cc3068a9e4 1833 * @arg ADC_InjectedChannel_14: ADC Channel14 selected
mbed_official 125:23cc3068a9e4 1834 * @arg ADC_InjectedChannel_15: ADC Channel15 selected
mbed_official 125:23cc3068a9e4 1835 * @arg ADC_InjectedChannel_16: ADC Channel16 selected
mbed_official 125:23cc3068a9e4 1836 * @arg ADC_InjectedChannel_17: ADC Channel17 selected
mbed_official 125:23cc3068a9e4 1837 * @arg ADC_InjectedChannel_18: ADC Channel18 selected
mbed_official 125:23cc3068a9e4 1838 * @param ADC_SampleTime: The sample time value to be set for the selected channel.
mbed_official 125:23cc3068a9e4 1839 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 1840 * @arg ADC_SampleTime_1Cycles5: Sample time equal to 1.5 cycles
mbed_official 125:23cc3068a9e4 1841 * @arg ADC_SampleTime_2Cycles5: Sample time equal to 2.5 cycles
mbed_official 125:23cc3068a9e4 1842 * @arg ADC_SampleTime_4Cycles5: Sample time equal to 4.5 cycles
mbed_official 125:23cc3068a9e4 1843 * @arg ADC_SampleTime_7Cycles5: Sample time equal to 7.5 cycles
mbed_official 125:23cc3068a9e4 1844 * @arg ADC_SampleTime_19Cycles5: Sample time equal to 19.5 cycles
mbed_official 125:23cc3068a9e4 1845 * @arg ADC_SampleTime_61Cycles5: Sample time equal to 61.5 cycles
mbed_official 125:23cc3068a9e4 1846 * @arg ADC_SampleTime_181Cycles5: Sample time equal to 181.5 cycles
mbed_official 125:23cc3068a9e4 1847 * @arg ADC_SampleTime_601Cycles5: Sample time equal to 601.5 cycles
mbed_official 125:23cc3068a9e4 1848 * @retval None
mbed_official 125:23cc3068a9e4 1849 */
mbed_official 125:23cc3068a9e4 1850 void ADC_InjectedChannelSampleTimeConfig(ADC_TypeDef* ADCx, uint8_t ADC_InjectedChannel, uint8_t ADC_SampleTime)
mbed_official 125:23cc3068a9e4 1851 {
mbed_official 125:23cc3068a9e4 1852 uint32_t tmpreg1 = 0;
mbed_official 125:23cc3068a9e4 1853 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1854 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1855 assert_param(IS_ADC_INJECTED_CHANNEL(ADC_InjectedChannel));
mbed_official 125:23cc3068a9e4 1856 assert_param(IS_ADC_SAMPLE_TIME(ADC_SampleTime));
mbed_official 125:23cc3068a9e4 1857
mbed_official 125:23cc3068a9e4 1858 /* Channel sampling configuration */
mbed_official 125:23cc3068a9e4 1859 /* if ADC_InjectedChannel_10 ... ADC_InjectedChannel_18 is selected */
mbed_official 125:23cc3068a9e4 1860 if (ADC_InjectedChannel > ADC_InjectedChannel_9)
mbed_official 125:23cc3068a9e4 1861 {
mbed_official 125:23cc3068a9e4 1862 /* Calculate the mask to clear */
mbed_official 125:23cc3068a9e4 1863 tmpreg1 = ADC_SMPR2_SMP10 << (3 * (ADC_InjectedChannel - 10));
mbed_official 125:23cc3068a9e4 1864 /* Clear the old channel sample time */
mbed_official 125:23cc3068a9e4 1865 ADCx->SMPR2 &= ~tmpreg1;
mbed_official 125:23cc3068a9e4 1866 /* Calculate the mask to set */
mbed_official 125:23cc3068a9e4 1867 ADCx->SMPR2 |= (uint32_t)ADC_SampleTime << (3 * (ADC_InjectedChannel - 10));
mbed_official 125:23cc3068a9e4 1868
mbed_official 125:23cc3068a9e4 1869 }
mbed_official 125:23cc3068a9e4 1870 else /* ADC_InjectedChannel include in ADC_InjectedChannel_[0..9] */
mbed_official 125:23cc3068a9e4 1871 {
mbed_official 125:23cc3068a9e4 1872 /* Calculate the mask to clear */
mbed_official 125:23cc3068a9e4 1873 tmpreg1 = ADC_SMPR1_SMP1 << (3 * (ADC_InjectedChannel - 1));
mbed_official 125:23cc3068a9e4 1874 /* Clear the old channel sample time */
mbed_official 125:23cc3068a9e4 1875 ADCx->SMPR1 &= ~tmpreg1;
mbed_official 125:23cc3068a9e4 1876 /* Calculate the mask to set */
mbed_official 125:23cc3068a9e4 1877 ADCx->SMPR1 |= (uint32_t)ADC_SampleTime << (3 * (ADC_InjectedChannel));
mbed_official 125:23cc3068a9e4 1878 }
mbed_official 125:23cc3068a9e4 1879 }
mbed_official 125:23cc3068a9e4 1880
mbed_official 125:23cc3068a9e4 1881 /**
mbed_official 125:23cc3068a9e4 1882 * @brief Enables or disables the selected ADC start of the injected
mbed_official 125:23cc3068a9e4 1883 * channels conversion.
mbed_official 125:23cc3068a9e4 1884 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1885 * @param NewState: new state of the selected ADC software start injected conversion.
mbed_official 125:23cc3068a9e4 1886 * This parameter can be: ENABLE or DISABLE.
mbed_official 125:23cc3068a9e4 1887 * @retval None
mbed_official 125:23cc3068a9e4 1888 */
mbed_official 125:23cc3068a9e4 1889 void ADC_StartInjectedConversion(ADC_TypeDef* ADCx)
mbed_official 125:23cc3068a9e4 1890 {
mbed_official 125:23cc3068a9e4 1891 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1892 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1893
mbed_official 125:23cc3068a9e4 1894 /* Enable the selected ADC conversion for injected group on external event and start the selected
mbed_official 125:23cc3068a9e4 1895 ADC injected conversion */
mbed_official 125:23cc3068a9e4 1896 ADCx->CR |= ADC_CR_JADSTART;
mbed_official 125:23cc3068a9e4 1897 }
mbed_official 125:23cc3068a9e4 1898
mbed_official 125:23cc3068a9e4 1899 /**
mbed_official 125:23cc3068a9e4 1900 * @brief Stops the selected ADC ongoing injected conversion.
mbed_official 125:23cc3068a9e4 1901 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1902 * @retval None
mbed_official 125:23cc3068a9e4 1903 */
mbed_official 125:23cc3068a9e4 1904 void ADC_StopInjectedConversion(ADC_TypeDef* ADCx)
mbed_official 125:23cc3068a9e4 1905 {
mbed_official 125:23cc3068a9e4 1906 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1907 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1908
mbed_official 125:23cc3068a9e4 1909 /* Set the JADSTP bit */
mbed_official 125:23cc3068a9e4 1910 ADCx->CR |= ADC_CR_JADSTP;
mbed_official 125:23cc3068a9e4 1911 }
mbed_official 125:23cc3068a9e4 1912
mbed_official 125:23cc3068a9e4 1913 /**
mbed_official 125:23cc3068a9e4 1914 * @brief Gets the selected ADC Software start injected conversion Status.
mbed_official 125:23cc3068a9e4 1915 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1916 * @retval The new state of ADC start injected conversion (SET or RESET).
mbed_official 125:23cc3068a9e4 1917 */
mbed_official 125:23cc3068a9e4 1918 FlagStatus ADC_GetStartInjectedConversionStatus(ADC_TypeDef* ADCx)
mbed_official 125:23cc3068a9e4 1919 {
mbed_official 125:23cc3068a9e4 1920 FlagStatus bitstatus = RESET;
mbed_official 125:23cc3068a9e4 1921 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1922 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1923
mbed_official 125:23cc3068a9e4 1924 /* Check the status of JADSTART bit */
mbed_official 125:23cc3068a9e4 1925 if ((ADCx->CR & ADC_CR_JADSTART) != (uint32_t)RESET)
mbed_official 125:23cc3068a9e4 1926 {
mbed_official 125:23cc3068a9e4 1927 /* JADSTART bit is set */
mbed_official 125:23cc3068a9e4 1928 bitstatus = SET;
mbed_official 125:23cc3068a9e4 1929 }
mbed_official 125:23cc3068a9e4 1930 else
mbed_official 125:23cc3068a9e4 1931 {
mbed_official 125:23cc3068a9e4 1932 /* JADSTART bit is reset */
mbed_official 125:23cc3068a9e4 1933 bitstatus = RESET;
mbed_official 125:23cc3068a9e4 1934 }
mbed_official 125:23cc3068a9e4 1935 /* Return the JADSTART bit status */
mbed_official 125:23cc3068a9e4 1936 return bitstatus;
mbed_official 125:23cc3068a9e4 1937 }
mbed_official 125:23cc3068a9e4 1938
mbed_official 125:23cc3068a9e4 1939 /**
mbed_official 125:23cc3068a9e4 1940 * @brief Enables or disables the selected ADC automatic injected group
mbed_official 125:23cc3068a9e4 1941 * conversion after regular one.
mbed_official 125:23cc3068a9e4 1942 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1943 * @param NewState: new state of the selected ADC auto injected conversion
mbed_official 125:23cc3068a9e4 1944 * This parameter can be: ENABLE or DISABLE.
mbed_official 125:23cc3068a9e4 1945 * @retval None
mbed_official 125:23cc3068a9e4 1946 */
mbed_official 125:23cc3068a9e4 1947 void ADC_AutoInjectedConvCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
mbed_official 125:23cc3068a9e4 1948 {
mbed_official 125:23cc3068a9e4 1949 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1950 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1951 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 125:23cc3068a9e4 1952 if (NewState != DISABLE)
mbed_official 125:23cc3068a9e4 1953 {
mbed_official 125:23cc3068a9e4 1954 /* Enable the selected ADC automatic injected group conversion */
mbed_official 125:23cc3068a9e4 1955 ADCx->CFGR |= ADC_CFGR_JAUTO;
mbed_official 125:23cc3068a9e4 1956 }
mbed_official 125:23cc3068a9e4 1957 else
mbed_official 125:23cc3068a9e4 1958 {
mbed_official 125:23cc3068a9e4 1959 /* Disable the selected ADC automatic injected group conversion */
mbed_official 125:23cc3068a9e4 1960 ADCx->CFGR &= ~ADC_CFGR_JAUTO;
mbed_official 125:23cc3068a9e4 1961 }
mbed_official 125:23cc3068a9e4 1962 }
mbed_official 125:23cc3068a9e4 1963
mbed_official 125:23cc3068a9e4 1964 /**
mbed_official 125:23cc3068a9e4 1965 * @brief Enables or disables the discontinuous mode for injected group
mbed_official 125:23cc3068a9e4 1966 * channel for the specified ADC
mbed_official 125:23cc3068a9e4 1967 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1968 * @param NewState: new state of the selected ADC discontinuous mode
mbed_official 125:23cc3068a9e4 1969 * on injected group channel.
mbed_official 125:23cc3068a9e4 1970 * This parameter can be: ENABLE or DISABLE.
mbed_official 125:23cc3068a9e4 1971 * @retval None
mbed_official 125:23cc3068a9e4 1972 */
mbed_official 125:23cc3068a9e4 1973 void ADC_InjectedDiscModeCmd(ADC_TypeDef* ADCx, FunctionalState NewState)
mbed_official 125:23cc3068a9e4 1974 {
mbed_official 125:23cc3068a9e4 1975 /* Check the parameters */
mbed_official 125:23cc3068a9e4 1976 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 1977 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 125:23cc3068a9e4 1978 if (NewState != DISABLE)
mbed_official 125:23cc3068a9e4 1979 {
mbed_official 125:23cc3068a9e4 1980 /* Enable the selected ADC injected discontinuous mode */
mbed_official 125:23cc3068a9e4 1981 ADCx->CFGR |= ADC_CFGR_JDISCEN;
mbed_official 125:23cc3068a9e4 1982 }
mbed_official 125:23cc3068a9e4 1983 else
mbed_official 125:23cc3068a9e4 1984 {
mbed_official 125:23cc3068a9e4 1985 /* Disable the selected ADC injected discontinuous mode */
mbed_official 125:23cc3068a9e4 1986 ADCx->CFGR &= ~ADC_CFGR_JDISCEN;
mbed_official 125:23cc3068a9e4 1987 }
mbed_official 125:23cc3068a9e4 1988 }
mbed_official 125:23cc3068a9e4 1989
mbed_official 125:23cc3068a9e4 1990 /**
mbed_official 125:23cc3068a9e4 1991 * @brief Returns the ADC injected channel conversion result
mbed_official 125:23cc3068a9e4 1992 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 1993 * @param ADC_InjectedSequence: the converted ADC injected sequence.
mbed_official 125:23cc3068a9e4 1994 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 1995 * @arg ADC_InjectedSequence_1: Injected Sequence1 selected
mbed_official 125:23cc3068a9e4 1996 * @arg ADC_InjectedSequence_2: Injected Sequence2 selected
mbed_official 125:23cc3068a9e4 1997 * @arg ADC_InjectedSequence_3: Injected Sequence3 selected
mbed_official 125:23cc3068a9e4 1998 * @arg ADC_InjectedSequence_4: Injected Sequence4 selected
mbed_official 125:23cc3068a9e4 1999 * @retval The Data conversion value.
mbed_official 125:23cc3068a9e4 2000 */
mbed_official 125:23cc3068a9e4 2001 uint16_t ADC_GetInjectedConversionValue(ADC_TypeDef* ADCx, uint8_t ADC_InjectedSequence)
mbed_official 125:23cc3068a9e4 2002 {
mbed_official 125:23cc3068a9e4 2003 __IO uint32_t tmp = 0;
mbed_official 125:23cc3068a9e4 2004
mbed_official 125:23cc3068a9e4 2005 /* Check the parameters */
mbed_official 125:23cc3068a9e4 2006 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 2007 assert_param(IS_ADC_INJECTED_SEQUENCE(ADC_InjectedSequence));
mbed_official 125:23cc3068a9e4 2008
mbed_official 125:23cc3068a9e4 2009 tmp = (uint32_t)ADCx;
mbed_official 125:23cc3068a9e4 2010 tmp += ((ADC_InjectedSequence - 1 )<< 2) + JDR_Offset;
mbed_official 125:23cc3068a9e4 2011
mbed_official 125:23cc3068a9e4 2012 /* Returns the selected injected channel conversion data value */
mbed_official 125:23cc3068a9e4 2013 return (uint16_t) (*(__IO uint32_t*) tmp);
mbed_official 125:23cc3068a9e4 2014 }
mbed_official 125:23cc3068a9e4 2015
mbed_official 125:23cc3068a9e4 2016 /**
mbed_official 125:23cc3068a9e4 2017 * @}
mbed_official 125:23cc3068a9e4 2018 */
mbed_official 125:23cc3068a9e4 2019
mbed_official 125:23cc3068a9e4 2020 /** @defgroup ADC_Group7 Interrupts and flags management functions
mbed_official 125:23cc3068a9e4 2021 * @brief Interrupts and flags management functions
mbed_official 125:23cc3068a9e4 2022 *
mbed_official 125:23cc3068a9e4 2023 @verbatim
mbed_official 125:23cc3068a9e4 2024 ===============================================================================
mbed_official 125:23cc3068a9e4 2025 ##### Interrupts and flags management functions #####
mbed_official 125:23cc3068a9e4 2026 ===============================================================================
mbed_official 125:23cc3068a9e4 2027
mbed_official 125:23cc3068a9e4 2028 [..] This section provides functions allowing to configure the ADC Interrupts, get
mbed_official 125:23cc3068a9e4 2029 the status and clear flags and Interrupts pending bits.
mbed_official 125:23cc3068a9e4 2030
mbed_official 125:23cc3068a9e4 2031 [..] The ADC provide 11 Interrupts sources and 11 Flags which can be divided into 3 groups:
mbed_official 125:23cc3068a9e4 2032
mbed_official 125:23cc3068a9e4 2033 (#) Flags and Interrupts for ADC regular channels
mbed_official 125:23cc3068a9e4 2034 (##)Flags
mbed_official 125:23cc3068a9e4 2035 (+) ADC_FLAG_RDY: ADC Ready flag
mbed_official 125:23cc3068a9e4 2036 (+) ADC_FLAG_EOSMP: ADC End of Sampling flag
mbed_official 125:23cc3068a9e4 2037 (+) ADC_FLAG_EOC: ADC End of Regular Conversion flag.
mbed_official 125:23cc3068a9e4 2038 (+) ADC_FLAG_EOS: ADC End of Regular sequence of Conversions flag
mbed_official 125:23cc3068a9e4 2039 (+) ADC_FLAG_OVR: ADC overrun flag
mbed_official 125:23cc3068a9e4 2040
mbed_official 125:23cc3068a9e4 2041 (##) Interrupts
mbed_official 125:23cc3068a9e4 2042 (+) ADC_IT_RDY: ADC Ready interrupt source
mbed_official 125:23cc3068a9e4 2043 (+) ADC_IT_EOSMP: ADC End of Sampling interrupt source
mbed_official 125:23cc3068a9e4 2044 (+) ADC_IT_EOC: ADC End of Regular Conversion interrupt source
mbed_official 125:23cc3068a9e4 2045 (+) ADC_IT_EOS: ADC End of Regular sequence of Conversions interrupt
mbed_official 125:23cc3068a9e4 2046 (+) ADC_IT_OVR: ADC overrun interrupt source
mbed_official 125:23cc3068a9e4 2047
mbed_official 125:23cc3068a9e4 2048
mbed_official 125:23cc3068a9e4 2049 (#) Flags and Interrupts for ADC regular channels
mbed_official 125:23cc3068a9e4 2050 (##)Flags
mbed_official 125:23cc3068a9e4 2051 (+) ADC_FLAG_JEOC: ADC Ready flag
mbed_official 125:23cc3068a9e4 2052 (+) ADC_FLAG_JEOS: ADC End of Sampling flag
mbed_official 125:23cc3068a9e4 2053 (+) ADC_FLAG_JQOVF: ADC End of Regular Conversion flag.
mbed_official 125:23cc3068a9e4 2054
mbed_official 125:23cc3068a9e4 2055 (##) Interrupts
mbed_official 125:23cc3068a9e4 2056 (+) ADC_IT_JEOC: ADC End of Injected Conversion interrupt source
mbed_official 125:23cc3068a9e4 2057 (+) ADC_IT_JEOS: ADC End of Injected sequence of Conversions interrupt source
mbed_official 125:23cc3068a9e4 2058 (+) ADC_IT_JQOVF: ADC Injected Context Queue Overflow interrupt source
mbed_official 125:23cc3068a9e4 2059
mbed_official 125:23cc3068a9e4 2060 (#) General Flags and Interrupts for the ADC
mbed_official 125:23cc3068a9e4 2061 (##)Flags
mbed_official 125:23cc3068a9e4 2062 (+) ADC_FLAG_AWD1: ADC Analog watchdog 1 flag
mbed_official 125:23cc3068a9e4 2063 (+) ADC_FLAG_AWD2: ADC Analog watchdog 2 flag
mbed_official 125:23cc3068a9e4 2064 (+) ADC_FLAG_AWD3: ADC Analog watchdog 3 flag
mbed_official 125:23cc3068a9e4 2065
mbed_official 125:23cc3068a9e4 2066 (##)Flags
mbed_official 125:23cc3068a9e4 2067 (+) ADC_IT_AWD1: ADC Analog watchdog 1 interrupt source
mbed_official 125:23cc3068a9e4 2068 (+) ADC_IT_AWD2: ADC Analog watchdog 2 interrupt source
mbed_official 125:23cc3068a9e4 2069 (+) ADC_IT_AWD3: ADC Analog watchdog 3 interrupt source
mbed_official 125:23cc3068a9e4 2070
mbed_official 125:23cc3068a9e4 2071 (#) Flags for ADC dual mode
mbed_official 125:23cc3068a9e4 2072 (##)Flags for Master
mbed_official 125:23cc3068a9e4 2073 (+) ADC_FLAG_MSTRDY: ADC master Ready (ADRDY) flag
mbed_official 125:23cc3068a9e4 2074 (+) ADC_FLAG_MSTEOSMP: ADC master End of Sampling flag
mbed_official 125:23cc3068a9e4 2075 (+) ADC_FLAG_MSTEOC: ADC master End of Regular Conversion flag
mbed_official 125:23cc3068a9e4 2076 (+) ADC_FLAG_MSTEOS: ADC master End of Regular sequence of Conversions flag
mbed_official 125:23cc3068a9e4 2077 (+) ADC_FLAG_MSTOVR: ADC master overrun flag
mbed_official 125:23cc3068a9e4 2078 (+) ADC_FLAG_MSTJEOC: ADC master End of Injected Conversion flag
mbed_official 125:23cc3068a9e4 2079 (+) ADC_FLAG_MSTJEOS: ADC master End of Injected sequence of Conversions flag
mbed_official 125:23cc3068a9e4 2080 (+) ADC_FLAG_MSTAWD1: ADC master Analog watchdog 1 flag
mbed_official 125:23cc3068a9e4 2081 (+) ADC_FLAG_MSTAWD2: ADC master Analog watchdog 2 flag
mbed_official 125:23cc3068a9e4 2082 (+) ADC_FLAG_MSTAWD3: ADC master Analog watchdog 3 flag
mbed_official 125:23cc3068a9e4 2083 (+) ADC_FLAG_MSTJQOVF: ADC master Injected Context Queue Overflow flag
mbed_official 125:23cc3068a9e4 2084
mbed_official 125:23cc3068a9e4 2085 (##) Flags for Slave
mbed_official 125:23cc3068a9e4 2086 (+) ADC_FLAG_SLVRDY: ADC slave Ready (ADRDY) flag
mbed_official 125:23cc3068a9e4 2087 (+) ADC_FLAG_SLVEOSMP: ADC slave End of Sampling flag
mbed_official 125:23cc3068a9e4 2088 (+) ADC_FLAG_SLVEOC: ADC slave End of Regular Conversion flag
mbed_official 125:23cc3068a9e4 2089 (+) ADC_FLAG_SLVEOS: ADC slave End of Regular sequence of Conversions flag
mbed_official 125:23cc3068a9e4 2090 (+) ADC_FLAG_SLVOVR: ADC slave overrun flag
mbed_official 125:23cc3068a9e4 2091 (+) ADC_FLAG_SLVJEOC: ADC slave End of Injected Conversion flag
mbed_official 125:23cc3068a9e4 2092 (+) ADC_FLAG_SLVJEOS: ADC slave End of Injected sequence of Conversions flag
mbed_official 125:23cc3068a9e4 2093 (+) ADC_FLAG_SLVAWD1: ADC slave Analog watchdog 1 flag
mbed_official 125:23cc3068a9e4 2094 (+) ADC_FLAG_SLVAWD2: ADC slave Analog watchdog 2 flag
mbed_official 125:23cc3068a9e4 2095 (+) ADC_FLAG_SLVAWD3: ADC slave Analog watchdog 3 flag
mbed_official 125:23cc3068a9e4 2096 (+) ADC_FLAG_SLVJQOVF: ADC slave Injected Context Queue Overflow flag
mbed_official 125:23cc3068a9e4 2097
mbed_official 125:23cc3068a9e4 2098 The user should identify which mode will be used in his application to manage
mbed_official 125:23cc3068a9e4 2099 the ADC controller events: Polling mode or Interrupt mode.
mbed_official 125:23cc3068a9e4 2100
mbed_official 125:23cc3068a9e4 2101 In the Polling Mode it is advised to use the following functions:
mbed_official 125:23cc3068a9e4 2102 - ADC_GetFlagStatus() : to check if flags events occur.
mbed_official 125:23cc3068a9e4 2103 - ADC_ClearFlag() : to clear the flags events.
mbed_official 125:23cc3068a9e4 2104
mbed_official 125:23cc3068a9e4 2105 In the Interrupt Mode it is advised to use the following functions:
mbed_official 125:23cc3068a9e4 2106 - ADC_ITConfig() : to enable or disable the interrupt source.
mbed_official 125:23cc3068a9e4 2107 - ADC_GetITStatus() : to check if Interrupt occurs.
mbed_official 125:23cc3068a9e4 2108 - ADC_ClearITPendingBit() : to clear the Interrupt pending Bit
mbed_official 125:23cc3068a9e4 2109 (corresponding Flag).
mbed_official 125:23cc3068a9e4 2110 @endverbatim
mbed_official 125:23cc3068a9e4 2111 * @{
mbed_official 125:23cc3068a9e4 2112 */
mbed_official 125:23cc3068a9e4 2113
mbed_official 125:23cc3068a9e4 2114 /**
mbed_official 125:23cc3068a9e4 2115 * @brief Enables or disables the specified ADC interrupts.
mbed_official 125:23cc3068a9e4 2116 * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 2117 * @param ADC_IT: specifies the ADC interrupt sources to be enabled or disabled.
mbed_official 125:23cc3068a9e4 2118 * This parameter can be any combination of the following values:
mbed_official 125:23cc3068a9e4 2119 * @arg ADC_IT_RDY: ADC Ready (ADRDY) interrupt source
mbed_official 125:23cc3068a9e4 2120 * @arg ADC_IT_EOSMP: ADC End of Sampling interrupt source
mbed_official 125:23cc3068a9e4 2121 * @arg ADC_IT_EOC: ADC End of Regular Conversion interrupt source
mbed_official 125:23cc3068a9e4 2122 * @arg ADC_IT_EOS: ADC End of Regular sequence of Conversions interrupt source
mbed_official 125:23cc3068a9e4 2123 * @arg ADC_IT_OVR: ADC overrun interrupt source
mbed_official 125:23cc3068a9e4 2124 * @arg ADC_IT_JEOC: ADC End of Injected Conversion interrupt source
mbed_official 125:23cc3068a9e4 2125 * @arg ADC_IT_JEOS: ADC End of Injected sequence of Conversions interrupt source
mbed_official 125:23cc3068a9e4 2126 * @arg ADC_IT_AWD1: ADC Analog watchdog 1 interrupt source
mbed_official 125:23cc3068a9e4 2127 * @arg ADC_IT_AWD2: ADC Analog watchdog 2 interrupt source
mbed_official 125:23cc3068a9e4 2128 * @arg ADC_IT_AWD3: ADC Analog watchdog 3 interrupt source
mbed_official 125:23cc3068a9e4 2129 * @arg ADC_IT_JQOVF: ADC Injected Context Queue Overflow interrupt source
mbed_official 125:23cc3068a9e4 2130 * @param NewState: new state of the specified ADC interrupts.
mbed_official 125:23cc3068a9e4 2131 * This parameter can be: ENABLE or DISABLE.
mbed_official 125:23cc3068a9e4 2132 * @retval None
mbed_official 125:23cc3068a9e4 2133 */
mbed_official 125:23cc3068a9e4 2134 void ADC_ITConfig(ADC_TypeDef* ADCx, uint32_t ADC_IT, FunctionalState NewState)
mbed_official 125:23cc3068a9e4 2135 {
mbed_official 125:23cc3068a9e4 2136 /* Check the parameters */
mbed_official 125:23cc3068a9e4 2137 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 2138 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 125:23cc3068a9e4 2139 assert_param(IS_ADC_IT(ADC_IT));
mbed_official 125:23cc3068a9e4 2140
mbed_official 125:23cc3068a9e4 2141 if (NewState != DISABLE)
mbed_official 125:23cc3068a9e4 2142 {
mbed_official 125:23cc3068a9e4 2143 /* Enable the selected ADC interrupts */
mbed_official 125:23cc3068a9e4 2144 ADCx->IER |= ADC_IT;
mbed_official 125:23cc3068a9e4 2145 }
mbed_official 125:23cc3068a9e4 2146 else
mbed_official 125:23cc3068a9e4 2147 {
mbed_official 125:23cc3068a9e4 2148 /* Disable the selected ADC interrupts */
mbed_official 125:23cc3068a9e4 2149 ADCx->IER &= (~(uint32_t)ADC_IT);
mbed_official 125:23cc3068a9e4 2150 }
mbed_official 125:23cc3068a9e4 2151 }
mbed_official 125:23cc3068a9e4 2152
mbed_official 125:23cc3068a9e4 2153 /**
mbed_official 125:23cc3068a9e4 2154 * @brief Checks whether the specified ADC flag is set or not.
mbed_official 125:23cc3068a9e4 2155 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 2156 * @param ADC_FLAG: specifies the flag to check.
mbed_official 125:23cc3068a9e4 2157 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 2158 * @arg ADC_FLAG_RDY: ADC Ready (ADRDY) flag
mbed_official 125:23cc3068a9e4 2159 * @arg ADC_FLAG_EOSMP: ADC End of Sampling flag
mbed_official 125:23cc3068a9e4 2160 * @arg ADC_FLAG_EOC: ADC End of Regular Conversion flag
mbed_official 125:23cc3068a9e4 2161 * @arg ADC_FLAG_EOS: ADC End of Regular sequence of Conversions flag
mbed_official 125:23cc3068a9e4 2162 * @arg ADC_FLAG_OVR: ADC overrun flag
mbed_official 125:23cc3068a9e4 2163 * @arg ADC_FLAG_JEOC: ADC End of Injected Conversion flag
mbed_official 125:23cc3068a9e4 2164 * @arg ADC_FLAG_JEOS: ADC End of Injected sequence of Conversions flag
mbed_official 125:23cc3068a9e4 2165 * @arg ADC_FLAG_AWD1: ADC Analog watchdog 1 flag
mbed_official 125:23cc3068a9e4 2166 * @arg ADC_FLAG_AWD2: ADC Analog watchdog 2 flag
mbed_official 125:23cc3068a9e4 2167 * @arg ADC_FLAG_AWD3: ADC Analog watchdog 3 flag
mbed_official 125:23cc3068a9e4 2168 * @arg ADC_FLAG_JQOVF: ADC Injected Context Queue Overflow flag
mbed_official 125:23cc3068a9e4 2169 * @retval The new state of ADC_FLAG (SET or RESET).
mbed_official 125:23cc3068a9e4 2170 */
mbed_official 125:23cc3068a9e4 2171 FlagStatus ADC_GetFlagStatus(ADC_TypeDef* ADCx, uint32_t ADC_FLAG)
mbed_official 125:23cc3068a9e4 2172 {
mbed_official 125:23cc3068a9e4 2173 FlagStatus bitstatus = RESET;
mbed_official 125:23cc3068a9e4 2174 /* Check the parameters */
mbed_official 125:23cc3068a9e4 2175 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 2176 assert_param(IS_ADC_GET_FLAG(ADC_FLAG));
mbed_official 125:23cc3068a9e4 2177
mbed_official 125:23cc3068a9e4 2178 /* Check the status of the specified ADC flag */
mbed_official 125:23cc3068a9e4 2179 if ((ADCx->ISR & ADC_FLAG) != (uint32_t)RESET)
mbed_official 125:23cc3068a9e4 2180 {
mbed_official 125:23cc3068a9e4 2181 /* ADC_FLAG is set */
mbed_official 125:23cc3068a9e4 2182 bitstatus = SET;
mbed_official 125:23cc3068a9e4 2183 }
mbed_official 125:23cc3068a9e4 2184 else
mbed_official 125:23cc3068a9e4 2185 {
mbed_official 125:23cc3068a9e4 2186 /* ADC_FLAG is reset */
mbed_official 125:23cc3068a9e4 2187 bitstatus = RESET;
mbed_official 125:23cc3068a9e4 2188 }
mbed_official 125:23cc3068a9e4 2189 /* Return the ADC_FLAG status */
mbed_official 125:23cc3068a9e4 2190 return bitstatus;
mbed_official 125:23cc3068a9e4 2191 }
mbed_official 125:23cc3068a9e4 2192
mbed_official 125:23cc3068a9e4 2193 /**
mbed_official 125:23cc3068a9e4 2194 * @brief Clears the ADCx's pending flags.
mbed_official 125:23cc3068a9e4 2195 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 2196 * @param ADC_FLAG: specifies the flag to clear.
mbed_official 125:23cc3068a9e4 2197 * This parameter can be any combination of the following values:
mbed_official 125:23cc3068a9e4 2198 * @arg ADC_FLAG_RDY: ADC Ready (ADRDY) flag
mbed_official 125:23cc3068a9e4 2199 * @arg ADC_FLAG_EOSMP: ADC End of Sampling flag
mbed_official 125:23cc3068a9e4 2200 * @arg ADC_FLAG_EOC: ADC End of Regular Conversion flag
mbed_official 125:23cc3068a9e4 2201 * @arg ADC_FLAG_EOS: ADC End of Regular sequence of Conversions flag
mbed_official 125:23cc3068a9e4 2202 * @arg ADC_FLAG_OVR: ADC overrun flag
mbed_official 125:23cc3068a9e4 2203 * @arg ADC_FLAG_JEOC: ADC End of Injected Conversion flag
mbed_official 125:23cc3068a9e4 2204 * @arg ADC_FLAG_JEOS: ADC End of Injected sequence of Conversions flag
mbed_official 125:23cc3068a9e4 2205 * @arg ADC_FLAG_AWD1: ADC Analog watchdog 1 flag
mbed_official 125:23cc3068a9e4 2206 * @arg ADC_FLAG_AWD2: ADC Analog watchdog 2 flag
mbed_official 125:23cc3068a9e4 2207 * @arg ADC_FLAG_AWD3: ADC Analog watchdog 3 flag
mbed_official 125:23cc3068a9e4 2208 * @arg ADC_FLAG_JQOVF: ADC Injected Context Queue Overflow flag
mbed_official 125:23cc3068a9e4 2209 * @retval None
mbed_official 125:23cc3068a9e4 2210 */
mbed_official 125:23cc3068a9e4 2211 void ADC_ClearFlag(ADC_TypeDef* ADCx, uint32_t ADC_FLAG)
mbed_official 125:23cc3068a9e4 2212 {
mbed_official 125:23cc3068a9e4 2213 /* Check the parameters */
mbed_official 125:23cc3068a9e4 2214 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 2215 assert_param(IS_ADC_CLEAR_FLAG(ADC_FLAG));
mbed_official 125:23cc3068a9e4 2216 /* Clear the selected ADC flags */
mbed_official 125:23cc3068a9e4 2217 ADCx->ISR = (uint32_t)ADC_FLAG;
mbed_official 125:23cc3068a9e4 2218 }
mbed_official 125:23cc3068a9e4 2219
mbed_official 125:23cc3068a9e4 2220 /**
mbed_official 125:23cc3068a9e4 2221 * @brief Checks whether the specified ADC flag is set or not.
mbed_official 125:23cc3068a9e4 2222 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 2223 * @param ADC_FLAG: specifies the master or slave flag to check.
mbed_official 125:23cc3068a9e4 2224 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 2225 * @arg ADC_FLAG_MSTRDY: ADC master Ready (ADRDY) flag
mbed_official 125:23cc3068a9e4 2226 * @arg ADC_FLAG_MSTEOSMP: ADC master End of Sampling flag
mbed_official 125:23cc3068a9e4 2227 * @arg ADC_FLAG_MSTEOC: ADC master End of Regular Conversion flag
mbed_official 125:23cc3068a9e4 2228 * @arg ADC_FLAG_MSTEOS: ADC master End of Regular sequence of Conversions flag
mbed_official 125:23cc3068a9e4 2229 * @arg ADC_FLAG_MSTOVR: ADC master overrun flag
mbed_official 125:23cc3068a9e4 2230 * @arg ADC_FLAG_MSTJEOC: ADC master End of Injected Conversion flag
mbed_official 125:23cc3068a9e4 2231 * @arg ADC_FLAG_MSTJEOS: ADC master End of Injected sequence of Conversions flag
mbed_official 125:23cc3068a9e4 2232 * @arg ADC_FLAG_MSTAWD1: ADC master Analog watchdog 1 flag
mbed_official 125:23cc3068a9e4 2233 * @arg ADC_FLAG_MSTAWD2: ADC master Analog watchdog 2 flag
mbed_official 125:23cc3068a9e4 2234 * @arg ADC_FLAG_MSTAWD3: ADC master Analog watchdog 3 flag
mbed_official 125:23cc3068a9e4 2235 * @arg ADC_FLAG_MSTJQOVF: ADC master Injected Context Queue Overflow flag
mbed_official 125:23cc3068a9e4 2236 * @arg ADC_FLAG_SLVRDY: ADC slave Ready (ADRDY) flag
mbed_official 125:23cc3068a9e4 2237 * @arg ADC_FLAG_SLVEOSMP: ADC slave End of Sampling flag
mbed_official 125:23cc3068a9e4 2238 * @arg ADC_FLAG_SLVEOC: ADC slave End of Regular Conversion flag
mbed_official 125:23cc3068a9e4 2239 * @arg ADC_FLAG_SLVEOS: ADC slave End of Regular sequence of Conversions flag
mbed_official 125:23cc3068a9e4 2240 * @arg ADC_FLAG_SLVOVR: ADC slave overrun flag
mbed_official 125:23cc3068a9e4 2241 * @arg ADC_FLAG_SLVJEOC: ADC slave End of Injected Conversion flag
mbed_official 125:23cc3068a9e4 2242 * @arg ADC_FLAG_SLVJEOS: ADC slave End of Injected sequence of Conversions flag
mbed_official 125:23cc3068a9e4 2243 * @arg ADC_FLAG_SLVAWD1: ADC slave Analog watchdog 1 flag
mbed_official 125:23cc3068a9e4 2244 * @arg ADC_FLAG_SLVAWD2: ADC slave Analog watchdog 2 flag
mbed_official 125:23cc3068a9e4 2245 * @arg ADC_FLAG_SLVAWD3: ADC slave Analog watchdog 3 flag
mbed_official 125:23cc3068a9e4 2246 * @arg ADC_FLAG_SLVJQOVF: ADC slave Injected Context Queue Overflow flag
mbed_official 125:23cc3068a9e4 2247 * @retval The new state of ADC_FLAG (SET or RESET).
mbed_official 125:23cc3068a9e4 2248 */
mbed_official 125:23cc3068a9e4 2249 FlagStatus ADC_GetCommonFlagStatus(ADC_TypeDef* ADCx, uint32_t ADC_FLAG)
mbed_official 125:23cc3068a9e4 2250 {
mbed_official 125:23cc3068a9e4 2251 uint32_t tmpreg1 = 0;
mbed_official 125:23cc3068a9e4 2252 FlagStatus bitstatus = RESET;
mbed_official 125:23cc3068a9e4 2253
mbed_official 125:23cc3068a9e4 2254 /* Check the parameters */
mbed_official 125:23cc3068a9e4 2255 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 2256 assert_param(IS_ADC_GET_COMMONFLAG(ADC_FLAG));
mbed_official 125:23cc3068a9e4 2257
mbed_official 125:23cc3068a9e4 2258 if((ADCx == ADC1) || (ADCx == ADC2))
mbed_official 125:23cc3068a9e4 2259 {
mbed_official 125:23cc3068a9e4 2260 tmpreg1 = ADC1_2->CSR;
mbed_official 125:23cc3068a9e4 2261 }
mbed_official 125:23cc3068a9e4 2262 else
mbed_official 125:23cc3068a9e4 2263 {
mbed_official 125:23cc3068a9e4 2264 tmpreg1 = ADC3_4->CSR;
mbed_official 125:23cc3068a9e4 2265 }
mbed_official 125:23cc3068a9e4 2266 /* Check the status of the specified ADC flag */
mbed_official 125:23cc3068a9e4 2267 if ((tmpreg1 & ADC_FLAG) != (uint32_t)RESET)
mbed_official 125:23cc3068a9e4 2268 {
mbed_official 125:23cc3068a9e4 2269 /* ADC_FLAG is set */
mbed_official 125:23cc3068a9e4 2270 bitstatus = SET;
mbed_official 125:23cc3068a9e4 2271 }
mbed_official 125:23cc3068a9e4 2272 else
mbed_official 125:23cc3068a9e4 2273 {
mbed_official 125:23cc3068a9e4 2274 /* ADC_FLAG is reset */
mbed_official 125:23cc3068a9e4 2275 bitstatus = RESET;
mbed_official 125:23cc3068a9e4 2276 }
mbed_official 125:23cc3068a9e4 2277 /* Return the ADC_FLAG status */
mbed_official 125:23cc3068a9e4 2278 return bitstatus;
mbed_official 125:23cc3068a9e4 2279 }
mbed_official 125:23cc3068a9e4 2280
mbed_official 125:23cc3068a9e4 2281 /**
mbed_official 125:23cc3068a9e4 2282 * @brief Clears the ADCx's pending flags.
mbed_official 125:23cc3068a9e4 2283 * @param ADCx: where x can be 1, 2, 3 or 4 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 2284 * @param ADC_FLAG: specifies the master or slave flag to clear.
mbed_official 125:23cc3068a9e4 2285 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 2286 * @arg ADC_FLAG_MSTRDY: ADC master Ready (ADRDY) flag
mbed_official 125:23cc3068a9e4 2287 * @arg ADC_FLAG_MSTEOSMP: ADC master End of Sampling flag
mbed_official 125:23cc3068a9e4 2288 * @arg ADC_FLAG_MSTEOC: ADC master End of Regular Conversion flag
mbed_official 125:23cc3068a9e4 2289 * @arg ADC_FLAG_MSTEOS: ADC master End of Regular sequence of Conversions flag
mbed_official 125:23cc3068a9e4 2290 * @arg ADC_FLAG_MSTOVR: ADC master overrun flag
mbed_official 125:23cc3068a9e4 2291 * @arg ADC_FLAG_MSTJEOC: ADC master End of Injected Conversion flag
mbed_official 125:23cc3068a9e4 2292 * @arg ADC_FLAG_MSTJEOS: ADC master End of Injected sequence of Conversions flag
mbed_official 125:23cc3068a9e4 2293 * @arg ADC_FLAG_MSTAWD1: ADC master Analog watchdog 1 flag
mbed_official 125:23cc3068a9e4 2294 * @arg ADC_FLAG_MSTAWD2: ADC master Analog watchdog 2 flag
mbed_official 125:23cc3068a9e4 2295 * @arg ADC_FLAG_MSTAWD3: ADC master Analog watchdog 3 flag
mbed_official 125:23cc3068a9e4 2296 * @arg ADC_FLAG_MSTJQOVF: ADC master Injected Context Queue Overflow flag
mbed_official 125:23cc3068a9e4 2297 * @arg ADC_FLAG_SLVRDY: ADC slave Ready (ADRDY) flag
mbed_official 125:23cc3068a9e4 2298 * @arg ADC_FLAG_SLVEOSMP: ADC slave End of Sampling flag
mbed_official 125:23cc3068a9e4 2299 * @arg ADC_FLAG_SLVEOC: ADC slave End of Regular Conversion flag
mbed_official 125:23cc3068a9e4 2300 * @arg ADC_FLAG_SLVEOS: ADC slave End of Regular sequence of Conversions flag
mbed_official 125:23cc3068a9e4 2301 * @arg ADC_FLAG_SLVOVR: ADC slave overrun flag
mbed_official 125:23cc3068a9e4 2302 * @arg ADC_FLAG_SLVJEOC: ADC slave End of Injected Conversion flag
mbed_official 125:23cc3068a9e4 2303 * @arg ADC_FLAG_SLVJEOS: ADC slave End of Injected sequence of Conversions flag
mbed_official 125:23cc3068a9e4 2304 * @arg ADC_FLAG_SLVAWD1: ADC slave Analog watchdog 1 flag
mbed_official 125:23cc3068a9e4 2305 * @arg ADC_FLAG_SLVAWD2: ADC slave Analog watchdog 2 flag
mbed_official 125:23cc3068a9e4 2306 * @arg ADC_FLAG_SLVAWD3: ADC slave Analog watchdog 3 flag
mbed_official 125:23cc3068a9e4 2307 * @arg ADC_FLAG_SLVJQOVF: ADC slave Injected Context Queue Overflow flag
mbed_official 125:23cc3068a9e4 2308 * @retval None
mbed_official 125:23cc3068a9e4 2309 */
mbed_official 125:23cc3068a9e4 2310 void ADC_ClearCommonFlag(ADC_TypeDef* ADCx, uint32_t ADC_FLAG)
mbed_official 125:23cc3068a9e4 2311 {
mbed_official 125:23cc3068a9e4 2312 /* Check the parameters */
mbed_official 125:23cc3068a9e4 2313 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 2314 assert_param(IS_ADC_CLEAR_COMMONFLAG(ADC_FLAG));
mbed_official 125:23cc3068a9e4 2315
mbed_official 125:23cc3068a9e4 2316 if((ADCx == ADC1) || (ADCx == ADC2))
mbed_official 125:23cc3068a9e4 2317 {
mbed_official 125:23cc3068a9e4 2318 /* Clear the selected ADC flags */
mbed_official 125:23cc3068a9e4 2319 ADC1_2->CSR |= (uint32_t)ADC_FLAG;
mbed_official 125:23cc3068a9e4 2320 }
mbed_official 125:23cc3068a9e4 2321 else
mbed_official 125:23cc3068a9e4 2322 {
mbed_official 125:23cc3068a9e4 2323 /* Clear the selected ADC flags */
mbed_official 125:23cc3068a9e4 2324 ADC3_4->CSR |= (uint32_t)ADC_FLAG;
mbed_official 125:23cc3068a9e4 2325 }
mbed_official 125:23cc3068a9e4 2326 }
mbed_official 125:23cc3068a9e4 2327
mbed_official 125:23cc3068a9e4 2328 /**
mbed_official 125:23cc3068a9e4 2329 * @brief Checks whether the specified ADC interrupt has occurred or not.
mbed_official 125:23cc3068a9e4 2330 * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 2331 * @param ADC_IT: specifies the ADC interrupt source to check.
mbed_official 125:23cc3068a9e4 2332 * This parameter can be one of the following values:
mbed_official 125:23cc3068a9e4 2333 * @arg ADC_IT_RDY: ADC Ready (ADRDY) interrupt source
mbed_official 125:23cc3068a9e4 2334 * @arg ADC_IT_EOSMP: ADC End of Sampling interrupt source
mbed_official 125:23cc3068a9e4 2335 * @arg ADC_IT_EOC: ADC End of Regular Conversion interrupt source
mbed_official 125:23cc3068a9e4 2336 * @arg ADC_IT_EOS: ADC End of Regular sequence of Conversions interrupt source
mbed_official 125:23cc3068a9e4 2337 * @arg ADC_IT_OVR: ADC overrun interrupt source
mbed_official 125:23cc3068a9e4 2338 * @arg ADC_IT_JEOC: ADC End of Injected Conversion interrupt source
mbed_official 125:23cc3068a9e4 2339 * @arg ADC_IT_JEOS: ADC End of Injected sequence of Conversions interrupt source
mbed_official 125:23cc3068a9e4 2340 * @arg ADC_IT_AWD1: ADC Analog watchdog 1 interrupt source
mbed_official 125:23cc3068a9e4 2341 * @arg ADC_IT_AWD2: ADC Analog watchdog 2 interrupt source
mbed_official 125:23cc3068a9e4 2342 * @arg ADC_IT_AWD3: ADC Analog watchdog 3 interrupt source
mbed_official 125:23cc3068a9e4 2343 * @arg ADC_IT_JQOVF: ADC Injected Context Queue Overflow interrupt source
mbed_official 125:23cc3068a9e4 2344 * @retval The new state of ADC_IT (SET or RESET).
mbed_official 125:23cc3068a9e4 2345 */
mbed_official 125:23cc3068a9e4 2346 ITStatus ADC_GetITStatus(ADC_TypeDef* ADCx, uint32_t ADC_IT)
mbed_official 125:23cc3068a9e4 2347 {
mbed_official 125:23cc3068a9e4 2348 ITStatus bitstatus = RESET;
mbed_official 125:23cc3068a9e4 2349 uint16_t itstatus = 0x0, itenable = 0x0;
mbed_official 125:23cc3068a9e4 2350 /* Check the parameters */
mbed_official 125:23cc3068a9e4 2351 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 2352 assert_param(IS_ADC_GET_IT(ADC_IT));
mbed_official 125:23cc3068a9e4 2353
mbed_official 125:23cc3068a9e4 2354 itstatus = ADCx->ISR & ADC_IT;
mbed_official 125:23cc3068a9e4 2355
mbed_official 125:23cc3068a9e4 2356 itenable = ADCx->IER & ADC_IT;
mbed_official 125:23cc3068a9e4 2357 if ((itstatus != (uint32_t)RESET) && (itenable != (uint32_t)RESET))
mbed_official 125:23cc3068a9e4 2358 {
mbed_official 125:23cc3068a9e4 2359 bitstatus = SET;
mbed_official 125:23cc3068a9e4 2360 }
mbed_official 125:23cc3068a9e4 2361 else
mbed_official 125:23cc3068a9e4 2362 {
mbed_official 125:23cc3068a9e4 2363 bitstatus = RESET;
mbed_official 125:23cc3068a9e4 2364 }
mbed_official 125:23cc3068a9e4 2365 return bitstatus;
mbed_official 125:23cc3068a9e4 2366 }
mbed_official 125:23cc3068a9e4 2367
mbed_official 125:23cc3068a9e4 2368 /**
mbed_official 125:23cc3068a9e4 2369 * @brief Clears the ADCx's interrupt pending bits.
mbed_official 125:23cc3068a9e4 2370 * @param ADCx: where x can be 1, 2 or 3 to select the ADC peripheral.
mbed_official 125:23cc3068a9e4 2371 * @param ADC_IT: specifies the ADC interrupt pending bit to clear.
mbed_official 125:23cc3068a9e4 2372 * This parameter can be any combination of the following values:
mbed_official 125:23cc3068a9e4 2373 * @arg ADC_IT_RDY: ADC Ready (ADRDY) interrupt source
mbed_official 125:23cc3068a9e4 2374 * @arg ADC_IT_EOSMP: ADC End of Sampling interrupt source
mbed_official 125:23cc3068a9e4 2375 * @arg ADC_IT_EOC: ADC End of Regular Conversion interrupt source
mbed_official 125:23cc3068a9e4 2376 * @arg ADC_IT_EOS: ADC End of Regular sequence of Conversions interrupt source
mbed_official 125:23cc3068a9e4 2377 * @arg ADC_IT_OVR: ADC overrun interrupt source
mbed_official 125:23cc3068a9e4 2378 * @arg ADC_IT_JEOC: ADC End of Injected Conversion interrupt source
mbed_official 125:23cc3068a9e4 2379 * @arg ADC_IT_JEOS: ADC End of Injected sequence of Conversions interrupt source
mbed_official 125:23cc3068a9e4 2380 * @arg ADC_IT_AWD1: ADC Analog watchdog 1 interrupt source
mbed_official 125:23cc3068a9e4 2381 * @arg ADC_IT_AWD2: ADC Analog watchdog 2 interrupt source
mbed_official 125:23cc3068a9e4 2382 * @arg ADC_IT_AWD3: ADC Analog watchdog 3 interrupt source
mbed_official 125:23cc3068a9e4 2383 * @arg ADC_IT_JQOVF: ADC Injected Context Queue Overflow interrupt source
mbed_official 125:23cc3068a9e4 2384 * @retval None
mbed_official 125:23cc3068a9e4 2385 */
mbed_official 125:23cc3068a9e4 2386 void ADC_ClearITPendingBit(ADC_TypeDef* ADCx, uint32_t ADC_IT)
mbed_official 125:23cc3068a9e4 2387 {
mbed_official 125:23cc3068a9e4 2388 /* Check the parameters */
mbed_official 125:23cc3068a9e4 2389 assert_param(IS_ADC_ALL_PERIPH(ADCx));
mbed_official 125:23cc3068a9e4 2390 assert_param(IS_ADC_IT(ADC_IT));
mbed_official 125:23cc3068a9e4 2391 /* Clear the selected ADC interrupt pending bit */
mbed_official 125:23cc3068a9e4 2392 ADCx->ISR = (uint32_t)ADC_IT;
mbed_official 125:23cc3068a9e4 2393 }
mbed_official 125:23cc3068a9e4 2394
mbed_official 125:23cc3068a9e4 2395 /**
mbed_official 125:23cc3068a9e4 2396 * @}
mbed_official 125:23cc3068a9e4 2397 */
mbed_official 125:23cc3068a9e4 2398
mbed_official 125:23cc3068a9e4 2399 /**
mbed_official 125:23cc3068a9e4 2400 * @}
mbed_official 125:23cc3068a9e4 2401 */
mbed_official 125:23cc3068a9e4 2402
mbed_official 125:23cc3068a9e4 2403 /**
mbed_official 125:23cc3068a9e4 2404 * @}
mbed_official 125:23cc3068a9e4 2405 */
mbed_official 125:23cc3068a9e4 2406
mbed_official 125:23cc3068a9e4 2407 /**
mbed_official 125:23cc3068a9e4 2408 * @}
mbed_official 125:23cc3068a9e4 2409 */
mbed_official 125:23cc3068a9e4 2410
mbed_official 125:23cc3068a9e4 2411 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/