mbed library sources

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Fri Jul 31 14:15:09 2015 +0100
Revision:
600:7d17ca308cd1
Parent:
489:119543c9f674
Synchronized with git revision e4cd8bbd3e05b68e5a7f466c74035a85743d45e0

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

Enable LPC8xx usart when configuring it

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 489:119543c9f674 1 /**
mbed_official 489:119543c9f674 2 ******************************************************************************
mbed_official 489:119543c9f674 3 * @file stm32f1xx_hal_adc.h
mbed_official 489:119543c9f674 4 * @author MCD Application Team
mbed_official 489:119543c9f674 5 * @version V1.0.0
mbed_official 489:119543c9f674 6 * @date 15-December-2014
mbed_official 489:119543c9f674 7 * @brief Header file containing functions prototypes of ADC HAL library.
mbed_official 489:119543c9f674 8 ******************************************************************************
mbed_official 489:119543c9f674 9 * @attention
mbed_official 489:119543c9f674 10 *
mbed_official 489:119543c9f674 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 489:119543c9f674 12 *
mbed_official 489:119543c9f674 13 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 489:119543c9f674 14 * are permitted provided that the following conditions are met:
mbed_official 489:119543c9f674 15 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 489:119543c9f674 16 * this list of conditions and the following disclaimer.
mbed_official 489:119543c9f674 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 489:119543c9f674 18 * this list of conditions and the following disclaimer in the documentation
mbed_official 489:119543c9f674 19 * and/or other materials provided with the distribution.
mbed_official 489:119543c9f674 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 489:119543c9f674 21 * may be used to endorse or promote products derived from this software
mbed_official 489:119543c9f674 22 * without specific prior written permission.
mbed_official 489:119543c9f674 23 *
mbed_official 489:119543c9f674 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 489:119543c9f674 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 489:119543c9f674 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 489:119543c9f674 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 489:119543c9f674 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 489:119543c9f674 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 489:119543c9f674 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 489:119543c9f674 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 489:119543c9f674 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 489:119543c9f674 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 489:119543c9f674 34 *
mbed_official 489:119543c9f674 35 ******************************************************************************
mbed_official 489:119543c9f674 36 */
mbed_official 489:119543c9f674 37
mbed_official 489:119543c9f674 38 /* Define to prevent recursive inclusion -------------------------------------*/
mbed_official 489:119543c9f674 39 #ifndef __STM32F1xx_HAL_ADC_H
mbed_official 489:119543c9f674 40 #define __STM32F1xx_HAL_ADC_H
mbed_official 489:119543c9f674 41
mbed_official 489:119543c9f674 42 #ifdef __cplusplus
mbed_official 489:119543c9f674 43 extern "C" {
mbed_official 489:119543c9f674 44 #endif
mbed_official 489:119543c9f674 45
mbed_official 489:119543c9f674 46 /* Includes ------------------------------------------------------------------*/
mbed_official 489:119543c9f674 47 #include "stm32f1xx_hal_def.h"
mbed_official 489:119543c9f674 48 /** @addtogroup STM32F1xx_HAL_Driver
mbed_official 489:119543c9f674 49 * @{
mbed_official 489:119543c9f674 50 */
mbed_official 489:119543c9f674 51
mbed_official 489:119543c9f674 52 /** @addtogroup ADC
mbed_official 489:119543c9f674 53 * @{
mbed_official 489:119543c9f674 54 */
mbed_official 489:119543c9f674 55
mbed_official 489:119543c9f674 56 /* Exported types ------------------------------------------------------------*/
mbed_official 489:119543c9f674 57 /** @defgroup ADC_Exported_Types ADC Exported Types
mbed_official 489:119543c9f674 58 * @{
mbed_official 489:119543c9f674 59 */
mbed_official 489:119543c9f674 60
mbed_official 489:119543c9f674 61 /**
mbed_official 489:119543c9f674 62 * @brief Structure definition of ADC and regular group initialization
mbed_official 489:119543c9f674 63 * @note Parameters of this structure are shared within 2 scopes:
mbed_official 489:119543c9f674 64 * - Scope entire ADC (affects regular and injected groups): DataAlign, ScanConvMode.
mbed_official 489:119543c9f674 65 * - Scope regular group: ContinuousConvMode, NbrOfConversion, DiscontinuousConvMode, NbrOfDiscConversion, ExternalTrigConvEdge, ExternalTrigConv.
mbed_official 489:119543c9f674 66 * @note The setting of these parameters with function HAL_ADC_Init() is conditioned to ADC state.
mbed_official 489:119543c9f674 67 * ADC can be either disabled or enabled without conversion on going on regular group.
mbed_official 489:119543c9f674 68 */
mbed_official 489:119543c9f674 69 typedef struct
mbed_official 489:119543c9f674 70 {
mbed_official 489:119543c9f674 71 uint32_t DataAlign; /*!< Specifies ADC data alignment to right (MSB on register bit 11 and LSB on register bit 0) (default setting)
mbed_official 489:119543c9f674 72 or to left (if regular group: MSB on register bit 15 and LSB on register bit 4, if injected group (MSB kept as signed value due to potential negative value after offset application): MSB on register bit 14 and LSB on register bit 3).
mbed_official 489:119543c9f674 73 This parameter can be a value of @ref ADC_Data_align */
mbed_official 489:119543c9f674 74 uint32_t ScanConvMode; /*!< Configures the sequencer of regular and injected groups.
mbed_official 489:119543c9f674 75 This parameter can be associated to parameter 'DiscontinuousConvMode' to have main sequence subdivided in successive parts.
mbed_official 489:119543c9f674 76 If disabled: Conversion is performed in single mode (one channel converted, the one defined in rank 1).
mbed_official 489:119543c9f674 77 Parameters 'NbrOfConversion' and 'InjectedNbrOfConversion' are discarded (equivalent to set to 1).
mbed_official 489:119543c9f674 78 If enabled: Conversions are performed in sequence mode (multiple ranks defined by 'NbrOfConversion'/'InjectedNbrOfConversion' and each channel rank).
mbed_official 489:119543c9f674 79 Scan direction is upward: from rank1 to rank 'n'.
mbed_official 489:119543c9f674 80 This parameter can be a value of @ref ADC_Scan_mode
mbed_official 489:119543c9f674 81 Note: For regular group, this parameter should be enabled in conversion either by polling (HAL_ADC_Start with Discontinuous mode and NbrOfDiscConversion=1)
mbed_official 489:119543c9f674 82 or by DMA (HAL_ADC_Start_DMA), but not by interruption (HAL_ADC_Start_IT): in scan mode, interruption is triggered only on the
mbed_official 489:119543c9f674 83 the last conversion of the sequence. All previous conversions would be overwritten by the last one.
mbed_official 489:119543c9f674 84 Injected group used with scan mode has not this constraint: each rank has its own result register, no data is overwritten. */
mbed_official 489:119543c9f674 85 uint32_t ContinuousConvMode; /*!< Specifies whether the conversion is performed in single mode (one conversion) or continuous mode for regular group,
mbed_official 489:119543c9f674 86 after the selected trigger occurred (software start or external trigger).
mbed_official 489:119543c9f674 87 This parameter can be set to ENABLE or DISABLE. */
mbed_official 489:119543c9f674 88 uint32_t NbrOfConversion; /*!< Specifies the number of ranks that will be converted within the regular group sequencer.
mbed_official 489:119543c9f674 89 To use regular group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
mbed_official 489:119543c9f674 90 This parameter must be a number between Min_Data = 1 and Max_Data = 16. */
mbed_official 489:119543c9f674 91 uint32_t DiscontinuousConvMode; /*!< Specifies whether the conversions sequence of regular group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts).
mbed_official 489:119543c9f674 92 Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
mbed_official 489:119543c9f674 93 Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
mbed_official 489:119543c9f674 94 This parameter can be set to ENABLE or DISABLE. */
mbed_official 489:119543c9f674 95 uint32_t NbrOfDiscConversion; /*!< Specifies the number of discontinuous conversions in which the main sequence of regular group (parameter NbrOfConversion) will be subdivided.
mbed_official 489:119543c9f674 96 If parameter 'DiscontinuousConvMode' is disabled, this parameter is discarded.
mbed_official 489:119543c9f674 97 This parameter must be a number between Min_Data = 1 and Max_Data = 8. */
mbed_official 489:119543c9f674 98 uint32_t ExternalTrigConv; /*!< Selects the external event used to trigger the conversion start of regular group.
mbed_official 489:119543c9f674 99 If set to ADC_SOFTWARE_START, external triggers are disabled.
mbed_official 489:119543c9f674 100 If set to external trigger source, triggering is on event rising edge.
mbed_official 489:119543c9f674 101 This parameter can be a value of @ref ADC_External_trigger_source_Regular */
mbed_official 489:119543c9f674 102 }ADC_InitTypeDef;
mbed_official 489:119543c9f674 103
mbed_official 489:119543c9f674 104 /**
mbed_official 489:119543c9f674 105 * @brief Structure definition of ADC channel for regular group
mbed_official 489:119543c9f674 106 * @note The setting of these parameters with function HAL_ADC_ConfigChannel() is conditioned to ADC state.
mbed_official 489:119543c9f674 107 * ADC can be either disabled or enabled without conversion on going on regular group.
mbed_official 489:119543c9f674 108 */
mbed_official 489:119543c9f674 109 typedef struct
mbed_official 489:119543c9f674 110 {
mbed_official 489:119543c9f674 111 uint32_t Channel; /*!< Specifies the channel to configure into ADC regular group.
mbed_official 489:119543c9f674 112 This parameter can be a value of @ref ADC_channels
mbed_official 489:119543c9f674 113 Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability.
mbed_official 489:119543c9f674 114 Note: On STM32F1 devices with several ADC: Only ADC1 can access internal measurement channels (VrefInt/TempSensor)
mbed_official 489:119543c9f674 115 Note: On STM32F10xx8 and STM32F10xxB devices: A low-amplitude voltage glitch may be generated (on ADC input 0) on the PA0 pin, when the ADC is converting with injection trigger.
mbed_official 489:119543c9f674 116 It is advised to distribute the analog channels so that Channel 0 is configured as an injected channel.
mbed_official 489:119543c9f674 117 Refer to errata sheet of these devices for more details. */
mbed_official 489:119543c9f674 118 uint32_t Rank; /*!< Specifies the rank in the regular group sequencer
mbed_official 489:119543c9f674 119 This parameter can be a value of @ref ADC_regular_rank
mbed_official 489:119543c9f674 120 Note: In case of need to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by the new channel setting (or parameter number of conversions can be adjusted) */
mbed_official 489:119543c9f674 121 uint32_t SamplingTime; /*!< Sampling time value to be set for the selected channel.
mbed_official 489:119543c9f674 122 Unit: ADC clock cycles
mbed_official 489:119543c9f674 123 Conversion time is the addition of sampling time and processing time (12.5 ADC clock cycles at ADC resolution 12 bits).
mbed_official 489:119543c9f674 124 This parameter can be a value of @ref ADC_sampling_times
mbed_official 489:119543c9f674 125 Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups.
mbed_official 489:119543c9f674 126 If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting.
mbed_official 489:119543c9f674 127 Note: In case of usage of internal measurement channels (VrefInt/TempSensor),
mbed_official 489:119543c9f674 128 sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
mbed_official 489:119543c9f674 129 Refer to device datasheet for timings values, parameters TS_vrefint, TS_temp (values rough order: 5us to 17.1us min). */
mbed_official 489:119543c9f674 130 }ADC_ChannelConfTypeDef;
mbed_official 489:119543c9f674 131
mbed_official 489:119543c9f674 132 /**
mbed_official 489:119543c9f674 133 * @brief ADC Configuration analog watchdog definition
mbed_official 489:119543c9f674 134 * @note The setting of these parameters with function is conditioned to ADC state.
mbed_official 489:119543c9f674 135 * ADC state can be either disabled or enabled without conversion on going on regular and injected groups.
mbed_official 489:119543c9f674 136 */
mbed_official 489:119543c9f674 137 typedef struct
mbed_official 489:119543c9f674 138 {
mbed_official 489:119543c9f674 139 uint32_t WatchdogMode; /*!< Configures the ADC analog watchdog mode: single/all channels, regular/injected group.
mbed_official 489:119543c9f674 140 This parameter can be a value of @ref ADC_analog_watchdog_mode. */
mbed_official 489:119543c9f674 141 uint32_t Channel; /*!< Selects which ADC channel to monitor by analog watchdog.
mbed_official 489:119543c9f674 142 This parameter has an effect only if watchdog mode is configured on single channel (parameter WatchdogMode)
mbed_official 489:119543c9f674 143 This parameter can be a value of @ref ADC_channels. */
mbed_official 489:119543c9f674 144 uint32_t ITMode; /*!< Specifies whether the analog watchdog is configured in interrupt or polling mode.
mbed_official 489:119543c9f674 145 This parameter can be set to ENABLE or DISABLE */
mbed_official 489:119543c9f674 146 uint32_t HighThreshold; /*!< Configures the ADC analog watchdog High threshold value.
mbed_official 489:119543c9f674 147 This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */
mbed_official 489:119543c9f674 148 uint32_t LowThreshold; /*!< Configures the ADC analog watchdog High threshold value.
mbed_official 489:119543c9f674 149 This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */
mbed_official 489:119543c9f674 150 uint32_t WatchdogNumber; /*!< Reserved for future use, can be set to 0 */
mbed_official 489:119543c9f674 151 }ADC_AnalogWDGConfTypeDef;
mbed_official 489:119543c9f674 152
mbed_official 489:119543c9f674 153 /**
mbed_official 489:119543c9f674 154 * @brief HAL ADC state machine: ADC States structure definition
mbed_official 489:119543c9f674 155 */
mbed_official 489:119543c9f674 156 typedef enum
mbed_official 489:119543c9f674 157 {
mbed_official 489:119543c9f674 158 HAL_ADC_STATE_RESET = 0x00, /*!< ADC not yet initialized or disabled */
mbed_official 489:119543c9f674 159 HAL_ADC_STATE_READY = 0x01, /*!< ADC peripheral ready for use */
mbed_official 489:119543c9f674 160 HAL_ADC_STATE_BUSY = 0x02, /*!< An internal process is ongoing */
mbed_official 489:119543c9f674 161 HAL_ADC_STATE_BUSY_REG = 0x12, /*!< Regular conversion is ongoing */
mbed_official 489:119543c9f674 162 HAL_ADC_STATE_BUSY_INJ = 0x22, /*!< Injected conversion is ongoing */
mbed_official 489:119543c9f674 163 HAL_ADC_STATE_BUSY_INJ_REG = 0x32, /*!< Injected and regular conversion are ongoing */
mbed_official 489:119543c9f674 164 HAL_ADC_STATE_TIMEOUT = 0x03, /*!< Timeout state */
mbed_official 489:119543c9f674 165 HAL_ADC_STATE_ERROR = 0x04, /*!< ADC state error */
mbed_official 489:119543c9f674 166 HAL_ADC_STATE_EOC = 0x05, /*!< Conversion is completed */
mbed_official 489:119543c9f674 167 HAL_ADC_STATE_EOC_REG = 0x15, /*!< Regular conversion is completed */
mbed_official 489:119543c9f674 168 HAL_ADC_STATE_EOC_INJ = 0x25, /*!< Injected conversion is completed */
mbed_official 489:119543c9f674 169 HAL_ADC_STATE_EOC_INJ_REG = 0x35, /*!< Injected and regular conversion are completed */
mbed_official 489:119543c9f674 170 HAL_ADC_STATE_AWD = 0x06, /*!< ADC state analog watchdog */
mbed_official 489:119543c9f674 171 HAL_ADC_STATE_AWD2 = 0x07, /*!< Not used on STM32F1xx devices (kept for compatibility with other devices featuring several AWD) */
mbed_official 489:119543c9f674 172 HAL_ADC_STATE_AWD3 = 0x08, /*!< Not used on STM32F1xx devices (kept for compatibility with other devices featuring several AWD) */
mbed_official 489:119543c9f674 173 }HAL_ADC_StateTypeDef;
mbed_official 489:119543c9f674 174
mbed_official 489:119543c9f674 175 /**
mbed_official 489:119543c9f674 176 * @brief ADC handle Structure definition
mbed_official 489:119543c9f674 177 */
mbed_official 489:119543c9f674 178 typedef struct
mbed_official 489:119543c9f674 179 {
mbed_official 489:119543c9f674 180 ADC_TypeDef *Instance; /*!< Register base address */
mbed_official 489:119543c9f674 181
mbed_official 489:119543c9f674 182 ADC_InitTypeDef Init; /*!< ADC required parameters */
mbed_official 489:119543c9f674 183
mbed_official 489:119543c9f674 184 __IO uint32_t NbrOfConversionRank ; /*!< ADC conversion rank counter */
mbed_official 489:119543c9f674 185
mbed_official 489:119543c9f674 186 DMA_HandleTypeDef *DMA_Handle; /*!< Pointer DMA Handler */
mbed_official 489:119543c9f674 187
mbed_official 489:119543c9f674 188 HAL_LockTypeDef Lock; /*!< ADC locking object */
mbed_official 489:119543c9f674 189
mbed_official 489:119543c9f674 190 __IO HAL_ADC_StateTypeDef State; /*!< ADC communication state */
mbed_official 489:119543c9f674 191
mbed_official 489:119543c9f674 192 __IO uint32_t ErrorCode; /*!< ADC Error code */
mbed_official 489:119543c9f674 193 }ADC_HandleTypeDef;
mbed_official 489:119543c9f674 194 /**
mbed_official 489:119543c9f674 195 * @}
mbed_official 489:119543c9f674 196 */
mbed_official 489:119543c9f674 197
mbed_official 489:119543c9f674 198
mbed_official 489:119543c9f674 199
mbed_official 489:119543c9f674 200 /* Exported constants --------------------------------------------------------*/
mbed_official 489:119543c9f674 201
mbed_official 489:119543c9f674 202 /** @defgroup ADC_Exported_Constants ADC Exported Constants
mbed_official 489:119543c9f674 203 * @{
mbed_official 489:119543c9f674 204 */
mbed_official 489:119543c9f674 205
mbed_official 489:119543c9f674 206 /** @defgroup ADC_Error_Code ADC Error Code
mbed_official 489:119543c9f674 207 * @{
mbed_official 489:119543c9f674 208 */
mbed_official 489:119543c9f674 209 #define HAL_ADC_ERROR_NONE ((uint32_t)0x00) /*!< No error */
mbed_official 489:119543c9f674 210 #define HAL_ADC_ERROR_INTERNAL ((uint32_t)0x01) /*!< ADC IP internal error: if problem of clocking,
mbed_official 489:119543c9f674 211 enable/disable, erroneous state */
mbed_official 489:119543c9f674 212 #define HAL_ADC_ERROR_OVR ((uint32_t)0x02) /*!< Overrun error */
mbed_official 489:119543c9f674 213 #define HAL_ADC_ERROR_DMA ((uint32_t)0x04) /*!< DMA transfer error */
mbed_official 489:119543c9f674 214
mbed_official 489:119543c9f674 215 /**
mbed_official 489:119543c9f674 216 * @}
mbed_official 489:119543c9f674 217 */
mbed_official 489:119543c9f674 218
mbed_official 489:119543c9f674 219
mbed_official 489:119543c9f674 220 /** @defgroup ADC_Data_align ADC data alignment
mbed_official 489:119543c9f674 221 * @{
mbed_official 489:119543c9f674 222 */
mbed_official 489:119543c9f674 223 #define ADC_DATAALIGN_RIGHT ((uint32_t)0x00000000)
mbed_official 489:119543c9f674 224 #define ADC_DATAALIGN_LEFT ((uint32_t)ADC_CR2_ALIGN)
mbed_official 489:119543c9f674 225 /**
mbed_official 489:119543c9f674 226 * @}
mbed_official 489:119543c9f674 227 */
mbed_official 489:119543c9f674 228
mbed_official 489:119543c9f674 229 /** @defgroup ADC_Scan_mode ADC scan mode
mbed_official 489:119543c9f674 230 * @{
mbed_official 489:119543c9f674 231 */
mbed_official 489:119543c9f674 232 /* Note: Scan mode values are not among binary choices ENABLE/DISABLE for */
mbed_official 489:119543c9f674 233 /* compatibility with other STM32 devices having a sequencer with */
mbed_official 489:119543c9f674 234 /* additional options. */
mbed_official 489:119543c9f674 235 #define ADC_SCAN_DISABLE ((uint32_t)0x00000000)
mbed_official 489:119543c9f674 236 #define ADC_SCAN_ENABLE ((uint32_t)ADC_CR1_SCAN)
mbed_official 489:119543c9f674 237 /**
mbed_official 489:119543c9f674 238 * @}
mbed_official 489:119543c9f674 239 */
mbed_official 489:119543c9f674 240
mbed_official 489:119543c9f674 241 /** @defgroup ADC_External_trigger_edge_Regular ADC external trigger enable for regular group
mbed_official 489:119543c9f674 242 * @{
mbed_official 489:119543c9f674 243 */
mbed_official 489:119543c9f674 244 #define ADC_EXTERNALTRIGCONVEDGE_NONE ((uint32_t)0x00000000)
mbed_official 489:119543c9f674 245 #define ADC_EXTERNALTRIGCONVEDGE_RISING ((uint32_t)ADC_CR2_EXTTRIG)
mbed_official 489:119543c9f674 246 /**
mbed_official 489:119543c9f674 247 * @}
mbed_official 489:119543c9f674 248 */
mbed_official 489:119543c9f674 249
mbed_official 489:119543c9f674 250 /** @defgroup ADC_channels ADC channels
mbed_official 489:119543c9f674 251 * @{
mbed_official 489:119543c9f674 252 */
mbed_official 489:119543c9f674 253 /* Note: Depending on devices, some channels may not be available on package */
mbed_official 489:119543c9f674 254 /* pins. Refer to device datasheet for channels availability. */
mbed_official 489:119543c9f674 255 #define ADC_CHANNEL_0 ((uint32_t)0x00000000)
mbed_official 489:119543c9f674 256 #define ADC_CHANNEL_1 ((uint32_t)( ADC_SQR3_SQ1_0))
mbed_official 489:119543c9f674 257 #define ADC_CHANNEL_2 ((uint32_t)( ADC_SQR3_SQ1_1 ))
mbed_official 489:119543c9f674 258 #define ADC_CHANNEL_3 ((uint32_t)( ADC_SQR3_SQ1_1 | ADC_SQR3_SQ1_0))
mbed_official 489:119543c9f674 259 #define ADC_CHANNEL_4 ((uint32_t)( ADC_SQR3_SQ1_2 ))
mbed_official 489:119543c9f674 260 #define ADC_CHANNEL_5 ((uint32_t)( ADC_SQR3_SQ1_2 | ADC_SQR3_SQ1_0))
mbed_official 489:119543c9f674 261 #define ADC_CHANNEL_6 ((uint32_t)( ADC_SQR3_SQ1_2 | ADC_SQR3_SQ1_1 ))
mbed_official 489:119543c9f674 262 #define ADC_CHANNEL_7 ((uint32_t)( ADC_SQR3_SQ1_2 | ADC_SQR3_SQ1_1 | ADC_SQR3_SQ1_0))
mbed_official 489:119543c9f674 263 #define ADC_CHANNEL_8 ((uint32_t)( ADC_SQR3_SQ1_3 ))
mbed_official 489:119543c9f674 264 #define ADC_CHANNEL_9 ((uint32_t)( ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_0))
mbed_official 489:119543c9f674 265 #define ADC_CHANNEL_10 ((uint32_t)( ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_1 ))
mbed_official 489:119543c9f674 266 #define ADC_CHANNEL_11 ((uint32_t)( ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_1 | ADC_SQR3_SQ1_0))
mbed_official 489:119543c9f674 267 #define ADC_CHANNEL_12 ((uint32_t)( ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_2 ))
mbed_official 489:119543c9f674 268 #define ADC_CHANNEL_13 ((uint32_t)( ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_2 | ADC_SQR3_SQ1_0))
mbed_official 489:119543c9f674 269 #define ADC_CHANNEL_14 ((uint32_t)( ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_2 | ADC_SQR3_SQ1_1 ))
mbed_official 489:119543c9f674 270 #define ADC_CHANNEL_15 ((uint32_t)( ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_2 | ADC_SQR3_SQ1_1 | ADC_SQR3_SQ1_0))
mbed_official 489:119543c9f674 271 #define ADC_CHANNEL_16 ((uint32_t)(ADC_SQR3_SQ1_4 ))
mbed_official 489:119543c9f674 272 #define ADC_CHANNEL_17 ((uint32_t)(ADC_SQR3_SQ1_4 | ADC_SQR3_SQ1_0))
mbed_official 489:119543c9f674 273
mbed_official 489:119543c9f674 274 #define ADC_CHANNEL_TEMPSENSOR ADC_CHANNEL_16 /* ADC internal channel (no connection on device pin) */
mbed_official 489:119543c9f674 275 #define ADC_CHANNEL_VREFINT ADC_CHANNEL_17 /* ADC internal channel (no connection on device pin) */
mbed_official 489:119543c9f674 276 /**
mbed_official 489:119543c9f674 277 * @}
mbed_official 489:119543c9f674 278 */
mbed_official 489:119543c9f674 279
mbed_official 489:119543c9f674 280 /** @defgroup ADC_sampling_times ADC sampling times
mbed_official 489:119543c9f674 281 * @{
mbed_official 489:119543c9f674 282 */
mbed_official 489:119543c9f674 283 #define ADC_SAMPLETIME_1CYCLE_5 ((uint32_t)0x00000000) /*!< Sampling time 1.5 ADC clock cycle */
mbed_official 489:119543c9f674 284 #define ADC_SAMPLETIME_7CYCLES_5 ((uint32_t)( ADC_SMPR2_SMP0_0)) /*!< Sampling time 7.5 ADC clock cycles */
mbed_official 489:119543c9f674 285 #define ADC_SAMPLETIME_13CYCLES_5 ((uint32_t)( ADC_SMPR2_SMP0_1 )) /*!< Sampling time 13.5 ADC clock cycles */
mbed_official 489:119543c9f674 286 #define ADC_SAMPLETIME_28CYCLES_5 ((uint32_t)( ADC_SMPR2_SMP0_1 | ADC_SMPR2_SMP0_0)) /*!< Sampling time 28.5 ADC clock cycles */
mbed_official 489:119543c9f674 287 #define ADC_SAMPLETIME_41CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP0_2 )) /*!< Sampling time 41.5 ADC clock cycles */
mbed_official 489:119543c9f674 288 #define ADC_SAMPLETIME_55CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP0_2 | ADC_SMPR2_SMP0_0)) /*!< Sampling time 55.5 ADC clock cycles */
mbed_official 489:119543c9f674 289 #define ADC_SAMPLETIME_71CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP0_2 | ADC_SMPR2_SMP0_1 )) /*!< Sampling time 71.5 ADC clock cycles */
mbed_official 489:119543c9f674 290 #define ADC_SAMPLETIME_239CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP0_2 | ADC_SMPR2_SMP0_1 | ADC_SMPR2_SMP0_0)) /*!< Sampling time 239.5 ADC clock cycles */
mbed_official 489:119543c9f674 291 /**
mbed_official 489:119543c9f674 292 * @}
mbed_official 489:119543c9f674 293 */
mbed_official 489:119543c9f674 294
mbed_official 489:119543c9f674 295 /** @defgroup ADC_regular_rank ADC rank into regular group
mbed_official 489:119543c9f674 296 * @{
mbed_official 489:119543c9f674 297 */
mbed_official 489:119543c9f674 298 #define ADC_REGULAR_RANK_1 ((uint32_t)0x00000001)
mbed_official 489:119543c9f674 299 #define ADC_REGULAR_RANK_2 ((uint32_t)0x00000002)
mbed_official 489:119543c9f674 300 #define ADC_REGULAR_RANK_3 ((uint32_t)0x00000003)
mbed_official 489:119543c9f674 301 #define ADC_REGULAR_RANK_4 ((uint32_t)0x00000004)
mbed_official 489:119543c9f674 302 #define ADC_REGULAR_RANK_5 ((uint32_t)0x00000005)
mbed_official 489:119543c9f674 303 #define ADC_REGULAR_RANK_6 ((uint32_t)0x00000006)
mbed_official 489:119543c9f674 304 #define ADC_REGULAR_RANK_7 ((uint32_t)0x00000007)
mbed_official 489:119543c9f674 305 #define ADC_REGULAR_RANK_8 ((uint32_t)0x00000008)
mbed_official 489:119543c9f674 306 #define ADC_REGULAR_RANK_9 ((uint32_t)0x00000009)
mbed_official 489:119543c9f674 307 #define ADC_REGULAR_RANK_10 ((uint32_t)0x0000000A)
mbed_official 489:119543c9f674 308 #define ADC_REGULAR_RANK_11 ((uint32_t)0x0000000B)
mbed_official 489:119543c9f674 309 #define ADC_REGULAR_RANK_12 ((uint32_t)0x0000000C)
mbed_official 489:119543c9f674 310 #define ADC_REGULAR_RANK_13 ((uint32_t)0x0000000D)
mbed_official 489:119543c9f674 311 #define ADC_REGULAR_RANK_14 ((uint32_t)0x0000000E)
mbed_official 489:119543c9f674 312 #define ADC_REGULAR_RANK_15 ((uint32_t)0x0000000F)
mbed_official 489:119543c9f674 313 #define ADC_REGULAR_RANK_16 ((uint32_t)0x00000010)
mbed_official 489:119543c9f674 314 /**
mbed_official 489:119543c9f674 315 * @}
mbed_official 489:119543c9f674 316 */
mbed_official 489:119543c9f674 317
mbed_official 489:119543c9f674 318 /** @defgroup ADC_analog_watchdog_mode ADC analog watchdog mode
mbed_official 489:119543c9f674 319 * @{
mbed_official 489:119543c9f674 320 */
mbed_official 489:119543c9f674 321 #define ADC_ANALOGWATCHDOG_NONE ((uint32_t)0x00000000)
mbed_official 489:119543c9f674 322 #define ADC_ANALOGWATCHDOG_SINGLE_REG ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN))
mbed_official 489:119543c9f674 323 #define ADC_ANALOGWATCHDOG_SINGLE_INJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_JAWDEN))
mbed_official 489:119543c9f674 324 #define ADC_ANALOGWATCHDOG_SINGLE_REGINJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
mbed_official 489:119543c9f674 325 #define ADC_ANALOGWATCHDOG_ALL_REG ((uint32_t) ADC_CR1_AWDEN)
mbed_official 489:119543c9f674 326 #define ADC_ANALOGWATCHDOG_ALL_INJEC ((uint32_t) ADC_CR1_JAWDEN)
mbed_official 489:119543c9f674 327 #define ADC_ANALOGWATCHDOG_ALL_REGINJEC ((uint32_t)(ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
mbed_official 489:119543c9f674 328 /**
mbed_official 489:119543c9f674 329 * @}
mbed_official 489:119543c9f674 330 */
mbed_official 489:119543c9f674 331
mbed_official 489:119543c9f674 332 /** @defgroup ADC_conversion_group ADC conversion group
mbed_official 489:119543c9f674 333 * @{
mbed_official 489:119543c9f674 334 */
mbed_official 489:119543c9f674 335 #define ADC_REGULAR_GROUP ((uint32_t)(ADC_FLAG_EOC))
mbed_official 489:119543c9f674 336 #define ADC_INJECTED_GROUP ((uint32_t)(ADC_FLAG_JEOC))
mbed_official 489:119543c9f674 337 #define ADC_REGULAR_INJECTED_GROUP ((uint32_t)(ADC_FLAG_EOC | ADC_FLAG_JEOC))
mbed_official 489:119543c9f674 338 /**
mbed_official 489:119543c9f674 339 * @}
mbed_official 489:119543c9f674 340 */
mbed_official 489:119543c9f674 341
mbed_official 489:119543c9f674 342 /** @defgroup ADC_Event_type ADC Event type
mbed_official 489:119543c9f674 343 * @{
mbed_official 489:119543c9f674 344 */
mbed_official 489:119543c9f674 345 #define ADC_AWD_EVENT ((uint32_t)ADC_FLAG_AWD) /*!< ADC Analog watchdog event */
mbed_official 489:119543c9f674 346
mbed_official 489:119543c9f674 347 #define ADC_AWD1_EVENT ADC_AWD_EVENT /*!< ADC Analog watchdog 1 event: Alternate naming for compatibility with other STM32 devices having several analog watchdogs */
mbed_official 489:119543c9f674 348 /**
mbed_official 489:119543c9f674 349 * @}
mbed_official 489:119543c9f674 350 */
mbed_official 489:119543c9f674 351
mbed_official 489:119543c9f674 352 /** @defgroup ADC_interrupts_definition ADC interrupts definition
mbed_official 489:119543c9f674 353 * @{
mbed_official 489:119543c9f674 354 */
mbed_official 489:119543c9f674 355 #define ADC_IT_EOC ADC_CR1_EOCIE /*!< ADC End of Regular Conversion interrupt source */
mbed_official 489:119543c9f674 356 #define ADC_IT_JEOC ADC_CR1_JEOCIE /*!< ADC End of Injected Conversion interrupt source */
mbed_official 489:119543c9f674 357 #define ADC_IT_AWD ADC_CR1_AWDIE /*!< ADC Analog watchdog interrupt source */
mbed_official 489:119543c9f674 358 /**
mbed_official 489:119543c9f674 359 * @}
mbed_official 489:119543c9f674 360 */
mbed_official 489:119543c9f674 361
mbed_official 489:119543c9f674 362 /** @defgroup ADC_flags_definition ADC flags definition
mbed_official 489:119543c9f674 363 * @{
mbed_official 489:119543c9f674 364 */
mbed_official 489:119543c9f674 365 #define ADC_FLAG_STRT ADC_SR_STRT /*!< ADC Regular group start flag */
mbed_official 489:119543c9f674 366 #define ADC_FLAG_JSTRT ADC_SR_JSTRT /*!< ADC Injected group start flag */
mbed_official 489:119543c9f674 367 #define ADC_FLAG_EOC ADC_SR_EOC /*!< ADC End of Regular conversion flag */
mbed_official 489:119543c9f674 368 #define ADC_FLAG_JEOC ADC_SR_JEOC /*!< ADC End of Injected conversion flag */
mbed_official 489:119543c9f674 369 #define ADC_FLAG_AWD ADC_SR_AWD /*!< ADC Analog watchdog flag */
mbed_official 489:119543c9f674 370 /**
mbed_official 489:119543c9f674 371 * @}
mbed_official 489:119543c9f674 372 */
mbed_official 489:119543c9f674 373
mbed_official 489:119543c9f674 374
mbed_official 489:119543c9f674 375 /**
mbed_official 489:119543c9f674 376 * @}
mbed_official 489:119543c9f674 377 */
mbed_official 489:119543c9f674 378
mbed_official 489:119543c9f674 379 /* Private constants ---------------------------------------------------------*/
mbed_official 489:119543c9f674 380
mbed_official 489:119543c9f674 381 /** @addtogroup ADC_Private_Constants ADC Private Constants
mbed_official 489:119543c9f674 382 * @{
mbed_official 489:119543c9f674 383 */
mbed_official 489:119543c9f674 384
mbed_official 489:119543c9f674 385 /** @defgroup ADC_conversion_cycles ADC conversion cycles
mbed_official 489:119543c9f674 386 * @{
mbed_official 489:119543c9f674 387 */
mbed_official 489:119543c9f674 388 /* ADC conversion cycles (unit: ADC clock cycles) */
mbed_official 489:119543c9f674 389 /* (selected sampling time + conversion time of 12.5 ADC clock cycles, with */
mbed_official 489:119543c9f674 390 /* resolution 12 bits) */
mbed_official 489:119543c9f674 391 #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_1CYCLE5 ((uint32_t) 14)
mbed_official 489:119543c9f674 392 #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_7CYCLES5 ((uint32_t) 20)
mbed_official 489:119543c9f674 393 #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_13CYCLES5 ((uint32_t) 26)
mbed_official 489:119543c9f674 394 #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_28CYCLES5 ((uint32_t) 41)
mbed_official 489:119543c9f674 395 #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_41CYCLES5 ((uint32_t) 54)
mbed_official 489:119543c9f674 396 #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_55CYCLES5 ((uint32_t) 68)
mbed_official 489:119543c9f674 397 #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_71CYCLES5 ((uint32_t) 84)
mbed_official 489:119543c9f674 398 #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_239CYCLES5 ((uint32_t)252)
mbed_official 489:119543c9f674 399 /**
mbed_official 489:119543c9f674 400 * @}
mbed_official 489:119543c9f674 401 */
mbed_official 489:119543c9f674 402
mbed_official 489:119543c9f674 403 /** @defgroup ADC_sampling_times_all_channels ADC sampling times all channels
mbed_official 489:119543c9f674 404 * @{
mbed_official 489:119543c9f674 405 */
mbed_official 489:119543c9f674 406 #define ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT2 \
mbed_official 489:119543c9f674 407 (ADC_SMPR2_SMP9_2 | ADC_SMPR2_SMP8_2 | ADC_SMPR2_SMP7_2 | ADC_SMPR2_SMP6_2 | \
mbed_official 489:119543c9f674 408 ADC_SMPR2_SMP5_2 | ADC_SMPR2_SMP4_2 | ADC_SMPR2_SMP3_2 | ADC_SMPR2_SMP2_2 | \
mbed_official 489:119543c9f674 409 ADC_SMPR2_SMP1_2 | ADC_SMPR2_SMP0_2)
mbed_official 489:119543c9f674 410 #define ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT2 \
mbed_official 489:119543c9f674 411 (ADC_SMPR1_SMP17_2 | ADC_SMPR1_SMP16_2 | ADC_SMPR1_SMP15_2 | ADC_SMPR1_SMP14_2 | \
mbed_official 489:119543c9f674 412 ADC_SMPR1_SMP13_2 | ADC_SMPR1_SMP12_2 | ADC_SMPR1_SMP11_2 | ADC_SMPR1_SMP10_2 )
mbed_official 489:119543c9f674 413
mbed_official 489:119543c9f674 414 #define ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1 \
mbed_official 489:119543c9f674 415 (ADC_SMPR2_SMP9_1 | ADC_SMPR2_SMP8_1 | ADC_SMPR2_SMP7_1 | ADC_SMPR2_SMP6_1 | \
mbed_official 489:119543c9f674 416 ADC_SMPR2_SMP5_1 | ADC_SMPR2_SMP4_1 | ADC_SMPR2_SMP3_1 | ADC_SMPR2_SMP2_1 | \
mbed_official 489:119543c9f674 417 ADC_SMPR2_SMP1_1 | ADC_SMPR2_SMP0_1)
mbed_official 489:119543c9f674 418 #define ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1 \
mbed_official 489:119543c9f674 419 (ADC_SMPR1_SMP17_1 | ADC_SMPR1_SMP16_1 | ADC_SMPR1_SMP15_1 | ADC_SMPR1_SMP14_1 | \
mbed_official 489:119543c9f674 420 ADC_SMPR1_SMP13_1 | ADC_SMPR1_SMP12_1 | ADC_SMPR1_SMP11_1 | ADC_SMPR1_SMP10_1 )
mbed_official 489:119543c9f674 421
mbed_official 489:119543c9f674 422 #define ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT0 \
mbed_official 489:119543c9f674 423 (ADC_SMPR2_SMP9_0 | ADC_SMPR2_SMP8_0 | ADC_SMPR2_SMP7_0 | ADC_SMPR2_SMP6_0 | \
mbed_official 489:119543c9f674 424 ADC_SMPR2_SMP5_0 | ADC_SMPR2_SMP4_0 | ADC_SMPR2_SMP3_0 | ADC_SMPR2_SMP2_0 | \
mbed_official 489:119543c9f674 425 ADC_SMPR2_SMP1_0 | ADC_SMPR2_SMP0_0)
mbed_official 489:119543c9f674 426 #define ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0 \
mbed_official 489:119543c9f674 427 (ADC_SMPR1_SMP17_0 | ADC_SMPR1_SMP16_0 | ADC_SMPR1_SMP15_0 | ADC_SMPR1_SMP14_0 | \
mbed_official 489:119543c9f674 428 ADC_SMPR1_SMP13_0 | ADC_SMPR1_SMP12_0 | ADC_SMPR1_SMP11_0 | ADC_SMPR1_SMP10_0 )
mbed_official 489:119543c9f674 429
mbed_official 489:119543c9f674 430 #define ADC_SAMPLETIME_1CYCLE5_SMPR2ALLCHANNELS ((uint32_t)0x00000000)
mbed_official 489:119543c9f674 431 #define ADC_SAMPLETIME_7CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT0)
mbed_official 489:119543c9f674 432 #define ADC_SAMPLETIME_13CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1)
mbed_official 489:119543c9f674 433 #define ADC_SAMPLETIME_28CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1 | ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT0)
mbed_official 489:119543c9f674 434 #define ADC_SAMPLETIME_41CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT2)
mbed_official 489:119543c9f674 435 #define ADC_SAMPLETIME_55CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT2 | ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT0)
mbed_official 489:119543c9f674 436 #define ADC_SAMPLETIME_71CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT2 | ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1)
mbed_official 489:119543c9f674 437 #define ADC_SAMPLETIME_239CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT2 | ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1 | ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT0)
mbed_official 489:119543c9f674 438
mbed_official 489:119543c9f674 439 #define ADC_SAMPLETIME_1CYCLE5_SMPR1ALLCHANNELS ((uint32_t)0x00000000)
mbed_official 489:119543c9f674 440 #define ADC_SAMPLETIME_7CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0)
mbed_official 489:119543c9f674 441 #define ADC_SAMPLETIME_13CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1)
mbed_official 489:119543c9f674 442 #define ADC_SAMPLETIME_28CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1 | ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0)
mbed_official 489:119543c9f674 443 #define ADC_SAMPLETIME_41CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT2)
mbed_official 489:119543c9f674 444 #define ADC_SAMPLETIME_55CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT2 | ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0)
mbed_official 489:119543c9f674 445 #define ADC_SAMPLETIME_71CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT2 | ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1)
mbed_official 489:119543c9f674 446 #define ADC_SAMPLETIME_239CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT2 | ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1 | ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0)
mbed_official 489:119543c9f674 447 /**
mbed_official 489:119543c9f674 448 * @}
mbed_official 489:119543c9f674 449 */
mbed_official 489:119543c9f674 450
mbed_official 489:119543c9f674 451 /* Combination of all post-conversion flags bits: EOC/EOS, JEOC/JEOS, OVR, AWDx */
mbed_official 489:119543c9f674 452 #define ADC_FLAG_POSTCONV_ALL (ADC_FLAG_EOC | ADC_FLAG_JEOC | ADC_FLAG_AWD )
mbed_official 489:119543c9f674 453
mbed_official 489:119543c9f674 454 /**
mbed_official 489:119543c9f674 455 * @}
mbed_official 489:119543c9f674 456 */
mbed_official 489:119543c9f674 457
mbed_official 489:119543c9f674 458
mbed_official 489:119543c9f674 459 /* Exported macro ------------------------------------------------------------*/
mbed_official 489:119543c9f674 460
mbed_official 489:119543c9f674 461 /** @defgroup ADC_Exported_Macros ADC Exported Macros
mbed_official 489:119543c9f674 462 * @{
mbed_official 489:119543c9f674 463 */
mbed_official 489:119543c9f674 464 /* Macro for internal HAL driver usage, and possibly can be used into code of */
mbed_official 489:119543c9f674 465 /* final user. */
mbed_official 489:119543c9f674 466
mbed_official 489:119543c9f674 467 /**
mbed_official 489:119543c9f674 468 * @brief Enable the ADC peripheral
mbed_official 489:119543c9f674 469 * @note ADC enable requires a delay for ADC stabilization time
mbed_official 489:119543c9f674 470 * (refer to device datasheet, parameter tSTAB)
mbed_official 489:119543c9f674 471 * @note On STM32F1, if ADC is already enabled this macro trigs a conversion
mbed_official 489:119543c9f674 472 * SW start on regular group.
mbed_official 489:119543c9f674 473 * @param __HANDLE__: ADC handle
mbed_official 489:119543c9f674 474 * @retval None
mbed_official 489:119543c9f674 475 */
mbed_official 489:119543c9f674 476 #define __HAL_ADC_ENABLE(__HANDLE__) \
mbed_official 489:119543c9f674 477 (SET_BIT((__HANDLE__)->Instance->CR2, (ADC_CR2_ADON)))
mbed_official 489:119543c9f674 478
mbed_official 489:119543c9f674 479 /**
mbed_official 489:119543c9f674 480 * @brief Disable the ADC peripheral
mbed_official 489:119543c9f674 481 * @param __HANDLE__: ADC handle
mbed_official 489:119543c9f674 482 * @retval None
mbed_official 489:119543c9f674 483 */
mbed_official 489:119543c9f674 484 #define __HAL_ADC_DISABLE(__HANDLE__) \
mbed_official 489:119543c9f674 485 (CLEAR_BIT((__HANDLE__)->Instance->CR2, (ADC_CR2_ADON)))
mbed_official 489:119543c9f674 486
mbed_official 489:119543c9f674 487 /** @brief Enable the ADC end of conversion interrupt.
mbed_official 489:119543c9f674 488 * @param __HANDLE__: ADC handle
mbed_official 489:119543c9f674 489 * @param __INTERRUPT__: ADC Interrupt
mbed_official 489:119543c9f674 490 * This parameter can be any combination of the following values:
mbed_official 489:119543c9f674 491 * @arg ADC_IT_EOC: ADC End of Regular Conversion interrupt source
mbed_official 489:119543c9f674 492 * @arg ADC_IT_JEOC: ADC End of Injected Conversion interrupt source
mbed_official 489:119543c9f674 493 * @arg ADC_IT_AWD: ADC Analog watchdog interrupt source
mbed_official 489:119543c9f674 494 * @retval None
mbed_official 489:119543c9f674 495 */
mbed_official 489:119543c9f674 496 #define __HAL_ADC_ENABLE_IT(__HANDLE__, __INTERRUPT__) \
mbed_official 489:119543c9f674 497 (SET_BIT((__HANDLE__)->Instance->CR1, (__INTERRUPT__)))
mbed_official 489:119543c9f674 498
mbed_official 489:119543c9f674 499 /** @brief Disable the ADC end of conversion interrupt.
mbed_official 489:119543c9f674 500 * @param __HANDLE__: ADC handle
mbed_official 489:119543c9f674 501 * @param __INTERRUPT__: ADC Interrupt
mbed_official 489:119543c9f674 502 * This parameter can be any combination of the following values:
mbed_official 489:119543c9f674 503 * @arg ADC_IT_EOC: ADC End of Regular Conversion interrupt source
mbed_official 489:119543c9f674 504 * @arg ADC_IT_JEOC: ADC End of Injected Conversion interrupt source
mbed_official 489:119543c9f674 505 * @arg ADC_IT_AWD: ADC Analog watchdog interrupt source
mbed_official 489:119543c9f674 506 * @retval None
mbed_official 489:119543c9f674 507 */
mbed_official 489:119543c9f674 508 #define __HAL_ADC_DISABLE_IT(__HANDLE__, __INTERRUPT__) \
mbed_official 489:119543c9f674 509 (CLEAR_BIT((__HANDLE__)->Instance->CR1, (__INTERRUPT__)))
mbed_official 489:119543c9f674 510
mbed_official 489:119543c9f674 511 /** @brief Checks if the specified ADC interrupt source is enabled or disabled.
mbed_official 489:119543c9f674 512 * @param __HANDLE__: ADC handle
mbed_official 489:119543c9f674 513 * @param __INTERRUPT__: ADC interrupt source to check
mbed_official 489:119543c9f674 514 * This parameter can be any combination of the following values:
mbed_official 489:119543c9f674 515 * @arg ADC_IT_EOC: ADC End of Regular Conversion interrupt source
mbed_official 489:119543c9f674 516 * @arg ADC_IT_JEOC: ADC End of Injected Conversion interrupt source
mbed_official 489:119543c9f674 517 * @arg ADC_IT_AWD: ADC Analog watchdog interrupt source
mbed_official 489:119543c9f674 518 * @retval None
mbed_official 489:119543c9f674 519 */
mbed_official 489:119543c9f674 520 #define __HAL_ADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \
mbed_official 489:119543c9f674 521 (((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__))
mbed_official 489:119543c9f674 522
mbed_official 489:119543c9f674 523 /** @brief Get the selected ADC's flag status.
mbed_official 489:119543c9f674 524 * @param __HANDLE__: ADC handle
mbed_official 489:119543c9f674 525 * @param __FLAG__: ADC flag
mbed_official 489:119543c9f674 526 * This parameter can be any combination of the following values:
mbed_official 489:119543c9f674 527 * @arg ADC_FLAG_STRT: ADC Regular group start flag
mbed_official 489:119543c9f674 528 * @arg ADC_FLAG_JSTRT: ADC Injected group start flag
mbed_official 489:119543c9f674 529 * @arg ADC_FLAG_EOC: ADC End of Regular conversion flag
mbed_official 489:119543c9f674 530 * @arg ADC_FLAG_JEOC: ADC End of Injected conversion flag
mbed_official 489:119543c9f674 531 * @arg ADC_FLAG_AWD: ADC Analog watchdog flag
mbed_official 489:119543c9f674 532 * @retval None
mbed_official 489:119543c9f674 533 */
mbed_official 489:119543c9f674 534 #define __HAL_ADC_GET_FLAG(__HANDLE__, __FLAG__) \
mbed_official 489:119543c9f674 535 ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
mbed_official 489:119543c9f674 536
mbed_official 489:119543c9f674 537 /** @brief Clear the ADC's pending flags
mbed_official 489:119543c9f674 538 * @param __HANDLE__: ADC handle
mbed_official 489:119543c9f674 539 * @param __FLAG__: ADC flag
mbed_official 489:119543c9f674 540 * This parameter can be any combination of the following values:
mbed_official 489:119543c9f674 541 * @arg ADC_FLAG_STRT: ADC Regular group start flag
mbed_official 489:119543c9f674 542 * @arg ADC_FLAG_JSTRT: ADC Injected group start flag
mbed_official 489:119543c9f674 543 * @arg ADC_FLAG_EOC: ADC End of Regular conversion flag
mbed_official 489:119543c9f674 544 * @arg ADC_FLAG_JEOC: ADC End of Injected conversion flag
mbed_official 489:119543c9f674 545 * @arg ADC_FLAG_AWD: ADC Analog watchdog flag
mbed_official 489:119543c9f674 546 * @retval None
mbed_official 489:119543c9f674 547 */
mbed_official 489:119543c9f674 548 #define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__) \
mbed_official 489:119543c9f674 549 (CLEAR_BIT((__HANDLE__)->Instance->SR, (__FLAG__)))
mbed_official 489:119543c9f674 550
mbed_official 489:119543c9f674 551 /** @brief Reset ADC handle state
mbed_official 489:119543c9f674 552 * @param __HANDLE__: ADC handle
mbed_official 489:119543c9f674 553 * @retval None
mbed_official 489:119543c9f674 554 */
mbed_official 489:119543c9f674 555 #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) \
mbed_official 489:119543c9f674 556 ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
mbed_official 489:119543c9f674 557
mbed_official 489:119543c9f674 558 /**
mbed_official 489:119543c9f674 559 * @}
mbed_official 489:119543c9f674 560 */
mbed_official 489:119543c9f674 561
mbed_official 489:119543c9f674 562 /* Private macro ------------------------------------------------------------*/
mbed_official 489:119543c9f674 563
mbed_official 489:119543c9f674 564 /** @defgroup ADC_Private_Macros ADC Private Macros
mbed_official 489:119543c9f674 565 * @{
mbed_official 489:119543c9f674 566 */
mbed_official 489:119543c9f674 567 /* Macro reserved for internal HAL driver usage, not intended to be used in */
mbed_official 489:119543c9f674 568 /* code of final user. */
mbed_official 489:119543c9f674 569
mbed_official 489:119543c9f674 570 /**
mbed_official 489:119543c9f674 571 * @brief Verification of ADC state: enabled or disabled
mbed_official 489:119543c9f674 572 * @param __HANDLE__: ADC handle
mbed_official 489:119543c9f674 573 * @retval SET (ADC enabled) or RESET (ADC disabled)
mbed_official 489:119543c9f674 574 */
mbed_official 489:119543c9f674 575 #define ADC_IS_ENABLE(__HANDLE__) \
mbed_official 489:119543c9f674 576 ((( ((__HANDLE__)->Instance->CR2 & ADC_CR2_ADON) == ADC_CR2_ADON ) \
mbed_official 489:119543c9f674 577 ) ? SET : RESET)
mbed_official 489:119543c9f674 578
mbed_official 489:119543c9f674 579 /**
mbed_official 489:119543c9f674 580 * @brief Test if conversion trigger of regular group is software start
mbed_official 489:119543c9f674 581 * or external trigger.
mbed_official 489:119543c9f674 582 * @param __HANDLE__: ADC handle
mbed_official 489:119543c9f674 583 * @retval SET (software start) or RESET (external trigger)
mbed_official 489:119543c9f674 584 */
mbed_official 489:119543c9f674 585 #define ADC_IS_SOFTWARE_START_REGULAR(__HANDLE__) \
mbed_official 489:119543c9f674 586 (READ_BIT((__HANDLE__)->Instance->CR2, ADC_CR2_EXTSEL) == ADC_SOFTWARE_START)
mbed_official 489:119543c9f674 587
mbed_official 489:119543c9f674 588 /**
mbed_official 489:119543c9f674 589 * @brief Test if conversion trigger of injected group is software start
mbed_official 489:119543c9f674 590 * or external trigger.
mbed_official 489:119543c9f674 591 * @param __HANDLE__: ADC handle
mbed_official 489:119543c9f674 592 * @retval SET (software start) or RESET (external trigger)
mbed_official 489:119543c9f674 593 */
mbed_official 489:119543c9f674 594 #define ADC_IS_SOFTWARE_START_INJECTED(__HANDLE__) \
mbed_official 489:119543c9f674 595 (READ_BIT((__HANDLE__)->Instance->CR2, ADC_CR2_JEXTSEL) == ADC_INJECTED_SOFTWARE_START)
mbed_official 489:119543c9f674 596
mbed_official 489:119543c9f674 597 /**
mbed_official 489:119543c9f674 598 * @brief Clear ADC error code (set it to error code: "no error")
mbed_official 489:119543c9f674 599 * @param __HANDLE__: ADC handle
mbed_official 489:119543c9f674 600 * @retval None
mbed_official 489:119543c9f674 601 */
mbed_official 489:119543c9f674 602 #define ADC_CLEAR_ERRORCODE(__HANDLE__) \
mbed_official 489:119543c9f674 603 ((__HANDLE__)->ErrorCode = HAL_ADC_ERROR_NONE)
mbed_official 489:119543c9f674 604
mbed_official 489:119543c9f674 605 /**
mbed_official 489:119543c9f674 606 * @brief Set ADC number of conversions into regular channel sequence length.
mbed_official 489:119543c9f674 607 * @param _NbrOfConversion_: Regular channel sequence length
mbed_official 489:119543c9f674 608 * @retval None
mbed_official 489:119543c9f674 609 */
mbed_official 489:119543c9f674 610 #define ADC_SQR1_L_SHIFT(_NbrOfConversion_) \
mbed_official 489:119543c9f674 611 (((_NbrOfConversion_) - (uint8_t)1) << POSITION_VAL(ADC_SQR1_L))
mbed_official 489:119543c9f674 612
mbed_official 489:119543c9f674 613 /**
mbed_official 489:119543c9f674 614 * @brief Set the ADC's sample time for channel numbers between 10 and 18.
mbed_official 489:119543c9f674 615 * @param _SAMPLETIME_: Sample time parameter.
mbed_official 489:119543c9f674 616 * @param _CHANNELNB_: Channel number.
mbed_official 489:119543c9f674 617 * @retval None
mbed_official 489:119543c9f674 618 */
mbed_official 489:119543c9f674 619 #define ADC_SMPR1(_SAMPLETIME_, _CHANNELNB_) \
mbed_official 489:119543c9f674 620 ((_SAMPLETIME_) << (POSITION_VAL(ADC_SMPR1_SMP11) * ((_CHANNELNB_) - 10)))
mbed_official 489:119543c9f674 621
mbed_official 489:119543c9f674 622 /**
mbed_official 489:119543c9f674 623 * @brief Set the ADC's sample time for channel numbers between 0 and 9.
mbed_official 489:119543c9f674 624 * @param _SAMPLETIME_: Sample time parameter.
mbed_official 489:119543c9f674 625 * @param _CHANNELNB_: Channel number.
mbed_official 489:119543c9f674 626 * @retval None
mbed_official 489:119543c9f674 627 */
mbed_official 489:119543c9f674 628 #define ADC_SMPR2(_SAMPLETIME_, _CHANNELNB_) \
mbed_official 489:119543c9f674 629 ((_SAMPLETIME_) << (POSITION_VAL(ADC_SMPR2_SMP1) * (_CHANNELNB_)))
mbed_official 489:119543c9f674 630
mbed_official 489:119543c9f674 631 /**
mbed_official 489:119543c9f674 632 * @brief Set the selected regular channel rank for rank between 1 and 6.
mbed_official 489:119543c9f674 633 * @param _CHANNELNB_: Channel number.
mbed_official 489:119543c9f674 634 * @param _RANKNB_: Rank number.
mbed_official 489:119543c9f674 635 * @retval None
mbed_official 489:119543c9f674 636 */
mbed_official 489:119543c9f674 637 #define ADC_SQR3_RK(_CHANNELNB_, _RANKNB_) \
mbed_official 489:119543c9f674 638 ((_CHANNELNB_) << (POSITION_VAL(ADC_SQR3_SQ2) * ((_RANKNB_) - 1)))
mbed_official 489:119543c9f674 639
mbed_official 489:119543c9f674 640 /**
mbed_official 489:119543c9f674 641 * @brief Set the selected regular channel rank for rank between 7 and 12.
mbed_official 489:119543c9f674 642 * @param _CHANNELNB_: Channel number.
mbed_official 489:119543c9f674 643 * @param _RANKNB_: Rank number.
mbed_official 489:119543c9f674 644 * @retval None
mbed_official 489:119543c9f674 645 */
mbed_official 489:119543c9f674 646 #define ADC_SQR2_RK(_CHANNELNB_, _RANKNB_) \
mbed_official 489:119543c9f674 647 ((_CHANNELNB_) << (POSITION_VAL(ADC_SQR2_SQ8) * ((_RANKNB_) - 7)))
mbed_official 489:119543c9f674 648
mbed_official 489:119543c9f674 649 /**
mbed_official 489:119543c9f674 650 * @brief Set the selected regular channel rank for rank between 13 and 16.
mbed_official 489:119543c9f674 651 * @param _CHANNELNB_: Channel number.
mbed_official 489:119543c9f674 652 * @param _RANKNB_: Rank number.
mbed_official 489:119543c9f674 653 * @retval None
mbed_official 489:119543c9f674 654 */
mbed_official 489:119543c9f674 655 #define ADC_SQR1_RK(_CHANNELNB_, _RANKNB_) \
mbed_official 489:119543c9f674 656 ((_CHANNELNB_) << (POSITION_VAL(ADC_SQR1_SQ14) * ((_RANKNB_) - 13)))
mbed_official 489:119543c9f674 657
mbed_official 489:119543c9f674 658 /**
mbed_official 489:119543c9f674 659 * @brief Set the injected sequence length.
mbed_official 489:119543c9f674 660 * @param _JSQR_JL_: Sequence length.
mbed_official 489:119543c9f674 661 * @retval None
mbed_official 489:119543c9f674 662 */
mbed_official 489:119543c9f674 663 #define ADC_JSQR_JL_SHIFT(_JSQR_JL_) \
mbed_official 489:119543c9f674 664 (((_JSQR_JL_) -1) << POSITION_VAL(ADC_JSQR_JL))
mbed_official 489:119543c9f674 665
mbed_official 489:119543c9f674 666 /**
mbed_official 489:119543c9f674 667 * @brief Set the selected injected channel rank
mbed_official 489:119543c9f674 668 * Note: on STM32F1 devices, channel rank position in JSQR register
mbed_official 489:119543c9f674 669 * is depending on total number of ranks selected into
mbed_official 489:119543c9f674 670 * injected sequencer (ranks sequence starting from 4-JL)
mbed_official 489:119543c9f674 671 * @param _CHANNELNB_: Channel number.
mbed_official 489:119543c9f674 672 * @param _RANKNB_: Rank number.
mbed_official 489:119543c9f674 673 * @param _JSQR_JL_: Sequence length.
mbed_official 489:119543c9f674 674 * @retval None
mbed_official 489:119543c9f674 675 */
mbed_official 489:119543c9f674 676 #define ADC_JSQR_RK_JL(_CHANNELNB_, _RANKNB_, _JSQR_JL_) \
mbed_official 489:119543c9f674 677 ((_CHANNELNB_) << (POSITION_VAL(ADC_JSQR_JSQ2) * ((4 - ((_JSQR_JL_) - (_RANKNB_))) - 1)))
mbed_official 489:119543c9f674 678
mbed_official 489:119543c9f674 679 /**
mbed_official 489:119543c9f674 680 * @brief Enable ADC continuous conversion mode.
mbed_official 489:119543c9f674 681 * @param _CONTINUOUS_MODE_: Continuous mode.
mbed_official 489:119543c9f674 682 * @retval None
mbed_official 489:119543c9f674 683 */
mbed_official 489:119543c9f674 684 #define ADC_CR2_CONTINUOUS(_CONTINUOUS_MODE_) \
mbed_official 489:119543c9f674 685 ((_CONTINUOUS_MODE_) << POSITION_VAL(ADC_CR2_CONT))
mbed_official 489:119543c9f674 686
mbed_official 489:119543c9f674 687 /**
mbed_official 489:119543c9f674 688 * @brief Configures the number of discontinuous conversions for the regular group channels.
mbed_official 489:119543c9f674 689 * @param _NBR_DISCONTINUOUS_CONV_: Number of discontinuous conversions.
mbed_official 489:119543c9f674 690 * @retval None
mbed_official 489:119543c9f674 691 */
mbed_official 489:119543c9f674 692 #define ADC_CR1_DISCONTINUOUS_NUM(_NBR_DISCONTINUOUS_CONV_) \
mbed_official 489:119543c9f674 693 (((_NBR_DISCONTINUOUS_CONV_) - 1) << POSITION_VAL(ADC_CR1_DISCNUM))
mbed_official 489:119543c9f674 694
mbed_official 489:119543c9f674 695 /**
mbed_official 489:119543c9f674 696 * @brief Enable ADC scan mode to convert multiple ranks with sequencer.
mbed_official 489:119543c9f674 697 * @param _SCAN_MODE_: Scan conversion mode.
mbed_official 489:119543c9f674 698 * @retval None
mbed_official 489:119543c9f674 699 */
mbed_official 489:119543c9f674 700 /* Note: Scan mode is compared to ENABLE for legacy purpose, this parameter */
mbed_official 489:119543c9f674 701 /* is equivalent to ADC_SCAN_ENABLE. */
mbed_official 489:119543c9f674 702 #define ADC_CR1_SCAN_SET(_SCAN_MODE_) \
mbed_official 489:119543c9f674 703 (( ((_SCAN_MODE_) == ADC_SCAN_ENABLE) || ((_SCAN_MODE_) == ENABLE) \
mbed_official 489:119543c9f674 704 )? (ADC_SCAN_ENABLE) : (ADC_SCAN_DISABLE) \
mbed_official 489:119543c9f674 705 )
mbed_official 489:119543c9f674 706
mbed_official 489:119543c9f674 707 /**
mbed_official 489:119543c9f674 708 * @brief Get the maximum ADC conversion cycles on all channels.
mbed_official 489:119543c9f674 709 * Returns the selected sampling time + conversion time (12.5 ADC clock cycles)
mbed_official 489:119543c9f674 710 * Approximation of sampling time within 4 ranges, returns the highest value:
mbed_official 489:119543c9f674 711 * below 7.5 cycles {1.5 cycle; 7.5 cycles},
mbed_official 489:119543c9f674 712 * between 13.5 cycles and 28.5 cycles {13.5 cycles; 28.5 cycles}
mbed_official 489:119543c9f674 713 * between 41.5 cycles and 71.5 cycles {41.5 cycles; 55.5 cycles; 71.5cycles}
mbed_official 489:119543c9f674 714 * equal to 239.5 cycles
mbed_official 489:119543c9f674 715 * Unit: ADC clock cycles
mbed_official 489:119543c9f674 716 * @param __HANDLE__: ADC handle
mbed_official 489:119543c9f674 717 * @retval ADC conversion cycles on all channels
mbed_official 489:119543c9f674 718 */
mbed_official 489:119543c9f674 719 #define ADC_CONVCYCLES_MAX_RANGE(__HANDLE__) \
mbed_official 489:119543c9f674 720 (( (((__HANDLE__)->Instance->SMPR2 & ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT2) == RESET) && \
mbed_official 489:119543c9f674 721 (((__HANDLE__)->Instance->SMPR1 & ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT2) == RESET) ) ? \
mbed_official 489:119543c9f674 722 \
mbed_official 489:119543c9f674 723 (( (((__HANDLE__)->Instance->SMPR2 & ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1) == RESET) && \
mbed_official 489:119543c9f674 724 (((__HANDLE__)->Instance->SMPR1 & ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1) == RESET) ) ? \
mbed_official 489:119543c9f674 725 ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_7CYCLES5 : ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_28CYCLES5) \
mbed_official 489:119543c9f674 726 : \
mbed_official 489:119543c9f674 727 ((((((__HANDLE__)->Instance->SMPR2 & ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1) == RESET) && \
mbed_official 489:119543c9f674 728 (((__HANDLE__)->Instance->SMPR1 & ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1) == RESET)) || \
mbed_official 489:119543c9f674 729 ((((__HANDLE__)->Instance->SMPR2 & ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0) == RESET) && \
mbed_official 489:119543c9f674 730 (((__HANDLE__)->Instance->SMPR1 & ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0) == RESET))) ? \
mbed_official 489:119543c9f674 731 ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_71CYCLES5 : ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_239CYCLES5) \
mbed_official 489:119543c9f674 732 )
mbed_official 489:119543c9f674 733
mbed_official 489:119543c9f674 734 #define IS_ADC_DATA_ALIGN(ALIGN) (((ALIGN) == ADC_DATAALIGN_RIGHT) || \
mbed_official 489:119543c9f674 735 ((ALIGN) == ADC_DATAALIGN_LEFT) )
mbed_official 489:119543c9f674 736
mbed_official 489:119543c9f674 737 #define IS_ADC_SCAN_MODE(SCAN_MODE) (((SCAN_MODE) == ADC_SCAN_DISABLE) || \
mbed_official 489:119543c9f674 738 ((SCAN_MODE) == ADC_SCAN_ENABLE) )
mbed_official 489:119543c9f674 739
mbed_official 489:119543c9f674 740 #define IS_ADC_EXTTRIG_EDGE(EDGE) (((EDGE) == ADC_EXTERNALTRIGCONVEDGE_NONE) || \
mbed_official 489:119543c9f674 741 ((EDGE) == ADC_EXTERNALTRIGCONVEDGE_RISING) )
mbed_official 489:119543c9f674 742
mbed_official 489:119543c9f674 743 #define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) == ADC_CHANNEL_0) || \
mbed_official 489:119543c9f674 744 ((CHANNEL) == ADC_CHANNEL_1) || \
mbed_official 489:119543c9f674 745 ((CHANNEL) == ADC_CHANNEL_2) || \
mbed_official 489:119543c9f674 746 ((CHANNEL) == ADC_CHANNEL_3) || \
mbed_official 489:119543c9f674 747 ((CHANNEL) == ADC_CHANNEL_4) || \
mbed_official 489:119543c9f674 748 ((CHANNEL) == ADC_CHANNEL_5) || \
mbed_official 489:119543c9f674 749 ((CHANNEL) == ADC_CHANNEL_6) || \
mbed_official 489:119543c9f674 750 ((CHANNEL) == ADC_CHANNEL_7) || \
mbed_official 489:119543c9f674 751 ((CHANNEL) == ADC_CHANNEL_8) || \
mbed_official 489:119543c9f674 752 ((CHANNEL) == ADC_CHANNEL_9) || \
mbed_official 489:119543c9f674 753 ((CHANNEL) == ADC_CHANNEL_10) || \
mbed_official 489:119543c9f674 754 ((CHANNEL) == ADC_CHANNEL_11) || \
mbed_official 489:119543c9f674 755 ((CHANNEL) == ADC_CHANNEL_12) || \
mbed_official 489:119543c9f674 756 ((CHANNEL) == ADC_CHANNEL_13) || \
mbed_official 489:119543c9f674 757 ((CHANNEL) == ADC_CHANNEL_14) || \
mbed_official 489:119543c9f674 758 ((CHANNEL) == ADC_CHANNEL_15) || \
mbed_official 489:119543c9f674 759 ((CHANNEL) == ADC_CHANNEL_16) || \
mbed_official 489:119543c9f674 760 ((CHANNEL) == ADC_CHANNEL_17) )
mbed_official 489:119543c9f674 761
mbed_official 489:119543c9f674 762 #define IS_ADC_SAMPLE_TIME(TIME) (((TIME) == ADC_SAMPLETIME_1CYCLE_5) || \
mbed_official 489:119543c9f674 763 ((TIME) == ADC_SAMPLETIME_7CYCLES_5) || \
mbed_official 489:119543c9f674 764 ((TIME) == ADC_SAMPLETIME_13CYCLES_5) || \
mbed_official 489:119543c9f674 765 ((TIME) == ADC_SAMPLETIME_28CYCLES_5) || \
mbed_official 489:119543c9f674 766 ((TIME) == ADC_SAMPLETIME_41CYCLES_5) || \
mbed_official 489:119543c9f674 767 ((TIME) == ADC_SAMPLETIME_55CYCLES_5) || \
mbed_official 489:119543c9f674 768 ((TIME) == ADC_SAMPLETIME_71CYCLES_5) || \
mbed_official 489:119543c9f674 769 ((TIME) == ADC_SAMPLETIME_239CYCLES_5) )
mbed_official 489:119543c9f674 770
mbed_official 489:119543c9f674 771 #define IS_ADC_REGULAR_RANK(CHANNEL) (((CHANNEL) == ADC_REGULAR_RANK_1 ) || \
mbed_official 489:119543c9f674 772 ((CHANNEL) == ADC_REGULAR_RANK_2 ) || \
mbed_official 489:119543c9f674 773 ((CHANNEL) == ADC_REGULAR_RANK_3 ) || \
mbed_official 489:119543c9f674 774 ((CHANNEL) == ADC_REGULAR_RANK_4 ) || \
mbed_official 489:119543c9f674 775 ((CHANNEL) == ADC_REGULAR_RANK_5 ) || \
mbed_official 489:119543c9f674 776 ((CHANNEL) == ADC_REGULAR_RANK_6 ) || \
mbed_official 489:119543c9f674 777 ((CHANNEL) == ADC_REGULAR_RANK_7 ) || \
mbed_official 489:119543c9f674 778 ((CHANNEL) == ADC_REGULAR_RANK_8 ) || \
mbed_official 489:119543c9f674 779 ((CHANNEL) == ADC_REGULAR_RANK_9 ) || \
mbed_official 489:119543c9f674 780 ((CHANNEL) == ADC_REGULAR_RANK_10) || \
mbed_official 489:119543c9f674 781 ((CHANNEL) == ADC_REGULAR_RANK_11) || \
mbed_official 489:119543c9f674 782 ((CHANNEL) == ADC_REGULAR_RANK_12) || \
mbed_official 489:119543c9f674 783 ((CHANNEL) == ADC_REGULAR_RANK_13) || \
mbed_official 489:119543c9f674 784 ((CHANNEL) == ADC_REGULAR_RANK_14) || \
mbed_official 489:119543c9f674 785 ((CHANNEL) == ADC_REGULAR_RANK_15) || \
mbed_official 489:119543c9f674 786 ((CHANNEL) == ADC_REGULAR_RANK_16) )
mbed_official 489:119543c9f674 787
mbed_official 489:119543c9f674 788 #define IS_ADC_ANALOG_WATCHDOG_MODE(WATCHDOG) (((WATCHDOG) == ADC_ANALOGWATCHDOG_NONE) || \
mbed_official 489:119543c9f674 789 ((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_REG) || \
mbed_official 489:119543c9f674 790 ((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_INJEC) || \
mbed_official 489:119543c9f674 791 ((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC) || \
mbed_official 489:119543c9f674 792 ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_REG) || \
mbed_official 489:119543c9f674 793 ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_INJEC) || \
mbed_official 489:119543c9f674 794 ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_REGINJEC) )
mbed_official 489:119543c9f674 795
mbed_official 489:119543c9f674 796 #define IS_ADC_CONVERSION_GROUP(CONVERSION) (((CONVERSION) == ADC_REGULAR_GROUP) || \
mbed_official 489:119543c9f674 797 ((CONVERSION) == ADC_INJECTED_GROUP) || \
mbed_official 489:119543c9f674 798 ((CONVERSION) == ADC_REGULAR_INJECTED_GROUP) )
mbed_official 489:119543c9f674 799
mbed_official 489:119543c9f674 800 #define IS_ADC_EVENT_TYPE(EVENT) ((EVENT) == ADC_AWD_EVENT)
mbed_official 489:119543c9f674 801
mbed_official 489:119543c9f674 802
mbed_official 489:119543c9f674 803 /** @defgroup ADC_range_verification ADC range verification
mbed_official 489:119543c9f674 804 * For a unique ADC resolution: 12 bits
mbed_official 489:119543c9f674 805 * @{
mbed_official 489:119543c9f674 806 */
mbed_official 489:119543c9f674 807 #define IS_ADC_RANGE(ADC_VALUE) ((ADC_VALUE) <= ((uint32_t)0x0FFF))
mbed_official 489:119543c9f674 808 /**
mbed_official 489:119543c9f674 809 * @}
mbed_official 489:119543c9f674 810 */
mbed_official 489:119543c9f674 811
mbed_official 489:119543c9f674 812 /** @defgroup ADC_regular_nb_conv_verification ADC regular nb conv verification
mbed_official 489:119543c9f674 813 * @{
mbed_official 489:119543c9f674 814 */
mbed_official 489:119543c9f674 815 #define IS_ADC_REGULAR_NB_CONV(LENGTH) (((LENGTH) >= ((uint32_t)1)) && ((LENGTH) <= ((uint32_t)16)))
mbed_official 489:119543c9f674 816 /**
mbed_official 489:119543c9f674 817 * @}
mbed_official 489:119543c9f674 818 */
mbed_official 489:119543c9f674 819
mbed_official 489:119543c9f674 820 /** @defgroup ADC_regular_discontinuous_mode_number_verification ADC regular discontinuous mode number verification
mbed_official 489:119543c9f674 821 * @{
mbed_official 489:119543c9f674 822 */
mbed_official 489:119543c9f674 823 #define IS_ADC_REGULAR_DISCONT_NUMBER(NUMBER) (((NUMBER) >= ((uint32_t)1)) && ((NUMBER) <= ((uint32_t)8)))
mbed_official 489:119543c9f674 824 /**
mbed_official 489:119543c9f674 825 * @}
mbed_official 489:119543c9f674 826 */
mbed_official 489:119543c9f674 827
mbed_official 489:119543c9f674 828 /**
mbed_official 489:119543c9f674 829 * @}
mbed_official 489:119543c9f674 830 */
mbed_official 489:119543c9f674 831
mbed_official 489:119543c9f674 832 /* Include ADC HAL Extension module */
mbed_official 489:119543c9f674 833 #include "stm32f1xx_hal_adc_ex.h"
mbed_official 489:119543c9f674 834
mbed_official 489:119543c9f674 835 /* Exported functions --------------------------------------------------------*/
mbed_official 489:119543c9f674 836 /** @addtogroup ADC_Exported_Functions
mbed_official 489:119543c9f674 837 * @{
mbed_official 489:119543c9f674 838 */
mbed_official 489:119543c9f674 839
mbed_official 489:119543c9f674 840 /** @addtogroup ADC_Exported_Functions_Group1
mbed_official 489:119543c9f674 841 * @{
mbed_official 489:119543c9f674 842 */
mbed_official 489:119543c9f674 843
mbed_official 489:119543c9f674 844
mbed_official 489:119543c9f674 845 /* Initialization and de-initialization functions **********************************/
mbed_official 489:119543c9f674 846 HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc);
mbed_official 489:119543c9f674 847 HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
mbed_official 489:119543c9f674 848 void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
mbed_official 489:119543c9f674 849 void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
mbed_official 489:119543c9f674 850 /**
mbed_official 489:119543c9f674 851 * @}
mbed_official 489:119543c9f674 852 */
mbed_official 489:119543c9f674 853
mbed_official 489:119543c9f674 854 /* IO operation functions *****************************************************/
mbed_official 489:119543c9f674 855
mbed_official 489:119543c9f674 856 /** @addtogroup ADC_Exported_Functions_Group2
mbed_official 489:119543c9f674 857 * @{
mbed_official 489:119543c9f674 858 */
mbed_official 489:119543c9f674 859
mbed_official 489:119543c9f674 860
mbed_official 489:119543c9f674 861 /* Blocking mode: Polling */
mbed_official 489:119543c9f674 862 HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc);
mbed_official 489:119543c9f674 863 HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc);
mbed_official 489:119543c9f674 864 HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
mbed_official 489:119543c9f674 865 HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout);
mbed_official 489:119543c9f674 866
mbed_official 489:119543c9f674 867 /* Non-blocking mode: Interruption */
mbed_official 489:119543c9f674 868 HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc);
mbed_official 489:119543c9f674 869 HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc);
mbed_official 489:119543c9f674 870
mbed_official 489:119543c9f674 871 /* Non-blocking mode: DMA */
mbed_official 489:119543c9f674 872 HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length);
mbed_official 489:119543c9f674 873 HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc);
mbed_official 489:119543c9f674 874
mbed_official 489:119543c9f674 875 /* ADC retrieve conversion value intended to be used with polling or interruption */
mbed_official 489:119543c9f674 876 uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc);
mbed_official 489:119543c9f674 877
mbed_official 489:119543c9f674 878 /* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption and DMA) */
mbed_official 489:119543c9f674 879 void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc);
mbed_official 489:119543c9f674 880 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc);
mbed_official 489:119543c9f674 881 void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc);
mbed_official 489:119543c9f674 882 void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc);
mbed_official 489:119543c9f674 883 void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
mbed_official 489:119543c9f674 884 /**
mbed_official 489:119543c9f674 885 * @}
mbed_official 489:119543c9f674 886 */
mbed_official 489:119543c9f674 887
mbed_official 489:119543c9f674 888
mbed_official 489:119543c9f674 889 /* Peripheral Control functions ***********************************************/
mbed_official 489:119543c9f674 890 /** @addtogroup ADC_Exported_Functions_Group3
mbed_official 489:119543c9f674 891 * @{
mbed_official 489:119543c9f674 892 */
mbed_official 489:119543c9f674 893 HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig);
mbed_official 489:119543c9f674 894 HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig);
mbed_official 489:119543c9f674 895 /**
mbed_official 489:119543c9f674 896 * @}
mbed_official 489:119543c9f674 897 */
mbed_official 489:119543c9f674 898
mbed_official 489:119543c9f674 899
mbed_official 489:119543c9f674 900 /* Peripheral State functions *************************************************/
mbed_official 489:119543c9f674 901 /** @addtogroup ADC_Exported_Functions_Group4
mbed_official 489:119543c9f674 902 * @{
mbed_official 489:119543c9f674 903 */
mbed_official 489:119543c9f674 904 HAL_ADC_StateTypeDef HAL_ADC_GetState(ADC_HandleTypeDef* hadc);
mbed_official 489:119543c9f674 905 uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc);
mbed_official 489:119543c9f674 906 /**
mbed_official 489:119543c9f674 907 * @}
mbed_official 489:119543c9f674 908 */
mbed_official 489:119543c9f674 909
mbed_official 489:119543c9f674 910
mbed_official 489:119543c9f674 911 /**
mbed_official 489:119543c9f674 912 * @}
mbed_official 489:119543c9f674 913 */
mbed_official 489:119543c9f674 914
mbed_official 489:119543c9f674 915
mbed_official 489:119543c9f674 916 /* Internal HAL driver functions **********************************************/
mbed_official 489:119543c9f674 917 /** @addtogroup ADC_Private_Functions
mbed_official 489:119543c9f674 918 * @{
mbed_official 489:119543c9f674 919 */
mbed_official 489:119543c9f674 920 HAL_StatusTypeDef ADC_Enable(ADC_HandleTypeDef* hadc);
mbed_official 489:119543c9f674 921 HAL_StatusTypeDef ADC_ConversionStop_Disable(ADC_HandleTypeDef* hadc);
mbed_official 489:119543c9f674 922 void ADC_StabilizationTime(uint32_t DelayUs);
mbed_official 489:119543c9f674 923 void ADC_DMAConvCplt(DMA_HandleTypeDef *hdma);
mbed_official 489:119543c9f674 924 void ADC_DMAHalfConvCplt(DMA_HandleTypeDef *hdma);
mbed_official 489:119543c9f674 925 void ADC_DMAError(DMA_HandleTypeDef *hdma);
mbed_official 489:119543c9f674 926 /**
mbed_official 489:119543c9f674 927 * @}
mbed_official 489:119543c9f674 928 */
mbed_official 489:119543c9f674 929
mbed_official 489:119543c9f674 930
mbed_official 489:119543c9f674 931 /**
mbed_official 489:119543c9f674 932 * @}
mbed_official 489:119543c9f674 933 */
mbed_official 489:119543c9f674 934
mbed_official 489:119543c9f674 935 /**
mbed_official 489:119543c9f674 936 * @}
mbed_official 489:119543c9f674 937 */
mbed_official 489:119543c9f674 938
mbed_official 489:119543c9f674 939 #ifdef __cplusplus
mbed_official 489:119543c9f674 940 }
mbed_official 489:119543c9f674 941 #endif
mbed_official 489:119543c9f674 942
mbed_official 489:119543c9f674 943
mbed_official 489:119543c9f674 944 #endif /* __STM32F1xx_HAL_ADC_H */
mbed_official 489:119543c9f674 945
mbed_official 489:119543c9f674 946 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/