mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
Kojto
Date:
Tue Mar 15 14:34:00 2016 +0000
Revision:
116:c0f6e94411f5
Parent:
107:4f6c30876dfa
Child:
122:f9eeca106725
Release 116 of the mbed library

Changes:
- new targets - NUCLEO_L073RZ
- fixes to IOTSS BEID platform
- LPC824, LPC1549 and LPC11U68 - fix PWMOut SCT bugs
- STM32F7 - Cube driver
- STM32F4 - add RTC LSI macro, defined as 0
- STM32F3 - fix multiple ADC clock initialization
- retarget - binary mode fix for GCC

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 107:4f6c30876dfa 1 /**
Kojto 107:4f6c30876dfa 2 ******************************************************************************
Kojto 107:4f6c30876dfa 3 * @file stm32f7xx_hal_adc.h
Kojto 107:4f6c30876dfa 4 * @author MCD Application Team
Kojto 116:c0f6e94411f5 5 * @version V1.0.4
Kojto 116:c0f6e94411f5 6 * @date 09-December-2015
Kojto 107:4f6c30876dfa 7 * @brief Header file of ADC HAL extension module.
Kojto 107:4f6c30876dfa 8 ******************************************************************************
Kojto 107:4f6c30876dfa 9 * @attention
Kojto 107:4f6c30876dfa 10 *
Kojto 107:4f6c30876dfa 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
Kojto 107:4f6c30876dfa 12 *
Kojto 107:4f6c30876dfa 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 107:4f6c30876dfa 14 * are permitted provided that the following conditions are met:
Kojto 107:4f6c30876dfa 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 107:4f6c30876dfa 16 * this list of conditions and the following disclaimer.
Kojto 107:4f6c30876dfa 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 107:4f6c30876dfa 18 * this list of conditions and the following disclaimer in the documentation
Kojto 107:4f6c30876dfa 19 * and/or other materials provided with the distribution.
Kojto 107:4f6c30876dfa 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 107:4f6c30876dfa 21 * may be used to endorse or promote products derived from this software
Kojto 107:4f6c30876dfa 22 * without specific prior written permission.
Kojto 107:4f6c30876dfa 23 *
Kojto 107:4f6c30876dfa 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 107:4f6c30876dfa 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 107:4f6c30876dfa 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 107:4f6c30876dfa 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 107:4f6c30876dfa 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 107:4f6c30876dfa 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 107:4f6c30876dfa 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 107:4f6c30876dfa 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 107:4f6c30876dfa 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 107:4f6c30876dfa 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 107:4f6c30876dfa 34 *
Kojto 107:4f6c30876dfa 35 ******************************************************************************
Kojto 107:4f6c30876dfa 36 */
Kojto 107:4f6c30876dfa 37
Kojto 107:4f6c30876dfa 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 107:4f6c30876dfa 39 #ifndef __STM32F7xx_ADC_H
Kojto 107:4f6c30876dfa 40 #define __STM32F7xx_ADC_H
Kojto 107:4f6c30876dfa 41
Kojto 107:4f6c30876dfa 42 #ifdef __cplusplus
Kojto 107:4f6c30876dfa 43 extern "C" {
Kojto 107:4f6c30876dfa 44 #endif
Kojto 107:4f6c30876dfa 45
Kojto 107:4f6c30876dfa 46 /* Includes ------------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 47 #include "stm32f7xx_hal_def.h"
Kojto 107:4f6c30876dfa 48
Kojto 107:4f6c30876dfa 49 /** @addtogroup STM32F7xx_HAL_Driver
Kojto 107:4f6c30876dfa 50 * @{
Kojto 107:4f6c30876dfa 51 */
Kojto 107:4f6c30876dfa 52
Kojto 107:4f6c30876dfa 53 /** @addtogroup ADC
Kojto 107:4f6c30876dfa 54 * @{
Kojto 107:4f6c30876dfa 55 */
Kojto 107:4f6c30876dfa 56
Kojto 107:4f6c30876dfa 57 /* Exported types ------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 58 /** @defgroup ADC_Exported_Types ADC Exported Types
Kojto 107:4f6c30876dfa 59 * @{
Kojto 107:4f6c30876dfa 60 */
Kojto 107:4f6c30876dfa 61
Kojto 107:4f6c30876dfa 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 107:4f6c30876dfa 75 typedef struct
Kojto 107:4f6c30876dfa 76 {
Kojto 116:c0f6e94411f5 77 uint32_t ClockPrescaler; /*!< Select ADC clock prescaler. The clock is common for
Kojto 107:4f6c30876dfa 78 all the ADCs.
Kojto 107:4f6c30876dfa 79 This parameter can be a value of @ref ADC_ClockPrescaler */
Kojto 116:c0f6e94411f5 80 uint32_t Resolution; /*!< Configures the ADC resolution.
Kojto 107:4f6c30876dfa 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 107:4f6c30876dfa 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 107:4f6c30876dfa 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 107:4f6c30876dfa 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 107:4f6c30876dfa 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 107:4f6c30876dfa 110 This parameter must be a number between Min_Data = 1 and Max_Data = 8. */
Kojto 107:4f6c30876dfa 111 uint32_t ExternalTrigConv; /*!< Selects the external event used to trigger the conversion start of regular group.
Kojto 107:4f6c30876dfa 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 107:4f6c30876dfa 115 uint32_t ExternalTrigConvEdge; /*!< Selects the external trigger edge of regular group.
Kojto 107:4f6c30876dfa 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 107:4f6c30876dfa 123 }ADC_InitTypeDef;
Kojto 107:4f6c30876dfa 124
Kojto 116:c0f6e94411f5 125
Kojto 116:c0f6e94411f5 126
Kojto 107:4f6c30876dfa 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 107:4f6c30876dfa 131 */
Kojto 107:4f6c30876dfa 132 typedef struct
Kojto 107:4f6c30876dfa 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 107:4f6c30876dfa 148 }ADC_ChannelConfTypeDef;
Kojto 107:4f6c30876dfa 149
Kojto 107:4f6c30876dfa 150 /**
Kojto 116:c0f6e94411f5 151 * @brief ADC Configuration multi-mode structure definition
Kojto 107:4f6c30876dfa 152 */
Kojto 107:4f6c30876dfa 153 typedef struct
Kojto 107:4f6c30876dfa 154 {
Kojto 107:4f6c30876dfa 155 uint32_t WatchdogMode; /*!< Configures the ADC analog watchdog mode.
Kojto 107:4f6c30876dfa 156 This parameter can be a value of @ref ADC_analog_watchdog_selection */
Kojto 107:4f6c30876dfa 157 uint32_t HighThreshold; /*!< Configures the ADC analog watchdog High threshold value.
Kojto 107:4f6c30876dfa 158 This parameter must be a 12-bit value. */
Kojto 107:4f6c30876dfa 159 uint32_t LowThreshold; /*!< Configures the ADC analog watchdog High threshold value.
Kojto 107:4f6c30876dfa 160 This parameter must be a 12-bit value. */
Kojto 107:4f6c30876dfa 161 uint32_t Channel; /*!< Configures ADC channel for the analog watchdog.
Kojto 107:4f6c30876dfa 162 This parameter has an effect only if watchdog mode is configured on single channel
Kojto 107:4f6c30876dfa 163 This parameter can be a value of @ref ADC_channels */
Kojto 107:4f6c30876dfa 164 uint32_t ITMode; /*!< Specifies whether the analog watchdog is configured
Kojto 107:4f6c30876dfa 165 is interrupt mode or in polling mode.
Kojto 107:4f6c30876dfa 166 This parameter can be set to ENABLE or DISABLE */
Kojto 107:4f6c30876dfa 167 uint32_t WatchdogNumber; /*!< Reserved for future use, can be set to 0 */
Kojto 107:4f6c30876dfa 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 107:4f6c30876dfa 223 /**
Kojto 107:4f6c30876dfa 224 * @}
Kojto 107:4f6c30876dfa 225 */
Kojto 107:4f6c30876dfa 226
Kojto 107:4f6c30876dfa 227 /* Exported constants --------------------------------------------------------*/
Kojto 107:4f6c30876dfa 228 /** @defgroup ADC_Exported_Constants ADC Exported Constants
Kojto 107:4f6c30876dfa 229 * @{
Kojto 107:4f6c30876dfa 230 */
Kojto 107:4f6c30876dfa 231
Kojto 107:4f6c30876dfa 232 /** @defgroup ADC_Error_Code ADC Error Code
Kojto 107:4f6c30876dfa 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 107:4f6c30876dfa 240 /**
Kojto 107:4f6c30876dfa 241 * @}
Kojto 116:c0f6e94411f5 242 */
Kojto 107:4f6c30876dfa 243
Kojto 107:4f6c30876dfa 244
Kojto 116:c0f6e94411f5 245 /** @defgroup ADC_ClockPrescaler ADC Clock Prescaler
Kojto 107:4f6c30876dfa 246 * @{
Kojto 107:4f6c30876dfa 247 */
Kojto 107:4f6c30876dfa 248 #define ADC_CLOCK_SYNC_PCLK_DIV2 ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 249 #define ADC_CLOCK_SYNC_PCLK_DIV4 ((uint32_t)ADC_CCR_ADCPRE_0)
Kojto 107:4f6c30876dfa 250 #define ADC_CLOCK_SYNC_PCLK_DIV6 ((uint32_t)ADC_CCR_ADCPRE_1)
Kojto 107:4f6c30876dfa 251 #define ADC_CLOCK_SYNC_PCLK_DIV8 ((uint32_t)ADC_CCR_ADCPRE)
Kojto 107:4f6c30876dfa 252 /**
Kojto 107:4f6c30876dfa 253 * @}
Kojto 107:4f6c30876dfa 254 */
Kojto 107:4f6c30876dfa 255
Kojto 107:4f6c30876dfa 256 /** @defgroup ADC_delay_between_2_sampling_phases ADC Delay Between 2 Sampling Phases
Kojto 107:4f6c30876dfa 257 * @{
Kojto 107:4f6c30876dfa 258 */
Kojto 107:4f6c30876dfa 259 #define ADC_TWOSAMPLINGDELAY_5CYCLES ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 260 #define ADC_TWOSAMPLINGDELAY_6CYCLES ((uint32_t)ADC_CCR_DELAY_0)
Kojto 107:4f6c30876dfa 261 #define ADC_TWOSAMPLINGDELAY_7CYCLES ((uint32_t)ADC_CCR_DELAY_1)
Kojto 107:4f6c30876dfa 262 #define ADC_TWOSAMPLINGDELAY_8CYCLES ((uint32_t)(ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
Kojto 107:4f6c30876dfa 263 #define ADC_TWOSAMPLINGDELAY_9CYCLES ((uint32_t)ADC_CCR_DELAY_2)
Kojto 107:4f6c30876dfa 264 #define ADC_TWOSAMPLINGDELAY_10CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0))
Kojto 107:4f6c30876dfa 265 #define ADC_TWOSAMPLINGDELAY_11CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1))
Kojto 107:4f6c30876dfa 266 #define ADC_TWOSAMPLINGDELAY_12CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
Kojto 107:4f6c30876dfa 267 #define ADC_TWOSAMPLINGDELAY_13CYCLES ((uint32_t)ADC_CCR_DELAY_3)
Kojto 107:4f6c30876dfa 268 #define ADC_TWOSAMPLINGDELAY_14CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_0))
Kojto 107:4f6c30876dfa 269 #define ADC_TWOSAMPLINGDELAY_15CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1))
Kojto 107:4f6c30876dfa 270 #define ADC_TWOSAMPLINGDELAY_16CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
Kojto 107:4f6c30876dfa 271 #define ADC_TWOSAMPLINGDELAY_17CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2))
Kojto 107:4f6c30876dfa 272 #define ADC_TWOSAMPLINGDELAY_18CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0))
Kojto 107:4f6c30876dfa 273 #define ADC_TWOSAMPLINGDELAY_19CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1))
Kojto 107:4f6c30876dfa 274 #define ADC_TWOSAMPLINGDELAY_20CYCLES ((uint32_t)ADC_CCR_DELAY)
Kojto 107:4f6c30876dfa 275 /**
Kojto 107:4f6c30876dfa 276 * @}
Kojto 107:4f6c30876dfa 277 */
Kojto 107:4f6c30876dfa 278
Kojto 107:4f6c30876dfa 279 /** @defgroup ADC_Resolution ADC Resolution
Kojto 107:4f6c30876dfa 280 * @{
Kojto 107:4f6c30876dfa 281 */
Kojto 107:4f6c30876dfa 282 #define ADC_RESOLUTION_12B ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 283 #define ADC_RESOLUTION_10B ((uint32_t)ADC_CR1_RES_0)
Kojto 107:4f6c30876dfa 284 #define ADC_RESOLUTION_8B ((uint32_t)ADC_CR1_RES_1)
Kojto 107:4f6c30876dfa 285 #define ADC_RESOLUTION_6B ((uint32_t)ADC_CR1_RES)
Kojto 107:4f6c30876dfa 286 /**
Kojto 107:4f6c30876dfa 287 * @}
Kojto 107:4f6c30876dfa 288 */
Kojto 107:4f6c30876dfa 289
Kojto 107:4f6c30876dfa 290 /** @defgroup ADC_External_trigger_edge_Regular ADC External Trigger Edge Regular
Kojto 107:4f6c30876dfa 291 * @{
Kojto 107:4f6c30876dfa 292 */
Kojto 107:4f6c30876dfa 293 #define ADC_EXTERNALTRIGCONVEDGE_NONE ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 294 #define ADC_EXTERNALTRIGCONVEDGE_RISING ((uint32_t)ADC_CR2_EXTEN_0)
Kojto 107:4f6c30876dfa 295 #define ADC_EXTERNALTRIGCONVEDGE_FALLING ((uint32_t)ADC_CR2_EXTEN_1)
Kojto 107:4f6c30876dfa 296 #define ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING ((uint32_t)ADC_CR2_EXTEN)
Kojto 107:4f6c30876dfa 297 /**
Kojto 107:4f6c30876dfa 298 * @}
Kojto 107:4f6c30876dfa 299 */
Kojto 107:4f6c30876dfa 300
Kojto 107:4f6c30876dfa 301 /** @defgroup ADC_External_trigger_Source_Regular ADC External Trigger Source Regular
Kojto 107:4f6c30876dfa 302 * @{
Kojto 107:4f6c30876dfa 303 */
Kojto 107:4f6c30876dfa 304 /* Note: Parameter ADC_SOFTWARE_START is a software parameter used for */
Kojto 107:4f6c30876dfa 305 /* compatibility with other STM32 devices. */
Kojto 116:c0f6e94411f5 306
Kojto 116:c0f6e94411f5 307
Kojto 107:4f6c30876dfa 308 #define ADC_EXTERNALTRIGCONV_T1_CC1 ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 309 #define ADC_EXTERNALTRIGCONV_T1_CC2 ((uint32_t)ADC_CR2_EXTSEL_0)
Kojto 107:4f6c30876dfa 310 #define ADC_EXTERNALTRIGCONV_T1_CC3 ((uint32_t)ADC_CR2_EXTSEL_1)
Kojto 107:4f6c30876dfa 311 #define ADC_EXTERNALTRIGCONV_T2_CC2 ((uint32_t)(ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
Kojto 107:4f6c30876dfa 312 #define ADC_EXTERNALTRIGCONV_T5_TRGO ((uint32_t)ADC_CR2_EXTSEL_2)
Kojto 107:4f6c30876dfa 313 #define ADC_EXTERNALTRIGCONV_T4_CC4 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
Kojto 107:4f6c30876dfa 314 #define ADC_EXTERNALTRIGCONV_T3_CC4 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1))
Kojto 107:4f6c30876dfa 315 #define ADC_EXTERNALTRIGCONV_T8_TRGO ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
Kojto 107:4f6c30876dfa 316 #define ADC_EXTERNALTRIGCONV_T8_TRGO2 ((uint32_t)ADC_CR2_EXTSEL_3)
Kojto 107:4f6c30876dfa 317 #define ADC_EXTERNALTRIGCONV_T1_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_0))
Kojto 107:4f6c30876dfa 318 #define ADC_EXTERNALTRIGCONV_T1_TRGO2 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1))
Kojto 107:4f6c30876dfa 319 #define ADC_EXTERNALTRIGCONV_T2_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
Kojto 107:4f6c30876dfa 320 #define ADC_EXTERNALTRIGCONV_T4_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2))
Kojto 107:4f6c30876dfa 321 #define ADC_EXTERNALTRIGCONV_T6_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
Kojto 107:4f6c30876dfa 322
Kojto 107:4f6c30876dfa 323 #define ADC_EXTERNALTRIGCONV_EXT_IT11 ((uint32_t)ADC_CR2_EXTSEL)
Kojto 107:4f6c30876dfa 324 #define ADC_SOFTWARE_START ((uint32_t)ADC_CR2_EXTSEL + 1)
Kojto 116:c0f6e94411f5 325
Kojto 107:4f6c30876dfa 326 /**
Kojto 107:4f6c30876dfa 327 * @}
Kojto 107:4f6c30876dfa 328 */
Kojto 107:4f6c30876dfa 329
Kojto 116:c0f6e94411f5 330 /** @defgroup ADC_data_align ADC Data Align
Kojto 107:4f6c30876dfa 331 * @{
Kojto 107:4f6c30876dfa 332 */
Kojto 107:4f6c30876dfa 333 #define ADC_DATAALIGN_RIGHT ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 334 #define ADC_DATAALIGN_LEFT ((uint32_t)ADC_CR2_ALIGN)
Kojto 107:4f6c30876dfa 335 /**
Kojto 107:4f6c30876dfa 336 * @}
Kojto 107:4f6c30876dfa 337 */
Kojto 107:4f6c30876dfa 338
Kojto 107:4f6c30876dfa 339 /** @defgroup ADC_channels ADC Common Channels
Kojto 107:4f6c30876dfa 340 * @{
Kojto 107:4f6c30876dfa 341 */
Kojto 107:4f6c30876dfa 342 #define ADC_CHANNEL_0 ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 343 #define ADC_CHANNEL_1 ((uint32_t)ADC_CR1_AWDCH_0)
Kojto 107:4f6c30876dfa 344 #define ADC_CHANNEL_2 ((uint32_t)ADC_CR1_AWDCH_1)
Kojto 107:4f6c30876dfa 345 #define ADC_CHANNEL_3 ((uint32_t)(ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 107:4f6c30876dfa 346 #define ADC_CHANNEL_4 ((uint32_t)ADC_CR1_AWDCH_2)
Kojto 107:4f6c30876dfa 347 #define ADC_CHANNEL_5 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0))
Kojto 107:4f6c30876dfa 348 #define ADC_CHANNEL_6 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1))
Kojto 107:4f6c30876dfa 349 #define ADC_CHANNEL_7 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 107:4f6c30876dfa 350 #define ADC_CHANNEL_8 ((uint32_t)ADC_CR1_AWDCH_3)
Kojto 107:4f6c30876dfa 351 #define ADC_CHANNEL_9 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0))
Kojto 107:4f6c30876dfa 352 #define ADC_CHANNEL_10 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1))
Kojto 107:4f6c30876dfa 353 #define ADC_CHANNEL_11 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 107:4f6c30876dfa 354 #define ADC_CHANNEL_12 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2))
Kojto 107:4f6c30876dfa 355 #define ADC_CHANNEL_13 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0))
Kojto 107:4f6c30876dfa 356 #define ADC_CHANNEL_14 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1))
Kojto 107:4f6c30876dfa 357 #define ADC_CHANNEL_15 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 107:4f6c30876dfa 358 #define ADC_CHANNEL_16 ((uint32_t)ADC_CR1_AWDCH_4)
Kojto 107:4f6c30876dfa 359 #define ADC_CHANNEL_17 ((uint32_t)(ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_0))
Kojto 107:4f6c30876dfa 360 #define ADC_CHANNEL_18 ((uint32_t)(ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_1))
Kojto 107:4f6c30876dfa 361
Kojto 107:4f6c30876dfa 362 #define ADC_CHANNEL_VREFINT ((uint32_t)ADC_CHANNEL_17)
Kojto 107:4f6c30876dfa 363 #define ADC_CHANNEL_VBAT ((uint32_t)ADC_CHANNEL_18)
Kojto 107:4f6c30876dfa 364 /**
Kojto 107:4f6c30876dfa 365 * @}
Kojto 107:4f6c30876dfa 366 */
Kojto 107:4f6c30876dfa 367
Kojto 107:4f6c30876dfa 368 /** @defgroup ADC_sampling_times ADC Sampling Times
Kojto 107:4f6c30876dfa 369 * @{
Kojto 107:4f6c30876dfa 370 */
Kojto 107:4f6c30876dfa 371 #define ADC_SAMPLETIME_3CYCLES ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 372 #define ADC_SAMPLETIME_15CYCLES ((uint32_t)ADC_SMPR1_SMP10_0)
Kojto 107:4f6c30876dfa 373 #define ADC_SAMPLETIME_28CYCLES ((uint32_t)ADC_SMPR1_SMP10_1)
Kojto 107:4f6c30876dfa 374 #define ADC_SAMPLETIME_56CYCLES ((uint32_t)(ADC_SMPR1_SMP10_1 | ADC_SMPR1_SMP10_0))
Kojto 107:4f6c30876dfa 375 #define ADC_SAMPLETIME_84CYCLES ((uint32_t)ADC_SMPR1_SMP10_2)
Kojto 107:4f6c30876dfa 376 #define ADC_SAMPLETIME_112CYCLES ((uint32_t)(ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_0))
Kojto 107:4f6c30876dfa 377 #define ADC_SAMPLETIME_144CYCLES ((uint32_t)(ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_1))
Kojto 107:4f6c30876dfa 378 #define ADC_SAMPLETIME_480CYCLES ((uint32_t)ADC_SMPR1_SMP10)
Kojto 107:4f6c30876dfa 379 /**
Kojto 107:4f6c30876dfa 380 * @}
Kojto 107:4f6c30876dfa 381 */
Kojto 107:4f6c30876dfa 382
Kojto 107:4f6c30876dfa 383 /** @defgroup ADC_EOCSelection ADC EOC Selection
Kojto 107:4f6c30876dfa 384 * @{
Kojto 107:4f6c30876dfa 385 */
Kojto 107:4f6c30876dfa 386 #define ADC_EOC_SEQ_CONV ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 387 #define ADC_EOC_SINGLE_CONV ((uint32_t)0x00000001)
Kojto 107:4f6c30876dfa 388 #define ADC_EOC_SINGLE_SEQ_CONV ((uint32_t)0x00000002) /*!< reserved for future use */
Kojto 107:4f6c30876dfa 389 /**
Kojto 107:4f6c30876dfa 390 * @}
Kojto 107:4f6c30876dfa 391 */
Kojto 107:4f6c30876dfa 392
Kojto 107:4f6c30876dfa 393 /** @defgroup ADC_Event_type ADC Event Type
Kojto 107:4f6c30876dfa 394 * @{
Kojto 107:4f6c30876dfa 395 */
Kojto 107:4f6c30876dfa 396 #define ADC_AWD_EVENT ((uint32_t)ADC_FLAG_AWD)
Kojto 107:4f6c30876dfa 397 #define ADC_OVR_EVENT ((uint32_t)ADC_FLAG_OVR)
Kojto 107:4f6c30876dfa 398 /**
Kojto 107:4f6c30876dfa 399 * @}
Kojto 107:4f6c30876dfa 400 */
Kojto 107:4f6c30876dfa 401
Kojto 107:4f6c30876dfa 402 /** @defgroup ADC_analog_watchdog_selection ADC Analog Watchdog Selection
Kojto 107:4f6c30876dfa 403 * @{
Kojto 107:4f6c30876dfa 404 */
Kojto 107:4f6c30876dfa 405 #define ADC_ANALOGWATCHDOG_SINGLE_REG ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN))
Kojto 107:4f6c30876dfa 406 #define ADC_ANALOGWATCHDOG_SINGLE_INJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_JAWDEN))
Kojto 107:4f6c30876dfa 407 #define ADC_ANALOGWATCHDOG_SINGLE_REGINJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
Kojto 107:4f6c30876dfa 408 #define ADC_ANALOGWATCHDOG_ALL_REG ((uint32_t)ADC_CR1_AWDEN)
Kojto 107:4f6c30876dfa 409 #define ADC_ANALOGWATCHDOG_ALL_INJEC ((uint32_t)ADC_CR1_JAWDEN)
Kojto 107:4f6c30876dfa 410 #define ADC_ANALOGWATCHDOG_ALL_REGINJEC ((uint32_t)(ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
Kojto 107:4f6c30876dfa 411 #define ADC_ANALOGWATCHDOG_NONE ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 412 /**
Kojto 107:4f6c30876dfa 413 * @}
Kojto 107:4f6c30876dfa 414 */
Kojto 107:4f6c30876dfa 415
Kojto 107:4f6c30876dfa 416 /** @defgroup ADC_interrupts_definition ADC Interrupts Definition
Kojto 107:4f6c30876dfa 417 * @{
Kojto 107:4f6c30876dfa 418 */
Kojto 107:4f6c30876dfa 419 #define ADC_IT_EOC ((uint32_t)ADC_CR1_EOCIE)
Kojto 107:4f6c30876dfa 420 #define ADC_IT_AWD ((uint32_t)ADC_CR1_AWDIE)
Kojto 107:4f6c30876dfa 421 #define ADC_IT_JEOC ((uint32_t)ADC_CR1_JEOCIE)
Kojto 107:4f6c30876dfa 422 #define ADC_IT_OVR ((uint32_t)ADC_CR1_OVRIE)
Kojto 107:4f6c30876dfa 423 /**
Kojto 107:4f6c30876dfa 424 * @}
Kojto 107:4f6c30876dfa 425 */
Kojto 107:4f6c30876dfa 426
Kojto 107:4f6c30876dfa 427 /** @defgroup ADC_flags_definition ADC Flags Definition
Kojto 107:4f6c30876dfa 428 * @{
Kojto 107:4f6c30876dfa 429 */
Kojto 107:4f6c30876dfa 430 #define ADC_FLAG_AWD ((uint32_t)ADC_SR_AWD)
Kojto 107:4f6c30876dfa 431 #define ADC_FLAG_EOC ((uint32_t)ADC_SR_EOC)
Kojto 107:4f6c30876dfa 432 #define ADC_FLAG_JEOC ((uint32_t)ADC_SR_JEOC)
Kojto 107:4f6c30876dfa 433 #define ADC_FLAG_JSTRT ((uint32_t)ADC_SR_JSTRT)
Kojto 107:4f6c30876dfa 434 #define ADC_FLAG_STRT ((uint32_t)ADC_SR_STRT)
Kojto 107:4f6c30876dfa 435 #define ADC_FLAG_OVR ((uint32_t)ADC_SR_OVR)
Kojto 107:4f6c30876dfa 436 /**
Kojto 107:4f6c30876dfa 437 * @}
Kojto 107:4f6c30876dfa 438 */
Kojto 107:4f6c30876dfa 439
Kojto 107:4f6c30876dfa 440 /** @defgroup ADC_channels_type ADC Channels Type
Kojto 107:4f6c30876dfa 441 * @{
Kojto 107:4f6c30876dfa 442 */
Kojto 107:4f6c30876dfa 443 #define ADC_ALL_CHANNELS ((uint32_t)0x00000001)
Kojto 107:4f6c30876dfa 444 #define ADC_REGULAR_CHANNELS ((uint32_t)0x00000002) /*!< reserved for future use */
Kojto 107:4f6c30876dfa 445 #define ADC_INJECTED_CHANNELS ((uint32_t)0x00000003) /*!< reserved for future use */
Kojto 107:4f6c30876dfa 446 /**
Kojto 107:4f6c30876dfa 447 * @}
Kojto 107:4f6c30876dfa 448 */
Kojto 107:4f6c30876dfa 449
Kojto 107:4f6c30876dfa 450 /**
Kojto 107:4f6c30876dfa 451 * @}
Kojto 107:4f6c30876dfa 452 */
Kojto 107:4f6c30876dfa 453
Kojto 107:4f6c30876dfa 454 /* Exported macro ------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 455 /** @defgroup ADC_Exported_Macros ADC Exported Macros
Kojto 107:4f6c30876dfa 456 * @{
Kojto 107:4f6c30876dfa 457 */
Kojto 107:4f6c30876dfa 458
Kojto 107:4f6c30876dfa 459 /** @brief Reset ADC handle state
Kojto 107:4f6c30876dfa 460 * @param __HANDLE__: ADC handle
Kojto 107:4f6c30876dfa 461 * @retval None
Kojto 107:4f6c30876dfa 462 */
Kojto 107:4f6c30876dfa 463 #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
Kojto 107:4f6c30876dfa 464
Kojto 107:4f6c30876dfa 465 /**
Kojto 107:4f6c30876dfa 466 * @brief Enable the ADC peripheral.
Kojto 107:4f6c30876dfa 467 * @param __HANDLE__: ADC handle
Kojto 107:4f6c30876dfa 468 * @retval None
Kojto 107:4f6c30876dfa 469 */
Kojto 107:4f6c30876dfa 470 #define __HAL_ADC_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR2 |= ADC_CR2_ADON)
Kojto 107:4f6c30876dfa 471
Kojto 107:4f6c30876dfa 472 /**
Kojto 107:4f6c30876dfa 473 * @brief Disable the ADC peripheral.
Kojto 107:4f6c30876dfa 474 * @param __HANDLE__: ADC handle
Kojto 107:4f6c30876dfa 475 * @retval None
Kojto 107:4f6c30876dfa 476 */
Kojto 107:4f6c30876dfa 477 #define __HAL_ADC_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR2 &= ~ADC_CR2_ADON)
Kojto 107:4f6c30876dfa 478
Kojto 107:4f6c30876dfa 479 /**
Kojto 107:4f6c30876dfa 480 * @brief Enable the ADC end of conversion interrupt.
Kojto 107:4f6c30876dfa 481 * @param __HANDLE__: specifies the ADC Handle.
Kojto 107:4f6c30876dfa 482 * @param __INTERRUPT__: ADC Interrupt.
Kojto 107:4f6c30876dfa 483 * @retval None
Kojto 107:4f6c30876dfa 484 */
Kojto 107:4f6c30876dfa 485 #define __HAL_ADC_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1) |= (__INTERRUPT__))
Kojto 107:4f6c30876dfa 486
Kojto 107:4f6c30876dfa 487 /**
Kojto 107:4f6c30876dfa 488 * @brief Disable the ADC end of conversion interrupt.
Kojto 107:4f6c30876dfa 489 * @param __HANDLE__: specifies the ADC Handle.
Kojto 107:4f6c30876dfa 490 * @param __INTERRUPT__: ADC interrupt.
Kojto 107:4f6c30876dfa 491 * @retval None
Kojto 107:4f6c30876dfa 492 */
Kojto 107:4f6c30876dfa 493 #define __HAL_ADC_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1) &= ~(__INTERRUPT__))
Kojto 107:4f6c30876dfa 494
Kojto 107:4f6c30876dfa 495 /** @brief Check if the specified ADC interrupt source is enabled or disabled.
Kojto 107:4f6c30876dfa 496 * @param __HANDLE__: specifies the ADC Handle.
Kojto 107:4f6c30876dfa 497 * @param __INTERRUPT__: specifies the ADC interrupt source to check.
Kojto 107:4f6c30876dfa 498 * @retval The new state of __IT__ (TRUE or FALSE).
Kojto 107:4f6c30876dfa 499 */
Kojto 107:4f6c30876dfa 500 #define __HAL_ADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__))
Kojto 107:4f6c30876dfa 501
Kojto 107:4f6c30876dfa 502 /**
Kojto 107:4f6c30876dfa 503 * @brief Clear the ADC's pending flags.
Kojto 107:4f6c30876dfa 504 * @param __HANDLE__: specifies the ADC Handle.
Kojto 107:4f6c30876dfa 505 * @param __FLAG__: ADC flag.
Kojto 107:4f6c30876dfa 506 * @retval None
Kojto 107:4f6c30876dfa 507 */
Kojto 107:4f6c30876dfa 508 #define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) = ~(__FLAG__))
Kojto 107:4f6c30876dfa 509
Kojto 107:4f6c30876dfa 510 /**
Kojto 107:4f6c30876dfa 511 * @brief Get the selected ADC's flag status.
Kojto 107:4f6c30876dfa 512 * @param __HANDLE__: specifies the ADC Handle.
Kojto 107:4f6c30876dfa 513 * @param __FLAG__: ADC flag.
Kojto 107:4f6c30876dfa 514 * @retval None
Kojto 107:4f6c30876dfa 515 */
Kojto 107:4f6c30876dfa 516 #define __HAL_ADC_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
Kojto 107:4f6c30876dfa 517
Kojto 107:4f6c30876dfa 518 /**
Kojto 107:4f6c30876dfa 519 * @}
Kojto 107:4f6c30876dfa 520 */
Kojto 107:4f6c30876dfa 521
Kojto 107:4f6c30876dfa 522 /* Include ADC HAL Extension module */
Kojto 107:4f6c30876dfa 523 #include "stm32f7xx_hal_adc_ex.h"
Kojto 107:4f6c30876dfa 524
Kojto 107:4f6c30876dfa 525 /* Exported functions --------------------------------------------------------*/
Kojto 107:4f6c30876dfa 526 /** @addtogroup ADC_Exported_Functions
Kojto 107:4f6c30876dfa 527 * @{
Kojto 107:4f6c30876dfa 528 */
Kojto 107:4f6c30876dfa 529
Kojto 107:4f6c30876dfa 530 /** @addtogroup ADC_Exported_Functions_Group1
Kojto 107:4f6c30876dfa 531 * @{
Kojto 107:4f6c30876dfa 532 */
Kojto 107:4f6c30876dfa 533 /* Initialization/de-initialization functions ***********************************/
Kojto 107:4f6c30876dfa 534 HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 535 HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
Kojto 107:4f6c30876dfa 536 void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 537 void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 538 /**
Kojto 107:4f6c30876dfa 539 * @}
Kojto 107:4f6c30876dfa 540 */
Kojto 107:4f6c30876dfa 541
Kojto 107:4f6c30876dfa 542 /** @addtogroup ADC_Exported_Functions_Group2
Kojto 107:4f6c30876dfa 543 * @{
Kojto 107:4f6c30876dfa 544 */
Kojto 107:4f6c30876dfa 545 /* I/O operation functions ******************************************************/
Kojto 107:4f6c30876dfa 546 HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 547 HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 548 HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
Kojto 107:4f6c30876dfa 549
Kojto 107:4f6c30876dfa 550 HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout);
Kojto 107:4f6c30876dfa 551
Kojto 107:4f6c30876dfa 552 HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 553 HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 554
Kojto 107:4f6c30876dfa 555 void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 556
Kojto 107:4f6c30876dfa 557 HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length);
Kojto 107:4f6c30876dfa 558 HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 559
Kojto 107:4f6c30876dfa 560 uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 561
Kojto 107:4f6c30876dfa 562 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 563 void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 564 void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 565 void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
Kojto 107:4f6c30876dfa 566 /**
Kojto 107:4f6c30876dfa 567 * @}
Kojto 107:4f6c30876dfa 568 */
Kojto 107:4f6c30876dfa 569
Kojto 107:4f6c30876dfa 570 /** @addtogroup ADC_Exported_Functions_Group3
Kojto 107:4f6c30876dfa 571 * @{
Kojto 107:4f6c30876dfa 572 */
Kojto 107:4f6c30876dfa 573 /* Peripheral Control functions *************************************************/
Kojto 107:4f6c30876dfa 574 HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig);
Kojto 107:4f6c30876dfa 575 HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig);
Kojto 107:4f6c30876dfa 576 /**
Kojto 107:4f6c30876dfa 577 * @}
Kojto 107:4f6c30876dfa 578 */
Kojto 107:4f6c30876dfa 579
Kojto 107:4f6c30876dfa 580 /** @addtogroup ADC_Exported_Functions_Group4
Kojto 107:4f6c30876dfa 581 * @{
Kojto 107:4f6c30876dfa 582 */
Kojto 107:4f6c30876dfa 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 107:4f6c30876dfa 586 /**
Kojto 107:4f6c30876dfa 587 * @}
Kojto 107:4f6c30876dfa 588 */
Kojto 107:4f6c30876dfa 589
Kojto 107:4f6c30876dfa 590 /**
Kojto 107:4f6c30876dfa 591 * @}
Kojto 107:4f6c30876dfa 592 */
Kojto 107:4f6c30876dfa 593
Kojto 107:4f6c30876dfa 594 /* Private types -------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 595 /* Private variables ---------------------------------------------------------*/
Kojto 107:4f6c30876dfa 596 /* Private constants ---------------------------------------------------------*/
Kojto 107:4f6c30876dfa 597 /** @defgroup ADC_Private_Constants ADC Private Constants
Kojto 107:4f6c30876dfa 598 * @{
Kojto 107:4f6c30876dfa 599 */
Kojto 107:4f6c30876dfa 600 /* Delay for ADC stabilization time. */
Kojto 107:4f6c30876dfa 601 /* Maximum delay is 1us (refer to device datasheet, parameter tSTAB). */
Kojto 107:4f6c30876dfa 602 /* Unit: us */
Kojto 107:4f6c30876dfa 603 #define ADC_STAB_DELAY_US ((uint32_t) 3)
Kojto 107:4f6c30876dfa 604 /* Delay for temperature sensor stabilization time. */
Kojto 107:4f6c30876dfa 605 /* Maximum delay is 10us (refer to device datasheet, parameter tSTART). */
Kojto 107:4f6c30876dfa 606 /* Unit: us */
Kojto 107:4f6c30876dfa 607 #define ADC_TEMPSENSOR_DELAY_US ((uint32_t) 10)
Kojto 107:4f6c30876dfa 608 /**
Kojto 107:4f6c30876dfa 609 * @}
Kojto 107:4f6c30876dfa 610 */
Kojto 107:4f6c30876dfa 611
Kojto 107:4f6c30876dfa 612 /* Private macros ------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 613 /** @defgroup ADC_Private_Macros ADC Private Macros
Kojto 107:4f6c30876dfa 614 * @{
Kojto 107:4f6c30876dfa 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 107:4f6c30876dfa 662 #define IS_ADC_CLOCKPRESCALER(__ADC_CLOCK__) (((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV2) || \
Kojto 107:4f6c30876dfa 663 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV4) || \
Kojto 107:4f6c30876dfa 664 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV6) || \
Kojto 107:4f6c30876dfa 665 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV8))
Kojto 107:4f6c30876dfa 666 #define IS_ADC_SAMPLING_DELAY(__DELAY__) (((__DELAY__) == ADC_TWOSAMPLINGDELAY_5CYCLES) || \
Kojto 107:4f6c30876dfa 667 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_6CYCLES) || \
Kojto 107:4f6c30876dfa 668 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_7CYCLES) || \
Kojto 107:4f6c30876dfa 669 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_8CYCLES) || \
Kojto 107:4f6c30876dfa 670 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_9CYCLES) || \
Kojto 107:4f6c30876dfa 671 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_10CYCLES) || \
Kojto 107:4f6c30876dfa 672 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_11CYCLES) || \
Kojto 107:4f6c30876dfa 673 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_12CYCLES) || \
Kojto 107:4f6c30876dfa 674 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_13CYCLES) || \
Kojto 107:4f6c30876dfa 675 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_14CYCLES) || \
Kojto 107:4f6c30876dfa 676 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_15CYCLES) || \
Kojto 107:4f6c30876dfa 677 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_16CYCLES) || \
Kojto 107:4f6c30876dfa 678 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_17CYCLES) || \
Kojto 107:4f6c30876dfa 679 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_18CYCLES) || \
Kojto 107:4f6c30876dfa 680 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_19CYCLES) || \
Kojto 107:4f6c30876dfa 681 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_20CYCLES))
Kojto 107:4f6c30876dfa 682 #define IS_ADC_RESOLUTION(__RESOLUTION__) (((__RESOLUTION__) == ADC_RESOLUTION_12B) || \
Kojto 107:4f6c30876dfa 683 ((__RESOLUTION__) == ADC_RESOLUTION_10B) || \
Kojto 107:4f6c30876dfa 684 ((__RESOLUTION__) == ADC_RESOLUTION_8B) || \
Kojto 107:4f6c30876dfa 685 ((__RESOLUTION__) == ADC_RESOLUTION_6B))
Kojto 107:4f6c30876dfa 686 #define IS_ADC_EXT_TRIG_EDGE(__EDGE__) (((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_NONE) || \
Kojto 107:4f6c30876dfa 687 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_RISING) || \
Kojto 107:4f6c30876dfa 688 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_FALLING) || \
Kojto 107:4f6c30876dfa 689 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING))
Kojto 107:4f6c30876dfa 690 #define IS_ADC_EXT_TRIG(__REGTRIG__) (((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
Kojto 107:4f6c30876dfa 691 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
Kojto 107:4f6c30876dfa 692 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_CC3) || \
Kojto 107:4f6c30876dfa 693 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
Kojto 107:4f6c30876dfa 694 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T5_TRGO) || \
Kojto 107:4f6c30876dfa 695 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
Kojto 107:4f6c30876dfa 696 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T3_CC4) || \
Kojto 107:4f6c30876dfa 697 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T8_TRGO) || \
Kojto 107:4f6c30876dfa 698 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T8_TRGO2) || \
Kojto 107:4f6c30876dfa 699 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_TRGO) || \
Kojto 107:4f6c30876dfa 700 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_TRGO2) || \
Kojto 107:4f6c30876dfa 701 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T2_TRGO) || \
Kojto 107:4f6c30876dfa 702 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T4_TRGO) || \
Kojto 107:4f6c30876dfa 703 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T6_TRGO) || \
Kojto 107:4f6c30876dfa 704 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
Kojto 107:4f6c30876dfa 705 ((__REGTRIG__) == ADC_SOFTWARE_START))
Kojto 107:4f6c30876dfa 706 #define IS_ADC_DATA_ALIGN(__ALIGN__) (((__ALIGN__) == ADC_DATAALIGN_RIGHT) || \
Kojto 107:4f6c30876dfa 707 ((__ALIGN__) == ADC_DATAALIGN_LEFT))
Kojto 107:4f6c30876dfa 708
Kojto 107:4f6c30876dfa 709 #define IS_ADC_SAMPLE_TIME(__TIME__) (((__TIME__) == ADC_SAMPLETIME_3CYCLES) || \
Kojto 107:4f6c30876dfa 710 ((__TIME__) == ADC_SAMPLETIME_15CYCLES) || \
Kojto 107:4f6c30876dfa 711 ((__TIME__) == ADC_SAMPLETIME_28CYCLES) || \
Kojto 107:4f6c30876dfa 712 ((__TIME__) == ADC_SAMPLETIME_56CYCLES) || \
Kojto 107:4f6c30876dfa 713 ((__TIME__) == ADC_SAMPLETIME_84CYCLES) || \
Kojto 107:4f6c30876dfa 714 ((__TIME__) == ADC_SAMPLETIME_112CYCLES) || \
Kojto 107:4f6c30876dfa 715 ((__TIME__) == ADC_SAMPLETIME_144CYCLES) || \
Kojto 107:4f6c30876dfa 716 ((__TIME__) == ADC_SAMPLETIME_480CYCLES))
Kojto 107:4f6c30876dfa 717 #define IS_ADC_EOCSelection(__EOCSelection__) (((__EOCSelection__) == ADC_EOC_SINGLE_CONV) || \
Kojto 107:4f6c30876dfa 718 ((__EOCSelection__) == ADC_EOC_SEQ_CONV) || \
Kojto 107:4f6c30876dfa 719 ((__EOCSelection__) == ADC_EOC_SINGLE_SEQ_CONV))
Kojto 107:4f6c30876dfa 720 #define IS_ADC_EVENT_TYPE(__EVENT__) (((__EVENT__) == ADC_AWD_EVENT) || \
Kojto 107:4f6c30876dfa 721 ((__EVENT__) == ADC_OVR_EVENT))
Kojto 107:4f6c30876dfa 722 #define IS_ADC_ANALOG_WATCHDOG(__WATCHDOG__) (((__WATCHDOG__) == ADC_ANALOGWATCHDOG_SINGLE_REG) || \
Kojto 107:4f6c30876dfa 723 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_SINGLE_INJEC) || \
Kojto 107:4f6c30876dfa 724 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC) || \
Kojto 107:4f6c30876dfa 725 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_ALL_REG) || \
Kojto 107:4f6c30876dfa 726 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_ALL_INJEC) || \
Kojto 107:4f6c30876dfa 727 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_ALL_REGINJEC) || \
Kojto 107:4f6c30876dfa 728 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_NONE))
Kojto 107:4f6c30876dfa 729 #define IS_ADC_CHANNELS_TYPE(CHANNEL_TYPE) (((CHANNEL_TYPE) == ADC_ALL_CHANNELS) || \
Kojto 107:4f6c30876dfa 730 ((CHANNEL_TYPE) == ADC_REGULAR_CHANNELS) || \
Kojto 107:4f6c30876dfa 731 ((CHANNEL_TYPE) == ADC_INJECTED_CHANNELS))
Kojto 107:4f6c30876dfa 732 #define IS_ADC_THRESHOLD(__THRESHOLD__) ((__THRESHOLD__) <= ((uint32_t)0xFFF))
Kojto 107:4f6c30876dfa 733 #define IS_ADC_REGULAR_LENGTH(__LENGTH__) (((__LENGTH__) >= ((uint32_t)1)) && ((__LENGTH__) <= ((uint32_t)16)))
Kojto 107:4f6c30876dfa 734 #define IS_ADC_REGULAR_RANK(__RANK__) (((__RANK__) >= ((uint32_t)1)) && ((__RANK__) <= ((uint32_t)16)))
Kojto 107:4f6c30876dfa 735 #define IS_ADC_REGULAR_DISC_NUMBER(__NUMBER__) (((__NUMBER__) >= ((uint32_t)1)) && ((__NUMBER__) <= ((uint32_t)8)))
Kojto 107:4f6c30876dfa 736 #define IS_ADC_RANGE(__RESOLUTION__, __ADC_VALUE__) \
Kojto 107:4f6c30876dfa 737 ((((__RESOLUTION__) == ADC_RESOLUTION_12B) && ((__ADC_VALUE__) <= ((uint32_t)0x0FFF))) || \
Kojto 107:4f6c30876dfa 738 (((__RESOLUTION__) == ADC_RESOLUTION_10B) && ((__ADC_VALUE__) <= ((uint32_t)0x03FF))) || \
Kojto 107:4f6c30876dfa 739 (((__RESOLUTION__) == ADC_RESOLUTION_8B) && ((__ADC_VALUE__) <= ((uint32_t)0x00FF))) || \
Kojto 107:4f6c30876dfa 740 (((__RESOLUTION__) == ADC_RESOLUTION_6B) && ((__ADC_VALUE__) <= ((uint32_t)0x003F))))
Kojto 107:4f6c30876dfa 741
Kojto 107:4f6c30876dfa 742 /**
Kojto 107:4f6c30876dfa 743 * @brief Set ADC Regular channel sequence length.
Kojto 107:4f6c30876dfa 744 * @param _NbrOfConversion_: Regular channel sequence length.
Kojto 107:4f6c30876dfa 745 * @retval None
Kojto 107:4f6c30876dfa 746 */
Kojto 107:4f6c30876dfa 747 #define ADC_SQR1(_NbrOfConversion_) (((_NbrOfConversion_) - (uint8_t)1) << 20)
Kojto 107:4f6c30876dfa 748
Kojto 107:4f6c30876dfa 749 /**
Kojto 107:4f6c30876dfa 750 * @brief Set the ADC's sample time for channel numbers between 10 and 18.
Kojto 107:4f6c30876dfa 751 * @param _SAMPLETIME_: Sample time parameter.
Kojto 107:4f6c30876dfa 752 * @param _CHANNELNB_: Channel number.
Kojto 107:4f6c30876dfa 753 * @retval None
Kojto 107:4f6c30876dfa 754 */
Kojto 107:4f6c30876dfa 755 #define ADC_SMPR1(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3 * (((uint32_t)((uint16_t)(_CHANNELNB_))) - 10)))
Kojto 107:4f6c30876dfa 756
Kojto 107:4f6c30876dfa 757 /**
Kojto 107:4f6c30876dfa 758 * @brief Set the ADC's sample time for channel numbers between 0 and 9.
Kojto 107:4f6c30876dfa 759 * @param _SAMPLETIME_: Sample time parameter.
Kojto 107:4f6c30876dfa 760 * @param _CHANNELNB_: Channel number.
Kojto 107:4f6c30876dfa 761 * @retval None
Kojto 107:4f6c30876dfa 762 */
Kojto 107:4f6c30876dfa 763 #define ADC_SMPR2(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3 * ((uint32_t)((uint16_t)(_CHANNELNB_)))))
Kojto 107:4f6c30876dfa 764
Kojto 107:4f6c30876dfa 765 /**
Kojto 107:4f6c30876dfa 766 * @brief Set the selected regular channel rank for rank between 1 and 6.
Kojto 107:4f6c30876dfa 767 * @param _CHANNELNB_: Channel number.
Kojto 107:4f6c30876dfa 768 * @param _RANKNB_: Rank number.
Kojto 107:4f6c30876dfa 769 * @retval None
Kojto 107:4f6c30876dfa 770 */
Kojto 107:4f6c30876dfa 771 #define ADC_SQR3_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5 * ((_RANKNB_) - 1)))
Kojto 107:4f6c30876dfa 772
Kojto 107:4f6c30876dfa 773 /**
Kojto 107:4f6c30876dfa 774 * @brief Set the selected regular channel rank for rank between 7 and 12.
Kojto 107:4f6c30876dfa 775 * @param _CHANNELNB_: Channel number.
Kojto 107:4f6c30876dfa 776 * @param _RANKNB_: Rank number.
Kojto 107:4f6c30876dfa 777 * @retval None
Kojto 107:4f6c30876dfa 778 */
Kojto 107:4f6c30876dfa 779 #define ADC_SQR2_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5 * ((_RANKNB_) - 7)))
Kojto 107:4f6c30876dfa 780
Kojto 107:4f6c30876dfa 781 /**
Kojto 107:4f6c30876dfa 782 * @brief Set the selected regular channel rank for rank between 13 and 16.
Kojto 107:4f6c30876dfa 783 * @param _CHANNELNB_: Channel number.
Kojto 107:4f6c30876dfa 784 * @param _RANKNB_: Rank number.
Kojto 107:4f6c30876dfa 785 * @retval None
Kojto 107:4f6c30876dfa 786 */
Kojto 107:4f6c30876dfa 787 #define ADC_SQR1_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5 * ((_RANKNB_) - 13)))
Kojto 107:4f6c30876dfa 788
Kojto 107:4f6c30876dfa 789 /**
Kojto 107:4f6c30876dfa 790 * @brief Enable ADC continuous conversion mode.
Kojto 107:4f6c30876dfa 791 * @param _CONTINUOUS_MODE_: Continuous mode.
Kojto 107:4f6c30876dfa 792 * @retval None
Kojto 107:4f6c30876dfa 793 */
Kojto 107:4f6c30876dfa 794 #define ADC_CR2_CONTINUOUS(_CONTINUOUS_MODE_) ((_CONTINUOUS_MODE_) << 1)
Kojto 107:4f6c30876dfa 795
Kojto 107:4f6c30876dfa 796 /**
Kojto 107:4f6c30876dfa 797 * @brief Configures the number of discontinuous conversions for the regular group channels.
Kojto 107:4f6c30876dfa 798 * @param _NBR_DISCONTINUOUSCONV_: Number of discontinuous conversions.
Kojto 107:4f6c30876dfa 799 * @retval None
Kojto 107:4f6c30876dfa 800 */
Kojto 107:4f6c30876dfa 801 #define ADC_CR1_DISCONTINUOUS(_NBR_DISCONTINUOUSCONV_) (((_NBR_DISCONTINUOUSCONV_) - 1) << POSITION_VAL(ADC_CR1_DISCNUM))
Kojto 107:4f6c30876dfa 802
Kojto 107:4f6c30876dfa 803 /**
Kojto 107:4f6c30876dfa 804 * @brief Enable ADC scan mode.
Kojto 107:4f6c30876dfa 805 * @param _SCANCONV_MODE_: Scan conversion mode.
Kojto 107:4f6c30876dfa 806 * @retval None
Kojto 107:4f6c30876dfa 807 */
Kojto 107:4f6c30876dfa 808 #define ADC_CR1_SCANCONV(_SCANCONV_MODE_) ((_SCANCONV_MODE_) << 8)
Kojto 107:4f6c30876dfa 809
Kojto 107:4f6c30876dfa 810 /**
Kojto 107:4f6c30876dfa 811 * @brief Enable the ADC end of conversion selection.
Kojto 107:4f6c30876dfa 812 * @param _EOCSelection_MODE_: End of conversion selection mode.
Kojto 107:4f6c30876dfa 813 * @retval None
Kojto 107:4f6c30876dfa 814 */
Kojto 107:4f6c30876dfa 815 #define ADC_CR2_EOCSelection(_EOCSelection_MODE_) ((_EOCSelection_MODE_) << 10)
Kojto 107:4f6c30876dfa 816
Kojto 107:4f6c30876dfa 817 /**
Kojto 107:4f6c30876dfa 818 * @brief Enable the ADC DMA continuous request.
Kojto 107:4f6c30876dfa 819 * @param _DMAContReq_MODE_: DMA continuous request mode.
Kojto 107:4f6c30876dfa 820 * @retval None
Kojto 107:4f6c30876dfa 821 */
Kojto 107:4f6c30876dfa 822 #define ADC_CR2_DMAContReq(_DMAContReq_MODE_) ((_DMAContReq_MODE_) << 9)
Kojto 107:4f6c30876dfa 823
Kojto 107:4f6c30876dfa 824 /**
Kojto 107:4f6c30876dfa 825 * @brief Return resolution bits in CR1 register.
Kojto 107:4f6c30876dfa 826 * @param __HANDLE__: ADC handle
Kojto 107:4f6c30876dfa 827 * @retval None
Kojto 107:4f6c30876dfa 828 */
Kojto 107:4f6c30876dfa 829 #define ADC_GET_RESOLUTION(__HANDLE__) (((__HANDLE__)->Instance->CR1) & ADC_CR1_RES)
Kojto 107:4f6c30876dfa 830
Kojto 107:4f6c30876dfa 831 /**
Kojto 107:4f6c30876dfa 832 * @}
Kojto 107:4f6c30876dfa 833 */
Kojto 107:4f6c30876dfa 834
Kojto 107:4f6c30876dfa 835 /* Private functions ---------------------------------------------------------*/
Kojto 107:4f6c30876dfa 836 /** @defgroup ADC_Private_Functions ADC Private Functions
Kojto 107:4f6c30876dfa 837 * @{
Kojto 107:4f6c30876dfa 838 */
Kojto 107:4f6c30876dfa 839
Kojto 107:4f6c30876dfa 840 /**
Kojto 107:4f6c30876dfa 841 * @}
Kojto 107:4f6c30876dfa 842 */
Kojto 107:4f6c30876dfa 843
Kojto 107:4f6c30876dfa 844 /**
Kojto 107:4f6c30876dfa 845 * @}
Kojto 107:4f6c30876dfa 846 */
Kojto 107:4f6c30876dfa 847
Kojto 107:4f6c30876dfa 848 /**
Kojto 107:4f6c30876dfa 849 * @}
Kojto 107:4f6c30876dfa 850 */
Kojto 107:4f6c30876dfa 851
Kojto 107:4f6c30876dfa 852 #ifdef __cplusplus
Kojto 107:4f6c30876dfa 853 }
Kojto 107:4f6c30876dfa 854 #endif
Kojto 107:4f6c30876dfa 855
Kojto 107:4f6c30876dfa 856 #endif /*__STM32F7xx_ADC_H */
Kojto 107:4f6c30876dfa 857
Kojto 107:4f6c30876dfa 858
Kojto 107:4f6c30876dfa 859 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/