mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Thu Aug 20 10:45:13 2015 +0100
Revision:
613:bc40b8d2aec4
Parent:
532:fe11edbda85c
Synchronized with git revision 92ca8c7b60a283b6bb60eb65b183dac1599f0ade

Full URL: https://github.com/mbedmicro/mbed/commit/92ca8c7b60a283b6bb60eb65b183dac1599f0ade/

Nordic: update application start address in GCC linker script

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 235:685d5f11838f 1 /**
mbed_official 235:685d5f11838f 2 ******************************************************************************
mbed_official 235:685d5f11838f 3 * @file stm32f4xx_hal_adc.h
mbed_official 235:685d5f11838f 4 * @author MCD Application Team
mbed_official 613:bc40b8d2aec4 5 * @version V1.3.2
mbed_official 613:bc40b8d2aec4 6 * @date 26-June-2015
mbed_official 235:685d5f11838f 7 * @brief Header file of ADC HAL extension module.
mbed_official 235:685d5f11838f 8 ******************************************************************************
mbed_official 235:685d5f11838f 9 * @attention
mbed_official 235:685d5f11838f 10 *
mbed_official 532:fe11edbda85c 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
mbed_official 235:685d5f11838f 12 *
mbed_official 235:685d5f11838f 13 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 235:685d5f11838f 14 * are permitted provided that the following conditions are met:
mbed_official 235:685d5f11838f 15 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 235:685d5f11838f 16 * this list of conditions and the following disclaimer.
mbed_official 235:685d5f11838f 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 235:685d5f11838f 18 * this list of conditions and the following disclaimer in the documentation
mbed_official 235:685d5f11838f 19 * and/or other materials provided with the distribution.
mbed_official 235:685d5f11838f 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 235:685d5f11838f 21 * may be used to endorse or promote products derived from this software
mbed_official 235:685d5f11838f 22 * without specific prior written permission.
mbed_official 235:685d5f11838f 23 *
mbed_official 235:685d5f11838f 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 235:685d5f11838f 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 235:685d5f11838f 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 235:685d5f11838f 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 235:685d5f11838f 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 235:685d5f11838f 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 235:685d5f11838f 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 235:685d5f11838f 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 235:685d5f11838f 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 235:685d5f11838f 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 235:685d5f11838f 34 *
mbed_official 235:685d5f11838f 35 ******************************************************************************
mbed_official 235:685d5f11838f 36 */
mbed_official 235:685d5f11838f 37
mbed_official 235:685d5f11838f 38 /* Define to prevent recursive inclusion -------------------------------------*/
mbed_official 235:685d5f11838f 39 #ifndef __STM32F4xx_ADC_H
mbed_official 235:685d5f11838f 40 #define __STM32F4xx_ADC_H
mbed_official 235:685d5f11838f 41
mbed_official 235:685d5f11838f 42 #ifdef __cplusplus
mbed_official 235:685d5f11838f 43 extern "C" {
mbed_official 235:685d5f11838f 44 #endif
mbed_official 235:685d5f11838f 45
mbed_official 235:685d5f11838f 46 /* Includes ------------------------------------------------------------------*/
mbed_official 235:685d5f11838f 47 #include "stm32f4xx_hal_def.h"
mbed_official 235:685d5f11838f 48
mbed_official 235:685d5f11838f 49 /** @addtogroup STM32F4xx_HAL_Driver
mbed_official 235:685d5f11838f 50 * @{
mbed_official 235:685d5f11838f 51 */
mbed_official 235:685d5f11838f 52
mbed_official 235:685d5f11838f 53 /** @addtogroup ADC
mbed_official 235:685d5f11838f 54 * @{
mbed_official 235:685d5f11838f 55 */
mbed_official 235:685d5f11838f 56
mbed_official 235:685d5f11838f 57 /* Exported types ------------------------------------------------------------*/
mbed_official 532:fe11edbda85c 58 /** @defgroup ADC_Exported_Types ADC Exported Types
mbed_official 532:fe11edbda85c 59 * @{
mbed_official 532:fe11edbda85c 60 */
mbed_official 235:685d5f11838f 61
mbed_official 235:685d5f11838f 62 /**
mbed_official 532:fe11edbda85c 63 * @brief HAL State structures definition
mbed_official 235:685d5f11838f 64 */
mbed_official 235:685d5f11838f 65 typedef enum
mbed_official 235:685d5f11838f 66 {
mbed_official 235:685d5f11838f 67 HAL_ADC_STATE_RESET = 0x00, /*!< ADC not yet initialized or disabled */
mbed_official 235:685d5f11838f 68 HAL_ADC_STATE_READY = 0x01, /*!< ADC peripheral ready for use */
mbed_official 235:685d5f11838f 69 HAL_ADC_STATE_BUSY = 0x02, /*!< An internal process is ongoing */
mbed_official 235:685d5f11838f 70 HAL_ADC_STATE_BUSY_REG = 0x12, /*!< Regular conversion is ongoing */
mbed_official 235:685d5f11838f 71 HAL_ADC_STATE_BUSY_INJ = 0x22, /*!< Injected conversion is ongoing */
mbed_official 235:685d5f11838f 72 HAL_ADC_STATE_BUSY_INJ_REG = 0x32, /*!< Injected and regular conversion are ongoing */
mbed_official 235:685d5f11838f 73 HAL_ADC_STATE_TIMEOUT = 0x03, /*!< Timeout state */
mbed_official 235:685d5f11838f 74 HAL_ADC_STATE_ERROR = 0x04, /*!< ADC state error */
mbed_official 235:685d5f11838f 75 HAL_ADC_STATE_EOC = 0x05, /*!< Conversion is completed */
mbed_official 235:685d5f11838f 76 HAL_ADC_STATE_EOC_REG = 0x15, /*!< Regular conversion is completed */
mbed_official 235:685d5f11838f 77 HAL_ADC_STATE_EOC_INJ = 0x25, /*!< Injected conversion is completed */
mbed_official 235:685d5f11838f 78 HAL_ADC_STATE_EOC_INJ_REG = 0x35, /*!< Injected and regular conversion are completed */
mbed_official 235:685d5f11838f 79 HAL_ADC_STATE_AWD = 0x06 /*!< ADC state analog watchdog */
mbed_official 235:685d5f11838f 80
mbed_official 235:685d5f11838f 81 }HAL_ADC_StateTypeDef;
mbed_official 235:685d5f11838f 82
mbed_official 235:685d5f11838f 83 /**
mbed_official 532:fe11edbda85c 84 * @brief ADC Init structure definition
mbed_official 235:685d5f11838f 85 */
mbed_official 235:685d5f11838f 86 typedef struct
mbed_official 235:685d5f11838f 87 {
mbed_official 235:685d5f11838f 88 uint32_t ClockPrescaler; /*!< Select the frequency of the clock to the ADC. The clock is common for
mbed_official 235:685d5f11838f 89 all the ADCs.
mbed_official 235:685d5f11838f 90 This parameter can be a value of @ref ADC_ClockPrescaler */
mbed_official 235:685d5f11838f 91 uint32_t Resolution; /*!< Configures the ADC resolution dual mode.
mbed_official 235:685d5f11838f 92 This parameter can be a value of @ref ADC_Resolution */
mbed_official 235:685d5f11838f 93 uint32_t DataAlign; /*!< Specifies whether the ADC data alignment is left or right.
mbed_official 235:685d5f11838f 94 This parameter can be a value of @ref ADC_data_align */
mbed_official 235:685d5f11838f 95 uint32_t ScanConvMode; /*!< Specifies whether the conversion is performed in Scan (multi channels) or
mbed_official 235:685d5f11838f 96 Single (one channel) mode.
mbed_official 235:685d5f11838f 97 This parameter can be set to ENABLE or DISABLE */
mbed_official 235:685d5f11838f 98 uint32_t EOCSelection; /*!< Specifies whether the EOC flag is set
mbed_official 235:685d5f11838f 99 at the end of single channel conversion or at the end of all conversions.
mbed_official 613:bc40b8d2aec4 100 This parameter can be a value of @ref ADC_EOCSelection
mbed_official 613:bc40b8d2aec4 101 Note: Impact on overrun when not using DMA: When EOCSelection is set to ADC_EOC_SINGLE_CONV,
mbed_official 613:bc40b8d2aec4 102 overrun detection is automatically enabled, in this case each conversion data must be read.
mbed_official 613:bc40b8d2aec4 103 To perform ADC conversions without having to read all conversion data, this parameter must
mbed_official 613:bc40b8d2aec4 104 be set to ADC_EOC_SEQ_CONV */
mbed_official 235:685d5f11838f 105 uint32_t ContinuousConvMode; /*!< Specifies whether the conversion is performed in Continuous or Single mode.
mbed_official 235:685d5f11838f 106 This parameter can be set to ENABLE or DISABLE. */
mbed_official 235:685d5f11838f 107 uint32_t DMAContinuousRequests; /*!< Specifies whether the DMA requests is performed in Continuous or in Single mode.
mbed_official 235:685d5f11838f 108 This parameter can be set to ENABLE or DISABLE. */
mbed_official 235:685d5f11838f 109 uint32_t NbrOfConversion; /*!< Specifies the number of ADC conversions that will be done using the sequencer for
mbed_official 235:685d5f11838f 110 regular channel group.
mbed_official 235:685d5f11838f 111 This parameter must be a number between Min_Data = 1 and Max_Data = 16. */
mbed_official 235:685d5f11838f 112 uint32_t DiscontinuousConvMode; /*!< Specifies whether the conversion is performed in Discontinuous or not
mbed_official 235:685d5f11838f 113 for regular channels.
mbed_official 235:685d5f11838f 114 This parameter can be set to ENABLE or DISABLE. */
mbed_official 235:685d5f11838f 115 uint32_t NbrOfDiscConversion; /*!< Specifies the number of ADC discontinuous conversions that will be done
mbed_official 235:685d5f11838f 116 using the sequencer for regular channel group.
mbed_official 235:685d5f11838f 117 This parameter must be a number between Min_Data = 1 and Max_Data = 8. */
mbed_official 532:fe11edbda85c 118 uint32_t ExternalTrigConv; /*!< Selects the external event used to trigger the conversion start of regular group.
mbed_official 532:fe11edbda85c 119 If set to ADC_SOFTWARE_START, external triggers are disabled.
mbed_official 532:fe11edbda85c 120 This parameter can be a value of @ref ADC_External_trigger_Source_Regular
mbed_official 532:fe11edbda85c 121 Note: This parameter can be modified only if there is no conversion is ongoing. */
mbed_official 532:fe11edbda85c 122 uint32_t ExternalTrigConvEdge; /*!< Selects the external trigger edge of regular group.
mbed_official 532:fe11edbda85c 123 If trigger is set to ADC_SOFTWARE_START, this parameter is discarded.
mbed_official 532:fe11edbda85c 124 This parameter can be a value of @ref ADC_External_trigger_edge_Regular
mbed_official 532:fe11edbda85c 125 Note: This parameter can be modified only if there is no conversion is ongoing. */
mbed_official 235:685d5f11838f 126 }ADC_InitTypeDef;
mbed_official 235:685d5f11838f 127
mbed_official 235:685d5f11838f 128 /**
mbed_official 532:fe11edbda85c 129 * @brief ADC handle Structure definition
mbed_official 235:685d5f11838f 130 */
mbed_official 235:685d5f11838f 131 typedef struct
mbed_official 235:685d5f11838f 132 {
mbed_official 235:685d5f11838f 133 ADC_TypeDef *Instance; /*!< Register base address */
mbed_official 235:685d5f11838f 134
mbed_official 235:685d5f11838f 135 ADC_InitTypeDef Init; /*!< ADC required parameters */
mbed_official 235:685d5f11838f 136
mbed_official 235:685d5f11838f 137 __IO uint32_t NbrOfCurrentConversionRank; /*!< ADC number of current conversion rank */
mbed_official 235:685d5f11838f 138
mbed_official 235:685d5f11838f 139 DMA_HandleTypeDef *DMA_Handle; /*!< Pointer DMA Handler */
mbed_official 235:685d5f11838f 140
mbed_official 235:685d5f11838f 141 HAL_LockTypeDef Lock; /*!< ADC locking object */
mbed_official 235:685d5f11838f 142
mbed_official 235:685d5f11838f 143 __IO HAL_ADC_StateTypeDef State; /*!< ADC communication state */
mbed_official 235:685d5f11838f 144
mbed_official 235:685d5f11838f 145 __IO uint32_t ErrorCode; /*!< ADC Error code */
mbed_official 235:685d5f11838f 146 }ADC_HandleTypeDef;
mbed_official 235:685d5f11838f 147
mbed_official 235:685d5f11838f 148 /**
mbed_official 532:fe11edbda85c 149 * @brief ADC Configuration regular Channel structure definition
mbed_official 235:685d5f11838f 150 */
mbed_official 235:685d5f11838f 151 typedef struct
mbed_official 235:685d5f11838f 152 {
mbed_official 235:685d5f11838f 153 uint32_t Channel; /*!< The ADC channel to configure.
mbed_official 235:685d5f11838f 154 This parameter can be a value of @ref ADC_channels */
mbed_official 235:685d5f11838f 155 uint32_t Rank; /*!< The rank in the regular group sequencer.
mbed_official 235:685d5f11838f 156 This parameter must be a number between Min_Data = 1 and Max_Data = 16 */
mbed_official 235:685d5f11838f 157 uint32_t SamplingTime; /*!< The sample time value to be set for the selected channel.
mbed_official 235:685d5f11838f 158 This parameter can be a value of @ref ADC_sampling_times */
mbed_official 235:685d5f11838f 159 uint32_t Offset; /*!< Reserved for future use, can be set to 0 */
mbed_official 235:685d5f11838f 160 }ADC_ChannelConfTypeDef;
mbed_official 235:685d5f11838f 161
mbed_official 235:685d5f11838f 162 /**
mbed_official 532:fe11edbda85c 163 * @brief ADC Configuration multi-mode structure definition
mbed_official 235:685d5f11838f 164 */
mbed_official 235:685d5f11838f 165 typedef struct
mbed_official 235:685d5f11838f 166 {
mbed_official 235:685d5f11838f 167 uint32_t WatchdogMode; /*!< Configures the ADC analog watchdog mode.
mbed_official 235:685d5f11838f 168 This parameter can be a value of @ref ADC_analog_watchdog_selection */
mbed_official 235:685d5f11838f 169 uint32_t HighThreshold; /*!< Configures the ADC analog watchdog High threshold value.
mbed_official 235:685d5f11838f 170 This parameter must be a 12-bit value. */
mbed_official 235:685d5f11838f 171 uint32_t LowThreshold; /*!< Configures the ADC analog watchdog High threshold value.
mbed_official 235:685d5f11838f 172 This parameter must be a 12-bit value. */
mbed_official 235:685d5f11838f 173 uint32_t Channel; /*!< Configures ADC channel for the analog watchdog.
mbed_official 235:685d5f11838f 174 This parameter has an effect only if watchdog mode is configured on single channel
mbed_official 235:685d5f11838f 175 This parameter can be a value of @ref ADC_channels */
mbed_official 235:685d5f11838f 176 uint32_t ITMode; /*!< Specifies whether the analog watchdog is configured
mbed_official 235:685d5f11838f 177 is interrupt mode or in polling mode.
mbed_official 235:685d5f11838f 178 This parameter can be set to ENABLE or DISABLE */
mbed_official 235:685d5f11838f 179 uint32_t WatchdogNumber; /*!< Reserved for future use, can be set to 0 */
mbed_official 235:685d5f11838f 180 }ADC_AnalogWDGConfTypeDef;
mbed_official 532:fe11edbda85c 181 /**
mbed_official 532:fe11edbda85c 182 * @}
mbed_official 532:fe11edbda85c 183 */
mbed_official 235:685d5f11838f 184
mbed_official 235:685d5f11838f 185 /* Exported constants --------------------------------------------------------*/
mbed_official 532:fe11edbda85c 186 /** @defgroup ADC_Exported_Constants ADC Exported Constants
mbed_official 235:685d5f11838f 187 * @{
mbed_official 235:685d5f11838f 188 */
mbed_official 235:685d5f11838f 189
mbed_official 532:fe11edbda85c 190 /** @defgroup ADC_Error_Code ADC Error Code
mbed_official 235:685d5f11838f 191 * @{
mbed_official 532:fe11edbda85c 192 */
mbed_official 235:685d5f11838f 193 #define HAL_ADC_ERROR_NONE ((uint32_t)0x00) /*!< No error */
mbed_official 235:685d5f11838f 194 #define HAL_ADC_ERROR_OVR ((uint32_t)0x01) /*!< OVR error */
mbed_official 235:685d5f11838f 195 #define HAL_ADC_ERROR_DMA ((uint32_t)0x02) /*!< DMA transfer error */
mbed_official 235:685d5f11838f 196 /**
mbed_official 235:685d5f11838f 197 * @}
mbed_official 235:685d5f11838f 198 */
mbed_official 235:685d5f11838f 199
mbed_official 235:685d5f11838f 200
mbed_official 532:fe11edbda85c 201 /** @defgroup ADC_ClockPrescaler ADC Clock Prescaler
mbed_official 235:685d5f11838f 202 * @{
mbed_official 235:685d5f11838f 203 */
mbed_official 235:685d5f11838f 204 #define ADC_CLOCKPRESCALER_PCLK_DIV2 ((uint32_t)0x00000000)
mbed_official 235:685d5f11838f 205 #define ADC_CLOCKPRESCALER_PCLK_DIV4 ((uint32_t)ADC_CCR_ADCPRE_0)
mbed_official 235:685d5f11838f 206 #define ADC_CLOCKPRESCALER_PCLK_DIV6 ((uint32_t)ADC_CCR_ADCPRE_1)
mbed_official 235:685d5f11838f 207 #define ADC_CLOCKPRESCALER_PCLK_DIV8 ((uint32_t)ADC_CCR_ADCPRE)
mbed_official 235:685d5f11838f 208 /**
mbed_official 235:685d5f11838f 209 * @}
mbed_official 235:685d5f11838f 210 */
mbed_official 235:685d5f11838f 211
mbed_official 532:fe11edbda85c 212 /** @defgroup ADC_delay_between_2_sampling_phases ADC Delay Between 2 Sampling Phases
mbed_official 235:685d5f11838f 213 * @{
mbed_official 235:685d5f11838f 214 */
mbed_official 235:685d5f11838f 215 #define ADC_TWOSAMPLINGDELAY_5CYCLES ((uint32_t)0x00000000)
mbed_official 235:685d5f11838f 216 #define ADC_TWOSAMPLINGDELAY_6CYCLES ((uint32_t)ADC_CCR_DELAY_0)
mbed_official 235:685d5f11838f 217 #define ADC_TWOSAMPLINGDELAY_7CYCLES ((uint32_t)ADC_CCR_DELAY_1)
mbed_official 235:685d5f11838f 218 #define ADC_TWOSAMPLINGDELAY_8CYCLES ((uint32_t)(ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
mbed_official 235:685d5f11838f 219 #define ADC_TWOSAMPLINGDELAY_9CYCLES ((uint32_t)ADC_CCR_DELAY_2)
mbed_official 235:685d5f11838f 220 #define ADC_TWOSAMPLINGDELAY_10CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0))
mbed_official 235:685d5f11838f 221 #define ADC_TWOSAMPLINGDELAY_11CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1))
mbed_official 235:685d5f11838f 222 #define ADC_TWOSAMPLINGDELAY_12CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
mbed_official 235:685d5f11838f 223 #define ADC_TWOSAMPLINGDELAY_13CYCLES ((uint32_t)ADC_CCR_DELAY_3)
mbed_official 235:685d5f11838f 224 #define ADC_TWOSAMPLINGDELAY_14CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_0))
mbed_official 235:685d5f11838f 225 #define ADC_TWOSAMPLINGDELAY_15CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1))
mbed_official 235:685d5f11838f 226 #define ADC_TWOSAMPLINGDELAY_16CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
mbed_official 235:685d5f11838f 227 #define ADC_TWOSAMPLINGDELAY_17CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2))
mbed_official 235:685d5f11838f 228 #define ADC_TWOSAMPLINGDELAY_18CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0))
mbed_official 235:685d5f11838f 229 #define ADC_TWOSAMPLINGDELAY_19CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1))
mbed_official 235:685d5f11838f 230 #define ADC_TWOSAMPLINGDELAY_20CYCLES ((uint32_t)ADC_CCR_DELAY)
mbed_official 235:685d5f11838f 231 /**
mbed_official 235:685d5f11838f 232 * @}
mbed_official 235:685d5f11838f 233 */
mbed_official 235:685d5f11838f 234
mbed_official 532:fe11edbda85c 235 /** @defgroup ADC_Resolution ADC Resolution
mbed_official 235:685d5f11838f 236 * @{
mbed_official 235:685d5f11838f 237 */
mbed_official 532:fe11edbda85c 238 #define ADC_RESOLUTION_12B ((uint32_t)0x00000000)
mbed_official 532:fe11edbda85c 239 #define ADC_RESOLUTION_10B ((uint32_t)ADC_CR1_RES_0)
mbed_official 532:fe11edbda85c 240 #define ADC_RESOLUTION_8B ((uint32_t)ADC_CR1_RES_1)
mbed_official 532:fe11edbda85c 241 #define ADC_RESOLUTION_6B ((uint32_t)ADC_CR1_RES)
mbed_official 235:685d5f11838f 242 /**
mbed_official 235:685d5f11838f 243 * @}
mbed_official 235:685d5f11838f 244 */
mbed_official 235:685d5f11838f 245
mbed_official 532:fe11edbda85c 246 /** @defgroup ADC_External_trigger_edge_Regular ADC External Trigger Edge Regular
mbed_official 235:685d5f11838f 247 * @{
mbed_official 235:685d5f11838f 248 */
mbed_official 235:685d5f11838f 249 #define ADC_EXTERNALTRIGCONVEDGE_NONE ((uint32_t)0x00000000)
mbed_official 235:685d5f11838f 250 #define ADC_EXTERNALTRIGCONVEDGE_RISING ((uint32_t)ADC_CR2_EXTEN_0)
mbed_official 235:685d5f11838f 251 #define ADC_EXTERNALTRIGCONVEDGE_FALLING ((uint32_t)ADC_CR2_EXTEN_1)
mbed_official 235:685d5f11838f 252 #define ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING ((uint32_t)ADC_CR2_EXTEN)
mbed_official 235:685d5f11838f 253 /**
mbed_official 235:685d5f11838f 254 * @}
mbed_official 235:685d5f11838f 255 */
mbed_official 235:685d5f11838f 256
mbed_official 532:fe11edbda85c 257 /** @defgroup ADC_External_trigger_Source_Regular ADC External Trigger Source Regular
mbed_official 235:685d5f11838f 258 * @{
mbed_official 532:fe11edbda85c 259 */
mbed_official 532:fe11edbda85c 260 /* Note: Parameter ADC_SOFTWARE_START is a software parameter used for */
mbed_official 532:fe11edbda85c 261 /* compatibility with other STM32 devices. */
mbed_official 235:685d5f11838f 262 #define ADC_EXTERNALTRIGCONV_T1_CC1 ((uint32_t)0x00000000)
mbed_official 235:685d5f11838f 263 #define ADC_EXTERNALTRIGCONV_T1_CC2 ((uint32_t)ADC_CR2_EXTSEL_0)
mbed_official 235:685d5f11838f 264 #define ADC_EXTERNALTRIGCONV_T1_CC3 ((uint32_t)ADC_CR2_EXTSEL_1)
mbed_official 235:685d5f11838f 265 #define ADC_EXTERNALTRIGCONV_T2_CC2 ((uint32_t)(ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
mbed_official 235:685d5f11838f 266 #define ADC_EXTERNALTRIGCONV_T2_CC3 ((uint32_t)ADC_CR2_EXTSEL_2)
mbed_official 235:685d5f11838f 267 #define ADC_EXTERNALTRIGCONV_T2_CC4 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
mbed_official 235:685d5f11838f 268 #define ADC_EXTERNALTRIGCONV_T2_TRGO ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1))
mbed_official 235:685d5f11838f 269 #define ADC_EXTERNALTRIGCONV_T3_CC1 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
mbed_official 235:685d5f11838f 270 #define ADC_EXTERNALTRIGCONV_T3_TRGO ((uint32_t)ADC_CR2_EXTSEL_3)
mbed_official 235:685d5f11838f 271 #define ADC_EXTERNALTRIGCONV_T4_CC4 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_0))
mbed_official 235:685d5f11838f 272 #define ADC_EXTERNALTRIGCONV_T5_CC1 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1))
mbed_official 235:685d5f11838f 273 #define ADC_EXTERNALTRIGCONV_T5_CC2 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
mbed_official 235:685d5f11838f 274 #define ADC_EXTERNALTRIGCONV_T5_CC3 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2))
mbed_official 235:685d5f11838f 275 #define ADC_EXTERNALTRIGCONV_T8_CC1 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
mbed_official 235:685d5f11838f 276 #define ADC_EXTERNALTRIGCONV_T8_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1))
mbed_official 235:685d5f11838f 277 #define ADC_EXTERNALTRIGCONV_Ext_IT11 ((uint32_t)ADC_CR2_EXTSEL)
mbed_official 532:fe11edbda85c 278 #define ADC_SOFTWARE_START ((uint32_t)ADC_CR2_EXTSEL + 1)
mbed_official 235:685d5f11838f 279 /**
mbed_official 235:685d5f11838f 280 * @}
mbed_official 235:685d5f11838f 281 */
mbed_official 235:685d5f11838f 282
mbed_official 532:fe11edbda85c 283 /** @defgroup ADC_data_align ADC Data Align
mbed_official 235:685d5f11838f 284 * @{
mbed_official 235:685d5f11838f 285 */
mbed_official 235:685d5f11838f 286 #define ADC_DATAALIGN_RIGHT ((uint32_t)0x00000000)
mbed_official 235:685d5f11838f 287 #define ADC_DATAALIGN_LEFT ((uint32_t)ADC_CR2_ALIGN)
mbed_official 235:685d5f11838f 288 /**
mbed_official 235:685d5f11838f 289 * @}
mbed_official 235:685d5f11838f 290 */
mbed_official 235:685d5f11838f 291
mbed_official 532:fe11edbda85c 292 /** @defgroup ADC_channels ADC Common Channels
mbed_official 235:685d5f11838f 293 * @{
mbed_official 235:685d5f11838f 294 */
mbed_official 235:685d5f11838f 295 #define ADC_CHANNEL_0 ((uint32_t)0x00000000)
mbed_official 235:685d5f11838f 296 #define ADC_CHANNEL_1 ((uint32_t)ADC_CR1_AWDCH_0)
mbed_official 235:685d5f11838f 297 #define ADC_CHANNEL_2 ((uint32_t)ADC_CR1_AWDCH_1)
mbed_official 235:685d5f11838f 298 #define ADC_CHANNEL_3 ((uint32_t)(ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
mbed_official 235:685d5f11838f 299 #define ADC_CHANNEL_4 ((uint32_t)ADC_CR1_AWDCH_2)
mbed_official 235:685d5f11838f 300 #define ADC_CHANNEL_5 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0))
mbed_official 235:685d5f11838f 301 #define ADC_CHANNEL_6 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1))
mbed_official 235:685d5f11838f 302 #define ADC_CHANNEL_7 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
mbed_official 235:685d5f11838f 303 #define ADC_CHANNEL_8 ((uint32_t)ADC_CR1_AWDCH_3)
mbed_official 235:685d5f11838f 304 #define ADC_CHANNEL_9 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0))
mbed_official 235:685d5f11838f 305 #define ADC_CHANNEL_10 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1))
mbed_official 235:685d5f11838f 306 #define ADC_CHANNEL_11 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
mbed_official 235:685d5f11838f 307 #define ADC_CHANNEL_12 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2))
mbed_official 235:685d5f11838f 308 #define ADC_CHANNEL_13 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0))
mbed_official 235:685d5f11838f 309 #define ADC_CHANNEL_14 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1))
mbed_official 235:685d5f11838f 310 #define ADC_CHANNEL_15 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
mbed_official 235:685d5f11838f 311 #define ADC_CHANNEL_16 ((uint32_t)ADC_CR1_AWDCH_4)
mbed_official 235:685d5f11838f 312 #define ADC_CHANNEL_17 ((uint32_t)(ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_0))
mbed_official 235:685d5f11838f 313 #define ADC_CHANNEL_18 ((uint32_t)(ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_1))
mbed_official 235:685d5f11838f 314
mbed_official 235:685d5f11838f 315 #define ADC_CHANNEL_VREFINT ((uint32_t)ADC_CHANNEL_17)
mbed_official 532:fe11edbda85c 316 #define ADC_CHANNEL_VBAT ((uint32_t)ADC_CHANNEL_18)
mbed_official 235:685d5f11838f 317 /**
mbed_official 235:685d5f11838f 318 * @}
mbed_official 235:685d5f11838f 319 */
mbed_official 235:685d5f11838f 320
mbed_official 532:fe11edbda85c 321 /** @defgroup ADC_sampling_times ADC Sampling Times
mbed_official 235:685d5f11838f 322 * @{
mbed_official 235:685d5f11838f 323 */
mbed_official 235:685d5f11838f 324 #define ADC_SAMPLETIME_3CYCLES ((uint32_t)0x00000000)
mbed_official 235:685d5f11838f 325 #define ADC_SAMPLETIME_15CYCLES ((uint32_t)ADC_SMPR1_SMP10_0)
mbed_official 235:685d5f11838f 326 #define ADC_SAMPLETIME_28CYCLES ((uint32_t)ADC_SMPR1_SMP10_1)
mbed_official 235:685d5f11838f 327 #define ADC_SAMPLETIME_56CYCLES ((uint32_t)(ADC_SMPR1_SMP10_1 | ADC_SMPR1_SMP10_0))
mbed_official 235:685d5f11838f 328 #define ADC_SAMPLETIME_84CYCLES ((uint32_t)ADC_SMPR1_SMP10_2)
mbed_official 235:685d5f11838f 329 #define ADC_SAMPLETIME_112CYCLES ((uint32_t)(ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_0))
mbed_official 235:685d5f11838f 330 #define ADC_SAMPLETIME_144CYCLES ((uint32_t)(ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_1))
mbed_official 235:685d5f11838f 331 #define ADC_SAMPLETIME_480CYCLES ((uint32_t)ADC_SMPR1_SMP10)
mbed_official 235:685d5f11838f 332 /**
mbed_official 235:685d5f11838f 333 * @}
mbed_official 235:685d5f11838f 334 */
mbed_official 235:685d5f11838f 335
mbed_official 532:fe11edbda85c 336 /** @defgroup ADC_EOCSelection ADC EOC Selection
mbed_official 235:685d5f11838f 337 * @{
mbed_official 235:685d5f11838f 338 */
mbed_official 532:fe11edbda85c 339 #define ADC_EOC_SEQ_CONV ((uint32_t)0x00000000)
mbed_official 532:fe11edbda85c 340 #define ADC_EOC_SINGLE_CONV ((uint32_t)0x00000001)
mbed_official 532:fe11edbda85c 341 #define ADC_EOC_SINGLE_SEQ_CONV ((uint32_t)0x00000002) /*!< reserved for future use */
mbed_official 235:685d5f11838f 342 /**
mbed_official 235:685d5f11838f 343 * @}
mbed_official 235:685d5f11838f 344 */
mbed_official 235:685d5f11838f 345
mbed_official 532:fe11edbda85c 346 /** @defgroup ADC_Event_type ADC Event Type
mbed_official 235:685d5f11838f 347 * @{
mbed_official 235:685d5f11838f 348 */
mbed_official 532:fe11edbda85c 349 #define ADC_AWD_EVENT ((uint32_t)ADC_FLAG_AWD)
mbed_official 532:fe11edbda85c 350 #define ADC_OVR_EVENT ((uint32_t)ADC_FLAG_OVR)
mbed_official 235:685d5f11838f 351 /**
mbed_official 235:685d5f11838f 352 * @}
mbed_official 235:685d5f11838f 353 */
mbed_official 235:685d5f11838f 354
mbed_official 532:fe11edbda85c 355 /** @defgroup ADC_analog_watchdog_selection ADC Analog Watchdog Selection
mbed_official 235:685d5f11838f 356 * @{
mbed_official 235:685d5f11838f 357 */
mbed_official 235:685d5f11838f 358 #define ADC_ANALOGWATCHDOG_SINGLE_REG ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN))
mbed_official 235:685d5f11838f 359 #define ADC_ANALOGWATCHDOG_SINGLE_INJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_JAWDEN))
mbed_official 235:685d5f11838f 360 #define ADC_ANALOGWATCHDOG_SINGLE_REGINJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
mbed_official 235:685d5f11838f 361 #define ADC_ANALOGWATCHDOG_ALL_REG ((uint32_t)ADC_CR1_AWDEN)
mbed_official 235:685d5f11838f 362 #define ADC_ANALOGWATCHDOG_ALL_INJEC ((uint32_t)ADC_CR1_JAWDEN)
mbed_official 235:685d5f11838f 363 #define ADC_ANALOGWATCHDOG_ALL_REGINJEC ((uint32_t)(ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
mbed_official 235:685d5f11838f 364 #define ADC_ANALOGWATCHDOG_NONE ((uint32_t)0x00000000)
mbed_official 235:685d5f11838f 365 /**
mbed_official 235:685d5f11838f 366 * @}
mbed_official 235:685d5f11838f 367 */
mbed_official 235:685d5f11838f 368
mbed_official 532:fe11edbda85c 369 /** @defgroup ADC_interrupts_definition ADC Interrupts Definition
mbed_official 235:685d5f11838f 370 * @{
mbed_official 235:685d5f11838f 371 */
mbed_official 235:685d5f11838f 372 #define ADC_IT_EOC ((uint32_t)ADC_CR1_EOCIE)
mbed_official 235:685d5f11838f 373 #define ADC_IT_AWD ((uint32_t)ADC_CR1_AWDIE)
mbed_official 235:685d5f11838f 374 #define ADC_IT_JEOC ((uint32_t)ADC_CR1_JEOCIE)
mbed_official 235:685d5f11838f 375 #define ADC_IT_OVR ((uint32_t)ADC_CR1_OVRIE)
mbed_official 235:685d5f11838f 376 /**
mbed_official 235:685d5f11838f 377 * @}
mbed_official 235:685d5f11838f 378 */
mbed_official 235:685d5f11838f 379
mbed_official 532:fe11edbda85c 380 /** @defgroup ADC_flags_definition ADC Flags Definition
mbed_official 235:685d5f11838f 381 * @{
mbed_official 235:685d5f11838f 382 */
mbed_official 235:685d5f11838f 383 #define ADC_FLAG_AWD ((uint32_t)ADC_SR_AWD)
mbed_official 235:685d5f11838f 384 #define ADC_FLAG_EOC ((uint32_t)ADC_SR_EOC)
mbed_official 235:685d5f11838f 385 #define ADC_FLAG_JEOC ((uint32_t)ADC_SR_JEOC)
mbed_official 235:685d5f11838f 386 #define ADC_FLAG_JSTRT ((uint32_t)ADC_SR_JSTRT)
mbed_official 235:685d5f11838f 387 #define ADC_FLAG_STRT ((uint32_t)ADC_SR_STRT)
mbed_official 235:685d5f11838f 388 #define ADC_FLAG_OVR ((uint32_t)ADC_SR_OVR)
mbed_official 235:685d5f11838f 389 /**
mbed_official 235:685d5f11838f 390 * @}
mbed_official 235:685d5f11838f 391 */
mbed_official 235:685d5f11838f 392
mbed_official 532:fe11edbda85c 393 /** @defgroup ADC_channels_type ADC Channels Type
mbed_official 235:685d5f11838f 394 * @{
mbed_official 235:685d5f11838f 395 */
mbed_official 532:fe11edbda85c 396 #define ADC_ALL_CHANNELS ((uint32_t)0x00000001)
mbed_official 532:fe11edbda85c 397 #define ADC_REGULAR_CHANNELS ((uint32_t)0x00000002) /*!< reserved for future use */
mbed_official 532:fe11edbda85c 398 #define ADC_INJECTED_CHANNELS ((uint32_t)0x00000003) /*!< reserved for future use */
mbed_official 235:685d5f11838f 399 /**
mbed_official 235:685d5f11838f 400 * @}
mbed_official 235:685d5f11838f 401 */
mbed_official 235:685d5f11838f 402
mbed_official 235:685d5f11838f 403 /**
mbed_official 235:685d5f11838f 404 * @}
mbed_official 235:685d5f11838f 405 */
mbed_official 235:685d5f11838f 406
mbed_official 235:685d5f11838f 407 /* Exported macro ------------------------------------------------------------*/
mbed_official 532:fe11edbda85c 408 /** @defgroup ADC_Exported_Macros ADC Exported Macros
mbed_official 532:fe11edbda85c 409 * @{
mbed_official 532:fe11edbda85c 410 */
mbed_official 235:685d5f11838f 411
mbed_official 235:685d5f11838f 412 /** @brief Reset ADC handle state
mbed_official 235:685d5f11838f 413 * @param __HANDLE__: ADC handle
mbed_official 235:685d5f11838f 414 * @retval None
mbed_official 235:685d5f11838f 415 */
mbed_official 235:685d5f11838f 416 #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
mbed_official 235:685d5f11838f 417
mbed_official 235:685d5f11838f 418 /**
mbed_official 235:685d5f11838f 419 * @brief Enable the ADC peripheral.
mbed_official 235:685d5f11838f 420 * @param __HANDLE__: ADC handle
mbed_official 235:685d5f11838f 421 * @retval None
mbed_official 235:685d5f11838f 422 */
mbed_official 235:685d5f11838f 423 #define __HAL_ADC_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR2 |= ADC_CR2_ADON)
mbed_official 235:685d5f11838f 424
mbed_official 235:685d5f11838f 425 /**
mbed_official 235:685d5f11838f 426 * @brief Disable the ADC peripheral.
mbed_official 235:685d5f11838f 427 * @param __HANDLE__: ADC handle
mbed_official 235:685d5f11838f 428 * @retval None
mbed_official 235:685d5f11838f 429 */
mbed_official 235:685d5f11838f 430 #define __HAL_ADC_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR2 &= ~ADC_CR2_ADON)
mbed_official 235:685d5f11838f 431
mbed_official 235:685d5f11838f 432 /**
mbed_official 235:685d5f11838f 433 * @brief Enable the ADC end of conversion interrupt.
mbed_official 235:685d5f11838f 434 * @param __HANDLE__: specifies the ADC Handle.
mbed_official 235:685d5f11838f 435 * @param __INTERRUPT__: ADC Interrupt.
mbed_official 235:685d5f11838f 436 * @retval None
mbed_official 235:685d5f11838f 437 */
mbed_official 235:685d5f11838f 438 #define __HAL_ADC_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1) |= (__INTERRUPT__))
mbed_official 235:685d5f11838f 439
mbed_official 235:685d5f11838f 440 /**
mbed_official 235:685d5f11838f 441 * @brief Disable the ADC end of conversion interrupt.
mbed_official 235:685d5f11838f 442 * @param __HANDLE__: specifies the ADC Handle.
mbed_official 235:685d5f11838f 443 * @param __INTERRUPT__: ADC interrupt.
mbed_official 235:685d5f11838f 444 * @retval None
mbed_official 235:685d5f11838f 445 */
mbed_official 235:685d5f11838f 446 #define __HAL_ADC_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1) &= ~(__INTERRUPT__))
mbed_official 235:685d5f11838f 447
mbed_official 235:685d5f11838f 448 /** @brief Check if the specified ADC interrupt source is enabled or disabled.
mbed_official 235:685d5f11838f 449 * @param __HANDLE__: specifies the ADC Handle.
mbed_official 235:685d5f11838f 450 * @param __INTERRUPT__: specifies the ADC interrupt source to check.
mbed_official 235:685d5f11838f 451 * @retval The new state of __IT__ (TRUE or FALSE).
mbed_official 235:685d5f11838f 452 */
mbed_official 532:fe11edbda85c 453 #define __HAL_ADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__))
mbed_official 235:685d5f11838f 454
mbed_official 235:685d5f11838f 455 /**
mbed_official 235:685d5f11838f 456 * @brief Clear the ADC's pending flags.
mbed_official 235:685d5f11838f 457 * @param __HANDLE__: specifies the ADC Handle.
mbed_official 235:685d5f11838f 458 * @param __FLAG__: ADC flag.
mbed_official 235:685d5f11838f 459 * @retval None
mbed_official 235:685d5f11838f 460 */
mbed_official 235:685d5f11838f 461 #define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) = ~(__FLAG__))
mbed_official 235:685d5f11838f 462
mbed_official 235:685d5f11838f 463 /**
mbed_official 235:685d5f11838f 464 * @brief Get the selected ADC's flag status.
mbed_official 235:685d5f11838f 465 * @param __HANDLE__: specifies the ADC Handle.
mbed_official 235:685d5f11838f 466 * @param __FLAG__: ADC flag.
mbed_official 235:685d5f11838f 467 * @retval None
mbed_official 235:685d5f11838f 468 */
mbed_official 235:685d5f11838f 469 #define __HAL_ADC_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
mbed_official 235:685d5f11838f 470
mbed_official 235:685d5f11838f 471 /**
mbed_official 532:fe11edbda85c 472 * @}
mbed_official 235:685d5f11838f 473 */
mbed_official 235:685d5f11838f 474
mbed_official 235:685d5f11838f 475 /* Include ADC HAL Extension module */
mbed_official 235:685d5f11838f 476 #include "stm32f4xx_hal_adc_ex.h"
mbed_official 235:685d5f11838f 477
mbed_official 235:685d5f11838f 478 /* Exported functions --------------------------------------------------------*/
mbed_official 532:fe11edbda85c 479 /** @addtogroup ADC_Exported_Functions
mbed_official 532:fe11edbda85c 480 * @{
mbed_official 532:fe11edbda85c 481 */
mbed_official 532:fe11edbda85c 482
mbed_official 532:fe11edbda85c 483 /** @addtogroup ADC_Exported_Functions_Group1
mbed_official 532:fe11edbda85c 484 * @{
mbed_official 532:fe11edbda85c 485 */
mbed_official 235:685d5f11838f 486 /* Initialization/de-initialization functions ***********************************/
mbed_official 235:685d5f11838f 487 HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc);
mbed_official 235:685d5f11838f 488 HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
mbed_official 532:fe11edbda85c 489 void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
mbed_official 532:fe11edbda85c 490 void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
mbed_official 532:fe11edbda85c 491 /**
mbed_official 532:fe11edbda85c 492 * @}
mbed_official 532:fe11edbda85c 493 */
mbed_official 235:685d5f11838f 494
mbed_official 532:fe11edbda85c 495 /** @addtogroup ADC_Exported_Functions_Group2
mbed_official 532:fe11edbda85c 496 * @{
mbed_official 532:fe11edbda85c 497 */
mbed_official 235:685d5f11838f 498 /* I/O operation functions ******************************************************/
mbed_official 235:685d5f11838f 499 HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc);
mbed_official 235:685d5f11838f 500 HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc);
mbed_official 235:685d5f11838f 501 HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
mbed_official 235:685d5f11838f 502
mbed_official 235:685d5f11838f 503 HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout);
mbed_official 235:685d5f11838f 504
mbed_official 235:685d5f11838f 505 HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc);
mbed_official 235:685d5f11838f 506 HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc);
mbed_official 235:685d5f11838f 507
mbed_official 532:fe11edbda85c 508 void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc);
mbed_official 235:685d5f11838f 509
mbed_official 235:685d5f11838f 510 HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length);
mbed_official 235:685d5f11838f 511 HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc);
mbed_official 235:685d5f11838f 512
mbed_official 532:fe11edbda85c 513 uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc);
mbed_official 235:685d5f11838f 514
mbed_official 532:fe11edbda85c 515 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc);
mbed_official 532:fe11edbda85c 516 void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc);
mbed_official 532:fe11edbda85c 517 void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc);
mbed_official 532:fe11edbda85c 518 void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
mbed_official 532:fe11edbda85c 519 /**
mbed_official 532:fe11edbda85c 520 * @}
mbed_official 532:fe11edbda85c 521 */
mbed_official 235:685d5f11838f 522
mbed_official 532:fe11edbda85c 523 /** @addtogroup ADC_Exported_Functions_Group3
mbed_official 532:fe11edbda85c 524 * @{
mbed_official 532:fe11edbda85c 525 */
mbed_official 235:685d5f11838f 526 /* Peripheral Control functions *************************************************/
mbed_official 235:685d5f11838f 527 HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig);
mbed_official 235:685d5f11838f 528 HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig);
mbed_official 532:fe11edbda85c 529 /**
mbed_official 532:fe11edbda85c 530 * @}
mbed_official 532:fe11edbda85c 531 */
mbed_official 235:685d5f11838f 532
mbed_official 532:fe11edbda85c 533 /** @addtogroup ADC_Exported_Functions_Group4
mbed_official 532:fe11edbda85c 534 * @{
mbed_official 532:fe11edbda85c 535 */
mbed_official 235:685d5f11838f 536 /* Peripheral State functions ***************************************************/
mbed_official 235:685d5f11838f 537 HAL_ADC_StateTypeDef HAL_ADC_GetState(ADC_HandleTypeDef* hadc);
mbed_official 532:fe11edbda85c 538 uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc);
mbed_official 532:fe11edbda85c 539 /**
mbed_official 532:fe11edbda85c 540 * @}
mbed_official 532:fe11edbda85c 541 */
mbed_official 532:fe11edbda85c 542
mbed_official 532:fe11edbda85c 543 /**
mbed_official 532:fe11edbda85c 544 * @}
mbed_official 532:fe11edbda85c 545 */
mbed_official 532:fe11edbda85c 546 /* Private types -------------------------------------------------------------*/
mbed_official 532:fe11edbda85c 547 /* Private variables ---------------------------------------------------------*/
mbed_official 532:fe11edbda85c 548 /* Private constants ---------------------------------------------------------*/
mbed_official 532:fe11edbda85c 549 /** @defgroup ADC_Private_Constants ADC Private Constants
mbed_official 532:fe11edbda85c 550 * @{
mbed_official 532:fe11edbda85c 551 */
mbed_official 532:fe11edbda85c 552 /* Delay for ADC stabilization time. */
mbed_official 532:fe11edbda85c 553 /* Maximum delay is 1us (refer to device datasheet, parameter tSTAB). */
mbed_official 532:fe11edbda85c 554 /* Unit: us */
mbed_official 532:fe11edbda85c 555 #define ADC_STAB_DELAY_US ((uint32_t) 3)
mbed_official 532:fe11edbda85c 556 /* Delay for temperature sensor stabilization time. */
mbed_official 532:fe11edbda85c 557 /* Maximum delay is 10us (refer to device datasheet, parameter tSTART). */
mbed_official 532:fe11edbda85c 558 /* Unit: us */
mbed_official 532:fe11edbda85c 559 #define ADC_TEMPSENSOR_DELAY_US ((uint32_t) 10)
mbed_official 532:fe11edbda85c 560 /**
mbed_official 532:fe11edbda85c 561 * @}
mbed_official 532:fe11edbda85c 562 */
mbed_official 532:fe11edbda85c 563
mbed_official 532:fe11edbda85c 564 /* Private macros ------------------------------------------------------------*/
mbed_official 532:fe11edbda85c 565 /** @defgroup ADC_Private_Macros ADC Private Macros
mbed_official 532:fe11edbda85c 566 * @{
mbed_official 532:fe11edbda85c 567 */
mbed_official 532:fe11edbda85c 568 #define IS_ADC_CLOCKPRESCALER(ADC_CLOCK) (((ADC_CLOCK) == ADC_CLOCKPRESCALER_PCLK_DIV2) || \
mbed_official 532:fe11edbda85c 569 ((ADC_CLOCK) == ADC_CLOCKPRESCALER_PCLK_DIV4) || \
mbed_official 532:fe11edbda85c 570 ((ADC_CLOCK) == ADC_CLOCKPRESCALER_PCLK_DIV6) || \
mbed_official 532:fe11edbda85c 571 ((ADC_CLOCK) == ADC_CLOCKPRESCALER_PCLK_DIV8))
mbed_official 532:fe11edbda85c 572 #define IS_ADC_SAMPLING_DELAY(DELAY) (((DELAY) == ADC_TWOSAMPLINGDELAY_5CYCLES) || \
mbed_official 532:fe11edbda85c 573 ((DELAY) == ADC_TWOSAMPLINGDELAY_6CYCLES) || \
mbed_official 532:fe11edbda85c 574 ((DELAY) == ADC_TWOSAMPLINGDELAY_7CYCLES) || \
mbed_official 532:fe11edbda85c 575 ((DELAY) == ADC_TWOSAMPLINGDELAY_8CYCLES) || \
mbed_official 532:fe11edbda85c 576 ((DELAY) == ADC_TWOSAMPLINGDELAY_9CYCLES) || \
mbed_official 532:fe11edbda85c 577 ((DELAY) == ADC_TWOSAMPLINGDELAY_10CYCLES) || \
mbed_official 532:fe11edbda85c 578 ((DELAY) == ADC_TWOSAMPLINGDELAY_11CYCLES) || \
mbed_official 532:fe11edbda85c 579 ((DELAY) == ADC_TWOSAMPLINGDELAY_12CYCLES) || \
mbed_official 532:fe11edbda85c 580 ((DELAY) == ADC_TWOSAMPLINGDELAY_13CYCLES) || \
mbed_official 532:fe11edbda85c 581 ((DELAY) == ADC_TWOSAMPLINGDELAY_14CYCLES) || \
mbed_official 532:fe11edbda85c 582 ((DELAY) == ADC_TWOSAMPLINGDELAY_15CYCLES) || \
mbed_official 532:fe11edbda85c 583 ((DELAY) == ADC_TWOSAMPLINGDELAY_16CYCLES) || \
mbed_official 532:fe11edbda85c 584 ((DELAY) == ADC_TWOSAMPLINGDELAY_17CYCLES) || \
mbed_official 532:fe11edbda85c 585 ((DELAY) == ADC_TWOSAMPLINGDELAY_18CYCLES) || \
mbed_official 532:fe11edbda85c 586 ((DELAY) == ADC_TWOSAMPLINGDELAY_19CYCLES) || \
mbed_official 532:fe11edbda85c 587 ((DELAY) == ADC_TWOSAMPLINGDELAY_20CYCLES))
mbed_official 532:fe11edbda85c 588 #define IS_ADC_RESOLUTION(RESOLUTION) (((RESOLUTION) == ADC_RESOLUTION_12B) || \
mbed_official 532:fe11edbda85c 589 ((RESOLUTION) == ADC_RESOLUTION_10B) || \
mbed_official 532:fe11edbda85c 590 ((RESOLUTION) == ADC_RESOLUTION_8B) || \
mbed_official 532:fe11edbda85c 591 ((RESOLUTION) == ADC_RESOLUTION_6B))
mbed_official 532:fe11edbda85c 592 #define IS_ADC_EXT_TRIG_EDGE(EDGE) (((EDGE) == ADC_EXTERNALTRIGCONVEDGE_NONE) || \
mbed_official 532:fe11edbda85c 593 ((EDGE) == ADC_EXTERNALTRIGCONVEDGE_RISING) || \
mbed_official 532:fe11edbda85c 594 ((EDGE) == ADC_EXTERNALTRIGCONVEDGE_FALLING) || \
mbed_official 532:fe11edbda85c 595 ((EDGE) == ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING))
mbed_official 532:fe11edbda85c 596 #define IS_ADC_EXT_TRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
mbed_official 532:fe11edbda85c 597 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
mbed_official 532:fe11edbda85c 598 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC3) || \
mbed_official 532:fe11edbda85c 599 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
mbed_official 532:fe11edbda85c 600 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC3) || \
mbed_official 532:fe11edbda85c 601 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC4) || \
mbed_official 532:fe11edbda85c 602 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_TRGO) || \
mbed_official 532:fe11edbda85c 603 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_CC1) || \
mbed_official 532:fe11edbda85c 604 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
mbed_official 532:fe11edbda85c 605 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
mbed_official 532:fe11edbda85c 606 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T5_CC1) || \
mbed_official 532:fe11edbda85c 607 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T5_CC2) || \
mbed_official 532:fe11edbda85c 608 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T5_CC3) || \
mbed_official 532:fe11edbda85c 609 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_CC1) || \
mbed_official 532:fe11edbda85c 610 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_TRGO) || \
mbed_official 532:fe11edbda85c 611 ((REGTRIG) == ADC_EXTERNALTRIGCONV_Ext_IT11)|| \
mbed_official 532:fe11edbda85c 612 ((REGTRIG) == ADC_SOFTWARE_START))
mbed_official 532:fe11edbda85c 613 #define IS_ADC_DATA_ALIGN(ALIGN) (((ALIGN) == ADC_DATAALIGN_RIGHT) || \
mbed_official 532:fe11edbda85c 614 ((ALIGN) == ADC_DATAALIGN_LEFT))
mbed_official 532:fe11edbda85c 615 #define IS_ADC_SAMPLE_TIME(TIME) (((TIME) == ADC_SAMPLETIME_3CYCLES) || \
mbed_official 532:fe11edbda85c 616 ((TIME) == ADC_SAMPLETIME_15CYCLES) || \
mbed_official 532:fe11edbda85c 617 ((TIME) == ADC_SAMPLETIME_28CYCLES) || \
mbed_official 532:fe11edbda85c 618 ((TIME) == ADC_SAMPLETIME_56CYCLES) || \
mbed_official 532:fe11edbda85c 619 ((TIME) == ADC_SAMPLETIME_84CYCLES) || \
mbed_official 532:fe11edbda85c 620 ((TIME) == ADC_SAMPLETIME_112CYCLES) || \
mbed_official 532:fe11edbda85c 621 ((TIME) == ADC_SAMPLETIME_144CYCLES) || \
mbed_official 532:fe11edbda85c 622 ((TIME) == ADC_SAMPLETIME_480CYCLES))
mbed_official 532:fe11edbda85c 623 #define IS_ADC_EOCSelection(EOCSelection) (((EOCSelection) == ADC_EOC_SINGLE_CONV) || \
mbed_official 532:fe11edbda85c 624 ((EOCSelection) == ADC_EOC_SEQ_CONV) || \
mbed_official 532:fe11edbda85c 625 ((EOCSelection) == ADC_EOC_SINGLE_SEQ_CONV))
mbed_official 532:fe11edbda85c 626 #define IS_ADC_EVENT_TYPE(EVENT) (((EVENT) == ADC_AWD_EVENT) || \
mbed_official 532:fe11edbda85c 627 ((EVENT) == ADC_OVR_EVENT))
mbed_official 532:fe11edbda85c 628 #define IS_ADC_ANALOG_WATCHDOG(WATCHDOG) (((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_REG) || \
mbed_official 532:fe11edbda85c 629 ((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_INJEC) || \
mbed_official 532:fe11edbda85c 630 ((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC) || \
mbed_official 532:fe11edbda85c 631 ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_REG) || \
mbed_official 532:fe11edbda85c 632 ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_INJEC) || \
mbed_official 532:fe11edbda85c 633 ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_REGINJEC) || \
mbed_official 532:fe11edbda85c 634 ((WATCHDOG) == ADC_ANALOGWATCHDOG_NONE))
mbed_official 532:fe11edbda85c 635 #define IS_ADC_CHANNELS_TYPE(CHANNEL_TYPE) (((CHANNEL_TYPE) == ADC_ALL_CHANNELS) || \
mbed_official 532:fe11edbda85c 636 ((CHANNEL_TYPE) == ADC_REGULAR_CHANNELS) || \
mbed_official 532:fe11edbda85c 637 ((CHANNEL_TYPE) == ADC_INJECTED_CHANNELS))
mbed_official 532:fe11edbda85c 638 #define IS_ADC_THRESHOLD(THRESHOLD) ((THRESHOLD) <= ((uint32_t)0xFFF))
mbed_official 532:fe11edbda85c 639
mbed_official 532:fe11edbda85c 640 #define IS_ADC_REGULAR_LENGTH(LENGTH) (((LENGTH) >= ((uint32_t)1)) && ((LENGTH) <= ((uint32_t)16)))
mbed_official 532:fe11edbda85c 641 #define IS_ADC_REGULAR_RANK(RANK) (((RANK) >= ((uint32_t)1)) && ((RANK) <= ((uint32_t)16)))
mbed_official 532:fe11edbda85c 642 #define IS_ADC_REGULAR_DISC_NUMBER(NUMBER) (((NUMBER) >= ((uint32_t)1)) && ((NUMBER) <= ((uint32_t)8)))
mbed_official 532:fe11edbda85c 643 #define IS_ADC_RANGE(RESOLUTION, ADC_VALUE) \
mbed_official 532:fe11edbda85c 644 ((((RESOLUTION) == ADC_RESOLUTION_12B) && ((ADC_VALUE) <= ((uint32_t)0x0FFF))) || \
mbed_official 532:fe11edbda85c 645 (((RESOLUTION) == ADC_RESOLUTION_10B) && ((ADC_VALUE) <= ((uint32_t)0x03FF))) || \
mbed_official 532:fe11edbda85c 646 (((RESOLUTION) == ADC_RESOLUTION_8B) && ((ADC_VALUE) <= ((uint32_t)0x00FF))) || \
mbed_official 532:fe11edbda85c 647 (((RESOLUTION) == ADC_RESOLUTION_6B) && ((ADC_VALUE) <= ((uint32_t)0x003F))))
mbed_official 532:fe11edbda85c 648
mbed_official 532:fe11edbda85c 649 /**
mbed_official 532:fe11edbda85c 650 * @brief Set ADC Regular channel sequence length.
mbed_official 532:fe11edbda85c 651 * @param _NbrOfConversion_: Regular channel sequence length.
mbed_official 532:fe11edbda85c 652 * @retval None
mbed_official 532:fe11edbda85c 653 */
mbed_official 532:fe11edbda85c 654 #define ADC_SQR1(_NbrOfConversion_) (((_NbrOfConversion_) - (uint8_t)1) << 20)
mbed_official 532:fe11edbda85c 655
mbed_official 532:fe11edbda85c 656 /**
mbed_official 532:fe11edbda85c 657 * @brief Set the ADC's sample time for channel numbers between 10 and 18.
mbed_official 532:fe11edbda85c 658 * @param _SAMPLETIME_: Sample time parameter.
mbed_official 532:fe11edbda85c 659 * @param _CHANNELNB_: Channel number.
mbed_official 532:fe11edbda85c 660 * @retval None
mbed_official 532:fe11edbda85c 661 */
mbed_official 532:fe11edbda85c 662 #define ADC_SMPR1(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3 * (((uint32_t)((uint16_t)(_CHANNELNB_))) - 10)))
mbed_official 532:fe11edbda85c 663
mbed_official 532:fe11edbda85c 664 /**
mbed_official 532:fe11edbda85c 665 * @brief Set the ADC's sample time for channel numbers between 0 and 9.
mbed_official 532:fe11edbda85c 666 * @param _SAMPLETIME_: Sample time parameter.
mbed_official 532:fe11edbda85c 667 * @param _CHANNELNB_: Channel number.
mbed_official 532:fe11edbda85c 668 * @retval None
mbed_official 532:fe11edbda85c 669 */
mbed_official 532:fe11edbda85c 670 #define ADC_SMPR2(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3 * ((uint32_t)((uint16_t)(_CHANNELNB_)))))
mbed_official 532:fe11edbda85c 671
mbed_official 532:fe11edbda85c 672 /**
mbed_official 532:fe11edbda85c 673 * @brief Set the selected regular channel rank for rank between 1 and 6.
mbed_official 532:fe11edbda85c 674 * @param _CHANNELNB_: Channel number.
mbed_official 532:fe11edbda85c 675 * @param _RANKNB_: Rank number.
mbed_official 532:fe11edbda85c 676 * @retval None
mbed_official 532:fe11edbda85c 677 */
mbed_official 532:fe11edbda85c 678 #define ADC_SQR3_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5 * ((_RANKNB_) - 1)))
mbed_official 532:fe11edbda85c 679
mbed_official 532:fe11edbda85c 680 /**
mbed_official 532:fe11edbda85c 681 * @brief Set the selected regular channel rank for rank between 7 and 12.
mbed_official 532:fe11edbda85c 682 * @param _CHANNELNB_: Channel number.
mbed_official 532:fe11edbda85c 683 * @param _RANKNB_: Rank number.
mbed_official 532:fe11edbda85c 684 * @retval None
mbed_official 532:fe11edbda85c 685 */
mbed_official 532:fe11edbda85c 686 #define ADC_SQR2_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5 * ((_RANKNB_) - 7)))
mbed_official 532:fe11edbda85c 687
mbed_official 532:fe11edbda85c 688 /**
mbed_official 532:fe11edbda85c 689 * @brief Set the selected regular channel rank for rank between 13 and 16.
mbed_official 532:fe11edbda85c 690 * @param _CHANNELNB_: Channel number.
mbed_official 532:fe11edbda85c 691 * @param _RANKNB_: Rank number.
mbed_official 532:fe11edbda85c 692 * @retval None
mbed_official 532:fe11edbda85c 693 */
mbed_official 532:fe11edbda85c 694 #define ADC_SQR1_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5 * ((_RANKNB_) - 13)))
mbed_official 532:fe11edbda85c 695
mbed_official 532:fe11edbda85c 696 /**
mbed_official 532:fe11edbda85c 697 * @brief Enable ADC continuous conversion mode.
mbed_official 532:fe11edbda85c 698 * @param _CONTINUOUS_MODE_: Continuous mode.
mbed_official 532:fe11edbda85c 699 * @retval None
mbed_official 532:fe11edbda85c 700 */
mbed_official 532:fe11edbda85c 701 #define ADC_CR2_CONTINUOUS(_CONTINUOUS_MODE_) ((_CONTINUOUS_MODE_) << 1)
mbed_official 532:fe11edbda85c 702
mbed_official 532:fe11edbda85c 703 /**
mbed_official 532:fe11edbda85c 704 * @brief Configures the number of discontinuous conversions for the regular group channels.
mbed_official 532:fe11edbda85c 705 * @param _NBR_DISCONTINUOUSCONV_: Number of discontinuous conversions.
mbed_official 532:fe11edbda85c 706 * @retval None
mbed_official 532:fe11edbda85c 707 */
mbed_official 532:fe11edbda85c 708 #define ADC_CR1_DISCONTINUOUS(_NBR_DISCONTINUOUSCONV_) (((_NBR_DISCONTINUOUSCONV_) - 1) << POSITION_VAL(ADC_CR1_DISCNUM))
mbed_official 532:fe11edbda85c 709
mbed_official 532:fe11edbda85c 710 /**
mbed_official 532:fe11edbda85c 711 * @brief Enable ADC scan mode.
mbed_official 532:fe11edbda85c 712 * @param _SCANCONV_MODE_: Scan conversion mode.
mbed_official 532:fe11edbda85c 713 * @retval None
mbed_official 532:fe11edbda85c 714 */
mbed_official 532:fe11edbda85c 715 #define ADC_CR1_SCANCONV(_SCANCONV_MODE_) ((_SCANCONV_MODE_) << 8)
mbed_official 532:fe11edbda85c 716
mbed_official 532:fe11edbda85c 717 /**
mbed_official 532:fe11edbda85c 718 * @brief Enable the ADC end of conversion selection.
mbed_official 532:fe11edbda85c 719 * @param _EOCSelection_MODE_: End of conversion selection mode.
mbed_official 532:fe11edbda85c 720 * @retval None
mbed_official 532:fe11edbda85c 721 */
mbed_official 532:fe11edbda85c 722 #define ADC_CR2_EOCSelection(_EOCSelection_MODE_) ((_EOCSelection_MODE_) << 10)
mbed_official 532:fe11edbda85c 723
mbed_official 532:fe11edbda85c 724 /**
mbed_official 532:fe11edbda85c 725 * @brief Enable the ADC DMA continuous request.
mbed_official 532:fe11edbda85c 726 * @param _DMAContReq_MODE_: DMA continuous request mode.
mbed_official 532:fe11edbda85c 727 * @retval None
mbed_official 532:fe11edbda85c 728 */
mbed_official 532:fe11edbda85c 729 #define ADC_CR2_DMAContReq(_DMAContReq_MODE_) ((_DMAContReq_MODE_) << 9)
mbed_official 532:fe11edbda85c 730
mbed_official 532:fe11edbda85c 731 /**
mbed_official 532:fe11edbda85c 732 * @brief Return resolution bits in CR1 register.
mbed_official 532:fe11edbda85c 733 * @param __HANDLE__: ADC handle
mbed_official 532:fe11edbda85c 734 * @retval None
mbed_official 532:fe11edbda85c 735 */
mbed_official 532:fe11edbda85c 736 #define ADC_GET_RESOLUTION(__HANDLE__) (((__HANDLE__)->Instance->CR1) & ADC_CR1_RES)
mbed_official 532:fe11edbda85c 737
mbed_official 532:fe11edbda85c 738 /**
mbed_official 532:fe11edbda85c 739 * @}
mbed_official 532:fe11edbda85c 740 */
mbed_official 532:fe11edbda85c 741
mbed_official 532:fe11edbda85c 742 /* Private functions ---------------------------------------------------------*/
mbed_official 532:fe11edbda85c 743 /** @defgroup ADC_Private_Functions ADC Private Functions
mbed_official 532:fe11edbda85c 744 * @{
mbed_official 532:fe11edbda85c 745 */
mbed_official 532:fe11edbda85c 746
mbed_official 532:fe11edbda85c 747 /**
mbed_official 532:fe11edbda85c 748 * @}
mbed_official 532:fe11edbda85c 749 */
mbed_official 235:685d5f11838f 750
mbed_official 235:685d5f11838f 751 /**
mbed_official 235:685d5f11838f 752 * @}
mbed_official 235:685d5f11838f 753 */
mbed_official 235:685d5f11838f 754
mbed_official 235:685d5f11838f 755 /**
mbed_official 235:685d5f11838f 756 * @}
mbed_official 235:685d5f11838f 757 */
mbed_official 235:685d5f11838f 758
mbed_official 235:685d5f11838f 759 #ifdef __cplusplus
mbed_official 235:685d5f11838f 760 }
mbed_official 235:685d5f11838f 761 #endif
mbed_official 235:685d5f11838f 762
mbed_official 235:685d5f11838f 763 #endif /*__STM32F4xx_ADC_H */
mbed_official 235:685d5f11838f 764
mbed_official 235:685d5f11838f 765
mbed_official 235:685d5f11838f 766 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/