Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
elijahorr
Date:
Thu Apr 14 07:28:54 2016 +0000
Revision:
121:672067c3ada4
Parent:
116:c0f6e94411f5
.

Who changed what in which revision?

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