The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

This is the mbed 2 library. If you'd like to learn about Mbed OS please see the mbed-os docs.

Committer:
AnnaBridge
Date:
Wed Jun 21 17:31:38 2017 +0100
Revision:
145:64910690c574
Parent:
128:9bcdf88f62b0
Release 145 of the mbed library.

Who changed what in which revision?

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