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:
107:4f6c30876dfa
.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 107:4f6c30876dfa 1 /**
Kojto 107:4f6c30876dfa 2 ******************************************************************************
Kojto 107:4f6c30876dfa 3 * @file stm32l4xx_hal_adc.h
Kojto 107:4f6c30876dfa 4 * @author MCD Application Team
Kojto 107:4f6c30876dfa 5 * @version V1.0.0
Kojto 107:4f6c30876dfa 6 * @date 26-June-2015
Kojto 107:4f6c30876dfa 7 * @brief Header file of ADC HAL 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 __STM32L4xx_ADC_H
Kojto 107:4f6c30876dfa 40 #define __STM32L4xx_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 "stm32l4xx_hal_def.h"
Kojto 107:4f6c30876dfa 48
Kojto 107:4f6c30876dfa 49 /** @addtogroup STM32L4xx_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 107:4f6c30876dfa 63 /**
Kojto 107:4f6c30876dfa 64 * @brief ADC Regular Conversion Oversampling structure definition
Kojto 107:4f6c30876dfa 65 */
Kojto 107:4f6c30876dfa 66 typedef struct
Kojto 107:4f6c30876dfa 67 {
Kojto 107:4f6c30876dfa 68 uint32_t Ratio; /*!< Configures the oversampling ratio.
Kojto 107:4f6c30876dfa 69 This parameter can be a value of @ref ADCEx_Oversampling_Ratio */
Kojto 107:4f6c30876dfa 70
Kojto 107:4f6c30876dfa 71 uint32_t RightBitShift; /*!< Configures the division coefficient for the Oversampler.
Kojto 107:4f6c30876dfa 72 This parameter can be a value of @ref ADCEx_Right_Bit_Shift */
Kojto 107:4f6c30876dfa 73
Kojto 107:4f6c30876dfa 74 uint32_t TriggeredMode; /*!< Selects the regular triggered oversampling mode.
Kojto 107:4f6c30876dfa 75 This parameter can be a value of @ref ADCEx_Triggered_Oversampling_Mode */
Kojto 107:4f6c30876dfa 76
Kojto 107:4f6c30876dfa 77 uint32_t OversamplingStopReset; /*!< Selects the regular oversampling mode.
Kojto 107:4f6c30876dfa 78 The oversampling is either temporary stopped or reset upon an injected
Kojto 107:4f6c30876dfa 79 sequence interruption.
Kojto 107:4f6c30876dfa 80 If oversampling is enabled on both regular and injected groups, this parameter
Kojto 107:4f6c30876dfa 81 is discarded and forced to setting "ADC_REGOVERSAMPLING_RESUMED_MODE"
Kojto 107:4f6c30876dfa 82 (the oversampling buffer is zeroed during injection sequence).
Kojto 107:4f6c30876dfa 83 This parameter can be a value of @ref ADCEx_Regular_Oversampling_Mode */
Kojto 107:4f6c30876dfa 84
Kojto 107:4f6c30876dfa 85 }ADC_OversamplingTypeDef;
Kojto 107:4f6c30876dfa 86
Kojto 107:4f6c30876dfa 87
Kojto 107:4f6c30876dfa 88
Kojto 107:4f6c30876dfa 89
Kojto 107:4f6c30876dfa 90 /**
Kojto 107:4f6c30876dfa 91 * @brief Structure definition of ADC initialization and regular group
Kojto 107:4f6c30876dfa 92 * @note Parameters of this structure are shared within 2 scopes:
Kojto 107:4f6c30876dfa 93 * - Scope entire ADC (affects regular and injected groups): ClockPrescaler and ClockDivider, Resolution, DataAlign,
Kojto 107:4f6c30876dfa 94 * ScanConvMode, EOCSelection, LowPowerAutoWait.
Kojto 107:4f6c30876dfa 95 * - Scope regular group: ContinuousConvMode, NbrOfConversion, DiscontinuousConvMode, NbrOfDiscConversion, ExternalTrigConvEdge,
Kojto 107:4f6c30876dfa 96 * ExternalTrigConv, DMAContinuousRequests, Overrun, OversamplingMode, Oversampling.
Kojto 107:4f6c30876dfa 97 * @note The setting of these parameters by function HAL_ADC_Init() is conditioned by ADC state.
Kojto 107:4f6c30876dfa 98 * ADC state can be either:
Kojto 107:4f6c30876dfa 99 * - For all parameters: ADC disabled
Kojto 107:4f6c30876dfa 100 * - For all parameters except 'LowPowerAutoWait', 'DMAContinuousRequests' and 'Oversampling': ADC enabled without conversion on going on regular group.
Kojto 107:4f6c30876dfa 101 * - For parameters 'LowPowerAutoWait' and 'DMAContinuousRequests': ADC enabled without conversion on going on regular and injected groups.
Kojto 107:4f6c30876dfa 102 * If ADC is not in the appropriate state to modify some parameters, these parameters setting is bypassed
Kojto 107:4f6c30876dfa 103 * without error reporting (as it can be the expected behaviour in case of intended action to update another parameter
Kojto 107:4f6c30876dfa 104 * (which fulfills the ADC state condition) on the fly).
Kojto 107:4f6c30876dfa 105 */
Kojto 107:4f6c30876dfa 106 typedef struct
Kojto 107:4f6c30876dfa 107 {
Kojto 107:4f6c30876dfa 108 uint32_t ClockPrescaler; /*!< Selects ADC clock source (asynchronous System/PLLSAI1/PLLSAI2 clocks or synchronous AHB clock) as well as
Kojto 107:4f6c30876dfa 109 the division factor applied to the clock.
Kojto 107:4f6c30876dfa 110 This parameter can be a value of @ref ADC_ClockPrescaler.
Kojto 107:4f6c30876dfa 111 Note: The clock is common for all the ADCs.
Kojto 107:4f6c30876dfa 112 Note: In case of usage of channels on injected group, ADC frequency should be lower than AHB clock frequency /4 for resolution 12 or 10 bits,
Kojto 107:4f6c30876dfa 113 AHB clock frequency /3 for resolution 8 bits, AHB clock frequency /2 for resolution 6 bits.
Kojto 107:4f6c30876dfa 114 Note: In case of usage of the ADC dedicated PLL clock, this clock must be preliminarily enabled and prescaler set at RCC top level.
Kojto 107:4f6c30876dfa 115 Note: In case of synchronous clock mode based on HCLK/1, the configuration must be enabled only if the AHB clock prescaler is set to 1
Kojto 107:4f6c30876dfa 116 and if the system clock has a 50% duty cycle.
Kojto 107:4f6c30876dfa 117 Note: This parameter can be modified only if all ADCs are disabled. */
Kojto 107:4f6c30876dfa 118
Kojto 107:4f6c30876dfa 119 uint32_t Resolution; /*!< Configures the ADC resolution.
Kojto 107:4f6c30876dfa 120 This parameter can be a value of @ref ADC_Resolution */
Kojto 107:4f6c30876dfa 121
Kojto 107:4f6c30876dfa 122 uint32_t DataAlign; /*!< Specifies ADC data alignment (right or left).
Kojto 107:4f6c30876dfa 123 See reference manual for alignments formats versus resolutions.
Kojto 107:4f6c30876dfa 124 This parameter can be a value of @ref ADC_Data_align */
Kojto 107:4f6c30876dfa 125
Kojto 107:4f6c30876dfa 126 uint32_t ScanConvMode; /*!< Configures the sequencer of regular and injected groups.
Kojto 107:4f6c30876dfa 127 This parameter can be associated to parameter 'DiscontinuousConvMode' to have main sequence subdivided in successive parts.
Kojto 107:4f6c30876dfa 128 If disabled: Conversion is performed in single mode (one channel converted, that defined in rank 1).
Kojto 107:4f6c30876dfa 129 Parameters 'NbrOfConversion' and 'InjectedNbrOfConversion' are discarded (equivalent to set to 1).
Kojto 107:4f6c30876dfa 130 If enabled: Conversions are performed in sequence mode (multiple ranks defined by 'NbrOfConversion' or'InjectedNbrOfConversion').
Kojto 107:4f6c30876dfa 131 Scan direction is upward: from rank 1 to rank 'n'.
Kojto 107:4f6c30876dfa 132 This parameter can be a value of @ref ADC_Scan_mode */
Kojto 107:4f6c30876dfa 133
Kojto 107:4f6c30876dfa 134 uint32_t EOCSelection; /*!< Specifies which EOC (End Of Conversion) flag is used for conversion by polling and interruption: end of conversion of each rank or complete sequence.
Kojto 107:4f6c30876dfa 135 This parameter can be a value of @ref ADC_EOCSelection. */
Kojto 107:4f6c30876dfa 136
Kojto 107:4f6c30876dfa 137 uint32_t LowPowerAutoWait; /*!< Selects the dynamic low power Auto Delay: new conversion start only when the previous
Kojto 107:4f6c30876dfa 138 conversion (for regular group) or previous sequence (for injected group) has been processed by user software
Kojto 107:4f6c30876dfa 139 (EOC bit cleared or DR read for regular conversions, JEOS cleared for injected conversions).
Kojto 107:4f6c30876dfa 140 This feature automatically adapts the speed of ADC to the speed of the system that reads the data. Moreover, this avoids risk of overrun
Kojto 107:4f6c30876dfa 141 for low frequency applications.
Kojto 107:4f6c30876dfa 142 This parameter can be set to ENABLE or DISABLE.
Kojto 107:4f6c30876dfa 143 Note: Do not use with interruption or DMA (HAL_ADC_Start_IT(), HAL_ADC_Start_DMA(), HAL_ADCEx_InjectedStart_IT()) when it is necessary
Kojto 107:4f6c30876dfa 144 to clear immediately the EOC flag to free the IRQ vector sequencer.
Kojto 107:4f6c30876dfa 145 Do use with polling: 1. Start conversion with HAL_ADC_Start() or HAL_ADCEx_InjectedStart(), 2. When conversion data is available: use
Kojto 107:4f6c30876dfa 146 HAL_ADC_PollForConversion() to ensure that conversion is completed and HAL_ADC_GetValue() to retrieve conversion result and trig another
Kojto 107:4f6c30876dfa 147 conversion. For injected conversion, resort to HAL_ADCEx_InjectedPollForConversion() then HAL_ADCEx_InjectedGetValue() */
Kojto 107:4f6c30876dfa 148
Kojto 107:4f6c30876dfa 149 uint32_t ContinuousConvMode; /*!< Specifies whether the conversion is performed in single mode (one conversion) or continuous mode for regular group,
Kojto 107:4f6c30876dfa 150 after software start or external trigger occurred.
Kojto 107:4f6c30876dfa 151 This parameter can be set to ENABLE or DISABLE. */
Kojto 107:4f6c30876dfa 152
Kojto 107:4f6c30876dfa 153 uint32_t NbrOfConversion; /*!< Specifies the number of ranks that will be converted within the regular group sequencer.
Kojto 107:4f6c30876dfa 154 To use the regular group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
Kojto 107:4f6c30876dfa 155 This parameter must be a number between Min_Data = 1 and Max_Data = 16.
Kojto 107:4f6c30876dfa 156 Note: This parameter must be modified when no conversion is on going on regular group (ADC disabled, or ADC enabled without
Kojto 107:4f6c30876dfa 157 continuous mode or external trigger that could launch a conversion). */
Kojto 107:4f6c30876dfa 158
Kojto 107:4f6c30876dfa 159 uint32_t DiscontinuousConvMode; /*!< Specifies whether the conversions sequence of regular group is performed in Complete-sequence/Discontinuous-sequence (main sequence
Kojto 107:4f6c30876dfa 160 subdivided in successive parts).
Kojto 107:4f6c30876dfa 161 Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
Kojto 107:4f6c30876dfa 162 Discontinuous mode can be enabled only if continuous mode is disabled.
Kojto 107:4f6c30876dfa 163 This parameter can be set to ENABLE or DISABLE. */
Kojto 107:4f6c30876dfa 164
Kojto 107:4f6c30876dfa 165 uint32_t NbrOfDiscConversion; /*!< Specifies the number of discontinuous conversions in which the main sequence of regular group (parameter NbrOfConversion) will be subdivided.
Kojto 107:4f6c30876dfa 166 If parameter 'DiscontinuousConvMode' is disabled, this parameter is discarded.
Kojto 107:4f6c30876dfa 167 This parameter must be a number between Min_Data = 1 and Max_Data = 8. */
Kojto 107:4f6c30876dfa 168
Kojto 107:4f6c30876dfa 169 uint32_t ExternalTrigConv; /*!< Selects the external event used to trigger the conversion start of regular group.
Kojto 107:4f6c30876dfa 170 If set to ADC_SOFTWARE_START, external triggers are disabled and software trigger is used instead.
Kojto 107:4f6c30876dfa 171 This parameter can be a value of @ref ADC_Regular_External_Trigger_Source.
Kojto 107:4f6c30876dfa 172 Caution: external trigger source is common to ADCs. */
Kojto 107:4f6c30876dfa 173
Kojto 107:4f6c30876dfa 174 uint32_t ExternalTrigConvEdge; /*!< Selects the external trigger edge of regular group.
Kojto 107:4f6c30876dfa 175 If set to ADC_EXTERNALTRIGCONVEDGE_NONE, external triggers are disabled and software trigger is used instead.
Kojto 107:4f6c30876dfa 176 This parameter can be a value of @ref ADC_Regular_External_Trigger_Source_Edge */
Kojto 107:4f6c30876dfa 177
Kojto 107:4f6c30876dfa 178 uint32_t DMAContinuousRequests; /*!< Specifies whether the DMA requests are performed in one shot mode (DMA transfer stops when number of conversions is reached)
Kojto 107:4f6c30876dfa 179 or in Continuous mode (DMA transfer unlimited, whatever number of conversions).
Kojto 107:4f6c30876dfa 180 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 107:4f6c30876dfa 181 This parameter can be set to ENABLE or DISABLE.
Kojto 107:4f6c30876dfa 182 Note: This parameter must be modified when no conversion is on going on both regular and injected groups
Kojto 107:4f6c30876dfa 183 (ADC disabled, or ADC enabled without continuous mode or external trigger that could launch a conversion). */
Kojto 107:4f6c30876dfa 184
Kojto 107:4f6c30876dfa 185 uint32_t Overrun; /*!< Select the behaviour in case of overrun: data overwritten or preserved (default).
Kojto 107:4f6c30876dfa 186 This parameter applies to regular group only.
Kojto 107:4f6c30876dfa 187 This parameter can be a value of @ref ADC_Overrun.
Kojto 107:4f6c30876dfa 188 Note: Case of overrun set to data preserved and usage with end on conversion interruption (HAL_Start_IT()): ADC IRQ handler has to clear
Kojto 107:4f6c30876dfa 189 end of conversion flags, this induces the release of the preserved data. If needed, this data can be saved by user-developped function
Kojto 107:4f6c30876dfa 190 HAL_ADC_ConvCpltCallback() (called before end of conversion flags clear).
Kojto 107:4f6c30876dfa 191 Note: Error reporting with respect to the conversion mode:
Kojto 107:4f6c30876dfa 192 - Usage with ADC conversion by polling for event or interruption: Error is reported only if overrun is set to data preserved. If overrun is set to data
Kojto 107:4f6c30876dfa 193 overwritten, user can willingly not read all the converted data, this is not considered as an erroneous case.
Kojto 107:4f6c30876dfa 194 - Usage with ADC conversion by DMA: Error is reported whatever overrun setting (DMA is expected to process all data from data register). */
Kojto 107:4f6c30876dfa 195
Kojto 107:4f6c30876dfa 196 uint32_t OversamplingMode; /*!< Specifies whether the oversampling feature is enabled or disabled.
Kojto 107:4f6c30876dfa 197 This parameter can be set to ENABLE or DISABLE.
Kojto 107:4f6c30876dfa 198 Note: This parameter can be modified only if there is no conversion is ongoing (both ADSTART and JADSTART cleared). */
Kojto 107:4f6c30876dfa 199
Kojto 107:4f6c30876dfa 200 ADC_OversamplingTypeDef Oversampling; /*!< Specifies the Oversampling parameters.
Kojto 107:4f6c30876dfa 201 Caution: this setting overwrites the previous oversampling configuration if oversampling already enabled.
Kojto 107:4f6c30876dfa 202 Note: This parameter can be modified only if there is no conversion is ongoing (both ADSTART and JADSTART cleared). */
Kojto 107:4f6c30876dfa 203 }ADC_InitTypeDef;
Kojto 107:4f6c30876dfa 204
Kojto 107:4f6c30876dfa 205
Kojto 107:4f6c30876dfa 206 /** @defgroup ADC_States ADC States
Kojto 107:4f6c30876dfa 207 * @{
Kojto 107:4f6c30876dfa 208 */
Kojto 107:4f6c30876dfa 209
Kojto 107:4f6c30876dfa 210 /**
Kojto 107:4f6c30876dfa 211 * @brief HAL ADC state machine: ADC State bitfield definition
Kojto 107:4f6c30876dfa 212 */
Kojto 107:4f6c30876dfa 213 /* States of ADC global scope */
Kojto 107:4f6c30876dfa 214 #define HAL_ADC_STATE_RESET ((uint32_t)0x00000000) /*!< ADC not yet initialized or disabled */
Kojto 107:4f6c30876dfa 215 #define HAL_ADC_STATE_READY ((uint32_t)0x00000001) /*!< ADC peripheral ready for use */
Kojto 107:4f6c30876dfa 216 #define HAL_ADC_STATE_BUSY_INTERNAL ((uint32_t)0x00000002) /*!< ADC is busy because of an internal process (initialization, calibration) */
Kojto 107:4f6c30876dfa 217 #define HAL_ADC_STATE_TIMEOUT ((uint32_t)0x00000004) /*!< TimeOut occurrence */
Kojto 107:4f6c30876dfa 218
Kojto 107:4f6c30876dfa 219 /* States of ADC errors */
Kojto 107:4f6c30876dfa 220 #define HAL_ADC_STATE_ERROR_INTERNAL ((uint32_t)0x00000010) /*!< Internal error occurrence */
Kojto 107:4f6c30876dfa 221 #define HAL_ADC_STATE_ERROR_CONFIG ((uint32_t)0x00000020) /*!< Configuration error occurrence */
Kojto 107:4f6c30876dfa 222 #define HAL_ADC_STATE_ERROR_DMA ((uint32_t)0x00000040) /*!< DMA error occurrence */
Kojto 107:4f6c30876dfa 223
Kojto 107:4f6c30876dfa 224 /* States of ADC regular group */
Kojto 107:4f6c30876dfa 225 #define HAL_ADC_STATE_REG_BUSY ((uint32_t)0x00000100) /*!< A regular conversion is ongoing or can occur (either by continuous mode,
Kojto 107:4f6c30876dfa 226 external trigger, low power auto power-on, multimode ADC master control) */
Kojto 107:4f6c30876dfa 227 #define HAL_ADC_STATE_REG_EOC ((uint32_t)0x00000200) /*!< Regular conversion data available */
Kojto 107:4f6c30876dfa 228 #define HAL_ADC_STATE_REG_OVR ((uint32_t)0x00000400) /*!< Overrun occurrence */
Kojto 107:4f6c30876dfa 229 #define HAL_ADC_STATE_REG_EOSMP ((uint32_t)0x00000800) /*!< End Of Sampling flag raised */
Kojto 107:4f6c30876dfa 230
Kojto 107:4f6c30876dfa 231 /* States of ADC injected group */
Kojto 107:4f6c30876dfa 232 #define HAL_ADC_STATE_INJ_BUSY ((uint32_t)0x00001000) /*!< An injected conversion is ongoing or can occur (either by auto-injection mode,
Kojto 107:4f6c30876dfa 233 external trigger, low power auto power-on, multimode ADC master control) */
Kojto 107:4f6c30876dfa 234 #define HAL_ADC_STATE_INJ_EOC ((uint32_t)0x00002000) /*!< Injected conversion data available */
Kojto 107:4f6c30876dfa 235 #define HAL_ADC_STATE_INJ_JQOVF ((uint32_t)0x00004000) /*!< Injected queue overflow occurrence */
Kojto 107:4f6c30876dfa 236
Kojto 107:4f6c30876dfa 237 /* States of ADC analog watchdogs */
Kojto 107:4f6c30876dfa 238 #define HAL_ADC_STATE_AWD1 ((uint32_t)0x00010000) /*!< Out-of-window occurrence of Analog Watchdog 1 */
Kojto 107:4f6c30876dfa 239 #define HAL_ADC_STATE_AWD2 ((uint32_t)0x00020000) /*!< Out-of-window occurrence of Analog Watchdog 2 */
Kojto 107:4f6c30876dfa 240 #define HAL_ADC_STATE_AWD3 ((uint32_t)0x00040000) /*!< Out-of-window occurrence of Analog Watchdog 3 */
Kojto 107:4f6c30876dfa 241
Kojto 107:4f6c30876dfa 242 /* States of ADC multi-mode */
Kojto 107:4f6c30876dfa 243 #define HAL_ADC_STATE_MULTIMODE_SLAVE ((uint32_t)0x00100000) /*!< ADC in multimode slave state, controlled by another ADC master */
Kojto 107:4f6c30876dfa 244
Kojto 107:4f6c30876dfa 245 /**
Kojto 107:4f6c30876dfa 246 * @}
Kojto 107:4f6c30876dfa 247 */
Kojto 107:4f6c30876dfa 248
Kojto 107:4f6c30876dfa 249 /**
Kojto 107:4f6c30876dfa 250 * @brief ADC Injection Configuration
Kojto 107:4f6c30876dfa 251 */
Kojto 107:4f6c30876dfa 252 typedef struct
Kojto 107:4f6c30876dfa 253 {
Kojto 107:4f6c30876dfa 254 uint32_t ContextQueue; /*!< Injected channel configuration context: build-up over each
Kojto 107:4f6c30876dfa 255 HAL_ADCEx_InjectedConfigChannel() call to finally initialize
Kojto 107:4f6c30876dfa 256 JSQR register at HAL_ADCEx_InjectedConfigChannel() last call */
Kojto 107:4f6c30876dfa 257
Kojto 107:4f6c30876dfa 258 uint32_t ChannelCount; /*!< Number of channels in the injected sequence */
Kojto 107:4f6c30876dfa 259 }ADC_InjectionConfigTypeDef;
Kojto 107:4f6c30876dfa 260
Kojto 107:4f6c30876dfa 261
Kojto 107:4f6c30876dfa 262
Kojto 107:4f6c30876dfa 263 /**
Kojto 107:4f6c30876dfa 264 * @brief ADC handle Structure definition
Kojto 107:4f6c30876dfa 265 */
Kojto 107:4f6c30876dfa 266 typedef struct
Kojto 107:4f6c30876dfa 267 {
Kojto 107:4f6c30876dfa 268 ADC_TypeDef *Instance; /*!< Register base address */
Kojto 107:4f6c30876dfa 269
Kojto 107:4f6c30876dfa 270 ADC_InitTypeDef Init; /*!< ADC initialization parameters and regular conversions setting */
Kojto 107:4f6c30876dfa 271
Kojto 107:4f6c30876dfa 272 DMA_HandleTypeDef *DMA_Handle; /*!< Pointer DMA Handler */
Kojto 107:4f6c30876dfa 273
Kojto 107:4f6c30876dfa 274 HAL_LockTypeDef Lock; /*!< ADC locking object */
Kojto 107:4f6c30876dfa 275
Kojto 107:4f6c30876dfa 276 __IO uint32_t State; /*!< ADC communication state (bit-map of ADC states) */
Kojto 107:4f6c30876dfa 277
Kojto 107:4f6c30876dfa 278 __IO uint32_t ErrorCode; /*!< ADC Error code */
Kojto 107:4f6c30876dfa 279
Kojto 107:4f6c30876dfa 280 ADC_InjectionConfigTypeDef InjectionConfig ; /*!< ADC injected channel configuration build-up structure */
Kojto 107:4f6c30876dfa 281 }ADC_HandleTypeDef;
Kojto 107:4f6c30876dfa 282
Kojto 107:4f6c30876dfa 283
Kojto 107:4f6c30876dfa 284
Kojto 107:4f6c30876dfa 285 /**
Kojto 107:4f6c30876dfa 286 * @brief Structure definition of ADC channel for regular group
Kojto 107:4f6c30876dfa 287 * @note The setting of these parameters with function HAL_ADC_ConfigChannel() is conditioned by ADC state.
Kojto 107:4f6c30876dfa 288 * ADC state can be either:
Kojto 107:4f6c30876dfa 289 * - For all parameters: ADC disabled (this is the only possible ADC state to modify parameter 'SingleDiff')
Kojto 107:4f6c30876dfa 290 * - For all except parameters 'SamplingTime', 'Offset', 'OffsetNumber': ADC enabled without conversion on going on regular group.
Kojto 107:4f6c30876dfa 291 * - For parameters 'SamplingTime', 'Offset', 'OffsetNumber': ADC enabled without conversion on going on regular and injected groups.
Kojto 107:4f6c30876dfa 292 * If ADC is not in the appropriate state to modify some parameters, these parameters setting is bypassed
Kojto 107:4f6c30876dfa 293 * without error reporting (as it can be the expected behaviour in case of intended action to update another parameter
Kojto 107:4f6c30876dfa 294 * (which fulfills the ADC state condition) on the fly).
Kojto 107:4f6c30876dfa 295 */
Kojto 107:4f6c30876dfa 296 typedef struct
Kojto 107:4f6c30876dfa 297 {
Kojto 107:4f6c30876dfa 298 uint32_t Channel; /*!< Specifies the channel to configure into ADC regular group.
Kojto 107:4f6c30876dfa 299 This parameter can be a value of @ref ADC_channels
Kojto 107:4f6c30876dfa 300 Note: Depending on devices and ADC instances, some channels may not be available. Refer to device DataSheet for channels availability. */
Kojto 107:4f6c30876dfa 301 uint32_t Rank; /*!< Specifies the rank in the regular group sequencer.
Kojto 107:4f6c30876dfa 302 This parameter can be a value of @ref ADCEx_regular_rank
Kojto 107:4f6c30876dfa 303 Note: to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by
Kojto 107:4f6c30876dfa 304 the new channel setting (or parameter number of conversions adjusted) */
Kojto 107:4f6c30876dfa 305 uint32_t SamplingTime; /*!< Sampling time value to be set for the selected channel.
Kojto 107:4f6c30876dfa 306 Unit: ADC clock cycles
Kojto 107:4f6c30876dfa 307 Conversion time is the addition of sampling time and processing time (12.5 ADC clock cycles at ADC resolution 12 bits, 10.5 cycles at 10 bits,
Kojto 107:4f6c30876dfa 308 8.5 cycles at 8 bits, 6.5 cycles at 6 bits).
Kojto 107:4f6c30876dfa 309 This parameter can be a value of @ref ADC_sampling_times
Kojto 107:4f6c30876dfa 310 Caution: This parameter applies to a channel that can be used in a regular and/or injected group.
Kojto 107:4f6c30876dfa 311 It overwrites the last setting.
Kojto 107:4f6c30876dfa 312 Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor),
Kojto 107:4f6c30876dfa 313 sampling time constraints must be respected (sampling time can be adjusted with respect to the ADC clock frequency and sampling time setting)
Kojto 107:4f6c30876dfa 314 Refer to device DataSheet for timings values. */
Kojto 107:4f6c30876dfa 315 uint32_t SingleDiff; /*!< Selection of single-ended or differential input.
Kojto 107:4f6c30876dfa 316 In differential mode: Differential measurement is carried out between the selected channel 'i' (positive input) and channel 'i+1' (negative input).
Kojto 107:4f6c30876dfa 317 Only channel 'i' has to be configured, channel 'i+1' is configured automatically.
Kojto 107:4f6c30876dfa 318 This parameter must be a value of @ref ADCEx_SingleDifferential
Kojto 107:4f6c30876dfa 319 Caution: This parameter applies to a channel that can be used in a regular and/or injected group.
Kojto 107:4f6c30876dfa 320 It overwrites the last setting.
Kojto 107:4f6c30876dfa 321 Note: Refer to Reference Manual to ensure the selected channel is available in differential mode.
Kojto 107:4f6c30876dfa 322 Note: When configuring a channel 'i' in differential mode, the channel 'i+1' is not usable separately.
Kojto 107:4f6c30876dfa 323 Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion).
Kojto 107:4f6c30876dfa 324 If ADC is enabled, this parameter setting is bypassed without error reporting (as it can be the expected behaviour in case
Kojto 107:4f6c30876dfa 325 of another parameter update on the fly) */
Kojto 107:4f6c30876dfa 326 uint32_t OffsetNumber; /*!< Selects the offset number
Kojto 107:4f6c30876dfa 327 This parameter can be a value of @ref ADCEx_OffsetNumber
Kojto 107:4f6c30876dfa 328 Caution: Only one offset is allowed per channel. This parameter overwrites the last setting. */
Kojto 107:4f6c30876dfa 329 uint32_t Offset; /*!< Defines the offset to be subtracted from the raw converted data.
Kojto 107:4f6c30876dfa 330 Offset value must be a positive number.
Kojto 107:4f6c30876dfa 331 Depending of ADC resolution selected (12, 10, 8 or 6 bits), this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF,
Kojto 107:4f6c30876dfa 332 0x3FF, 0xFF or 0x3F respectively.
Kojto 107:4f6c30876dfa 333 Note: This parameter must be modified when no conversion is on going on both regular and injected groups (ADC disabled, or ADC enabled
Kojto 107:4f6c30876dfa 334 without continuous mode or external trigger that could launch a conversion). */
Kojto 107:4f6c30876dfa 335 }ADC_ChannelConfTypeDef;
Kojto 107:4f6c30876dfa 336
Kojto 107:4f6c30876dfa 337
Kojto 107:4f6c30876dfa 338 /**
Kojto 107:4f6c30876dfa 339 * @brief Structure definition of ADC analog watchdog
Kojto 107:4f6c30876dfa 340 * @note The setting of these parameters with function HAL_ADC_AnalogWDGConfig() is conditioned by ADC state.
Kojto 107:4f6c30876dfa 341 * ADC state can be either: ADC disabled or ADC enabled without conversion on going on regular and injected groups.
Kojto 107:4f6c30876dfa 342 */
Kojto 107:4f6c30876dfa 343 typedef struct
Kojto 107:4f6c30876dfa 344 {
Kojto 107:4f6c30876dfa 345 uint32_t WatchdogNumber; /*!< Selects which ADC analog watchdog is applied to the selected channel.
Kojto 107:4f6c30876dfa 346 For Analog Watchdog 1: Only 1 channel can be monitored (or overall group of channels by setting parameter 'WatchdogMode')
Kojto 107:4f6c30876dfa 347 For Analog Watchdog 2 and 3: Several channels can be monitored (by successive calls of 'HAL_ADC_AnalogWDGConfig()' for each channel)
Kojto 107:4f6c30876dfa 348 This parameter can be a value of @ref ADCEx_analog_watchdog_number. */
Kojto 107:4f6c30876dfa 349 uint32_t WatchdogMode; /*!< For Analog Watchdog 1: Configures the ADC analog watchdog mode: single channel/overall group of channels, regular/injected group.
Kojto 107:4f6c30876dfa 350 For Analog Watchdog 2 and 3: There is no configuration for overall group of channels as AWD1. Set value 'ADC_ANALOGWATCHDOG_NONE' to reset
Kojto 107:4f6c30876dfa 351 channels group programmed with parameter 'Channel', set any other value to program the channel(s) to be monitored.
Kojto 107:4f6c30876dfa 352 This parameter can be a value of @ref ADCEx_analog_watchdog_mode. */
Kojto 107:4f6c30876dfa 353 uint32_t Channel; /*!< Selects which ADC channel to monitor by analog watchdog.
Kojto 107:4f6c30876dfa 354 For Analog Watchdog 1: this parameter has an effect only if parameter 'WatchdogMode' is configured on single channel (only 1 channel can be monitored).
Kojto 107:4f6c30876dfa 355 For Analog Watchdog 2 and 3: Several channels can be monitored (successive calls of HAL_ADC_AnalogWDGConfig() must be done, one for each channel.
Kojto 107:4f6c30876dfa 356 Channels group reset can be done by setting WatchdogMode to 'ADC_ANALOGWATCHDOG_NONE').
Kojto 107:4f6c30876dfa 357 This parameter can be a value of @ref ADC_channels. */
Kojto 107:4f6c30876dfa 358 uint32_t ITMode; /*!< Specifies whether the analog watchdog is configured in interrupt or polling mode.
Kojto 107:4f6c30876dfa 359 This parameter can be set to ENABLE or DISABLE */
Kojto 107:4f6c30876dfa 360 uint32_t HighThreshold; /*!< Configures the ADC analog watchdog High threshold value.
Kojto 107:4f6c30876dfa 361 Depending of ADC resolution selected (12, 10, 8 or 6 bits), this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF,
Kojto 107:4f6c30876dfa 362 0x3FF, 0xFF or 0x3F respectively.
Kojto 107:4f6c30876dfa 363 Note: Analog watchdog 2 and 3 are limited to a resolution of 8 bits: if ADC resolution is 12 bits
Kojto 107:4f6c30876dfa 364 the 4 LSB are ignored, if ADC resolution is 10 bits the 2 LSB are ignored. */
Kojto 107:4f6c30876dfa 365 uint32_t LowThreshold; /*!< Configures the ADC analog watchdog Low threshold value.
Kojto 107:4f6c30876dfa 366 Depending of ADC resolution selected (12, 10, 8 or 6 bits), this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF, 0x3FF, 0xFF or 0x3F respectively.
Kojto 107:4f6c30876dfa 367 Note: Analog watchdog 2 and 3 are limited to a resolution of 8 bits: if ADC resolution is 12 bits
Kojto 107:4f6c30876dfa 368 the 4 LSB are ignored, if ADC resolution is 10 bits the 2 LSB are ignored. */
Kojto 107:4f6c30876dfa 369 }ADC_AnalogWDGConfTypeDef;
Kojto 107:4f6c30876dfa 370
Kojto 107:4f6c30876dfa 371
Kojto 107:4f6c30876dfa 372 /**
Kojto 107:4f6c30876dfa 373 * @}
Kojto 107:4f6c30876dfa 374 */
Kojto 107:4f6c30876dfa 375
Kojto 107:4f6c30876dfa 376 /* Exported constants --------------------------------------------------------*/
Kojto 107:4f6c30876dfa 377
Kojto 107:4f6c30876dfa 378 /** @defgroup ADC_Exported_Constants ADC Exported Constants
Kojto 107:4f6c30876dfa 379 * @{
Kojto 107:4f6c30876dfa 380 */
Kojto 107:4f6c30876dfa 381
Kojto 107:4f6c30876dfa 382 /** @defgroup ADC_Error_Code ADC Error Code
Kojto 107:4f6c30876dfa 383 * @{
Kojto 107:4f6c30876dfa 384 */
Kojto 107:4f6c30876dfa 385 #define HAL_ADC_ERROR_NONE ((uint32_t)0x00) /*!< No error */
Kojto 107:4f6c30876dfa 386 #define HAL_ADC_ERROR_INTERNAL ((uint32_t)0x01) /*!< ADC IP internal error: problem of
Kojto 107:4f6c30876dfa 387 clocking, enable/disable, erroneous state */
Kojto 107:4f6c30876dfa 388 #define HAL_ADC_ERROR_OVR ((uint32_t)0x02) /*!< Overrun error */
Kojto 107:4f6c30876dfa 389 #define HAL_ADC_ERROR_DMA ((uint32_t)0x04) /*!< DMA transfer error */
Kojto 107:4f6c30876dfa 390 #define HAL_ADC_ERROR_JQOVF ((uint32_t)0x08) /*!< Injected context queue overflow error */
Kojto 107:4f6c30876dfa 391 /**
Kojto 107:4f6c30876dfa 392 * @}
Kojto 107:4f6c30876dfa 393 */
Kojto 107:4f6c30876dfa 394
Kojto 107:4f6c30876dfa 395 /** @defgroup ADC_ClockPrescaler ADC Clock Prescaler
Kojto 107:4f6c30876dfa 396 * @{
Kojto 107:4f6c30876dfa 397 */
Kojto 107:4f6c30876dfa 398 #define ADC_CLOCK_SYNC_PCLK_DIV1 ((uint32_t)ADC_CCR_CKMODE_0) /*!< ADC synchronous clock derived from AHB clock not divided */
Kojto 107:4f6c30876dfa 399 #define ADC_CLOCK_SYNC_PCLK_DIV2 ((uint32_t)ADC_CCR_CKMODE_1) /*!< ADC synchronous clock derived from AHB clock divided by 2 */
Kojto 107:4f6c30876dfa 400 #define ADC_CLOCK_SYNC_PCLK_DIV4 ((uint32_t)ADC_CCR_CKMODE) /*!< ADC synchronous clock derived from AHB clock divided by 4 */
Kojto 107:4f6c30876dfa 401
Kojto 107:4f6c30876dfa 402 #define ADC_CLOCKPRESCALER_PCLK_DIV1 ADC_CLOCK_SYNC_PCLK_DIV1 /*!< Obsolete naming, kept for compatibility with some other devices */
Kojto 107:4f6c30876dfa 403 #define ADC_CLOCKPRESCALER_PCLK_DIV2 ADC_CLOCK_SYNC_PCLK_DIV2 /*!< Obsolete naming, kept for compatibility with some other devices */
Kojto 107:4f6c30876dfa 404 #define ADC_CLOCKPRESCALER_PCLK_DIV4 ADC_CLOCK_SYNC_PCLK_DIV4 /*!< Obsolete naming, kept for compatibility with some other devices */
Kojto 107:4f6c30876dfa 405
Kojto 107:4f6c30876dfa 406 #define ADC_CLOCK_ASYNC_DIV1 ((uint32_t)0x00000000) /*!< ADC asynchronous clock not divided */
Kojto 107:4f6c30876dfa 407 #define ADC_CLOCK_ASYNC_DIV2 ((uint32_t)ADC_CCR_PRESC_0) /*!< ADC asynchronous clock divided by 2 */
Kojto 107:4f6c30876dfa 408 #define ADC_CLOCK_ASYNC_DIV4 ((uint32_t)ADC_CCR_PRESC_1) /*!< ADC asynchronous clock divided by 4 */
Kojto 107:4f6c30876dfa 409 #define ADC_CLOCK_ASYNC_DIV6 ((uint32_t)(ADC_CCR_PRESC_1|ADC_CCR_PRESC_0)) /*!< ADC asynchronous clock divided by 6 */
Kojto 107:4f6c30876dfa 410 #define ADC_CLOCK_ASYNC_DIV8 ((uint32_t)(ADC_CCR_PRESC_2)) /*!< ADC asynchronous clock divided by 8 */
Kojto 107:4f6c30876dfa 411 #define ADC_CLOCK_ASYNC_DIV10 ((uint32_t)(ADC_CCR_PRESC_2|ADC_CCR_PRESC_0)) /*!< ADC asynchronous clock divided by 10 */
Kojto 107:4f6c30876dfa 412 #define ADC_CLOCK_ASYNC_DIV12 ((uint32_t)(ADC_CCR_PRESC_2|ADC_CCR_PRESC_1)) /*!< ADC asynchronous clock divided by 12 */
Kojto 107:4f6c30876dfa 413 #define ADC_CLOCK_ASYNC_DIV16 ((uint32_t)(ADC_CCR_PRESC_2|ADC_CCR_PRESC_1|ADC_CCR_PRESC_0)) /*!< ADC asynchronous clock divided by 16 */
Kojto 107:4f6c30876dfa 414 #define ADC_CLOCK_ASYNC_DIV32 ((uint32_t)(ADC_CCR_PRESC_3)) /*!< ADC asynchronous clock divided by 32 */
Kojto 107:4f6c30876dfa 415 #define ADC_CLOCK_ASYNC_DIV64 ((uint32_t)(ADC_CCR_PRESC_3|ADC_CCR_PRESC_0)) /*!< ADC asynchronous clock divided by 64 */
Kojto 107:4f6c30876dfa 416 #define ADC_CLOCK_ASYNC_DIV128 ((uint32_t)(ADC_CCR_PRESC_3|ADC_CCR_PRESC_1)) /*!< ADC asynchronous clock divided by 128 */
Kojto 107:4f6c30876dfa 417 #define ADC_CLOCK_ASYNC_DIV256 ((uint32_t)(ADC_CCR_PRESC_3|ADC_CCR_PRESC_1|ADC_CCR_PRESC_0)) /*!< ADC asynchronous clock divided by 256 */
Kojto 107:4f6c30876dfa 418 /**
Kojto 107:4f6c30876dfa 419 * @}
Kojto 107:4f6c30876dfa 420 */
Kojto 107:4f6c30876dfa 421
Kojto 107:4f6c30876dfa 422
Kojto 107:4f6c30876dfa 423 /** @defgroup ADC_Resolution ADC Resolution
Kojto 107:4f6c30876dfa 424 * @{
Kojto 107:4f6c30876dfa 425 */
Kojto 107:4f6c30876dfa 426 #define ADC_RESOLUTION_12B ((uint32_t)0x00000000) /*!< ADC 12-bit resolution */
Kojto 107:4f6c30876dfa 427 #define ADC_RESOLUTION_10B ((uint32_t)ADC_CFGR_RES_0) /*!< ADC 10-bit resolution */
Kojto 107:4f6c30876dfa 428 #define ADC_RESOLUTION_8B ((uint32_t)ADC_CFGR_RES_1) /*!< ADC 8-bit resolution */
Kojto 107:4f6c30876dfa 429 #define ADC_RESOLUTION_6B ((uint32_t)ADC_CFGR_RES) /*!< ADC 6-bit resolution */
Kojto 107:4f6c30876dfa 430 /**
Kojto 107:4f6c30876dfa 431 * @}
Kojto 107:4f6c30876dfa 432 */
Kojto 107:4f6c30876dfa 433
Kojto 107:4f6c30876dfa 434 /** @defgroup ADC_Data_align ADC Data Alignment
Kojto 107:4f6c30876dfa 435 * @{
Kojto 107:4f6c30876dfa 436 */
Kojto 107:4f6c30876dfa 437 #define ADC_DATAALIGN_RIGHT ((uint32_t)0x00000000) /*!< Data right alignment */
Kojto 107:4f6c30876dfa 438 #define ADC_DATAALIGN_LEFT ((uint32_t)ADC_CFGR_ALIGN) /*!< Data left alignment */
Kojto 107:4f6c30876dfa 439 /**
Kojto 107:4f6c30876dfa 440 * @}
Kojto 107:4f6c30876dfa 441 */
Kojto 107:4f6c30876dfa 442
Kojto 107:4f6c30876dfa 443 /** @defgroup ADC_Scan_mode ADC Scan Mode
Kojto 107:4f6c30876dfa 444 * @{
Kojto 107:4f6c30876dfa 445 */
Kojto 107:4f6c30876dfa 446 #define ADC_SCAN_DISABLE ((uint32_t)0x00000000) /*!< Scan mode disabled */
Kojto 107:4f6c30876dfa 447 #define ADC_SCAN_ENABLE ((uint32_t)0x00000001) /*!< Scan mode enabled */
Kojto 107:4f6c30876dfa 448 /**
Kojto 107:4f6c30876dfa 449 * @}
Kojto 107:4f6c30876dfa 450 */
Kojto 107:4f6c30876dfa 451
Kojto 107:4f6c30876dfa 452 /** @defgroup ADC_Regular_External_Trigger_Source_Edge ADC External Trigger Source Edge for Regular Group
Kojto 107:4f6c30876dfa 453 * @{
Kojto 107:4f6c30876dfa 454 */
Kojto 107:4f6c30876dfa 455 #define ADC_EXTERNALTRIGCONVEDGE_NONE ((uint32_t)0x00000000) /*!< Regular conversions hardware trigger detection disabled */
Kojto 107:4f6c30876dfa 456 #define ADC_EXTERNALTRIGCONVEDGE_RISING ((uint32_t)ADC_CFGR_EXTEN_0) /*!< Regular conversions hardware trigger detection on the rising edge */
Kojto 107:4f6c30876dfa 457 #define ADC_EXTERNALTRIGCONVEDGE_FALLING ((uint32_t)ADC_CFGR_EXTEN_1) /*!< Regular conversions hardware trigger detection on the falling edge */
Kojto 107:4f6c30876dfa 458 #define ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING ((uint32_t)ADC_CFGR_EXTEN) /*!< Regular conversions hardware trigger detection on both the rising and falling edges */
Kojto 107:4f6c30876dfa 459 /**
Kojto 107:4f6c30876dfa 460 * @}
Kojto 107:4f6c30876dfa 461 */
Kojto 107:4f6c30876dfa 462
Kojto 107:4f6c30876dfa 463 /** @defgroup ADC_Regular_External_Trigger_Source ADC External Trigger Source for Regular Group
Kojto 107:4f6c30876dfa 464 * @{
Kojto 107:4f6c30876dfa 465 */
Kojto 107:4f6c30876dfa 466
Kojto 107:4f6c30876dfa 467 /* External triggers of ADC regular group */
Kojto 107:4f6c30876dfa 468 #define ADC_EXTERNALTRIG_T1_CC1 ((uint32_t)0x00000000) /*!< Event 0 triggers regular group conversion start */
Kojto 107:4f6c30876dfa 469 #define ADC_EXTERNALTRIG_T1_CC2 ((uint32_t)ADC_CFGR_EXTSEL_0) /*!< Event 1 triggers regular group conversion start */
Kojto 107:4f6c30876dfa 470 #define ADC_EXTERNALTRIG_T1_CC3 ((uint32_t)ADC_CFGR_EXTSEL_1) /*!< Event 2 triggers regular group conversion start */
Kojto 107:4f6c30876dfa 471 #define ADC_EXTERNALTRIG_T2_CC2 ((uint32_t)(ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0)) /*!< Event 3 triggers regular group conversion start */
Kojto 107:4f6c30876dfa 472 #define ADC_EXTERNALTRIG_T3_TRGO ((uint32_t)ADC_CFGR_EXTSEL_2) /*!< Event 4 triggers regular group conversion start */
Kojto 107:4f6c30876dfa 473 #define ADC_EXTERNALTRIG_T4_CC4 ((uint32_t)(ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0)) /*!< Event 5 triggers regular group conversion start */
Kojto 107:4f6c30876dfa 474 #define ADC_EXTERNALTRIG_EXT_IT11 ((uint32_t)(ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1)) /*!< Event 6 triggers regular group conversion start */
Kojto 107:4f6c30876dfa 475 #define ADC_EXTERNALTRIG_T8_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0)) /*!< Event 7 triggers regular group conversion start */
Kojto 107:4f6c30876dfa 476 #define ADC_EXTERNALTRIG_T8_TRGO2 ((uint32_t) ADC_CFGR_EXTSEL_3) /*!< Event 8 triggers regular group conversion start */
Kojto 107:4f6c30876dfa 477 #define ADC_EXTERNALTRIG_T1_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_0)) /*!< Event 9 triggers regular group conversion start */
Kojto 107:4f6c30876dfa 478 #define ADC_EXTERNALTRIG_T1_TRGO2 ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1)) /*!< Event 10 triggers regular group conversion start */
Kojto 107:4f6c30876dfa 479 #define ADC_EXTERNALTRIG_T2_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_1 | ADC_CFGR_EXTSEL_0)) /*!< Event 11 triggers regular group conversion start */
Kojto 107:4f6c30876dfa 480 #define ADC_EXTERNALTRIG_T4_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2)) /*!< Event 12 triggers regular group conversion start */
Kojto 107:4f6c30876dfa 481 #define ADC_EXTERNALTRIG_T6_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_0)) /*!< Event 13 triggers regular group conversion start */
Kojto 107:4f6c30876dfa 482 #define ADC_EXTERNALTRIG_T15_TRGO ((uint32_t)(ADC_CFGR_EXTSEL_3 | ADC_CFGR_EXTSEL_2 | ADC_CFGR_EXTSEL_1)) /*!< Event 14 triggers regular group conversion start */
Kojto 107:4f6c30876dfa 483 #define ADC_EXTERNALTRIG_T3_CC4 ((uint32_t)ADC_CFGR_EXTSEL) /*!< Event 15 triggers regular group conversion start */
Kojto 107:4f6c30876dfa 484
Kojto 107:4f6c30876dfa 485 #define ADC_SOFTWARE_START ((uint32_t)0x00000001) /*!< Software triggers regular group conversion start */
Kojto 107:4f6c30876dfa 486 /**
Kojto 107:4f6c30876dfa 487 * @}
Kojto 107:4f6c30876dfa 488 */
Kojto 107:4f6c30876dfa 489
Kojto 107:4f6c30876dfa 490
Kojto 107:4f6c30876dfa 491 /** @defgroup ADC_EOCSelection ADC End of Regular Sequence/Conversion
Kojto 107:4f6c30876dfa 492 * @{
Kojto 107:4f6c30876dfa 493 */
Kojto 107:4f6c30876dfa 494 #define ADC_EOC_SINGLE_CONV ((uint32_t) ADC_ISR_EOC) /*!< End of conversion flag */
Kojto 107:4f6c30876dfa 495 #define ADC_EOC_SEQ_CONV ((uint32_t) ADC_ISR_EOS) /*!< End of sequence flag */
Kojto 107:4f6c30876dfa 496 #define ADC_EOC_SINGLE_SEQ_CONV ((uint32_t)(ADC_ISR_EOC | ADC_ISR_EOS)) /*!< Reserved for future use */
Kojto 107:4f6c30876dfa 497 /**
Kojto 107:4f6c30876dfa 498 * @}
Kojto 107:4f6c30876dfa 499 */
Kojto 107:4f6c30876dfa 500
Kojto 107:4f6c30876dfa 501 /** @defgroup ADC_Overrun ADC overrun
Kojto 107:4f6c30876dfa 502 * @{
Kojto 107:4f6c30876dfa 503 */
Kojto 107:4f6c30876dfa 504 #define ADC_OVR_DATA_PRESERVED ((uint32_t)0x00000000) /*!< Data preserved in case of overrun */
Kojto 107:4f6c30876dfa 505 #define ADC_OVR_DATA_OVERWRITTEN ((uint32_t)ADC_CFGR_OVRMOD) /*!< Data overwritten in case of overrun */
Kojto 107:4f6c30876dfa 506 /**
Kojto 107:4f6c30876dfa 507 * @}
Kojto 107:4f6c30876dfa 508 */
Kojto 107:4f6c30876dfa 509
Kojto 107:4f6c30876dfa 510 /** @defgroup ADC_channels ADC Channels
Kojto 107:4f6c30876dfa 511 * @{
Kojto 107:4f6c30876dfa 512 */
Kojto 107:4f6c30876dfa 513 #define ADC_CHANNEL_0 ((uint32_t)(0x00000000)) /*!< ADC channel 0 */
Kojto 107:4f6c30876dfa 514 #define ADC_CHANNEL_1 ((uint32_t)(ADC_SQR3_SQ10_0)) /*!< ADC channel 1 */
Kojto 107:4f6c30876dfa 515 #define ADC_CHANNEL_2 ((uint32_t)(ADC_SQR3_SQ10_1)) /*!< ADC channel 2 */
Kojto 107:4f6c30876dfa 516 #define ADC_CHANNEL_3 ((uint32_t)(ADC_SQR3_SQ10_1 | ADC_SQR3_SQ10_0)) /*!< ADC channel 3 */
Kojto 107:4f6c30876dfa 517 #define ADC_CHANNEL_4 ((uint32_t)(ADC_SQR3_SQ10_2)) /*!< ADC channel 4 */
Kojto 107:4f6c30876dfa 518 #define ADC_CHANNEL_5 ((uint32_t)(ADC_SQR3_SQ10_2 | ADC_SQR3_SQ10_0)) /*!< ADC channel 5 */
Kojto 107:4f6c30876dfa 519 #define ADC_CHANNEL_6 ((uint32_t)(ADC_SQR3_SQ10_2 | ADC_SQR3_SQ10_1)) /*!< ADC channel 6 */
Kojto 107:4f6c30876dfa 520 #define ADC_CHANNEL_7 ((uint32_t)(ADC_SQR3_SQ10_2 | ADC_SQR3_SQ10_1 | ADC_SQR3_SQ10_0)) /*!< ADC channel 7 */
Kojto 107:4f6c30876dfa 521 #define ADC_CHANNEL_8 ((uint32_t)(ADC_SQR3_SQ10_3)) /*!< ADC channel 8 */
Kojto 107:4f6c30876dfa 522 #define ADC_CHANNEL_9 ((uint32_t)(ADC_SQR3_SQ10_3 | ADC_SQR3_SQ10_0)) /*!< ADC channel 9 */
Kojto 107:4f6c30876dfa 523 #define ADC_CHANNEL_10 ((uint32_t)(ADC_SQR3_SQ10_3 | ADC_SQR3_SQ10_1)) /*!< ADC channel 10 */
Kojto 107:4f6c30876dfa 524 #define ADC_CHANNEL_11 ((uint32_t)(ADC_SQR3_SQ10_3 | ADC_SQR3_SQ10_1 | ADC_SQR3_SQ10_0)) /*!< ADC channel 11 */
Kojto 107:4f6c30876dfa 525 #define ADC_CHANNEL_12 ((uint32_t)(ADC_SQR3_SQ10_3 | ADC_SQR3_SQ10_2)) /*!< ADC channel 12 */
Kojto 107:4f6c30876dfa 526 #define ADC_CHANNEL_13 ((uint32_t)(ADC_SQR3_SQ10_3 | ADC_SQR3_SQ10_2 | ADC_SQR3_SQ10_0)) /*!< ADC channel 13 */
Kojto 107:4f6c30876dfa 527 #define ADC_CHANNEL_14 ((uint32_t)(ADC_SQR3_SQ10_3 | ADC_SQR3_SQ10_2 | ADC_SQR3_SQ10_1)) /*!< ADC channel 14 */
Kojto 107:4f6c30876dfa 528 #define ADC_CHANNEL_15 ((uint32_t)(ADC_SQR3_SQ10_3 | ADC_SQR3_SQ10_2 | ADC_SQR3_SQ10_1 | ADC_SQR3_SQ10_0)) /*!< ADC channel 15 */
Kojto 107:4f6c30876dfa 529 #define ADC_CHANNEL_16 ((uint32_t)(ADC_SQR3_SQ10_4)) /*!< ADC channel 16 */
Kojto 107:4f6c30876dfa 530 #define ADC_CHANNEL_17 ((uint32_t)(ADC_SQR3_SQ10_4 | ADC_SQR3_SQ10_0)) /*!< ADC channel 17 */
Kojto 107:4f6c30876dfa 531 #define ADC_CHANNEL_18 ((uint32_t)(ADC_SQR3_SQ10_4 | ADC_SQR3_SQ10_1)) /*!< ADC channel 18 */
Kojto 107:4f6c30876dfa 532
Kojto 107:4f6c30876dfa 533 /* Note: VrefInt, TempSensor and Vbat internal channels are not available on all ADC's
Kojto 107:4f6c30876dfa 534 (information present in Reference Manual) */
Kojto 107:4f6c30876dfa 535 #define ADC_CHANNEL_TEMPSENSOR ADC_CHANNEL_17 /*!< ADC temperature sensor channel */
Kojto 107:4f6c30876dfa 536 #define ADC_CHANNEL_VBAT ADC_CHANNEL_18 /*!< ADC Vbat channel */
Kojto 107:4f6c30876dfa 537 #define ADC_CHANNEL_VREFINT ADC_CHANNEL_0 /*!< ADC Vrefint channel */
Kojto 107:4f6c30876dfa 538 /**
Kojto 107:4f6c30876dfa 539 * @}
Kojto 107:4f6c30876dfa 540 */
Kojto 107:4f6c30876dfa 541
Kojto 107:4f6c30876dfa 542 /** @defgroup ADC_sampling_times ADC Sampling Times
Kojto 107:4f6c30876dfa 543 * @{
Kojto 107:4f6c30876dfa 544 */
Kojto 107:4f6c30876dfa 545 #define ADC_SAMPLETIME_2CYCLE_5 ((uint32_t)0x00000000) /*!< Sampling time 2.5 ADC clock cycle */
Kojto 107:4f6c30876dfa 546 #define ADC_SAMPLETIME_6CYCLES_5 ((uint32_t)ADC_SMPR2_SMP10_0) /*!< Sampling time 6.5 ADC clock cycles */
Kojto 107:4f6c30876dfa 547 #define ADC_SAMPLETIME_12CYCLES_5 ((uint32_t)ADC_SMPR2_SMP10_1) /*!< Sampling time 12.5 ADC clock cycles */
Kojto 107:4f6c30876dfa 548 #define ADC_SAMPLETIME_24CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP10_1 | ADC_SMPR2_SMP10_0)) /*!< Sampling time 24.5 ADC clock cycles */
Kojto 107:4f6c30876dfa 549 #define ADC_SAMPLETIME_47CYCLES_5 ((uint32_t)ADC_SMPR2_SMP10_2) /*!< Sampling time 47.5 ADC clock cycles */
Kojto 107:4f6c30876dfa 550 #define ADC_SAMPLETIME_92CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_0)) /*!< Sampling time 92.5 ADC clock cycles */
Kojto 107:4f6c30876dfa 551 #define ADC_SAMPLETIME_247CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_1)) /*!< Sampling time 247.5 ADC clock cycles */
Kojto 107:4f6c30876dfa 552 #define ADC_SAMPLETIME_640CYCLES_5 ((uint32_t)ADC_SMPR2_SMP10) /*!< Sampling time 640.5 ADC clock cycles */
Kojto 107:4f6c30876dfa 553 /**
Kojto 107:4f6c30876dfa 554 * @}
Kojto 107:4f6c30876dfa 555 */
Kojto 107:4f6c30876dfa 556
Kojto 107:4f6c30876dfa 557 /**
Kojto 107:4f6c30876dfa 558 * @}
Kojto 107:4f6c30876dfa 559 */
Kojto 107:4f6c30876dfa 560
Kojto 107:4f6c30876dfa 561 /* Private macros ------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 562
Kojto 107:4f6c30876dfa 563 /** @defgroup ADC_Private_Macro ADC Private Macros
Kojto 107:4f6c30876dfa 564 * @{
Kojto 107:4f6c30876dfa 565 */
Kojto 107:4f6c30876dfa 566
Kojto 107:4f6c30876dfa 567 /**
Kojto 107:4f6c30876dfa 568 * @brief Test if conversion trigger of regular group is software start
Kojto 107:4f6c30876dfa 569 * or external trigger.
Kojto 107:4f6c30876dfa 570 * @param __HANDLE__: ADC handle.
Kojto 107:4f6c30876dfa 571 * @retval SET (software start) or RESET (external trigger)
Kojto 107:4f6c30876dfa 572 */
Kojto 107:4f6c30876dfa 573 #define ADC_IS_SOFTWARE_START_REGULAR(__HANDLE__) \
Kojto 107:4f6c30876dfa 574 (((__HANDLE__)->Instance->CFGR & ADC_CFGR_EXTEN) == RESET)
Kojto 107:4f6c30876dfa 575
Kojto 107:4f6c30876dfa 576 /**
Kojto 107:4f6c30876dfa 577 * @brief Return resolution bits in CFGR register RES[1:0] field.
Kojto 107:4f6c30876dfa 578 * @param __HANDLE__: ADC handle.
Kojto 107:4f6c30876dfa 579 * @retval 2-bit field RES of CFGR register.
Kojto 107:4f6c30876dfa 580 */
Kojto 107:4f6c30876dfa 581 #define ADC_GET_RESOLUTION(__HANDLE__) (((__HANDLE__)->Instance->CFGR) & ADC_CFGR_RES)
Kojto 107:4f6c30876dfa 582
Kojto 107:4f6c30876dfa 583 /**
Kojto 107:4f6c30876dfa 584 * @brief Clear ADC error code (set it to no error code "HAL_ADC_ERROR_NONE").
Kojto 107:4f6c30876dfa 585 * @param __HANDLE__: ADC handle.
Kojto 107:4f6c30876dfa 586 * @retval None
Kojto 107:4f6c30876dfa 587 */
Kojto 107:4f6c30876dfa 588 #define ADC_CLEAR_ERRORCODE(__HANDLE__) ((__HANDLE__)->ErrorCode = HAL_ADC_ERROR_NONE)
Kojto 107:4f6c30876dfa 589
Kojto 107:4f6c30876dfa 590 /**
Kojto 107:4f6c30876dfa 591 * @brief Verification of ADC state: enabled or disabled.
Kojto 107:4f6c30876dfa 592 * @param __HANDLE__: ADC handle.
Kojto 107:4f6c30876dfa 593 * @retval SET (ADC enabled) or RESET (ADC disabled)
Kojto 107:4f6c30876dfa 594 */
Kojto 107:4f6c30876dfa 595 #define ADC_IS_ENABLE(__HANDLE__) \
Kojto 107:4f6c30876dfa 596 (( ((((__HANDLE__)->Instance->CR) & (ADC_CR_ADEN | ADC_CR_ADDIS)) == ADC_CR_ADEN) && \
Kojto 107:4f6c30876dfa 597 ((((__HANDLE__)->Instance->ISR) & ADC_FLAG_RDY) == ADC_FLAG_RDY) \
Kojto 107:4f6c30876dfa 598 ) ? SET : RESET)
Kojto 107:4f6c30876dfa 599
Kojto 107:4f6c30876dfa 600
Kojto 107:4f6c30876dfa 601 /**
Kojto 107:4f6c30876dfa 602 * @brief Check if conversion is on going on regular group.
Kojto 107:4f6c30876dfa 603 * @param __HANDLE__: ADC handle.
Kojto 107:4f6c30876dfa 604 * @retval SET (conversion is on going) or RESET (no conversion is on going)
Kojto 107:4f6c30876dfa 605 */
Kojto 107:4f6c30876dfa 606 #define ADC_IS_CONVERSION_ONGOING_REGULAR(__HANDLE__) \
Kojto 107:4f6c30876dfa 607 (( (((__HANDLE__)->Instance->CR) & ADC_CR_ADSTART) == RESET \
Kojto 107:4f6c30876dfa 608 ) ? RESET : SET)
Kojto 107:4f6c30876dfa 609
Kojto 107:4f6c30876dfa 610
Kojto 107:4f6c30876dfa 611 /**
Kojto 107:4f6c30876dfa 612 * @brief Simultaneously clear and set specific bits of the handle State.
Kojto 107:4f6c30876dfa 613 * @note ADC_STATE_CLR_SET() macro is merely aliased to generic macro MODIFY_REG(),
Kojto 107:4f6c30876dfa 614 * the first parameter is the ADC handle State, the second parameter is the
Kojto 107:4f6c30876dfa 615 * bit field to clear, the third and last parameter is the bit field to set.
Kojto 107:4f6c30876dfa 616 * @retval None
Kojto 107:4f6c30876dfa 617 */
Kojto 107:4f6c30876dfa 618 #define ADC_STATE_CLR_SET MODIFY_REG
Kojto 107:4f6c30876dfa 619
Kojto 107:4f6c30876dfa 620 /**
Kojto 107:4f6c30876dfa 621 * @brief Verify that a given value is aligned with the ADC resolution range.
Kojto 107:4f6c30876dfa 622 * @param __RESOLUTION__: ADC resolution (12, 10, 8 or 6 bits).
Kojto 107:4f6c30876dfa 623 * @param __ADC_VALUE__: value checked against the resolution.
Kojto 107:4f6c30876dfa 624 * @retval SET (__ADC_VALUE__ in line with __RESOLUTION__) or RESET (__ADC_VALUE__ not in line with __RESOLUTION__)
Kojto 107:4f6c30876dfa 625 */
Kojto 107:4f6c30876dfa 626 #define IS_ADC_RANGE(__RESOLUTION__, __ADC_VALUE__) \
Kojto 107:4f6c30876dfa 627 ((((__RESOLUTION__) == ADC_RESOLUTION_12B) && ((__ADC_VALUE__) <= ((uint32_t)0x0FFF))) || \
Kojto 107:4f6c30876dfa 628 (((__RESOLUTION__) == ADC_RESOLUTION_10B) && ((__ADC_VALUE__) <= ((uint32_t)0x03FF))) || \
Kojto 107:4f6c30876dfa 629 (((__RESOLUTION__) == ADC_RESOLUTION_8B) && ((__ADC_VALUE__) <= ((uint32_t)0x00FF))) || \
Kojto 107:4f6c30876dfa 630 (((__RESOLUTION__) == ADC_RESOLUTION_6B) && ((__ADC_VALUE__) <= ((uint32_t)0x003F))) )
Kojto 107:4f6c30876dfa 631
Kojto 107:4f6c30876dfa 632
Kojto 107:4f6c30876dfa 633 /**
Kojto 107:4f6c30876dfa 634 * @brief Verify the length of the scheduled regular conversions group.
Kojto 107:4f6c30876dfa 635 * @param __LENGTH__: number of programmed conversions.
Kojto 107:4f6c30876dfa 636 * @retval SET (__LENGTH__ is within the maximum number of possible programmable regular conversions) or RESET (__LENGTH__ is null or too large)
Kojto 107:4f6c30876dfa 637 */
Kojto 107:4f6c30876dfa 638 #define IS_ADC_REGULAR_NB_CONV(__LENGTH__) (((__LENGTH__) >= ((uint32_t)1)) && ((__LENGTH__) <= ((uint32_t)16)))
Kojto 107:4f6c30876dfa 639
Kojto 107:4f6c30876dfa 640
Kojto 107:4f6c30876dfa 641 /**
Kojto 107:4f6c30876dfa 642 * @brief Verify the number of scheduled regular conversions in discontinuous mode.
Kojto 107:4f6c30876dfa 643 * @param NUMBER: number of scheduled regular conversions in discontinuous mode.
Kojto 107:4f6c30876dfa 644 * @retval SET (NUMBER is within the maximum number of regular conversions in discontinous mode) or RESET (NUMBER is null or too large)
Kojto 107:4f6c30876dfa 645 */
Kojto 107:4f6c30876dfa 646 #define IS_ADC_REGULAR_DISCONT_NUMBER(NUMBER) (((NUMBER) >= ((uint32_t)1)) && ((NUMBER) <= ((uint32_t)8)))
Kojto 107:4f6c30876dfa 647
Kojto 107:4f6c30876dfa 648
Kojto 107:4f6c30876dfa 649 /**
Kojto 107:4f6c30876dfa 650 * @brief Verify the ADC clock setting.
Kojto 107:4f6c30876dfa 651 * @param __ADC_CLOCK__: programmed ADC clock.
Kojto 107:4f6c30876dfa 652 * @retval SET (__ADC_CLOCK__ is a valid value) or RESET (__ADC_CLOCK__ is invalid)
Kojto 107:4f6c30876dfa 653 */
Kojto 107:4f6c30876dfa 654 #define IS_ADC_CLOCKPRESCALER(__ADC_CLOCK__) (((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV1) || \
Kojto 107:4f6c30876dfa 655 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV2) || \
Kojto 107:4f6c30876dfa 656 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV4) || \
Kojto 107:4f6c30876dfa 657 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV1) || \
Kojto 107:4f6c30876dfa 658 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV2) || \
Kojto 107:4f6c30876dfa 659 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV4) || \
Kojto 107:4f6c30876dfa 660 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV6) || \
Kojto 107:4f6c30876dfa 661 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV8) || \
Kojto 107:4f6c30876dfa 662 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV10) || \
Kojto 107:4f6c30876dfa 663 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV12) || \
Kojto 107:4f6c30876dfa 664 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV16) || \
Kojto 107:4f6c30876dfa 665 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV32) || \
Kojto 107:4f6c30876dfa 666 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV64) || \
Kojto 107:4f6c30876dfa 667 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV128) || \
Kojto 107:4f6c30876dfa 668 ((__ADC_CLOCK__) == ADC_CLOCK_ASYNC_DIV256) )
Kojto 107:4f6c30876dfa 669
Kojto 107:4f6c30876dfa 670
Kojto 107:4f6c30876dfa 671 /**
Kojto 107:4f6c30876dfa 672 * @brief Verify the ADC resolution setting.
Kojto 107:4f6c30876dfa 673 * @param __RESOLUTION__: programmed ADC resolution.
Kojto 107:4f6c30876dfa 674 * @retval SET (__RESOLUTION__ is a valid value) or RESET (__RESOLUTION__ is invalid)
Kojto 107:4f6c30876dfa 675 */
Kojto 107:4f6c30876dfa 676 #define IS_ADC_RESOLUTION(__RESOLUTION__) (((__RESOLUTION__) == ADC_RESOLUTION_12B) || \
Kojto 107:4f6c30876dfa 677 ((__RESOLUTION__) == ADC_RESOLUTION_10B) || \
Kojto 107:4f6c30876dfa 678 ((__RESOLUTION__) == ADC_RESOLUTION_8B) || \
Kojto 107:4f6c30876dfa 679 ((__RESOLUTION__) == ADC_RESOLUTION_6B) )
Kojto 107:4f6c30876dfa 680
Kojto 107:4f6c30876dfa 681 /**
Kojto 107:4f6c30876dfa 682 * @brief Verify the ADC resolution setting when limited to 6 or 8 bits.
Kojto 107:4f6c30876dfa 683 * @param __RESOLUTION__: programmed ADC resolution when limited to 6 or 8 bits.
Kojto 107:4f6c30876dfa 684 * @retval SET (__RESOLUTION__ is a valid value) or RESET (__RESOLUTION__ is invalid)
Kojto 107:4f6c30876dfa 685 */
Kojto 107:4f6c30876dfa 686 #define IS_ADC_RESOLUTION_8_6_BITS(__RESOLUTION__) (((__RESOLUTION__) == ADC_RESOLUTION_8B) || \
Kojto 107:4f6c30876dfa 687 ((__RESOLUTION__) == ADC_RESOLUTION_6B) )
Kojto 107:4f6c30876dfa 688
Kojto 107:4f6c30876dfa 689 /**
Kojto 107:4f6c30876dfa 690 * @brief Verify the ADC converted data alignment.
Kojto 107:4f6c30876dfa 691 * @param __ALIGN__: programmed ADC converted data alignment.
Kojto 107:4f6c30876dfa 692 * @retval SET (__ALIGN__ is a valid value) or RESET (__ALIGN__ is invalid)
Kojto 107:4f6c30876dfa 693 */
Kojto 107:4f6c30876dfa 694 #define IS_ADC_DATA_ALIGN(__ALIGN__) (((__ALIGN__) == ADC_DATAALIGN_RIGHT) || \
Kojto 107:4f6c30876dfa 695 ((__ALIGN__) == ADC_DATAALIGN_LEFT) )
Kojto 107:4f6c30876dfa 696
Kojto 107:4f6c30876dfa 697
Kojto 107:4f6c30876dfa 698 /**
Kojto 107:4f6c30876dfa 699 * @brief Verify the ADC scan mode.
Kojto 107:4f6c30876dfa 700 * @param __SCAN_MODE__: programmed ADC scan mode.
Kojto 107:4f6c30876dfa 701 * @retval SET (__SCAN_MODE__ is valid) or RESET (__SCAN_MODE__ is invalid)
Kojto 107:4f6c30876dfa 702 */
Kojto 107:4f6c30876dfa 703 #define IS_ADC_SCAN_MODE(__SCAN_MODE__) (((__SCAN_MODE__) == ADC_SCAN_DISABLE) || \
Kojto 107:4f6c30876dfa 704 ((__SCAN_MODE__) == ADC_SCAN_ENABLE) )
Kojto 107:4f6c30876dfa 705
Kojto 107:4f6c30876dfa 706 /**
Kojto 107:4f6c30876dfa 707 * @brief Verify the ADC edge trigger setting for regular group.
Kojto 107:4f6c30876dfa 708 * @param __EDGE__: programmed ADC edge trigger setting.
Kojto 107:4f6c30876dfa 709 * @retval SET (__EDGE__ is a valid value) or RESET (__EDGE__ is invalid)
Kojto 107:4f6c30876dfa 710 */
Kojto 107:4f6c30876dfa 711 #define IS_ADC_EXTTRIG_EDGE(__EDGE__) (((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_NONE) || \
Kojto 107:4f6c30876dfa 712 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_RISING) || \
Kojto 107:4f6c30876dfa 713 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_FALLING) || \
Kojto 107:4f6c30876dfa 714 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING) )
Kojto 107:4f6c30876dfa 715
Kojto 107:4f6c30876dfa 716
Kojto 107:4f6c30876dfa 717
Kojto 107:4f6c30876dfa 718 /**
Kojto 107:4f6c30876dfa 719 * @brief Verify the ADC regular conversions external trigger.
Kojto 107:4f6c30876dfa 720 * @param __REGTRIG__: programmed ADC regular conversions external trigger.
Kojto 107:4f6c30876dfa 721 * @retval SET (__REGTRIG__ is a valid value) or RESET (__REGTRIG__ is invalid)
Kojto 107:4f6c30876dfa 722 */
Kojto 107:4f6c30876dfa 723 #define IS_ADC_EXTTRIG(__REGTRIG__) (((__REGTRIG__) == ADC_EXTERNALTRIG_T1_CC1) || \
Kojto 107:4f6c30876dfa 724 ((__REGTRIG__) == ADC_EXTERNALTRIG_T1_CC2) || \
Kojto 107:4f6c30876dfa 725 ((__REGTRIG__) == ADC_EXTERNALTRIG_T1_CC3) || \
Kojto 107:4f6c30876dfa 726 ((__REGTRIG__) == ADC_EXTERNALTRIG_T2_CC2) || \
Kojto 107:4f6c30876dfa 727 ((__REGTRIG__) == ADC_EXTERNALTRIG_T3_TRGO) || \
Kojto 107:4f6c30876dfa 728 ((__REGTRIG__) == ADC_EXTERNALTRIG_T4_CC4) || \
Kojto 107:4f6c30876dfa 729 ((__REGTRIG__) == ADC_EXTERNALTRIG_EXT_IT11) || \
Kojto 107:4f6c30876dfa 730 ((__REGTRIG__) == ADC_EXTERNALTRIG_T8_TRGO) || \
Kojto 107:4f6c30876dfa 731 ((__REGTRIG__) == ADC_EXTERNALTRIG_T8_TRGO2) || \
Kojto 107:4f6c30876dfa 732 ((__REGTRIG__) == ADC_EXTERNALTRIG_T1_TRGO) || \
Kojto 107:4f6c30876dfa 733 ((__REGTRIG__) == ADC_EXTERNALTRIG_T1_TRGO2) || \
Kojto 107:4f6c30876dfa 734 ((__REGTRIG__) == ADC_EXTERNALTRIG_T2_TRGO) || \
Kojto 107:4f6c30876dfa 735 ((__REGTRIG__) == ADC_EXTERNALTRIG_T4_TRGO) || \
Kojto 107:4f6c30876dfa 736 ((__REGTRIG__) == ADC_EXTERNALTRIG_T6_TRGO) || \
Kojto 107:4f6c30876dfa 737 ((__REGTRIG__) == ADC_EXTERNALTRIG_T15_TRGO) || \
Kojto 107:4f6c30876dfa 738 ((__REGTRIG__) == ADC_EXTERNALTRIG_T3_CC4) || \
Kojto 107:4f6c30876dfa 739 \
Kojto 107:4f6c30876dfa 740 ((__REGTRIG__) == ADC_SOFTWARE_START) )
Kojto 107:4f6c30876dfa 741
Kojto 107:4f6c30876dfa 742
Kojto 107:4f6c30876dfa 743
Kojto 107:4f6c30876dfa 744 /**
Kojto 107:4f6c30876dfa 745 * @brief Verify the ADC regular conversions check for converted data availability.
Kojto 107:4f6c30876dfa 746 * @param __EOC_SELECTION__: converted data availability check.
Kojto 107:4f6c30876dfa 747 * @retval SET (__EOC_SELECTION__ is a valid value) or RESET (__EOC_SELECTION__ is invalid)
Kojto 107:4f6c30876dfa 748 */
Kojto 107:4f6c30876dfa 749 #define IS_ADC_EOC_SELECTION(__EOC_SELECTION__) (((__EOC_SELECTION__) == ADC_EOC_SINGLE_CONV) || \
Kojto 107:4f6c30876dfa 750 ((__EOC_SELECTION__) == ADC_EOC_SEQ_CONV) || \
Kojto 107:4f6c30876dfa 751 ((__EOC_SELECTION__) == ADC_EOC_SINGLE_SEQ_CONV) )
Kojto 107:4f6c30876dfa 752
Kojto 107:4f6c30876dfa 753 /**
Kojto 107:4f6c30876dfa 754 * @brief Verify the ADC regular conversions overrun handling.
Kojto 107:4f6c30876dfa 755 * @param __OVR__: ADC regular conversions overrun handling.
Kojto 107:4f6c30876dfa 756 * @retval SET (__OVR__ is a valid value) or RESET (__OVR__ is invalid)
Kojto 107:4f6c30876dfa 757 */
Kojto 107:4f6c30876dfa 758 #define IS_ADC_OVERRUN(__OVR__) (((__OVR__) == ADC_OVR_DATA_PRESERVED) || \
Kojto 107:4f6c30876dfa 759 ((__OVR__) == ADC_OVR_DATA_OVERWRITTEN) )
Kojto 107:4f6c30876dfa 760
Kojto 107:4f6c30876dfa 761 /**
Kojto 107:4f6c30876dfa 762 * @brief Verify the ADC conversions sampling time.
Kojto 107:4f6c30876dfa 763 * @param __TIME__: ADC conversions sampling time.
Kojto 107:4f6c30876dfa 764 * @retval SET (__TIME__ is a valid value) or RESET (__TIME__ is invalid)
Kojto 107:4f6c30876dfa 765 */
Kojto 107:4f6c30876dfa 766 #define IS_ADC_SAMPLE_TIME(__TIME__) (((__TIME__) == ADC_SAMPLETIME_2CYCLE_5) || \
Kojto 107:4f6c30876dfa 767 ((__TIME__) == ADC_SAMPLETIME_6CYCLES_5) || \
Kojto 107:4f6c30876dfa 768 ((__TIME__) == ADC_SAMPLETIME_12CYCLES_5) || \
Kojto 107:4f6c30876dfa 769 ((__TIME__) == ADC_SAMPLETIME_24CYCLES_5) || \
Kojto 107:4f6c30876dfa 770 ((__TIME__) == ADC_SAMPLETIME_47CYCLES_5) || \
Kojto 107:4f6c30876dfa 771 ((__TIME__) == ADC_SAMPLETIME_92CYCLES_5) || \
Kojto 107:4f6c30876dfa 772 ((__TIME__) == ADC_SAMPLETIME_247CYCLES_5) || \
Kojto 107:4f6c30876dfa 773 ((__TIME__) == ADC_SAMPLETIME_640CYCLES_5) )
Kojto 107:4f6c30876dfa 774 /**
Kojto 107:4f6c30876dfa 775 * @}
Kojto 107:4f6c30876dfa 776 */
Kojto 107:4f6c30876dfa 777
Kojto 107:4f6c30876dfa 778
Kojto 107:4f6c30876dfa 779 /* Private constants ---------------------------------------------------------*/
Kojto 107:4f6c30876dfa 780
Kojto 107:4f6c30876dfa 781 /** @defgroup ADC_Private_Constants ADC Private Constants
Kojto 107:4f6c30876dfa 782 * @{
Kojto 107:4f6c30876dfa 783 */
Kojto 107:4f6c30876dfa 784
Kojto 107:4f6c30876dfa 785 /* Fixed timeout values for ADC conversion (including sampling time) */
Kojto 107:4f6c30876dfa 786 /* Maximum sampling time is 640.5 ADC clock cycle (SMPx[2:0] = 0b111 */
Kojto 107:4f6c30876dfa 787 /* Maximum conversion time is 12.5 + Maximum sampling time */
Kojto 107:4f6c30876dfa 788 /* or 12.5 + 640.5 = 653 ADC clock cycles */
Kojto 107:4f6c30876dfa 789 /* Minimum ADC Clock frequency is 0.14 MHz */
Kojto 107:4f6c30876dfa 790 /* Maximum conversion time is */
Kojto 107:4f6c30876dfa 791 /* 653 / 0.14 MHz = 4.66 ms */
Kojto 107:4f6c30876dfa 792 #define ADC_STOP_CONVERSION_TIMEOUT ((uint32_t) 5) /*!< ADC stop time-out value */
Kojto 107:4f6c30876dfa 793
Kojto 107:4f6c30876dfa 794 /* Delay for temperature sensor stabilization time. */
Kojto 107:4f6c30876dfa 795 /* Maximum delay is 10 us (refer device DataSheet, parameter t_START). */
Kojto 107:4f6c30876dfa 796 /* Delay in CPU cycles, fixed to worst case with maximum CPU frequency */
Kojto 107:4f6c30876dfa 797 /* equal to 80 MHz. */
Kojto 107:4f6c30876dfa 798 /* The minimum number of CPU cycles to fulfill this delay is 800 */
Kojto 107:4f6c30876dfa 799 #define ADC_TEMPSENSOR_DELAY_CPU_CYCLES ((uint32_t)800) /*!< ADC temperature sensor stabilization duration */
Kojto 107:4f6c30876dfa 800
Kojto 107:4f6c30876dfa 801 /**
Kojto 107:4f6c30876dfa 802 * @}
Kojto 107:4f6c30876dfa 803 */
Kojto 107:4f6c30876dfa 804
Kojto 107:4f6c30876dfa 805 /* Exported macros -----------------------------------------------------------*/
Kojto 107:4f6c30876dfa 806
Kojto 107:4f6c30876dfa 807 /** @defgroup ADC_Exported_Macro ADC Exported Macros
Kojto 107:4f6c30876dfa 808 * @{
Kojto 107:4f6c30876dfa 809 */
Kojto 107:4f6c30876dfa 810
Kojto 107:4f6c30876dfa 811 /** @brief Reset ADC handle state.
Kojto 107:4f6c30876dfa 812 * @param __HANDLE__: ADC handle.
Kojto 107:4f6c30876dfa 813 * @retval None
Kojto 107:4f6c30876dfa 814 */
Kojto 107:4f6c30876dfa 815 #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
Kojto 107:4f6c30876dfa 816
Kojto 107:4f6c30876dfa 817
Kojto 107:4f6c30876dfa 818 /** @brief Check whether the specified ADC interrupt source is enabled or not.
Kojto 107:4f6c30876dfa 819 * @param __HANDLE__: ADC handle.
Kojto 107:4f6c30876dfa 820 * @param __INTERRUPT__: ADC interrupt source to check
Kojto 107:4f6c30876dfa 821 * This parameter can be one of the following values:
Kojto 107:4f6c30876dfa 822 * @arg ADC_IT_RDY, ADC Ready (ADRDY) interrupt source
Kojto 107:4f6c30876dfa 823 * @arg ADC_IT_EOSMP, ADC End of Sampling interrupt source
Kojto 107:4f6c30876dfa 824 * @arg ADC_IT_EOC, ADC End of Regular Conversion interrupt source
Kojto 107:4f6c30876dfa 825 * @arg ADC_IT_EOS, ADC End of Regular sequence of Conversions interrupt source
Kojto 107:4f6c30876dfa 826 * @arg ADC_IT_OVR, ADC overrun interrupt source
Kojto 107:4f6c30876dfa 827 * @arg ADC_IT_JEOC, ADC End of Injected Conversion interrupt source
Kojto 107:4f6c30876dfa 828 * @arg ADC_IT_JEOS, ADC End of Injected sequence of Conversions interrupt source
Kojto 107:4f6c30876dfa 829 * @arg ADC_IT_AWD1, ADC Analog watchdog 1 interrupt source (main analog watchdog)
Kojto 107:4f6c30876dfa 830 * @arg ADC_IT_AWD2, ADC Analog watchdog 2 interrupt source (additional analog watchdog)
Kojto 107:4f6c30876dfa 831 * @arg ADC_IT_AWD3, ADC Analog watchdog 3 interrupt source (additional analog watchdog)
Kojto 107:4f6c30876dfa 832 * @arg ADC_IT_JQOVF, ADC Injected Context Queue Overflow interrupt source.
Kojto 107:4f6c30876dfa 833 * @retval State of interruption (SET or RESET)
Kojto 107:4f6c30876dfa 834 */
Kojto 107:4f6c30876dfa 835 #define __HAL_ADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \
Kojto 107:4f6c30876dfa 836 (( ((__HANDLE__)->Instance->IER & (__INTERRUPT__)) == (__INTERRUPT__) \
Kojto 107:4f6c30876dfa 837 )? SET : RESET \
Kojto 107:4f6c30876dfa 838 )
Kojto 107:4f6c30876dfa 839
Kojto 107:4f6c30876dfa 840 /**
Kojto 107:4f6c30876dfa 841 * @brief Enable an ADC interrupt.
Kojto 107:4f6c30876dfa 842 * @param __HANDLE__: ADC handle.
Kojto 107:4f6c30876dfa 843 * @param __INTERRUPT__: ADC Interrupt to enable
Kojto 107:4f6c30876dfa 844 * This parameter can be one of the following values:
Kojto 107:4f6c30876dfa 845 * @arg ADC_IT_RDY, ADC Ready (ADRDY) interrupt source
Kojto 107:4f6c30876dfa 846 * @arg ADC_IT_EOSMP, ADC End of Sampling interrupt source
Kojto 107:4f6c30876dfa 847 * @arg ADC_IT_EOC, ADC End of Regular Conversion interrupt source
Kojto 107:4f6c30876dfa 848 * @arg ADC_IT_EOS, ADC End of Regular sequence of Conversions interrupt source
Kojto 107:4f6c30876dfa 849 * @arg ADC_IT_OVR, ADC overrun interrupt source
Kojto 107:4f6c30876dfa 850 * @arg ADC_IT_JEOC, ADC End of Injected Conversion interrupt source
Kojto 107:4f6c30876dfa 851 * @arg ADC_IT_JEOS, ADC End of Injected sequence of Conversions interrupt source
Kojto 107:4f6c30876dfa 852 * @arg ADC_IT_AWD1, ADC Analog watchdog 1 interrupt source (main analog watchdog)
Kojto 107:4f6c30876dfa 853 * @arg ADC_IT_AWD2, ADC Analog watchdog 2 interrupt source (additional analog watchdog)
Kojto 107:4f6c30876dfa 854 * @arg ADC_IT_AWD3, ADC Analog watchdog 3 interrupt source (additional analog watchdog)
Kojto 107:4f6c30876dfa 855 * @arg ADC_IT_JQOVF, ADC Injected Context Queue Overflow interrupt source.
Kojto 107:4f6c30876dfa 856 * @retval None
Kojto 107:4f6c30876dfa 857 */
Kojto 107:4f6c30876dfa 858 #define __HAL_ADC_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->IER) |= (__INTERRUPT__))
Kojto 107:4f6c30876dfa 859
Kojto 107:4f6c30876dfa 860 /**
Kojto 107:4f6c30876dfa 861 * @brief Disable an ADC interrupt.
Kojto 107:4f6c30876dfa 862 * @param __HANDLE__: ADC handle.
Kojto 107:4f6c30876dfa 863 * @param __INTERRUPT__: ADC Interrupt to disable
Kojto 107:4f6c30876dfa 864 * @arg ADC_IT_RDY, ADC Ready (ADRDY) interrupt source
Kojto 107:4f6c30876dfa 865 * @arg ADC_IT_EOSMP, ADC End of Sampling interrupt source
Kojto 107:4f6c30876dfa 866 * @arg ADC_IT_EOC, ADC End of Regular Conversion interrupt source
Kojto 107:4f6c30876dfa 867 * @arg ADC_IT_EOS, ADC End of Regular sequence of Conversions interrupt source
Kojto 107:4f6c30876dfa 868 * @arg ADC_IT_OVR, ADC overrun interrupt source
Kojto 107:4f6c30876dfa 869 * @arg ADC_IT_JEOC, ADC End of Injected Conversion interrupt source
Kojto 107:4f6c30876dfa 870 * @arg ADC_IT_JEOS, ADC End of Injected sequence of Conversions interrupt source
Kojto 107:4f6c30876dfa 871 * @arg ADC_IT_AWD1, ADC Analog watchdog 1 interrupt source (main analog watchdog)
Kojto 107:4f6c30876dfa 872 * @arg ADC_IT_AWD2, ADC Analog watchdog 2 interrupt source (additional analog watchdog)
Kojto 107:4f6c30876dfa 873 * @arg ADC_IT_AWD3, ADC Analog watchdog 3 interrupt source (additional analog watchdog)
Kojto 107:4f6c30876dfa 874 * @arg ADC_IT_JQOVF, ADC Injected Context Queue Overflow interrupt source.
Kojto 107:4f6c30876dfa 875 * @retval None
Kojto 107:4f6c30876dfa 876 */
Kojto 107:4f6c30876dfa 877 #define __HAL_ADC_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->IER) &= ~(__INTERRUPT__))
Kojto 107:4f6c30876dfa 878
Kojto 107:4f6c30876dfa 879 /**
Kojto 107:4f6c30876dfa 880 * @brief Check whether the specified ADC flag is set or not.
Kojto 107:4f6c30876dfa 881 * @param __HANDLE__: ADC handle.
Kojto 107:4f6c30876dfa 882 * @param __FLAG__: ADC flag to check
Kojto 107:4f6c30876dfa 883 * This parameter can be one of the following values:
Kojto 107:4f6c30876dfa 884 * @arg ADC_FLAG_RDY, ADC Ready (ADRDY) flag
Kojto 107:4f6c30876dfa 885 * @arg ADC_FLAG_EOSMP, ADC End of Sampling flag
Kojto 107:4f6c30876dfa 886 * @arg ADC_FLAG_EOC, ADC End of Regular Conversion flag
Kojto 107:4f6c30876dfa 887 * @arg ADC_FLAG_EOS, ADC End of Regular sequence of Conversions flag
Kojto 107:4f6c30876dfa 888 * @arg ADC_FLAG_OVR, ADC overrun flag
Kojto 107:4f6c30876dfa 889 * @arg ADC_FLAG_JEOC, ADC End of Injected Conversion flag
Kojto 107:4f6c30876dfa 890 * @arg ADC_FLAG_JEOS, ADC End of Injected sequence of Conversions flag
Kojto 107:4f6c30876dfa 891 * @arg ADC_FLAG_AWD1, ADC Analog watchdog 1 flag (main analog watchdog)
Kojto 107:4f6c30876dfa 892 * @arg ADC_FLAG_AWD2, ADC Analog watchdog 2 flag (additional analog watchdog)
Kojto 107:4f6c30876dfa 893 * @arg ADC_FLAG_AWD3, ADC Analog watchdog 3 flag (additional analog watchdog)
Kojto 107:4f6c30876dfa 894 * @arg ADC_FLAG_JQOVF, ADC Injected Context Queue Overflow flag.
Kojto 107:4f6c30876dfa 895 * @retval The new state of __FLAG__ (TRUE or FALSE).
Kojto 107:4f6c30876dfa 896 */
Kojto 107:4f6c30876dfa 897 #define __HAL_ADC_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->ISR) & (__FLAG__)) == (__FLAG__))
Kojto 107:4f6c30876dfa 898
Kojto 107:4f6c30876dfa 899 /**
Kojto 107:4f6c30876dfa 900 * @brief Clear a specified ADC flag.
Kojto 107:4f6c30876dfa 901 * @param __HANDLE__: ADC handle.
Kojto 107:4f6c30876dfa 902 * @param __FLAG__: ADC flag to clear
Kojto 107:4f6c30876dfa 903 * This parameter can be one of the following values:
Kojto 107:4f6c30876dfa 904 * @arg ADC_FLAG_RDY, ADC Ready (ADRDY) flag
Kojto 107:4f6c30876dfa 905 * @arg ADC_FLAG_EOSMP, ADC End of Sampling flag
Kojto 107:4f6c30876dfa 906 * @arg ADC_FLAG_EOC, ADC End of Regular Conversion flag
Kojto 107:4f6c30876dfa 907 * @arg ADC_FLAG_EOS, ADC End of Regular sequence of Conversions flag
Kojto 107:4f6c30876dfa 908 * @arg ADC_FLAG_OVR, ADC overrun flag
Kojto 107:4f6c30876dfa 909 * @arg ADC_FLAG_JEOC, ADC End of Injected Conversion flag
Kojto 107:4f6c30876dfa 910 * @arg ADC_FLAG_JEOS, ADC End of Injected sequence of Conversions flag
Kojto 107:4f6c30876dfa 911 * @arg ADC_FLAG_AWD1, ADC Analog watchdog 1 flag (main analog watchdog)
Kojto 107:4f6c30876dfa 912 * @arg ADC_FLAG_AWD2, ADC Analog watchdog 2 flag (additional analog watchdog)
Kojto 107:4f6c30876dfa 913 * @arg ADC_FLAG_AWD3, ADC Analog watchdog 3 flag (additional analog watchdog)
Kojto 107:4f6c30876dfa 914 * @arg ADC_FLAG_JQOVF, ADC Injected Context Queue Overflow flag.
Kojto 107:4f6c30876dfa 915 * @note Bit cleared bit by writing 1 (writing 0 has no effect on any bit of register ISR).
Kojto 107:4f6c30876dfa 916 * @retval None
Kojto 107:4f6c30876dfa 917 */
Kojto 107:4f6c30876dfa 918 #define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->ISR) = (__FLAG__))
Kojto 107:4f6c30876dfa 919
Kojto 107:4f6c30876dfa 920
Kojto 107:4f6c30876dfa 921 /**
Kojto 107:4f6c30876dfa 922 * @}
Kojto 107:4f6c30876dfa 923 */
Kojto 107:4f6c30876dfa 924
Kojto 107:4f6c30876dfa 925 /* Include ADC HAL Extended module */
Kojto 107:4f6c30876dfa 926 #include "stm32l4xx_hal_adc_ex.h"
Kojto 107:4f6c30876dfa 927
Kojto 107:4f6c30876dfa 928 /* Exported functions --------------------------------------------------------*/
Kojto 107:4f6c30876dfa 929 /** @addtogroup ADC_Exported_Functions ADC Exported Functions
Kojto 107:4f6c30876dfa 930 * @{
Kojto 107:4f6c30876dfa 931 */
Kojto 107:4f6c30876dfa 932
Kojto 107:4f6c30876dfa 933 /** @addtogroup ADC_Exported_Functions_Group1 Initialization and de-initialization functions
Kojto 107:4f6c30876dfa 934 * @brief Initialization and Configuration functions
Kojto 107:4f6c30876dfa 935 * @{
Kojto 107:4f6c30876dfa 936 */
Kojto 107:4f6c30876dfa 937 /* Initialization and de-initialization functions **********************************/
Kojto 107:4f6c30876dfa 938 HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 939 HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
Kojto 107:4f6c30876dfa 940 void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 941 void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 942 /**
Kojto 107:4f6c30876dfa 943 * @}
Kojto 107:4f6c30876dfa 944 */
Kojto 107:4f6c30876dfa 945
Kojto 107:4f6c30876dfa 946 /** @addtogroup ADC_Exported_Functions_Group2 Input and Output operation functions
Kojto 107:4f6c30876dfa 947 * @brief IO operation functions
Kojto 107:4f6c30876dfa 948 * @{
Kojto 107:4f6c30876dfa 949 */
Kojto 107:4f6c30876dfa 950 /* Blocking mode: Polling */
Kojto 107:4f6c30876dfa 951 HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 952 HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 953 HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
Kojto 107:4f6c30876dfa 954 HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout);
Kojto 107:4f6c30876dfa 955
Kojto 107:4f6c30876dfa 956 /* Non-blocking mode: Interruption */
Kojto 107:4f6c30876dfa 957 HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 958 HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 959
Kojto 107:4f6c30876dfa 960 /* Non-blocking mode: DMA */
Kojto 107:4f6c30876dfa 961 HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length);
Kojto 107:4f6c30876dfa 962 HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 963
Kojto 107:4f6c30876dfa 964 /* ADC retrieve conversion value intended to be used with polling or interruption */
Kojto 107:4f6c30876dfa 965 uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 966
Kojto 107:4f6c30876dfa 967 /* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption and DMA) */
Kojto 107:4f6c30876dfa 968 void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 969 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 970 void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 971 void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 972 void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
Kojto 107:4f6c30876dfa 973 /**
Kojto 107:4f6c30876dfa 974 * @}
Kojto 107:4f6c30876dfa 975 */
Kojto 107:4f6c30876dfa 976
Kojto 107:4f6c30876dfa 977 /** @addtogroup ADC_Exported_Functions_Group3 Peripheral Control functions
Kojto 107:4f6c30876dfa 978 * @brief Peripheral Control functions
Kojto 107:4f6c30876dfa 979 * @{
Kojto 107:4f6c30876dfa 980 */
Kojto 107:4f6c30876dfa 981 /* Peripheral Control functions ***********************************************/
Kojto 107:4f6c30876dfa 982 HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig);
Kojto 107:4f6c30876dfa 983 HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig);
Kojto 107:4f6c30876dfa 984 /**
Kojto 107:4f6c30876dfa 985 * @}
Kojto 107:4f6c30876dfa 986 */
Kojto 107:4f6c30876dfa 987
Kojto 107:4f6c30876dfa 988 /** @defgroup ADC_Exported_Functions_Group4 Peripheral State functions
Kojto 107:4f6c30876dfa 989 * @brief ADC Peripheral State functions
Kojto 107:4f6c30876dfa 990 * @{
Kojto 107:4f6c30876dfa 991 */
Kojto 107:4f6c30876dfa 992 /* Peripheral State functions *************************************************/
Kojto 107:4f6c30876dfa 993 uint32_t HAL_ADC_GetState(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 994 uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc);
Kojto 107:4f6c30876dfa 995 /**
Kojto 107:4f6c30876dfa 996 * @}
Kojto 107:4f6c30876dfa 997 */
Kojto 107:4f6c30876dfa 998
Kojto 107:4f6c30876dfa 999 /**
Kojto 107:4f6c30876dfa 1000 * @}
Kojto 107:4f6c30876dfa 1001 */
Kojto 107:4f6c30876dfa 1002
Kojto 107:4f6c30876dfa 1003 /* Private functions -----------------------------------------------------------*/
Kojto 107:4f6c30876dfa 1004 /** @addtogroup ADC_Private_Functions ADC Private Functions
Kojto 107:4f6c30876dfa 1005 * @{
Kojto 107:4f6c30876dfa 1006 */
Kojto 107:4f6c30876dfa 1007
Kojto 107:4f6c30876dfa 1008 HAL_StatusTypeDef ADC_ConversionStop(ADC_HandleTypeDef* hadc, uint32_t ConversionGroup);
Kojto 107:4f6c30876dfa 1009 HAL_StatusTypeDef ADC_Enable(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 1010 HAL_StatusTypeDef ADC_Disable(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 1011 void ADC_DMAConvCplt(DMA_HandleTypeDef *hdma);
Kojto 107:4f6c30876dfa 1012 void ADC_DMAHalfConvCplt(DMA_HandleTypeDef *hdma);
Kojto 107:4f6c30876dfa 1013 void ADC_DMAError(DMA_HandleTypeDef *hdma);
Kojto 107:4f6c30876dfa 1014
Kojto 107:4f6c30876dfa 1015 /**
Kojto 107:4f6c30876dfa 1016 * @}
Kojto 107:4f6c30876dfa 1017 */
Kojto 107:4f6c30876dfa 1018
Kojto 107:4f6c30876dfa 1019 /**
Kojto 107:4f6c30876dfa 1020 * @}
Kojto 107:4f6c30876dfa 1021 */
Kojto 107:4f6c30876dfa 1022
Kojto 107:4f6c30876dfa 1023 /**
Kojto 107:4f6c30876dfa 1024 * @}
Kojto 107:4f6c30876dfa 1025 */
Kojto 107:4f6c30876dfa 1026
Kojto 107:4f6c30876dfa 1027 #ifdef __cplusplus
Kojto 107:4f6c30876dfa 1028 }
Kojto 107:4f6c30876dfa 1029 #endif
Kojto 107:4f6c30876dfa 1030
Kojto 107:4f6c30876dfa 1031 #endif /*__STM32L4xx_ADC_H */
Kojto 107:4f6c30876dfa 1032
Kojto 107:4f6c30876dfa 1033
Kojto 107:4f6c30876dfa 1034 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/