SPKT

Dependencies:   F746_GUI SD_PlayerSkeleton F746_SAI_IO

Committer:
phungductung
Date:
Tue Jun 04 21:37:21 2019 +0000
Revision:
0:8ede47d38d10
SPKT

Who changed what in which revision?

UserRevisionLine numberNew contents of line
phungductung 0:8ede47d38d10 1 /**
phungductung 0:8ede47d38d10 2 ******************************************************************************
phungductung 0:8ede47d38d10 3 * @file stm32f7xx_hal_adc.h
phungductung 0:8ede47d38d10 4 * @author MCD Application Team
phungductung 0:8ede47d38d10 5 * @version V1.0.4
phungductung 0:8ede47d38d10 6 * @date 09-December-2015
phungductung 0:8ede47d38d10 7 * @brief Header file of ADC HAL extension module.
phungductung 0:8ede47d38d10 8 ******************************************************************************
phungductung 0:8ede47d38d10 9 * @attention
phungductung 0:8ede47d38d10 10 *
phungductung 0:8ede47d38d10 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
phungductung 0:8ede47d38d10 12 *
phungductung 0:8ede47d38d10 13 * Redistribution and use in source and binary forms, with or without modification,
phungductung 0:8ede47d38d10 14 * are permitted provided that the following conditions are met:
phungductung 0:8ede47d38d10 15 * 1. Redistributions of source code must retain the above copyright notice,
phungductung 0:8ede47d38d10 16 * this list of conditions and the following disclaimer.
phungductung 0:8ede47d38d10 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
phungductung 0:8ede47d38d10 18 * this list of conditions and the following disclaimer in the documentation
phungductung 0:8ede47d38d10 19 * and/or other materials provided with the distribution.
phungductung 0:8ede47d38d10 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
phungductung 0:8ede47d38d10 21 * may be used to endorse or promote products derived from this software
phungductung 0:8ede47d38d10 22 * without specific prior written permission.
phungductung 0:8ede47d38d10 23 *
phungductung 0:8ede47d38d10 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
phungductung 0:8ede47d38d10 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
phungductung 0:8ede47d38d10 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
phungductung 0:8ede47d38d10 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
phungductung 0:8ede47d38d10 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
phungductung 0:8ede47d38d10 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
phungductung 0:8ede47d38d10 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
phungductung 0:8ede47d38d10 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
phungductung 0:8ede47d38d10 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
phungductung 0:8ede47d38d10 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
phungductung 0:8ede47d38d10 34 *
phungductung 0:8ede47d38d10 35 ******************************************************************************
phungductung 0:8ede47d38d10 36 */
phungductung 0:8ede47d38d10 37
phungductung 0:8ede47d38d10 38 /* Define to prevent recursive inclusion -------------------------------------*/
phungductung 0:8ede47d38d10 39 #ifndef __STM32F7xx_ADC_H
phungductung 0:8ede47d38d10 40 #define __STM32F7xx_ADC_H
phungductung 0:8ede47d38d10 41
phungductung 0:8ede47d38d10 42 #ifdef __cplusplus
phungductung 0:8ede47d38d10 43 extern "C" {
phungductung 0:8ede47d38d10 44 #endif
phungductung 0:8ede47d38d10 45
phungductung 0:8ede47d38d10 46 /* Includes ------------------------------------------------------------------*/
phungductung 0:8ede47d38d10 47 #include "stm32f7xx_hal_def.h"
phungductung 0:8ede47d38d10 48
phungductung 0:8ede47d38d10 49 /** @addtogroup STM32F7xx_HAL_Driver
phungductung 0:8ede47d38d10 50 * @{
phungductung 0:8ede47d38d10 51 */
phungductung 0:8ede47d38d10 52
phungductung 0:8ede47d38d10 53 /** @addtogroup ADC
phungductung 0:8ede47d38d10 54 * @{
phungductung 0:8ede47d38d10 55 */
phungductung 0:8ede47d38d10 56
phungductung 0:8ede47d38d10 57 /* Exported types ------------------------------------------------------------*/
phungductung 0:8ede47d38d10 58 /** @defgroup ADC_Exported_Types ADC Exported Types
phungductung 0:8ede47d38d10 59 * @{
phungductung 0:8ede47d38d10 60 */
phungductung 0:8ede47d38d10 61
phungductung 0:8ede47d38d10 62 /**
phungductung 0:8ede47d38d10 63 * @brief Structure definition of ADC and regular group initialization
phungductung 0:8ede47d38d10 64 * @note Parameters of this structure are shared within 2 scopes:
phungductung 0:8ede47d38d10 65 * - Scope entire ADC (affects regular and injected groups): ClockPrescaler, Resolution, ScanConvMode, DataAlign, ScanConvMode, EOCSelection, LowPowerAutoWait, LowPowerAutoPowerOff, ChannelsBank.
phungductung 0:8ede47d38d10 66 * - Scope regular group: ContinuousConvMode, NbrOfConversion, DiscontinuousConvMode, NbrOfDiscConversion, ExternalTrigConvEdge, ExternalTrigConv.
phungductung 0:8ede47d38d10 67 * @note The setting of these parameters with function HAL_ADC_Init() is conditioned to ADC state.
phungductung 0:8ede47d38d10 68 * ADC state can be either:
phungductung 0:8ede47d38d10 69 * - For all parameters: ADC disabled
phungductung 0:8ede47d38d10 70 * - For all parameters except 'Resolution', 'ScanConvMode', 'DiscontinuousConvMode', 'NbrOfDiscConversion' : ADC enabled without conversion on going on regular group.
phungductung 0:8ede47d38d10 71 * - For parameters 'ExternalTrigConv' and 'ExternalTrigConvEdge': ADC enabled, even with conversion on going.
phungductung 0:8ede47d38d10 72 * If ADC is not in the appropriate state to modify some parameters, these parameters setting is bypassed
phungductung 0:8ede47d38d10 73 * without error reporting (as it can be the expected behaviour in case of intended action to update another parameter (which fullfills the ADC state condition) on the fly).
phungductung 0:8ede47d38d10 74 */
phungductung 0:8ede47d38d10 75 typedef struct
phungductung 0:8ede47d38d10 76 {
phungductung 0:8ede47d38d10 77 uint32_t ClockPrescaler; /*!< Select ADC clock prescaler. The clock is common for
phungductung 0:8ede47d38d10 78 all the ADCs.
phungductung 0:8ede47d38d10 79 This parameter can be a value of @ref ADC_ClockPrescaler */
phungductung 0:8ede47d38d10 80 uint32_t Resolution; /*!< Configures the ADC resolution.
phungductung 0:8ede47d38d10 81 This parameter can be a value of @ref ADC_Resolution */
phungductung 0:8ede47d38d10 82 uint32_t DataAlign; /*!< Specifies ADC data alignment to right (MSB on register bit 11 and LSB on register bit 0) (default setting)
phungductung 0:8ede47d38d10 83 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).
phungductung 0:8ede47d38d10 84 This parameter can be a value of @ref ADC_data_align */
phungductung 0:8ede47d38d10 85 uint32_t ScanConvMode; /*!< Configures the sequencer of regular and injected groups.
phungductung 0:8ede47d38d10 86 This parameter can be associated to parameter 'DiscontinuousConvMode' to have main sequence subdivided in successive parts.
phungductung 0:8ede47d38d10 87 If disabled: Conversion is performed in single mode (one channel converted, the one defined in rank 1).
phungductung 0:8ede47d38d10 88 Parameters 'NbrOfConversion' and 'InjectedNbrOfConversion' are discarded (equivalent to set to 1).
phungductung 0:8ede47d38d10 89 If enabled: Conversions are performed in sequence mode (multiple ranks defined by 'NbrOfConversion'/'InjectedNbrOfConversion' and each channel rank).
phungductung 0:8ede47d38d10 90 Scan direction is upward: from rank1 to rank 'n'. */
phungductung 0:8ede47d38d10 91 uint32_t EOCSelection; /*!< Specifies what EOC (End Of Conversion) flag is used for conversion by polling and interruption: end of conversion of each rank or complete sequence.
phungductung 0:8ede47d38d10 92 This parameter can be a value of @ref ADC_EOCSelection.
phungductung 0:8ede47d38d10 93 Note: For injected group, end of conversion (flag&IT) is raised only at the end of the sequence.
phungductung 0:8ede47d38d10 94 Therefore, if end of conversion is set to end of each conversion, injected group should not be used with interruption (HAL_ADCEx_InjectedStart_IT)
phungductung 0:8ede47d38d10 95 or polling (HAL_ADCEx_InjectedStart and HAL_ADCEx_InjectedPollForConversion). By the way, polling is still possible since driver will use an estimated timing for end of injected conversion.
phungductung 0:8ede47d38d10 96 Note: If overrun feature is intended to be used, use ADC in mode 'interruption' (function HAL_ADC_Start_IT() ) with parameter EOCSelection set to end of each conversion or in mode 'transfer by DMA' (function HAL_ADC_Start_DMA()).
phungductung 0:8ede47d38d10 97 If overrun feature is intended to be bypassed, use ADC in mode 'polling' or 'interruption' with parameter EOCSelection must be set to end of sequence */
phungductung 0:8ede47d38d10 98 uint32_t ContinuousConvMode; /*!< Specifies whether the conversion is performed in single mode (one conversion) or continuous mode for regular group,
phungductung 0:8ede47d38d10 99 after the selected trigger occurred (software start or external trigger).
phungductung 0:8ede47d38d10 100 This parameter can be set to ENABLE or DISABLE. */
phungductung 0:8ede47d38d10 101 uint32_t NbrOfConversion; /*!< Specifies the number of ranks that will be converted within the regular group sequencer.
phungductung 0:8ede47d38d10 102 To use regular group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
phungductung 0:8ede47d38d10 103 This parameter must be a number between Min_Data = 1 and Max_Data = 16. */
phungductung 0:8ede47d38d10 104 uint32_t DiscontinuousConvMode; /*!< Specifies whether the conversions sequence of regular group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts).
phungductung 0:8ede47d38d10 105 Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
phungductung 0:8ede47d38d10 106 Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
phungductung 0:8ede47d38d10 107 This parameter can be set to ENABLE or DISABLE. */
phungductung 0:8ede47d38d10 108 uint32_t NbrOfDiscConversion; /*!< Specifies the number of discontinuous conversions in which the main sequence of regular group (parameter NbrOfConversion) will be subdivided.
phungductung 0:8ede47d38d10 109 If parameter 'DiscontinuousConvMode' is disabled, this parameter is discarded.
phungductung 0:8ede47d38d10 110 This parameter must be a number between Min_Data = 1 and Max_Data = 8. */
phungductung 0:8ede47d38d10 111 uint32_t ExternalTrigConv; /*!< Selects the external event used to trigger the conversion start of regular group.
phungductung 0:8ede47d38d10 112 If set to ADC_SOFTWARE_START, external triggers are disabled.
phungductung 0:8ede47d38d10 113 If set to external trigger source, triggering is on event rising edge by default.
phungductung 0:8ede47d38d10 114 This parameter can be a value of @ref ADC_External_trigger_Source_Regular */
phungductung 0:8ede47d38d10 115 uint32_t ExternalTrigConvEdge; /*!< Selects the external trigger edge of regular group.
phungductung 0:8ede47d38d10 116 If trigger is set to ADC_SOFTWARE_START, this parameter is discarded.
phungductung 0:8ede47d38d10 117 This parameter can be a value of @ref ADC_External_trigger_edge_Regular */
phungductung 0:8ede47d38d10 118 uint32_t DMAContinuousRequests; /*!< Specifies whether the DMA requests are performed in one shot mode (DMA transfer stop when number of conversions is reached)
phungductung 0:8ede47d38d10 119 or in Continuous mode (DMA transfer unlimited, whatever number of conversions).
phungductung 0:8ede47d38d10 120 Note: In continuous mode, DMA must be configured in circular mode. Otherwise an overrun will be triggered when DMA buffer maximum pointer is reached.
phungductung 0:8ede47d38d10 121 Note: This parameter must be modified when no conversion is on going on both regular and injected groups (ADC disabled, or ADC enabled without continuous mode or external trigger that could launch a conversion).
phungductung 0:8ede47d38d10 122 This parameter can be set to ENABLE or DISABLE. */
phungductung 0:8ede47d38d10 123 }ADC_InitTypeDef;
phungductung 0:8ede47d38d10 124
phungductung 0:8ede47d38d10 125
phungductung 0:8ede47d38d10 126
phungductung 0:8ede47d38d10 127 /**
phungductung 0:8ede47d38d10 128 * @brief Structure definition of ADC channel for regular group
phungductung 0:8ede47d38d10 129 * @note The setting of these parameters with function HAL_ADC_ConfigChannel() is conditioned to ADC state.
phungductung 0:8ede47d38d10 130 * ADC can be either disabled or enabled without conversion on going on regular group.
phungductung 0:8ede47d38d10 131 */
phungductung 0:8ede47d38d10 132 typedef struct
phungductung 0:8ede47d38d10 133 {
phungductung 0:8ede47d38d10 134 uint32_t Channel; /*!< Specifies the channel to configure into ADC regular group.
phungductung 0:8ede47d38d10 135 This parameter can be a value of @ref ADC_channels */
phungductung 0:8ede47d38d10 136 uint32_t Rank; /*!< Specifies the rank in the regular group sequencer.
phungductung 0:8ede47d38d10 137 This parameter must be a number between Min_Data = 1 and Max_Data = 16 */
phungductung 0:8ede47d38d10 138 uint32_t SamplingTime; /*!< Sampling time value to be set for the selected channel.
phungductung 0:8ede47d38d10 139 Unit: ADC clock cycles
phungductung 0:8ede47d38d10 140 Conversion time is the addition of sampling time and processing time (12 ADC clock cycles at ADC resolution 12 bits, 11 cycles at 10 bits, 9 cycles at 8 bits, 7 cycles at 6 bits).
phungductung 0:8ede47d38d10 141 This parameter can be a value of @ref ADC_sampling_times
phungductung 0:8ede47d38d10 142 Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups.
phungductung 0:8ede47d38d10 143 If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting.
phungductung 0:8ede47d38d10 144 Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor),
phungductung 0:8ede47d38d10 145 sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
phungductung 0:8ede47d38d10 146 Refer to device datasheet for timings values, parameters TS_vrefint, TS_temp (values rough order: 4us min). */
phungductung 0:8ede47d38d10 147 uint32_t Offset; /*!< Reserved for future use, can be set to 0 */
phungductung 0:8ede47d38d10 148 }ADC_ChannelConfTypeDef;
phungductung 0:8ede47d38d10 149
phungductung 0:8ede47d38d10 150 /**
phungductung 0:8ede47d38d10 151 * @brief ADC Configuration multi-mode structure definition
phungductung 0:8ede47d38d10 152 */
phungductung 0:8ede47d38d10 153 typedef struct
phungductung 0:8ede47d38d10 154 {
phungductung 0:8ede47d38d10 155 uint32_t WatchdogMode; /*!< Configures the ADC analog watchdog mode.
phungductung 0:8ede47d38d10 156 This parameter can be a value of @ref ADC_analog_watchdog_selection */
phungductung 0:8ede47d38d10 157 uint32_t HighThreshold; /*!< Configures the ADC analog watchdog High threshold value.
phungductung 0:8ede47d38d10 158 This parameter must be a 12-bit value. */
phungductung 0:8ede47d38d10 159 uint32_t LowThreshold; /*!< Configures the ADC analog watchdog High threshold value.
phungductung 0:8ede47d38d10 160 This parameter must be a 12-bit value. */
phungductung 0:8ede47d38d10 161 uint32_t Channel; /*!< Configures ADC channel for the analog watchdog.
phungductung 0:8ede47d38d10 162 This parameter has an effect only if watchdog mode is configured on single channel
phungductung 0:8ede47d38d10 163 This parameter can be a value of @ref ADC_channels */
phungductung 0:8ede47d38d10 164 uint32_t ITMode; /*!< Specifies whether the analog watchdog is configured
phungductung 0:8ede47d38d10 165 is interrupt mode or in polling mode.
phungductung 0:8ede47d38d10 166 This parameter can be set to ENABLE or DISABLE */
phungductung 0:8ede47d38d10 167 uint32_t WatchdogNumber; /*!< Reserved for future use, can be set to 0 */
phungductung 0:8ede47d38d10 168 }ADC_AnalogWDGConfTypeDef;
phungductung 0:8ede47d38d10 169
phungductung 0:8ede47d38d10 170 /**
phungductung 0:8ede47d38d10 171 * @brief HAL ADC state machine: ADC states definition (bitfields)
phungductung 0:8ede47d38d10 172 */
phungductung 0:8ede47d38d10 173 /* States of ADC global scope */
phungductung 0:8ede47d38d10 174 #define HAL_ADC_STATE_RESET ((uint32_t)0x00000000) /*!< ADC not yet initialized or disabled */
phungductung 0:8ede47d38d10 175 #define HAL_ADC_STATE_READY ((uint32_t)0x00000001) /*!< ADC peripheral ready for use */
phungductung 0:8ede47d38d10 176 #define HAL_ADC_STATE_BUSY_INTERNAL ((uint32_t)0x00000002) /*!< ADC is busy to internal process (initialization, calibration) */
phungductung 0:8ede47d38d10 177 #define HAL_ADC_STATE_TIMEOUT ((uint32_t)0x00000004) /*!< TimeOut occurrence */
phungductung 0:8ede47d38d10 178
phungductung 0:8ede47d38d10 179 /* States of ADC errors */
phungductung 0:8ede47d38d10 180 #define HAL_ADC_STATE_ERROR_INTERNAL ((uint32_t)0x00000010) /*!< Internal error occurrence */
phungductung 0:8ede47d38d10 181 #define HAL_ADC_STATE_ERROR_CONFIG ((uint32_t)0x00000020) /*!< Configuration error occurrence */
phungductung 0:8ede47d38d10 182 #define HAL_ADC_STATE_ERROR_DMA ((uint32_t)0x00000040) /*!< DMA error occurrence */
phungductung 0:8ede47d38d10 183
phungductung 0:8ede47d38d10 184 /* States of ADC group regular */
phungductung 0:8ede47d38d10 185 #define HAL_ADC_STATE_REG_BUSY ((uint32_t)0x00000100) /*!< A conversion on group regular is ongoing or can occur (either by continuous mode,
phungductung 0:8ede47d38d10 186 external trigger, low power auto power-on (if feature available), multimode ADC master control (if feature available)) */
phungductung 0:8ede47d38d10 187 #define HAL_ADC_STATE_REG_EOC ((uint32_t)0x00000200) /*!< Conversion data available on group regular */
phungductung 0:8ede47d38d10 188 #define HAL_ADC_STATE_REG_OVR ((uint32_t)0x00000400) /*!< Overrun occurrence */
phungductung 0:8ede47d38d10 189
phungductung 0:8ede47d38d10 190 /* States of ADC group injected */
phungductung 0:8ede47d38d10 191 #define HAL_ADC_STATE_INJ_BUSY ((uint32_t)0x00001000) /*!< A conversion on group injected is ongoing or can occur (either by auto-injection mode,
phungductung 0:8ede47d38d10 192 external trigger, low power auto power-on (if feature available), multimode ADC master control (if feature available)) */
phungductung 0:8ede47d38d10 193 #define HAL_ADC_STATE_INJ_EOC ((uint32_t)0x00002000) /*!< Conversion data available on group injected */
phungductung 0:8ede47d38d10 194
phungductung 0:8ede47d38d10 195 /* States of ADC analog watchdogs */
phungductung 0:8ede47d38d10 196 #define HAL_ADC_STATE_AWD1 ((uint32_t)0x00010000) /*!< Out-of-window occurrence of analog watchdog 1 */
phungductung 0:8ede47d38d10 197 #define HAL_ADC_STATE_AWD2 ((uint32_t)0x00020000) /*!< Not available on STM32F7 device: Out-of-window occurrence of analog watchdog 2 */
phungductung 0:8ede47d38d10 198 #define HAL_ADC_STATE_AWD3 ((uint32_t)0x00040000) /*!< Not available on STM32F7 device: Out-of-window occurrence of analog watchdog 3 */
phungductung 0:8ede47d38d10 199
phungductung 0:8ede47d38d10 200 /* States of ADC multi-mode */
phungductung 0:8ede47d38d10 201 #define HAL_ADC_STATE_MULTIMODE_SLAVE ((uint32_t)0x00100000) /*!< Not available on STM32F4 device: ADC in multimode slave state, controlled by another ADC master ( */
phungductung 0:8ede47d38d10 202
phungductung 0:8ede47d38d10 203
phungductung 0:8ede47d38d10 204 /**
phungductung 0:8ede47d38d10 205 * @brief ADC handle Structure definition
phungductung 0:8ede47d38d10 206 */
phungductung 0:8ede47d38d10 207 typedef struct
phungductung 0:8ede47d38d10 208 {
phungductung 0:8ede47d38d10 209 ADC_TypeDef *Instance; /*!< Register base address */
phungductung 0:8ede47d38d10 210
phungductung 0:8ede47d38d10 211 ADC_InitTypeDef Init; /*!< ADC required parameters */
phungductung 0:8ede47d38d10 212
phungductung 0:8ede47d38d10 213 __IO uint32_t NbrOfCurrentConversionRank; /*!< ADC number of current conversion rank */
phungductung 0:8ede47d38d10 214
phungductung 0:8ede47d38d10 215 DMA_HandleTypeDef *DMA_Handle; /*!< Pointer DMA Handler */
phungductung 0:8ede47d38d10 216
phungductung 0:8ede47d38d10 217 HAL_LockTypeDef Lock; /*!< ADC locking object */
phungductung 0:8ede47d38d10 218
phungductung 0:8ede47d38d10 219 __IO uint32_t State; /*!< ADC communication state */
phungductung 0:8ede47d38d10 220
phungductung 0:8ede47d38d10 221 __IO uint32_t ErrorCode; /*!< ADC Error code */
phungductung 0:8ede47d38d10 222 }ADC_HandleTypeDef;
phungductung 0:8ede47d38d10 223 /**
phungductung 0:8ede47d38d10 224 * @}
phungductung 0:8ede47d38d10 225 */
phungductung 0:8ede47d38d10 226
phungductung 0:8ede47d38d10 227 /* Exported constants --------------------------------------------------------*/
phungductung 0:8ede47d38d10 228 /** @defgroup ADC_Exported_Constants ADC Exported Constants
phungductung 0:8ede47d38d10 229 * @{
phungductung 0:8ede47d38d10 230 */
phungductung 0:8ede47d38d10 231
phungductung 0:8ede47d38d10 232 /** @defgroup ADC_Error_Code ADC Error Code
phungductung 0:8ede47d38d10 233 * @{
phungductung 0:8ede47d38d10 234 */
phungductung 0:8ede47d38d10 235 #define HAL_ADC_ERROR_NONE ((uint32_t)0x00) /*!< No error */
phungductung 0:8ede47d38d10 236 #define HAL_ADC_ERROR_INTERNAL ((uint32_t)0x01) /*!< ADC IP internal error: if problem of clocking,
phungductung 0:8ede47d38d10 237 enable/disable, erroneous state */
phungductung 0:8ede47d38d10 238 #define HAL_ADC_ERROR_OVR ((uint32_t)0x02) /*!< Overrun error */
phungductung 0:8ede47d38d10 239 #define HAL_ADC_ERROR_DMA ((uint32_t)0x04) /*!< DMA transfer error */
phungductung 0:8ede47d38d10 240 /**
phungductung 0:8ede47d38d10 241 * @}
phungductung 0:8ede47d38d10 242 */
phungductung 0:8ede47d38d10 243
phungductung 0:8ede47d38d10 244
phungductung 0:8ede47d38d10 245 /** @defgroup ADC_ClockPrescaler ADC Clock Prescaler
phungductung 0:8ede47d38d10 246 * @{
phungductung 0:8ede47d38d10 247 */
phungductung 0:8ede47d38d10 248 #define ADC_CLOCK_SYNC_PCLK_DIV2 ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 249 #define ADC_CLOCK_SYNC_PCLK_DIV4 ((uint32_t)ADC_CCR_ADCPRE_0)
phungductung 0:8ede47d38d10 250 #define ADC_CLOCK_SYNC_PCLK_DIV6 ((uint32_t)ADC_CCR_ADCPRE_1)
phungductung 0:8ede47d38d10 251 #define ADC_CLOCK_SYNC_PCLK_DIV8 ((uint32_t)ADC_CCR_ADCPRE)
phungductung 0:8ede47d38d10 252 /**
phungductung 0:8ede47d38d10 253 * @}
phungductung 0:8ede47d38d10 254 */
phungductung 0:8ede47d38d10 255
phungductung 0:8ede47d38d10 256 /** @defgroup ADC_delay_between_2_sampling_phases ADC Delay Between 2 Sampling Phases
phungductung 0:8ede47d38d10 257 * @{
phungductung 0:8ede47d38d10 258 */
phungductung 0:8ede47d38d10 259 #define ADC_TWOSAMPLINGDELAY_5CYCLES ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 260 #define ADC_TWOSAMPLINGDELAY_6CYCLES ((uint32_t)ADC_CCR_DELAY_0)
phungductung 0:8ede47d38d10 261 #define ADC_TWOSAMPLINGDELAY_7CYCLES ((uint32_t)ADC_CCR_DELAY_1)
phungductung 0:8ede47d38d10 262 #define ADC_TWOSAMPLINGDELAY_8CYCLES ((uint32_t)(ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
phungductung 0:8ede47d38d10 263 #define ADC_TWOSAMPLINGDELAY_9CYCLES ((uint32_t)ADC_CCR_DELAY_2)
phungductung 0:8ede47d38d10 264 #define ADC_TWOSAMPLINGDELAY_10CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0))
phungductung 0:8ede47d38d10 265 #define ADC_TWOSAMPLINGDELAY_11CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1))
phungductung 0:8ede47d38d10 266 #define ADC_TWOSAMPLINGDELAY_12CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
phungductung 0:8ede47d38d10 267 #define ADC_TWOSAMPLINGDELAY_13CYCLES ((uint32_t)ADC_CCR_DELAY_3)
phungductung 0:8ede47d38d10 268 #define ADC_TWOSAMPLINGDELAY_14CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_0))
phungductung 0:8ede47d38d10 269 #define ADC_TWOSAMPLINGDELAY_15CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1))
phungductung 0:8ede47d38d10 270 #define ADC_TWOSAMPLINGDELAY_16CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
phungductung 0:8ede47d38d10 271 #define ADC_TWOSAMPLINGDELAY_17CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2))
phungductung 0:8ede47d38d10 272 #define ADC_TWOSAMPLINGDELAY_18CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0))
phungductung 0:8ede47d38d10 273 #define ADC_TWOSAMPLINGDELAY_19CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1))
phungductung 0:8ede47d38d10 274 #define ADC_TWOSAMPLINGDELAY_20CYCLES ((uint32_t)ADC_CCR_DELAY)
phungductung 0:8ede47d38d10 275 /**
phungductung 0:8ede47d38d10 276 * @}
phungductung 0:8ede47d38d10 277 */
phungductung 0:8ede47d38d10 278
phungductung 0:8ede47d38d10 279 /** @defgroup ADC_Resolution ADC Resolution
phungductung 0:8ede47d38d10 280 * @{
phungductung 0:8ede47d38d10 281 */
phungductung 0:8ede47d38d10 282 #define ADC_RESOLUTION_12B ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 283 #define ADC_RESOLUTION_10B ((uint32_t)ADC_CR1_RES_0)
phungductung 0:8ede47d38d10 284 #define ADC_RESOLUTION_8B ((uint32_t)ADC_CR1_RES_1)
phungductung 0:8ede47d38d10 285 #define ADC_RESOLUTION_6B ((uint32_t)ADC_CR1_RES)
phungductung 0:8ede47d38d10 286 /**
phungductung 0:8ede47d38d10 287 * @}
phungductung 0:8ede47d38d10 288 */
phungductung 0:8ede47d38d10 289
phungductung 0:8ede47d38d10 290 /** @defgroup ADC_External_trigger_edge_Regular ADC External Trigger Edge Regular
phungductung 0:8ede47d38d10 291 * @{
phungductung 0:8ede47d38d10 292 */
phungductung 0:8ede47d38d10 293 #define ADC_EXTERNALTRIGCONVEDGE_NONE ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 294 #define ADC_EXTERNALTRIGCONVEDGE_RISING ((uint32_t)ADC_CR2_EXTEN_0)
phungductung 0:8ede47d38d10 295 #define ADC_EXTERNALTRIGCONVEDGE_FALLING ((uint32_t)ADC_CR2_EXTEN_1)
phungductung 0:8ede47d38d10 296 #define ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING ((uint32_t)ADC_CR2_EXTEN)
phungductung 0:8ede47d38d10 297 /**
phungductung 0:8ede47d38d10 298 * @}
phungductung 0:8ede47d38d10 299 */
phungductung 0:8ede47d38d10 300
phungductung 0:8ede47d38d10 301 /** @defgroup ADC_External_trigger_Source_Regular ADC External Trigger Source Regular
phungductung 0:8ede47d38d10 302 * @{
phungductung 0:8ede47d38d10 303 */
phungductung 0:8ede47d38d10 304 /* Note: Parameter ADC_SOFTWARE_START is a software parameter used for */
phungductung 0:8ede47d38d10 305 /* compatibility with other STM32 devices. */
phungductung 0:8ede47d38d10 306
phungductung 0:8ede47d38d10 307
phungductung 0:8ede47d38d10 308 #define ADC_EXTERNALTRIGCONV_T1_CC1 ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 309 #define ADC_EXTERNALTRIGCONV_T1_CC2 ((uint32_t)ADC_CR2_EXTSEL_0)
phungductung 0:8ede47d38d10 310 #define ADC_EXTERNALTRIGCONV_T1_CC3 ((uint32_t)ADC_CR2_EXTSEL_1)
phungductung 0:8ede47d38d10 311 #define ADC_EXTERNALTRIGCONV_T2_CC2 ((uint32_t)(ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
phungductung 0:8ede47d38d10 312 #define ADC_EXTERNALTRIGCONV_T5_TRGO ((uint32_t)ADC_CR2_EXTSEL_2)
phungductung 0:8ede47d38d10 313 #define ADC_EXTERNALTRIGCONV_T4_CC4 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
phungductung 0:8ede47d38d10 314 #define ADC_EXTERNALTRIGCONV_T3_CC4 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1))
phungductung 0:8ede47d38d10 315 #define ADC_EXTERNALTRIGCONV_T8_TRGO ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
phungductung 0:8ede47d38d10 316 #define ADC_EXTERNALTRIGCONV_T8_TRGO2 ((uint32_t)ADC_CR2_EXTSEL_3)
phungductung 0:8ede47d38d10 317 #define ADC_EXTERNALTRIGCONV_T1_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_0))
phungductung 0:8ede47d38d10 318 #define ADC_EXTERNALTRIGCONV_T1_TRGO2 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1))
phungductung 0:8ede47d38d10 319 #define ADC_EXTERNALTRIGCONV_T2_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
phungductung 0:8ede47d38d10 320 #define ADC_EXTERNALTRIGCONV_T4_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2))
phungductung 0:8ede47d38d10 321 #define ADC_EXTERNALTRIGCONV_T6_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
phungductung 0:8ede47d38d10 322
phungductung 0:8ede47d38d10 323 #define ADC_EXTERNALTRIGCONV_EXT_IT11 ((uint32_t)ADC_CR2_EXTSEL)
phungductung 0:8ede47d38d10 324 #define ADC_SOFTWARE_START ((uint32_t)ADC_CR2_EXTSEL + 1)
phungductung 0:8ede47d38d10 325
phungductung 0:8ede47d38d10 326 /**
phungductung 0:8ede47d38d10 327 * @}
phungductung 0:8ede47d38d10 328 */
phungductung 0:8ede47d38d10 329
phungductung 0:8ede47d38d10 330 /** @defgroup ADC_data_align ADC Data Align
phungductung 0:8ede47d38d10 331 * @{
phungductung 0:8ede47d38d10 332 */
phungductung 0:8ede47d38d10 333 #define ADC_DATAALIGN_RIGHT ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 334 #define ADC_DATAALIGN_LEFT ((uint32_t)ADC_CR2_ALIGN)
phungductung 0:8ede47d38d10 335 /**
phungductung 0:8ede47d38d10 336 * @}
phungductung 0:8ede47d38d10 337 */
phungductung 0:8ede47d38d10 338
phungductung 0:8ede47d38d10 339 /** @defgroup ADC_channels ADC Common Channels
phungductung 0:8ede47d38d10 340 * @{
phungductung 0:8ede47d38d10 341 */
phungductung 0:8ede47d38d10 342 #define ADC_CHANNEL_0 ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 343 #define ADC_CHANNEL_1 ((uint32_t)ADC_CR1_AWDCH_0)
phungductung 0:8ede47d38d10 344 #define ADC_CHANNEL_2 ((uint32_t)ADC_CR1_AWDCH_1)
phungductung 0:8ede47d38d10 345 #define ADC_CHANNEL_3 ((uint32_t)(ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
phungductung 0:8ede47d38d10 346 #define ADC_CHANNEL_4 ((uint32_t)ADC_CR1_AWDCH_2)
phungductung 0:8ede47d38d10 347 #define ADC_CHANNEL_5 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0))
phungductung 0:8ede47d38d10 348 #define ADC_CHANNEL_6 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1))
phungductung 0:8ede47d38d10 349 #define ADC_CHANNEL_7 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
phungductung 0:8ede47d38d10 350 #define ADC_CHANNEL_8 ((uint32_t)ADC_CR1_AWDCH_3)
phungductung 0:8ede47d38d10 351 #define ADC_CHANNEL_9 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0))
phungductung 0:8ede47d38d10 352 #define ADC_CHANNEL_10 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1))
phungductung 0:8ede47d38d10 353 #define ADC_CHANNEL_11 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
phungductung 0:8ede47d38d10 354 #define ADC_CHANNEL_12 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2))
phungductung 0:8ede47d38d10 355 #define ADC_CHANNEL_13 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0))
phungductung 0:8ede47d38d10 356 #define ADC_CHANNEL_14 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1))
phungductung 0:8ede47d38d10 357 #define ADC_CHANNEL_15 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
phungductung 0:8ede47d38d10 358 #define ADC_CHANNEL_16 ((uint32_t)ADC_CR1_AWDCH_4)
phungductung 0:8ede47d38d10 359 #define ADC_CHANNEL_17 ((uint32_t)(ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_0))
phungductung 0:8ede47d38d10 360 #define ADC_CHANNEL_18 ((uint32_t)(ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_1))
phungductung 0:8ede47d38d10 361
phungductung 0:8ede47d38d10 362 #define ADC_CHANNEL_VREFINT ((uint32_t)ADC_CHANNEL_17)
phungductung 0:8ede47d38d10 363 #define ADC_CHANNEL_VBAT ((uint32_t)ADC_CHANNEL_18)
phungductung 0:8ede47d38d10 364 /**
phungductung 0:8ede47d38d10 365 * @}
phungductung 0:8ede47d38d10 366 */
phungductung 0:8ede47d38d10 367
phungductung 0:8ede47d38d10 368 /** @defgroup ADC_sampling_times ADC Sampling Times
phungductung 0:8ede47d38d10 369 * @{
phungductung 0:8ede47d38d10 370 */
phungductung 0:8ede47d38d10 371 #define ADC_SAMPLETIME_3CYCLES ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 372 #define ADC_SAMPLETIME_15CYCLES ((uint32_t)ADC_SMPR1_SMP10_0)
phungductung 0:8ede47d38d10 373 #define ADC_SAMPLETIME_28CYCLES ((uint32_t)ADC_SMPR1_SMP10_1)
phungductung 0:8ede47d38d10 374 #define ADC_SAMPLETIME_56CYCLES ((uint32_t)(ADC_SMPR1_SMP10_1 | ADC_SMPR1_SMP10_0))
phungductung 0:8ede47d38d10 375 #define ADC_SAMPLETIME_84CYCLES ((uint32_t)ADC_SMPR1_SMP10_2)
phungductung 0:8ede47d38d10 376 #define ADC_SAMPLETIME_112CYCLES ((uint32_t)(ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_0))
phungductung 0:8ede47d38d10 377 #define ADC_SAMPLETIME_144CYCLES ((uint32_t)(ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_1))
phungductung 0:8ede47d38d10 378 #define ADC_SAMPLETIME_480CYCLES ((uint32_t)ADC_SMPR1_SMP10)
phungductung 0:8ede47d38d10 379 /**
phungductung 0:8ede47d38d10 380 * @}
phungductung 0:8ede47d38d10 381 */
phungductung 0:8ede47d38d10 382
phungductung 0:8ede47d38d10 383 /** @defgroup ADC_EOCSelection ADC EOC Selection
phungductung 0:8ede47d38d10 384 * @{
phungductung 0:8ede47d38d10 385 */
phungductung 0:8ede47d38d10 386 #define ADC_EOC_SEQ_CONV ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 387 #define ADC_EOC_SINGLE_CONV ((uint32_t)0x00000001)
phungductung 0:8ede47d38d10 388 #define ADC_EOC_SINGLE_SEQ_CONV ((uint32_t)0x00000002) /*!< reserved for future use */
phungductung 0:8ede47d38d10 389 /**
phungductung 0:8ede47d38d10 390 * @}
phungductung 0:8ede47d38d10 391 */
phungductung 0:8ede47d38d10 392
phungductung 0:8ede47d38d10 393 /** @defgroup ADC_Event_type ADC Event Type
phungductung 0:8ede47d38d10 394 * @{
phungductung 0:8ede47d38d10 395 */
phungductung 0:8ede47d38d10 396 #define ADC_AWD_EVENT ((uint32_t)ADC_FLAG_AWD)
phungductung 0:8ede47d38d10 397 #define ADC_OVR_EVENT ((uint32_t)ADC_FLAG_OVR)
phungductung 0:8ede47d38d10 398 /**
phungductung 0:8ede47d38d10 399 * @}
phungductung 0:8ede47d38d10 400 */
phungductung 0:8ede47d38d10 401
phungductung 0:8ede47d38d10 402 /** @defgroup ADC_analog_watchdog_selection ADC Analog Watchdog Selection
phungductung 0:8ede47d38d10 403 * @{
phungductung 0:8ede47d38d10 404 */
phungductung 0:8ede47d38d10 405 #define ADC_ANALOGWATCHDOG_SINGLE_REG ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN))
phungductung 0:8ede47d38d10 406 #define ADC_ANALOGWATCHDOG_SINGLE_INJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_JAWDEN))
phungductung 0:8ede47d38d10 407 #define ADC_ANALOGWATCHDOG_SINGLE_REGINJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
phungductung 0:8ede47d38d10 408 #define ADC_ANALOGWATCHDOG_ALL_REG ((uint32_t)ADC_CR1_AWDEN)
phungductung 0:8ede47d38d10 409 #define ADC_ANALOGWATCHDOG_ALL_INJEC ((uint32_t)ADC_CR1_JAWDEN)
phungductung 0:8ede47d38d10 410 #define ADC_ANALOGWATCHDOG_ALL_REGINJEC ((uint32_t)(ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
phungductung 0:8ede47d38d10 411 #define ADC_ANALOGWATCHDOG_NONE ((uint32_t)0x00000000)
phungductung 0:8ede47d38d10 412 /**
phungductung 0:8ede47d38d10 413 * @}
phungductung 0:8ede47d38d10 414 */
phungductung 0:8ede47d38d10 415
phungductung 0:8ede47d38d10 416 /** @defgroup ADC_interrupts_definition ADC Interrupts Definition
phungductung 0:8ede47d38d10 417 * @{
phungductung 0:8ede47d38d10 418 */
phungductung 0:8ede47d38d10 419 #define ADC_IT_EOC ((uint32_t)ADC_CR1_EOCIE)
phungductung 0:8ede47d38d10 420 #define ADC_IT_AWD ((uint32_t)ADC_CR1_AWDIE)
phungductung 0:8ede47d38d10 421 #define ADC_IT_JEOC ((uint32_t)ADC_CR1_JEOCIE)
phungductung 0:8ede47d38d10 422 #define ADC_IT_OVR ((uint32_t)ADC_CR1_OVRIE)
phungductung 0:8ede47d38d10 423 /**
phungductung 0:8ede47d38d10 424 * @}
phungductung 0:8ede47d38d10 425 */
phungductung 0:8ede47d38d10 426
phungductung 0:8ede47d38d10 427 /** @defgroup ADC_flags_definition ADC Flags Definition
phungductung 0:8ede47d38d10 428 * @{
phungductung 0:8ede47d38d10 429 */
phungductung 0:8ede47d38d10 430 #define ADC_FLAG_AWD ((uint32_t)ADC_SR_AWD)
phungductung 0:8ede47d38d10 431 #define ADC_FLAG_EOC ((uint32_t)ADC_SR_EOC)
phungductung 0:8ede47d38d10 432 #define ADC_FLAG_JEOC ((uint32_t)ADC_SR_JEOC)
phungductung 0:8ede47d38d10 433 #define ADC_FLAG_JSTRT ((uint32_t)ADC_SR_JSTRT)
phungductung 0:8ede47d38d10 434 #define ADC_FLAG_STRT ((uint32_t)ADC_SR_STRT)
phungductung 0:8ede47d38d10 435 #define ADC_FLAG_OVR ((uint32_t)ADC_SR_OVR)
phungductung 0:8ede47d38d10 436 /**
phungductung 0:8ede47d38d10 437 * @}
phungductung 0:8ede47d38d10 438 */
phungductung 0:8ede47d38d10 439
phungductung 0:8ede47d38d10 440 /** @defgroup ADC_channels_type ADC Channels Type
phungductung 0:8ede47d38d10 441 * @{
phungductung 0:8ede47d38d10 442 */
phungductung 0:8ede47d38d10 443 #define ADC_ALL_CHANNELS ((uint32_t)0x00000001)
phungductung 0:8ede47d38d10 444 #define ADC_REGULAR_CHANNELS ((uint32_t)0x00000002) /*!< reserved for future use */
phungductung 0:8ede47d38d10 445 #define ADC_INJECTED_CHANNELS ((uint32_t)0x00000003) /*!< reserved for future use */
phungductung 0:8ede47d38d10 446 /**
phungductung 0:8ede47d38d10 447 * @}
phungductung 0:8ede47d38d10 448 */
phungductung 0:8ede47d38d10 449
phungductung 0:8ede47d38d10 450 /**
phungductung 0:8ede47d38d10 451 * @}
phungductung 0:8ede47d38d10 452 */
phungductung 0:8ede47d38d10 453
phungductung 0:8ede47d38d10 454 /* Exported macro ------------------------------------------------------------*/
phungductung 0:8ede47d38d10 455 /** @defgroup ADC_Exported_Macros ADC Exported Macros
phungductung 0:8ede47d38d10 456 * @{
phungductung 0:8ede47d38d10 457 */
phungductung 0:8ede47d38d10 458
phungductung 0:8ede47d38d10 459 /** @brief Reset ADC handle state
phungductung 0:8ede47d38d10 460 * @param __HANDLE__: ADC handle
phungductung 0:8ede47d38d10 461 * @retval None
phungductung 0:8ede47d38d10 462 */
phungductung 0:8ede47d38d10 463 #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
phungductung 0:8ede47d38d10 464
phungductung 0:8ede47d38d10 465 /**
phungductung 0:8ede47d38d10 466 * @brief Enable the ADC peripheral.
phungductung 0:8ede47d38d10 467 * @param __HANDLE__: ADC handle
phungductung 0:8ede47d38d10 468 * @retval None
phungductung 0:8ede47d38d10 469 */
phungductung 0:8ede47d38d10 470 #define __HAL_ADC_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR2 |= ADC_CR2_ADON)
phungductung 0:8ede47d38d10 471
phungductung 0:8ede47d38d10 472 /**
phungductung 0:8ede47d38d10 473 * @brief Disable the ADC peripheral.
phungductung 0:8ede47d38d10 474 * @param __HANDLE__: ADC handle
phungductung 0:8ede47d38d10 475 * @retval None
phungductung 0:8ede47d38d10 476 */
phungductung 0:8ede47d38d10 477 #define __HAL_ADC_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR2 &= ~ADC_CR2_ADON)
phungductung 0:8ede47d38d10 478
phungductung 0:8ede47d38d10 479 /**
phungductung 0:8ede47d38d10 480 * @brief Enable the ADC end of conversion interrupt.
phungductung 0:8ede47d38d10 481 * @param __HANDLE__: specifies the ADC Handle.
phungductung 0:8ede47d38d10 482 * @param __INTERRUPT__: ADC Interrupt.
phungductung 0:8ede47d38d10 483 * @retval None
phungductung 0:8ede47d38d10 484 */
phungductung 0:8ede47d38d10 485 #define __HAL_ADC_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1) |= (__INTERRUPT__))
phungductung 0:8ede47d38d10 486
phungductung 0:8ede47d38d10 487 /**
phungductung 0:8ede47d38d10 488 * @brief Disable the ADC end of conversion interrupt.
phungductung 0:8ede47d38d10 489 * @param __HANDLE__: specifies the ADC Handle.
phungductung 0:8ede47d38d10 490 * @param __INTERRUPT__: ADC interrupt.
phungductung 0:8ede47d38d10 491 * @retval None
phungductung 0:8ede47d38d10 492 */
phungductung 0:8ede47d38d10 493 #define __HAL_ADC_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1) &= ~(__INTERRUPT__))
phungductung 0:8ede47d38d10 494
phungductung 0:8ede47d38d10 495 /** @brief Check if the specified ADC interrupt source is enabled or disabled.
phungductung 0:8ede47d38d10 496 * @param __HANDLE__: specifies the ADC Handle.
phungductung 0:8ede47d38d10 497 * @param __INTERRUPT__: specifies the ADC interrupt source to check.
phungductung 0:8ede47d38d10 498 * @retval The new state of __IT__ (TRUE or FALSE).
phungductung 0:8ede47d38d10 499 */
phungductung 0:8ede47d38d10 500 #define __HAL_ADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__))
phungductung 0:8ede47d38d10 501
phungductung 0:8ede47d38d10 502 /**
phungductung 0:8ede47d38d10 503 * @brief Clear the ADC's pending flags.
phungductung 0:8ede47d38d10 504 * @param __HANDLE__: specifies the ADC Handle.
phungductung 0:8ede47d38d10 505 * @param __FLAG__: ADC flag.
phungductung 0:8ede47d38d10 506 * @retval None
phungductung 0:8ede47d38d10 507 */
phungductung 0:8ede47d38d10 508 #define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) = ~(__FLAG__))
phungductung 0:8ede47d38d10 509
phungductung 0:8ede47d38d10 510 /**
phungductung 0:8ede47d38d10 511 * @brief Get the selected ADC's flag status.
phungductung 0:8ede47d38d10 512 * @param __HANDLE__: specifies the ADC Handle.
phungductung 0:8ede47d38d10 513 * @param __FLAG__: ADC flag.
phungductung 0:8ede47d38d10 514 * @retval None
phungductung 0:8ede47d38d10 515 */
phungductung 0:8ede47d38d10 516 #define __HAL_ADC_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
phungductung 0:8ede47d38d10 517
phungductung 0:8ede47d38d10 518 /**
phungductung 0:8ede47d38d10 519 * @}
phungductung 0:8ede47d38d10 520 */
phungductung 0:8ede47d38d10 521
phungductung 0:8ede47d38d10 522 /* Include ADC HAL Extension module */
phungductung 0:8ede47d38d10 523 #include "stm32f7xx_hal_adc_ex.h"
phungductung 0:8ede47d38d10 524
phungductung 0:8ede47d38d10 525 /* Exported functions --------------------------------------------------------*/
phungductung 0:8ede47d38d10 526 /** @addtogroup ADC_Exported_Functions
phungductung 0:8ede47d38d10 527 * @{
phungductung 0:8ede47d38d10 528 */
phungductung 0:8ede47d38d10 529
phungductung 0:8ede47d38d10 530 /** @addtogroup ADC_Exported_Functions_Group1
phungductung 0:8ede47d38d10 531 * @{
phungductung 0:8ede47d38d10 532 */
phungductung 0:8ede47d38d10 533 /* Initialization/de-initialization functions ***********************************/
phungductung 0:8ede47d38d10 534 HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc);
phungductung 0:8ede47d38d10 535 HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
phungductung 0:8ede47d38d10 536 void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
phungductung 0:8ede47d38d10 537 void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
phungductung 0:8ede47d38d10 538 /**
phungductung 0:8ede47d38d10 539 * @}
phungductung 0:8ede47d38d10 540 */
phungductung 0:8ede47d38d10 541
phungductung 0:8ede47d38d10 542 /** @addtogroup ADC_Exported_Functions_Group2
phungductung 0:8ede47d38d10 543 * @{
phungductung 0:8ede47d38d10 544 */
phungductung 0:8ede47d38d10 545 /* I/O operation functions ******************************************************/
phungductung 0:8ede47d38d10 546 HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc);
phungductung 0:8ede47d38d10 547 HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc);
phungductung 0:8ede47d38d10 548 HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
phungductung 0:8ede47d38d10 549
phungductung 0:8ede47d38d10 550 HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout);
phungductung 0:8ede47d38d10 551
phungductung 0:8ede47d38d10 552 HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc);
phungductung 0:8ede47d38d10 553 HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc);
phungductung 0:8ede47d38d10 554
phungductung 0:8ede47d38d10 555 void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc);
phungductung 0:8ede47d38d10 556
phungductung 0:8ede47d38d10 557 HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length);
phungductung 0:8ede47d38d10 558 HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc);
phungductung 0:8ede47d38d10 559
phungductung 0:8ede47d38d10 560 uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc);
phungductung 0:8ede47d38d10 561
phungductung 0:8ede47d38d10 562 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc);
phungductung 0:8ede47d38d10 563 void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc);
phungductung 0:8ede47d38d10 564 void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc);
phungductung 0:8ede47d38d10 565 void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
phungductung 0:8ede47d38d10 566 /**
phungductung 0:8ede47d38d10 567 * @}
phungductung 0:8ede47d38d10 568 */
phungductung 0:8ede47d38d10 569
phungductung 0:8ede47d38d10 570 /** @addtogroup ADC_Exported_Functions_Group3
phungductung 0:8ede47d38d10 571 * @{
phungductung 0:8ede47d38d10 572 */
phungductung 0:8ede47d38d10 573 /* Peripheral Control functions *************************************************/
phungductung 0:8ede47d38d10 574 HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig);
phungductung 0:8ede47d38d10 575 HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig);
phungductung 0:8ede47d38d10 576 /**
phungductung 0:8ede47d38d10 577 * @}
phungductung 0:8ede47d38d10 578 */
phungductung 0:8ede47d38d10 579
phungductung 0:8ede47d38d10 580 /** @addtogroup ADC_Exported_Functions_Group4
phungductung 0:8ede47d38d10 581 * @{
phungductung 0:8ede47d38d10 582 */
phungductung 0:8ede47d38d10 583 /* Peripheral State functions ***************************************************/
phungductung 0:8ede47d38d10 584 uint32_t HAL_ADC_GetState(ADC_HandleTypeDef* hadc);
phungductung 0:8ede47d38d10 585 uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc);
phungductung 0:8ede47d38d10 586 /**
phungductung 0:8ede47d38d10 587 * @}
phungductung 0:8ede47d38d10 588 */
phungductung 0:8ede47d38d10 589
phungductung 0:8ede47d38d10 590 /**
phungductung 0:8ede47d38d10 591 * @}
phungductung 0:8ede47d38d10 592 */
phungductung 0:8ede47d38d10 593
phungductung 0:8ede47d38d10 594 /* Private types -------------------------------------------------------------*/
phungductung 0:8ede47d38d10 595 /* Private variables ---------------------------------------------------------*/
phungductung 0:8ede47d38d10 596 /* Private constants ---------------------------------------------------------*/
phungductung 0:8ede47d38d10 597 /** @defgroup ADC_Private_Constants ADC Private Constants
phungductung 0:8ede47d38d10 598 * @{
phungductung 0:8ede47d38d10 599 */
phungductung 0:8ede47d38d10 600 /* Delay for ADC stabilization time. */
phungductung 0:8ede47d38d10 601 /* Maximum delay is 1us (refer to device datasheet, parameter tSTAB). */
phungductung 0:8ede47d38d10 602 /* Unit: us */
phungductung 0:8ede47d38d10 603 #define ADC_STAB_DELAY_US ((uint32_t) 3)
phungductung 0:8ede47d38d10 604 /* Delay for temperature sensor stabilization time. */
phungductung 0:8ede47d38d10 605 /* Maximum delay is 10us (refer to device datasheet, parameter tSTART). */
phungductung 0:8ede47d38d10 606 /* Unit: us */
phungductung 0:8ede47d38d10 607 #define ADC_TEMPSENSOR_DELAY_US ((uint32_t) 10)
phungductung 0:8ede47d38d10 608 /**
phungductung 0:8ede47d38d10 609 * @}
phungductung 0:8ede47d38d10 610 */
phungductung 0:8ede47d38d10 611
phungductung 0:8ede47d38d10 612 /* Private macros ------------------------------------------------------------*/
phungductung 0:8ede47d38d10 613 /** @defgroup ADC_Private_Macros ADC Private Macros
phungductung 0:8ede47d38d10 614 * @{
phungductung 0:8ede47d38d10 615 */
phungductung 0:8ede47d38d10 616 /* Macro reserved for internal HAL driver usage, not intended to be used in
phungductung 0:8ede47d38d10 617 code of final user */
phungductung 0:8ede47d38d10 618
phungductung 0:8ede47d38d10 619 /**
phungductung 0:8ede47d38d10 620 * @brief Verification of ADC state: enabled or disabled
phungductung 0:8ede47d38d10 621 * @param __HANDLE__: ADC handle
phungductung 0:8ede47d38d10 622 * @retval SET (ADC enabled) or RESET (ADC disabled)
phungductung 0:8ede47d38d10 623 */
phungductung 0:8ede47d38d10 624 #define ADC_IS_ENABLE(__HANDLE__) \
phungductung 0:8ede47d38d10 625 ((( ((__HANDLE__)->Instance->SR & ADC_SR_ADONS) == ADC_SR_ADONS ) \
phungductung 0:8ede47d38d10 626 ) ? SET : RESET)
phungductung 0:8ede47d38d10 627
phungductung 0:8ede47d38d10 628 /**
phungductung 0:8ede47d38d10 629 * @brief Test if conversion trigger of regular group is software start
phungductung 0:8ede47d38d10 630 * or external trigger.
phungductung 0:8ede47d38d10 631 * @param __HANDLE__: ADC handle
phungductung 0:8ede47d38d10 632 * @retval SET (software start) or RESET (external trigger)
phungductung 0:8ede47d38d10 633 */
phungductung 0:8ede47d38d10 634 #define ADC_IS_SOFTWARE_START_REGULAR(__HANDLE__) \
phungductung 0:8ede47d38d10 635 (((__HANDLE__)->Instance->CR2 & ADC_CR2_EXTEN) == RESET)
phungductung 0:8ede47d38d10 636
phungductung 0:8ede47d38d10 637 /**
phungductung 0:8ede47d38d10 638 * @brief Test if conversion trigger of injected group is software start
phungductung 0:8ede47d38d10 639 * or external trigger.
phungductung 0:8ede47d38d10 640 * @param __HANDLE__: ADC handle
phungductung 0:8ede47d38d10 641 * @retval SET (software start) or RESET (external trigger)
phungductung 0:8ede47d38d10 642 */
phungductung 0:8ede47d38d10 643 #define ADC_IS_SOFTWARE_START_INJECTED(__HANDLE__) \
phungductung 0:8ede47d38d10 644 (((__HANDLE__)->Instance->CR2 & ADC_CR2_JEXTEN) == RESET)
phungductung 0:8ede47d38d10 645
phungductung 0:8ede47d38d10 646 /**
phungductung 0:8ede47d38d10 647 * @brief Simultaneously clears and sets specific bits of the handle State
phungductung 0:8ede47d38d10 648 * @note: ADC_STATE_CLR_SET() macro is merely aliased to generic macro MODIFY_REG(),
phungductung 0:8ede47d38d10 649 * the first parameter is the ADC handle State, the second parameter is the
phungductung 0:8ede47d38d10 650 * bit field to clear, the third and last parameter is the bit field to set.
phungductung 0:8ede47d38d10 651 * @retval None
phungductung 0:8ede47d38d10 652 */
phungductung 0:8ede47d38d10 653 #define ADC_STATE_CLR_SET MODIFY_REG
phungductung 0:8ede47d38d10 654
phungductung 0:8ede47d38d10 655 /**
phungductung 0:8ede47d38d10 656 * @brief Clear ADC error code (set it to error code: "no error")
phungductung 0:8ede47d38d10 657 * @param __HANDLE__: ADC handle
phungductung 0:8ede47d38d10 658 * @retval None
phungductung 0:8ede47d38d10 659 */
phungductung 0:8ede47d38d10 660 #define ADC_CLEAR_ERRORCODE(__HANDLE__) \
phungductung 0:8ede47d38d10 661 ((__HANDLE__)->ErrorCode = HAL_ADC_ERROR_NONE)
phungductung 0:8ede47d38d10 662 #define IS_ADC_CLOCKPRESCALER(__ADC_CLOCK__) (((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV2) || \
phungductung 0:8ede47d38d10 663 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV4) || \
phungductung 0:8ede47d38d10 664 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV6) || \
phungductung 0:8ede47d38d10 665 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV8))
phungductung 0:8ede47d38d10 666 #define IS_ADC_SAMPLING_DELAY(__DELAY__) (((__DELAY__) == ADC_TWOSAMPLINGDELAY_5CYCLES) || \
phungductung 0:8ede47d38d10 667 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_6CYCLES) || \
phungductung 0:8ede47d38d10 668 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_7CYCLES) || \
phungductung 0:8ede47d38d10 669 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_8CYCLES) || \
phungductung 0:8ede47d38d10 670 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_9CYCLES) || \
phungductung 0:8ede47d38d10 671 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_10CYCLES) || \
phungductung 0:8ede47d38d10 672 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_11CYCLES) || \
phungductung 0:8ede47d38d10 673 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_12CYCLES) || \
phungductung 0:8ede47d38d10 674 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_13CYCLES) || \
phungductung 0:8ede47d38d10 675 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_14CYCLES) || \
phungductung 0:8ede47d38d10 676 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_15CYCLES) || \
phungductung 0:8ede47d38d10 677 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_16CYCLES) || \
phungductung 0:8ede47d38d10 678 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_17CYCLES) || \
phungductung 0:8ede47d38d10 679 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_18CYCLES) || \
phungductung 0:8ede47d38d10 680 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_19CYCLES) || \
phungductung 0:8ede47d38d10 681 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_20CYCLES))
phungductung 0:8ede47d38d10 682 #define IS_ADC_RESOLUTION(__RESOLUTION__) (((__RESOLUTION__) == ADC_RESOLUTION_12B) || \
phungductung 0:8ede47d38d10 683 ((__RESOLUTION__) == ADC_RESOLUTION_10B) || \
phungductung 0:8ede47d38d10 684 ((__RESOLUTION__) == ADC_RESOLUTION_8B) || \
phungductung 0:8ede47d38d10 685 ((__RESOLUTION__) == ADC_RESOLUTION_6B))
phungductung 0:8ede47d38d10 686 #define IS_ADC_EXT_TRIG_EDGE(__EDGE__) (((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_NONE) || \
phungductung 0:8ede47d38d10 687 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_RISING) || \
phungductung 0:8ede47d38d10 688 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_FALLING) || \
phungductung 0:8ede47d38d10 689 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING))
phungductung 0:8ede47d38d10 690 #define IS_ADC_EXT_TRIG(__REGTRIG__) (((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
phungductung 0:8ede47d38d10 691 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
phungductung 0:8ede47d38d10 692 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_CC3) || \
phungductung 0:8ede47d38d10 693 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
phungductung 0:8ede47d38d10 694 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T5_TRGO) || \
phungductung 0:8ede47d38d10 695 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
phungductung 0:8ede47d38d10 696 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T3_CC4) || \
phungductung 0:8ede47d38d10 697 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T8_TRGO) || \
phungductung 0:8ede47d38d10 698 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T8_TRGO2) || \
phungductung 0:8ede47d38d10 699 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_TRGO) || \
phungductung 0:8ede47d38d10 700 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_TRGO2) || \
phungductung 0:8ede47d38d10 701 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T2_TRGO) || \
phungductung 0:8ede47d38d10 702 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T4_TRGO) || \
phungductung 0:8ede47d38d10 703 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T6_TRGO) || \
phungductung 0:8ede47d38d10 704 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
phungductung 0:8ede47d38d10 705 ((__REGTRIG__) == ADC_SOFTWARE_START))
phungductung 0:8ede47d38d10 706 #define IS_ADC_DATA_ALIGN(__ALIGN__) (((__ALIGN__) == ADC_DATAALIGN_RIGHT) || \
phungductung 0:8ede47d38d10 707 ((__ALIGN__) == ADC_DATAALIGN_LEFT))
phungductung 0:8ede47d38d10 708
phungductung 0:8ede47d38d10 709 #define IS_ADC_SAMPLE_TIME(__TIME__) (((__TIME__) == ADC_SAMPLETIME_3CYCLES) || \
phungductung 0:8ede47d38d10 710 ((__TIME__) == ADC_SAMPLETIME_15CYCLES) || \
phungductung 0:8ede47d38d10 711 ((__TIME__) == ADC_SAMPLETIME_28CYCLES) || \
phungductung 0:8ede47d38d10 712 ((__TIME__) == ADC_SAMPLETIME_56CYCLES) || \
phungductung 0:8ede47d38d10 713 ((__TIME__) == ADC_SAMPLETIME_84CYCLES) || \
phungductung 0:8ede47d38d10 714 ((__TIME__) == ADC_SAMPLETIME_112CYCLES) || \
phungductung 0:8ede47d38d10 715 ((__TIME__) == ADC_SAMPLETIME_144CYCLES) || \
phungductung 0:8ede47d38d10 716 ((__TIME__) == ADC_SAMPLETIME_480CYCLES))
phungductung 0:8ede47d38d10 717 #define IS_ADC_EOCSelection(__EOCSelection__) (((__EOCSelection__) == ADC_EOC_SINGLE_CONV) || \
phungductung 0:8ede47d38d10 718 ((__EOCSelection__) == ADC_EOC_SEQ_CONV) || \
phungductung 0:8ede47d38d10 719 ((__EOCSelection__) == ADC_EOC_SINGLE_SEQ_CONV))
phungductung 0:8ede47d38d10 720 #define IS_ADC_EVENT_TYPE(__EVENT__) (((__EVENT__) == ADC_AWD_EVENT) || \
phungductung 0:8ede47d38d10 721 ((__EVENT__) == ADC_OVR_EVENT))
phungductung 0:8ede47d38d10 722 #define IS_ADC_ANALOG_WATCHDOG(__WATCHDOG__) (((__WATCHDOG__) == ADC_ANALOGWATCHDOG_SINGLE_REG) || \
phungductung 0:8ede47d38d10 723 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_SINGLE_INJEC) || \
phungductung 0:8ede47d38d10 724 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC) || \
phungductung 0:8ede47d38d10 725 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_ALL_REG) || \
phungductung 0:8ede47d38d10 726 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_ALL_INJEC) || \
phungductung 0:8ede47d38d10 727 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_ALL_REGINJEC) || \
phungductung 0:8ede47d38d10 728 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_NONE))
phungductung 0:8ede47d38d10 729 #define IS_ADC_CHANNELS_TYPE(CHANNEL_TYPE) (((CHANNEL_TYPE) == ADC_ALL_CHANNELS) || \
phungductung 0:8ede47d38d10 730 ((CHANNEL_TYPE) == ADC_REGULAR_CHANNELS) || \
phungductung 0:8ede47d38d10 731 ((CHANNEL_TYPE) == ADC_INJECTED_CHANNELS))
phungductung 0:8ede47d38d10 732 #define IS_ADC_THRESHOLD(__THRESHOLD__) ((__THRESHOLD__) <= ((uint32_t)0xFFF))
phungductung 0:8ede47d38d10 733 #define IS_ADC_REGULAR_LENGTH(__LENGTH__) (((__LENGTH__) >= ((uint32_t)1)) && ((__LENGTH__) <= ((uint32_t)16)))
phungductung 0:8ede47d38d10 734 #define IS_ADC_REGULAR_RANK(__RANK__) (((__RANK__) >= ((uint32_t)1)) && ((__RANK__) <= ((uint32_t)16)))
phungductung 0:8ede47d38d10 735 #define IS_ADC_REGULAR_DISC_NUMBER(__NUMBER__) (((__NUMBER__) >= ((uint32_t)1)) && ((__NUMBER__) <= ((uint32_t)8)))
phungductung 0:8ede47d38d10 736 #define IS_ADC_RANGE(__RESOLUTION__, __ADC_VALUE__) \
phungductung 0:8ede47d38d10 737 ((((__RESOLUTION__) == ADC_RESOLUTION_12B) && ((__ADC_VALUE__) <= ((uint32_t)0x0FFF))) || \
phungductung 0:8ede47d38d10 738 (((__RESOLUTION__) == ADC_RESOLUTION_10B) && ((__ADC_VALUE__) <= ((uint32_t)0x03FF))) || \
phungductung 0:8ede47d38d10 739 (((__RESOLUTION__) == ADC_RESOLUTION_8B) && ((__ADC_VALUE__) <= ((uint32_t)0x00FF))) || \
phungductung 0:8ede47d38d10 740 (((__RESOLUTION__) == ADC_RESOLUTION_6B) && ((__ADC_VALUE__) <= ((uint32_t)0x003F))))
phungductung 0:8ede47d38d10 741
phungductung 0:8ede47d38d10 742 /**
phungductung 0:8ede47d38d10 743 * @brief Set ADC Regular channel sequence length.
phungductung 0:8ede47d38d10 744 * @param _NbrOfConversion_: Regular channel sequence length.
phungductung 0:8ede47d38d10 745 * @retval None
phungductung 0:8ede47d38d10 746 */
phungductung 0:8ede47d38d10 747 #define ADC_SQR1(_NbrOfConversion_) (((_NbrOfConversion_) - (uint8_t)1) << 20)
phungductung 0:8ede47d38d10 748
phungductung 0:8ede47d38d10 749 /**
phungductung 0:8ede47d38d10 750 * @brief Set the ADC's sample time for channel numbers between 10 and 18.
phungductung 0:8ede47d38d10 751 * @param _SAMPLETIME_: Sample time parameter.
phungductung 0:8ede47d38d10 752 * @param _CHANNELNB_: Channel number.
phungductung 0:8ede47d38d10 753 * @retval None
phungductung 0:8ede47d38d10 754 */
phungductung 0:8ede47d38d10 755 #define ADC_SMPR1(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3 * (((uint32_t)((uint16_t)(_CHANNELNB_))) - 10)))
phungductung 0:8ede47d38d10 756
phungductung 0:8ede47d38d10 757 /**
phungductung 0:8ede47d38d10 758 * @brief Set the ADC's sample time for channel numbers between 0 and 9.
phungductung 0:8ede47d38d10 759 * @param _SAMPLETIME_: Sample time parameter.
phungductung 0:8ede47d38d10 760 * @param _CHANNELNB_: Channel number.
phungductung 0:8ede47d38d10 761 * @retval None
phungductung 0:8ede47d38d10 762 */
phungductung 0:8ede47d38d10 763 #define ADC_SMPR2(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3 * ((uint32_t)((uint16_t)(_CHANNELNB_)))))
phungductung 0:8ede47d38d10 764
phungductung 0:8ede47d38d10 765 /**
phungductung 0:8ede47d38d10 766 * @brief Set the selected regular channel rank for rank between 1 and 6.
phungductung 0:8ede47d38d10 767 * @param _CHANNELNB_: Channel number.
phungductung 0:8ede47d38d10 768 * @param _RANKNB_: Rank number.
phungductung 0:8ede47d38d10 769 * @retval None
phungductung 0:8ede47d38d10 770 */
phungductung 0:8ede47d38d10 771 #define ADC_SQR3_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5 * ((_RANKNB_) - 1)))
phungductung 0:8ede47d38d10 772
phungductung 0:8ede47d38d10 773 /**
phungductung 0:8ede47d38d10 774 * @brief Set the selected regular channel rank for rank between 7 and 12.
phungductung 0:8ede47d38d10 775 * @param _CHANNELNB_: Channel number.
phungductung 0:8ede47d38d10 776 * @param _RANKNB_: Rank number.
phungductung 0:8ede47d38d10 777 * @retval None
phungductung 0:8ede47d38d10 778 */
phungductung 0:8ede47d38d10 779 #define ADC_SQR2_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5 * ((_RANKNB_) - 7)))
phungductung 0:8ede47d38d10 780
phungductung 0:8ede47d38d10 781 /**
phungductung 0:8ede47d38d10 782 * @brief Set the selected regular channel rank for rank between 13 and 16.
phungductung 0:8ede47d38d10 783 * @param _CHANNELNB_: Channel number.
phungductung 0:8ede47d38d10 784 * @param _RANKNB_: Rank number.
phungductung 0:8ede47d38d10 785 * @retval None
phungductung 0:8ede47d38d10 786 */
phungductung 0:8ede47d38d10 787 #define ADC_SQR1_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5 * ((_RANKNB_) - 13)))
phungductung 0:8ede47d38d10 788
phungductung 0:8ede47d38d10 789 /**
phungductung 0:8ede47d38d10 790 * @brief Enable ADC continuous conversion mode.
phungductung 0:8ede47d38d10 791 * @param _CONTINUOUS_MODE_: Continuous mode.
phungductung 0:8ede47d38d10 792 * @retval None
phungductung 0:8ede47d38d10 793 */
phungductung 0:8ede47d38d10 794 #define ADC_CR2_CONTINUOUS(_CONTINUOUS_MODE_) ((_CONTINUOUS_MODE_) << 1)
phungductung 0:8ede47d38d10 795
phungductung 0:8ede47d38d10 796 /**
phungductung 0:8ede47d38d10 797 * @brief Configures the number of discontinuous conversions for the regular group channels.
phungductung 0:8ede47d38d10 798 * @param _NBR_DISCONTINUOUSCONV_: Number of discontinuous conversions.
phungductung 0:8ede47d38d10 799 * @retval None
phungductung 0:8ede47d38d10 800 */
phungductung 0:8ede47d38d10 801 #define ADC_CR1_DISCONTINUOUS(_NBR_DISCONTINUOUSCONV_) (((_NBR_DISCONTINUOUSCONV_) - 1) << POSITION_VAL(ADC_CR1_DISCNUM))
phungductung 0:8ede47d38d10 802
phungductung 0:8ede47d38d10 803 /**
phungductung 0:8ede47d38d10 804 * @brief Enable ADC scan mode.
phungductung 0:8ede47d38d10 805 * @param _SCANCONV_MODE_: Scan conversion mode.
phungductung 0:8ede47d38d10 806 * @retval None
phungductung 0:8ede47d38d10 807 */
phungductung 0:8ede47d38d10 808 #define ADC_CR1_SCANCONV(_SCANCONV_MODE_) ((_SCANCONV_MODE_) << 8)
phungductung 0:8ede47d38d10 809
phungductung 0:8ede47d38d10 810 /**
phungductung 0:8ede47d38d10 811 * @brief Enable the ADC end of conversion selection.
phungductung 0:8ede47d38d10 812 * @param _EOCSelection_MODE_: End of conversion selection mode.
phungductung 0:8ede47d38d10 813 * @retval None
phungductung 0:8ede47d38d10 814 */
phungductung 0:8ede47d38d10 815 #define ADC_CR2_EOCSelection(_EOCSelection_MODE_) ((_EOCSelection_MODE_) << 10)
phungductung 0:8ede47d38d10 816
phungductung 0:8ede47d38d10 817 /**
phungductung 0:8ede47d38d10 818 * @brief Enable the ADC DMA continuous request.
phungductung 0:8ede47d38d10 819 * @param _DMAContReq_MODE_: DMA continuous request mode.
phungductung 0:8ede47d38d10 820 * @retval None
phungductung 0:8ede47d38d10 821 */
phungductung 0:8ede47d38d10 822 #define ADC_CR2_DMAContReq(_DMAContReq_MODE_) ((_DMAContReq_MODE_) << 9)
phungductung 0:8ede47d38d10 823
phungductung 0:8ede47d38d10 824 /**
phungductung 0:8ede47d38d10 825 * @brief Return resolution bits in CR1 register.
phungductung 0:8ede47d38d10 826 * @param __HANDLE__: ADC handle
phungductung 0:8ede47d38d10 827 * @retval None
phungductung 0:8ede47d38d10 828 */
phungductung 0:8ede47d38d10 829 #define ADC_GET_RESOLUTION(__HANDLE__) (((__HANDLE__)->Instance->CR1) & ADC_CR1_RES)
phungductung 0:8ede47d38d10 830
phungductung 0:8ede47d38d10 831 /**
phungductung 0:8ede47d38d10 832 * @}
phungductung 0:8ede47d38d10 833 */
phungductung 0:8ede47d38d10 834
phungductung 0:8ede47d38d10 835 /* Private functions ---------------------------------------------------------*/
phungductung 0:8ede47d38d10 836 /** @defgroup ADC_Private_Functions ADC Private Functions
phungductung 0:8ede47d38d10 837 * @{
phungductung 0:8ede47d38d10 838 */
phungductung 0:8ede47d38d10 839
phungductung 0:8ede47d38d10 840 /**
phungductung 0:8ede47d38d10 841 * @}
phungductung 0:8ede47d38d10 842 */
phungductung 0:8ede47d38d10 843
phungductung 0:8ede47d38d10 844 /**
phungductung 0:8ede47d38d10 845 * @}
phungductung 0:8ede47d38d10 846 */
phungductung 0:8ede47d38d10 847
phungductung 0:8ede47d38d10 848 /**
phungductung 0:8ede47d38d10 849 * @}
phungductung 0:8ede47d38d10 850 */
phungductung 0:8ede47d38d10 851
phungductung 0:8ede47d38d10 852 #ifdef __cplusplus
phungductung 0:8ede47d38d10 853 }
phungductung 0:8ede47d38d10 854 #endif
phungductung 0:8ede47d38d10 855
phungductung 0:8ede47d38d10 856 #endif /*__STM32F7xx_ADC_H */
phungductung 0:8ede47d38d10 857
phungductung 0:8ede47d38d10 858
phungductung 0:8ede47d38d10 859 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/