mbed library sources

Dependents:   Marvino mbot

Fork of mbed-src by mbed official

Committer:
jaerts
Date:
Tue Dec 22 13:22:16 2015 +0000
Revision:
637:ed69428d4850
Parent:
610:813dcc80987e
Add very shady LPC1768 CAN Filter implementation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 610:813dcc80987e 1 /**
mbed_official 610:813dcc80987e 2 ******************************************************************************
mbed_official 610:813dcc80987e 3 * @file stm32l4xx_hal_adc_ex.h
mbed_official 610:813dcc80987e 4 * @author MCD Application Team
mbed_official 610:813dcc80987e 5 * @version V1.0.0
mbed_official 610:813dcc80987e 6 * @date 26-June-2015
mbed_official 610:813dcc80987e 7 * @brief Header file of ADC HAL extended module.
mbed_official 610:813dcc80987e 8 ******************************************************************************
mbed_official 610:813dcc80987e 9 * @attention
mbed_official 610:813dcc80987e 10 *
mbed_official 610:813dcc80987e 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
mbed_official 610:813dcc80987e 12 *
mbed_official 610:813dcc80987e 13 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 610:813dcc80987e 14 * are permitted provided that the following conditions are met:
mbed_official 610:813dcc80987e 15 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 610:813dcc80987e 16 * this list of conditions and the following disclaimer.
mbed_official 610:813dcc80987e 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 610:813dcc80987e 18 * this list of conditions and the following disclaimer in the documentation
mbed_official 610:813dcc80987e 19 * and/or other materials provided with the distribution.
mbed_official 610:813dcc80987e 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 610:813dcc80987e 21 * may be used to endorse or promote products derived from this software
mbed_official 610:813dcc80987e 22 * without specific prior written permission.
mbed_official 610:813dcc80987e 23 *
mbed_official 610:813dcc80987e 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 610:813dcc80987e 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 610:813dcc80987e 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 610:813dcc80987e 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 610:813dcc80987e 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 610:813dcc80987e 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 610:813dcc80987e 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 610:813dcc80987e 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 610:813dcc80987e 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 610:813dcc80987e 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 610:813dcc80987e 34 *
mbed_official 610:813dcc80987e 35 ******************************************************************************
mbed_official 610:813dcc80987e 36 */
mbed_official 610:813dcc80987e 37
mbed_official 610:813dcc80987e 38 /* Define to prevent recursive inclusion -------------------------------------*/
mbed_official 610:813dcc80987e 39 #ifndef __STM32L4xx_ADC_EX_H
mbed_official 610:813dcc80987e 40 #define __STM32L4xx_ADC_EX_H
mbed_official 610:813dcc80987e 41
mbed_official 610:813dcc80987e 42 #ifdef __cplusplus
mbed_official 610:813dcc80987e 43 extern "C" {
mbed_official 610:813dcc80987e 44 #endif
mbed_official 610:813dcc80987e 45
mbed_official 610:813dcc80987e 46 /* Includes ------------------------------------------------------------------*/
mbed_official 610:813dcc80987e 47 #include "stm32l4xx_hal_def.h"
mbed_official 610:813dcc80987e 48
mbed_official 610:813dcc80987e 49 /** @addtogroup STM32L4xx_HAL_Driver
mbed_official 610:813dcc80987e 50 * @{
mbed_official 610:813dcc80987e 51 */
mbed_official 610:813dcc80987e 52
mbed_official 610:813dcc80987e 53 /** @addtogroup ADCEx ADCEx
mbed_official 610:813dcc80987e 54 * @{
mbed_official 610:813dcc80987e 55 */
mbed_official 610:813dcc80987e 56
mbed_official 610:813dcc80987e 57 /* Exported types ------------------------------------------------------------*/
mbed_official 610:813dcc80987e 58 /** @defgroup ADCEx_Exported_Types ADC Extended Exported Types
mbed_official 610:813dcc80987e 59 * @{
mbed_official 610:813dcc80987e 60 */
mbed_official 610:813dcc80987e 61
mbed_official 610:813dcc80987e 62 /**
mbed_official 610:813dcc80987e 63 * @brief ADC Injected Conversion Oversampling structure definition
mbed_official 610:813dcc80987e 64 */
mbed_official 610:813dcc80987e 65 typedef struct
mbed_official 610:813dcc80987e 66 {
mbed_official 610:813dcc80987e 67 uint32_t Ratio; /*!< Configures the oversampling ratio.
mbed_official 610:813dcc80987e 68 This parameter can be a value of @ref ADCEx_Oversampling_Ratio */
mbed_official 610:813dcc80987e 69
mbed_official 610:813dcc80987e 70 uint32_t RightBitShift; /*!< Configures the division coefficient for the Oversampler.
mbed_official 610:813dcc80987e 71 This parameter can be a value of @ref ADCEx_Right_Bit_Shift */
mbed_official 610:813dcc80987e 72 }ADC_InjOversamplingTypeDef;
mbed_official 610:813dcc80987e 73
mbed_official 610:813dcc80987e 74
mbed_official 610:813dcc80987e 75
mbed_official 610:813dcc80987e 76 /**
mbed_official 610:813dcc80987e 77 * @brief Structure definition of ADC injected group and ADC channel for injected group
mbed_official 610:813dcc80987e 78 * @note Parameters of this structure are shared within 2 scopes:
mbed_official 610:813dcc80987e 79 * - Scope channel: InjectedChannel, InjectedRank, InjectedSamplingTime , InjectedSingleDiff, InjectedOffsetNumber, InjectedOffset
mbed_official 610:813dcc80987e 80 * - Scope injected group (affects all channels of injected group): InjectedNbrOfConversion, InjectedDiscontinuousConvMode,
mbed_official 610:813dcc80987e 81 * AutoInjectedConv, QueueInjectedContext, ExternalTrigInjecConvEdge, ExternalTrigInjecConv, InjecOversamplingMode, InjecOversampling.
mbed_official 610:813dcc80987e 82 * @note The setting of these parameters by function HAL_ADCEx_InjectedConfigChannel() is conditioned by ADC state.
mbed_official 610:813dcc80987e 83 * ADC state can be either:
mbed_official 610:813dcc80987e 84 * - For all parameters: ADC disabled (this is the only possible ADC state to modify parameter 'InjectedSingleDiff')
mbed_official 610:813dcc80987e 85 * - For parameters 'InjectedDiscontinuousConvMode', 'QueueInjectedContext', 'InjecOversampling': ADC enabled without conversion on going on injected group.
mbed_official 610:813dcc80987e 86 * - For parameters 'InjectedSamplingTime', 'InjectedOffset', 'InjectedOffsetNumber', 'AutoInjectedConv': ADC enabled without conversion on going on regular and injected groups.
mbed_official 610:813dcc80987e 87 * - For parameters 'InjectedChannel', 'InjectedRank', 'InjectedNbrOfConversion', 'ExternalTrigInjecConv', 'ExternalTrigInjecConvEdge': ADC enabled and while conversion on going
mbed_official 610:813dcc80987e 88 * on regular and injected groups.
mbed_official 610:813dcc80987e 89 * If ADC is not in the appropriate state to modify some parameters, these parameters setting is bypassed
mbed_official 610:813dcc80987e 90 * without error reporting (as it can be the expected behaviour in case of intended action to update another parameter (which fulfills the ADC state condition) on the fly).
mbed_official 610:813dcc80987e 91 */
mbed_official 610:813dcc80987e 92 typedef struct
mbed_official 610:813dcc80987e 93 {
mbed_official 610:813dcc80987e 94 uint32_t InjectedChannel; /*!< Configure the ADC injected channel.
mbed_official 610:813dcc80987e 95 This parameter can be a value of @ref ADC_channels
mbed_official 610:813dcc80987e 96 Note: Depending on devices and ADC instances, some channels may not be available. Refer to device DataSheet for channels availability. */
mbed_official 610:813dcc80987e 97 uint32_t InjectedRank; /*!< The rank in the injected group sequencer.
mbed_official 610:813dcc80987e 98 This parameter must be a value of @ref ADCEx_injected_rank.
mbed_official 610:813dcc80987e 99 Note: to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by
mbed_official 610:813dcc80987e 100 the new channel setting (or parameter number of conversions adjusted). */
mbed_official 610:813dcc80987e 101 uint32_t InjectedSamplingTime; /*!< Sampling time value to be set for the selected channel.
mbed_official 610:813dcc80987e 102 Unit: ADC clock cycles.
mbed_official 610:813dcc80987e 103 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,
mbed_official 610:813dcc80987e 104 8.5 cycles at 8 bits, 6.5 cycles at 6 bits).
mbed_official 610:813dcc80987e 105 This parameter can be a value of @ref ADC_sampling_times.
mbed_official 610:813dcc80987e 106 Caution: This parameter applies to a channel that can be used in a regular and/or injected group.
mbed_official 610:813dcc80987e 107 It overwrites the last setting.
mbed_official 610:813dcc80987e 108 Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor),
mbed_official 610:813dcc80987e 109 sampling time constraints must be respected (sampling time can be adjusted with respect to the ADC clock frequency and sampling time
mbed_official 610:813dcc80987e 110 setting). Refer to device DataSheet for timings values. */
mbed_official 610:813dcc80987e 111 uint32_t InjectedSingleDiff; /*!< Selection of single-ended or differential input.
mbed_official 610:813dcc80987e 112 In differential mode: Differential measurement is between the selected channel 'i' (positive input) and channel 'i+1' (negative input).
mbed_official 610:813dcc80987e 113 Only channel 'i' has to be configured, channel 'i+1' is configured automatically.
mbed_official 610:813dcc80987e 114 This parameter must be a value of @ref ADCEx_SingleDifferential.
mbed_official 610:813dcc80987e 115 Caution: This parameter applies to a channel that can be used in a regular and/or injected group.
mbed_official 610:813dcc80987e 116 It overwrites the last setting.
mbed_official 610:813dcc80987e 117 Note: Refer to Reference Manual to ensure the selected channel is available in differential mode.
mbed_official 610:813dcc80987e 118 Note: When configuring a channel 'i' in differential mode, the channel 'i+1' is not usable separately.
mbed_official 610:813dcc80987e 119 Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion).
mbed_official 610:813dcc80987e 120 If ADC is enabled, this parameter setting is bypassed without error reporting (as it can be the expected behaviour in case
mbed_official 610:813dcc80987e 121 of another parameter update on the fly) */
mbed_official 610:813dcc80987e 122 uint32_t InjectedOffsetNumber; /*!< Selects the offset number.
mbed_official 610:813dcc80987e 123 This parameter can be a value of @ref ADCEx_OffsetNumber.
mbed_official 610:813dcc80987e 124 Caution: Only one offset is allowed per channel. This parameter overwrites the last setting. */
mbed_official 610:813dcc80987e 125 uint32_t InjectedOffset; /*!< Defines the offset to be subtracted from the raw converted data.
mbed_official 610:813dcc80987e 126 Offset value must be a positive number.
mbed_official 610:813dcc80987e 127 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,
mbed_official 610:813dcc80987e 128 0x3FF, 0xFF or 0x3F respectively.
mbed_official 610:813dcc80987e 129 Note: This parameter must be modified when no conversion is on going on both regular and injected groups (ADC disabled, or ADC enabled
mbed_official 610:813dcc80987e 130 without continuous mode or external trigger that could launch a conversion). */
mbed_official 610:813dcc80987e 131 uint32_t InjectedNbrOfConversion; /*!< Specifies the number of ranks that will be converted within the injected group sequencer.
mbed_official 610:813dcc80987e 132 To use the injected group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
mbed_official 610:813dcc80987e 133 This parameter must be a number between Min_Data = 1 and Max_Data = 4.
mbed_official 610:813dcc80987e 134 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
mbed_official 610:813dcc80987e 135 configure a channel on injected group can impact the configuration of other channels previously set. */
mbed_official 610:813dcc80987e 136 uint32_t InjectedDiscontinuousConvMode; /*!< Specifies whether the conversions sequence of injected group is performed in Complete-sequence/Discontinuous-sequence (main sequence
mbed_official 610:813dcc80987e 137 subdivided in successive parts).
mbed_official 610:813dcc80987e 138 Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
mbed_official 610:813dcc80987e 139 Discontinuous mode can be enabled only if continuous mode is disabled.
mbed_official 610:813dcc80987e 140 This parameter can be set to ENABLE or DISABLE.
mbed_official 610:813dcc80987e 141 Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion).
mbed_official 610:813dcc80987e 142 Note: For injected group, discontinuous mode converts the sequence channel by channel (only one channel at a time).
mbed_official 610:813dcc80987e 143 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
mbed_official 610:813dcc80987e 144 configure a channel on injected group can impact the configuration of other channels previously set. */
mbed_official 610:813dcc80987e 145 uint32_t AutoInjectedConv; /*!< Enables or disables the selected ADC automatic injected group conversion after regular one
mbed_official 610:813dcc80987e 146 This parameter can be set to ENABLE or DISABLE.
mbed_official 610:813dcc80987e 147 Note: To use Automatic injected conversion, discontinuous mode must be disabled ('DiscontinuousConvMode' and 'InjectedDiscontinuousConvMode' set to DISABLE)
mbed_official 610:813dcc80987e 148 Note: To use Automatic injected conversion, injected group external triggers must be disabled.
mbed_official 610:813dcc80987e 149 Note: In case of DMA used with regular group: if DMA configured in normal mode (single shot) JAUTO will be stopped upon DMA transfer complete.
mbed_official 610:813dcc80987e 150 To maintain JAUTO always enabled, DMA must be configured in circular mode.
mbed_official 610:813dcc80987e 151 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
mbed_official 610:813dcc80987e 152 configure a channel on injected group can impact the configuration of other channels previously set. */
mbed_official 610:813dcc80987e 153 uint32_t QueueInjectedContext; /*!< Specifies whether the context queue feature is enabled.
mbed_official 610:813dcc80987e 154 This parameter can be set to ENABLE or DISABLE.
mbed_official 610:813dcc80987e 155 If context queue is enabled, injected sequencer&channels configurations are queued on up to 2 contexts. If a
mbed_official 610:813dcc80987e 156 new injected context is set when queue is full, error is triggered by interruption and through function
mbed_official 610:813dcc80987e 157 'HAL_ADCEx_InjectedQueueOverflowCallback'.
mbed_official 610:813dcc80987e 158 Caution: This feature request that the sequence is fully configured before injected conversion start.
mbed_official 610:813dcc80987e 159 Therefore, configure channels with as many calls to HAL_ADCEx_InjectedConfigChannel() as the 'InjectedNbrOfConversion' parameter.
mbed_official 610:813dcc80987e 160 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
mbed_official 610:813dcc80987e 161 configure a channel on injected group can impact the configuration of other channels previously set.
mbed_official 610:813dcc80987e 162 Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion). */
mbed_official 610:813dcc80987e 163 uint32_t ExternalTrigInjecConv; /*!< Selects the external event used to trigger the conversion start of injected group.
mbed_official 610:813dcc80987e 164 If set to ADC_INJECTED_SOFTWARE_START, external triggers are disabled and software trigger is used instead.
mbed_official 610:813dcc80987e 165 This parameter can be a value of @ref ADCEx_Injected_External_Trigger_Source.
mbed_official 610:813dcc80987e 166 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
mbed_official 610:813dcc80987e 167 configure a channel on injected group can impact the configuration of other channels previously set. */
mbed_official 610:813dcc80987e 168 uint32_t ExternalTrigInjecConvEdge; /*!< Selects the external trigger edge of injected group.
mbed_official 610:813dcc80987e 169 This parameter can be a value of @ref ADCEx_Injected_External_Trigger_Source_Edge.
mbed_official 610:813dcc80987e 170 If trigger edge is set to ADC_EXTERNALTRIGINJECCONV_EDGE_NONE, external triggers are disabled and software trigger is used instead.
mbed_official 610:813dcc80987e 171 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
mbed_official 610:813dcc80987e 172 configure a channel on injected group can impact the configuration of other channels previously set. */
mbed_official 610:813dcc80987e 173
mbed_official 610:813dcc80987e 174 uint32_t InjecOversamplingMode; /*!< Specifies whether the oversampling feature is enabled or disabled.
mbed_official 610:813dcc80987e 175 This parameter can be set to ENABLE or DISABLE.
mbed_official 610:813dcc80987e 176 Note: This parameter can be modified only if there is no conversion is ongoing (both ADSTART and JADSTART cleared). */
mbed_official 610:813dcc80987e 177
mbed_official 610:813dcc80987e 178 ADC_InjOversamplingTypeDef InjecOversampling; /*!< Specifies the Oversampling parameters.
mbed_official 610:813dcc80987e 179 Caution: this setting overwrites the previous oversampling configuration if oversampling already enabled.
mbed_official 610:813dcc80987e 180 Note: This parameter can be modified only if there is no conversion is ongoing (both ADSTART and JADSTART cleared). */
mbed_official 610:813dcc80987e 181 }ADC_InjectionConfTypeDef;
mbed_official 610:813dcc80987e 182
mbed_official 610:813dcc80987e 183
mbed_official 610:813dcc80987e 184 /**
mbed_official 610:813dcc80987e 185 * @brief Structure definition of ADC multimode
mbed_official 610:813dcc80987e 186 * @note The setting of these parameters by function HAL_ADCEx_MultiModeConfigChannel() is conditioned by ADCs state (both Master and Slave ADCs).
mbed_official 610:813dcc80987e 187 * Both Master and Slave ADCs must be disabled.
mbed_official 610:813dcc80987e 188 */
mbed_official 610:813dcc80987e 189 typedef struct
mbed_official 610:813dcc80987e 190 {
mbed_official 610:813dcc80987e 191 uint32_t Mode; /*!< Configures the ADC to operate in independent or multimode.
mbed_official 610:813dcc80987e 192 This parameter can be a value of @ref ADCEx_Common_mode. */
mbed_official 610:813dcc80987e 193 uint32_t DMAAccessMode; /*!< Configures the DMA mode for multimode ADC:
mbed_official 610:813dcc80987e 194 selection whether 2 DMA channels (each ADC uses its own DMA channel) or 1 DMA channel (one DMA channel for both ADC, DMA of ADC master)
mbed_official 610:813dcc80987e 195 This parameter can be a value of @ref ADCEx_Direct_memory_access_mode_for_multimode. */
mbed_official 610:813dcc80987e 196 uint32_t TwoSamplingDelay; /*!< Configures the Delay between 2 sampling phases.
mbed_official 610:813dcc80987e 197 This parameter can be a value of @ref ADCEx_delay_between_2_sampling_phases.
mbed_official 610:813dcc80987e 198 Delay range depends on selected resolution:
mbed_official 610:813dcc80987e 199 from 1 to 12 clock cycles for 12 bits, from 1 to 10 clock cycles for 10 bits,
mbed_official 610:813dcc80987e 200 from 1 to 8 clock cycles for 8 bits, from 1 to 6 clock cycles for 6 bits. */
mbed_official 610:813dcc80987e 201 }ADC_MultiModeTypeDef;
mbed_official 610:813dcc80987e 202
mbed_official 610:813dcc80987e 203 /**
mbed_official 610:813dcc80987e 204 * @}
mbed_official 610:813dcc80987e 205 */
mbed_official 610:813dcc80987e 206
mbed_official 610:813dcc80987e 207 /* Exported constants --------------------------------------------------------*/
mbed_official 610:813dcc80987e 208
mbed_official 610:813dcc80987e 209 /** @defgroup ADCEx_Exported_Constants ADC Extended Exported Constants
mbed_official 610:813dcc80987e 210 * @{
mbed_official 610:813dcc80987e 211 */
mbed_official 610:813dcc80987e 212
mbed_official 610:813dcc80987e 213 /** @defgroup ADCEx_SingleDifferential ADC Extended Single-ended/Differential input mode
mbed_official 610:813dcc80987e 214 * @{
mbed_official 610:813dcc80987e 215 */
mbed_official 610:813dcc80987e 216 #define ADC_SINGLE_ENDED ((uint32_t)0x00000000) /*!< ADC channel set in single-ended input mode */
mbed_official 610:813dcc80987e 217 #define ADC_DIFFERENTIAL_ENDED ((uint32_t)ADC_CR_ADCALDIF) /*!< ADC channel set in differential mode */
mbed_official 610:813dcc80987e 218 /**
mbed_official 610:813dcc80987e 219 * @}
mbed_official 610:813dcc80987e 220 */
mbed_official 610:813dcc80987e 221
mbed_official 610:813dcc80987e 222 /** @defgroup ADCEx_OffsetNumber ADC Extended Offset Number
mbed_official 610:813dcc80987e 223 * @{
mbed_official 610:813dcc80987e 224 */
mbed_official 610:813dcc80987e 225 #define ADC_OFFSET_NONE ((uint32_t)0x00) /*!< No offset correction */
mbed_official 610:813dcc80987e 226 #define ADC_OFFSET_1 ((uint32_t)0x01) /*!< Offset correction to apply to a first channel */
mbed_official 610:813dcc80987e 227 #define ADC_OFFSET_2 ((uint32_t)0x02) /*!< Offset correction to apply to a second channel */
mbed_official 610:813dcc80987e 228 #define ADC_OFFSET_3 ((uint32_t)0x03) /*!< Offset correction to apply to a third channel */
mbed_official 610:813dcc80987e 229 #define ADC_OFFSET_4 ((uint32_t)0x04) /*!< Offset correction to apply to a fourth channel */
mbed_official 610:813dcc80987e 230 /**
mbed_official 610:813dcc80987e 231 * @}
mbed_official 610:813dcc80987e 232 */
mbed_official 610:813dcc80987e 233
mbed_official 610:813dcc80987e 234 /** @defgroup ADCEx_regular_rank ADC Extended Regular Channel Rank
mbed_official 610:813dcc80987e 235 * @{
mbed_official 610:813dcc80987e 236 */
mbed_official 610:813dcc80987e 237 #define ADC_REGULAR_RANK_1 ((uint32_t)0x00000001) /*!< ADC regular conversion rank 1 */
mbed_official 610:813dcc80987e 238 #define ADC_REGULAR_RANK_2 ((uint32_t)0x00000002) /*!< ADC regular conversion rank 2 */
mbed_official 610:813dcc80987e 239 #define ADC_REGULAR_RANK_3 ((uint32_t)0x00000003) /*!< ADC regular conversion rank 3 */
mbed_official 610:813dcc80987e 240 #define ADC_REGULAR_RANK_4 ((uint32_t)0x00000004) /*!< ADC regular conversion rank 4 */
mbed_official 610:813dcc80987e 241 #define ADC_REGULAR_RANK_5 ((uint32_t)0x00000005) /*!< ADC regular conversion rank 5 */
mbed_official 610:813dcc80987e 242 #define ADC_REGULAR_RANK_6 ((uint32_t)0x00000006) /*!< ADC regular conversion rank 6 */
mbed_official 610:813dcc80987e 243 #define ADC_REGULAR_RANK_7 ((uint32_t)0x00000007) /*!< ADC regular conversion rank 7 */
mbed_official 610:813dcc80987e 244 #define ADC_REGULAR_RANK_8 ((uint32_t)0x00000008) /*!< ADC regular conversion rank 8 */
mbed_official 610:813dcc80987e 245 #define ADC_REGULAR_RANK_9 ((uint32_t)0x00000009) /*!< ADC regular conversion rank 9 */
mbed_official 610:813dcc80987e 246 #define ADC_REGULAR_RANK_10 ((uint32_t)0x0000000A) /*!< ADC regular conversion rank 10 */
mbed_official 610:813dcc80987e 247 #define ADC_REGULAR_RANK_11 ((uint32_t)0x0000000B) /*!< ADC regular conversion rank 11 */
mbed_official 610:813dcc80987e 248 #define ADC_REGULAR_RANK_12 ((uint32_t)0x0000000C) /*!< ADC regular conversion rank 12 */
mbed_official 610:813dcc80987e 249 #define ADC_REGULAR_RANK_13 ((uint32_t)0x0000000D) /*!< ADC regular conversion rank 13 */
mbed_official 610:813dcc80987e 250 #define ADC_REGULAR_RANK_14 ((uint32_t)0x0000000E) /*!< ADC regular conversion rank 14 */
mbed_official 610:813dcc80987e 251 #define ADC_REGULAR_RANK_15 ((uint32_t)0x0000000F) /*!< ADC regular conversion rank 15 */
mbed_official 610:813dcc80987e 252 #define ADC_REGULAR_RANK_16 ((uint32_t)0x00000010) /*!< ADC regular conversion rank 16 */
mbed_official 610:813dcc80987e 253 /**
mbed_official 610:813dcc80987e 254 * @}
mbed_official 610:813dcc80987e 255 */
mbed_official 610:813dcc80987e 256
mbed_official 610:813dcc80987e 257 /** @defgroup ADCEx_injected_rank ADC Extended Injected Channel Rank
mbed_official 610:813dcc80987e 258 * @{
mbed_official 610:813dcc80987e 259 */
mbed_official 610:813dcc80987e 260 #define ADC_INJECTED_RANK_1 ((uint32_t)0x00000001) /*!< ADC injected conversion rank 1 */
mbed_official 610:813dcc80987e 261 #define ADC_INJECTED_RANK_2 ((uint32_t)0x00000002) /*!< ADC injected conversion rank 2 */
mbed_official 610:813dcc80987e 262 #define ADC_INJECTED_RANK_3 ((uint32_t)0x00000003) /*!< ADC injected conversion rank 3 */
mbed_official 610:813dcc80987e 263 #define ADC_INJECTED_RANK_4 ((uint32_t)0x00000004) /*!< ADC injected conversion rank 4 */
mbed_official 610:813dcc80987e 264 /**injected
mbed_official 610:813dcc80987e 265 * @}
mbed_official 610:813dcc80987e 266 */
mbed_official 610:813dcc80987e 267
mbed_official 610:813dcc80987e 268 /** @defgroup ADCEx_Injected_External_Trigger_Source_Edge ADC External Trigger Source Edge for Injected Group
mbed_official 610:813dcc80987e 269 * @{
mbed_official 610:813dcc80987e 270 */
mbed_official 610:813dcc80987e 271 #define ADC_EXTERNALTRIGINJECCONV_EDGE_NONE ((uint32_t)0x00000000) /*!< Injected conversions hardware trigger detection disabled */
mbed_official 610:813dcc80987e 272 #define ADC_EXTERNALTRIGINJECCONV_EDGE_RISING ((uint32_t)ADC_JSQR_JEXTEN_0) /*!< Injected conversions hardware trigger detection on the rising edge */
mbed_official 610:813dcc80987e 273 #define ADC_EXTERNALTRIGINJECCONV_EDGE_FALLING ((uint32_t)ADC_JSQR_JEXTEN_1) /*!< Injected conversions hardware trigger detection on the falling edge */
mbed_official 610:813dcc80987e 274 #define ADC_EXTERNALTRIGINJECCONV_EDGE_RISINGFALLING ((uint32_t)ADC_JSQR_JEXTEN) /*!< Injected conversions hardware trigger detection on both the rising and falling edges */
mbed_official 610:813dcc80987e 275 /**
mbed_official 610:813dcc80987e 276 * @}
mbed_official 610:813dcc80987e 277 */
mbed_official 610:813dcc80987e 278
mbed_official 610:813dcc80987e 279 /** @defgroup ADCEx_Injected_External_Trigger_Source ADC Extended External Trigger Source for Injected Group
mbed_official 610:813dcc80987e 280 * @{
mbed_official 610:813dcc80987e 281 */
mbed_official 610:813dcc80987e 282 #define ADC_EXTERNALTRIGINJEC_T1_TRGO ((uint32_t)0x00000000) /*!< Event 0 triggers injected group conversion start */
mbed_official 610:813dcc80987e 283 #define ADC_EXTERNALTRIGINJEC_T1_CC4 ((uint32_t)ADC_JSQR_JEXTSEL_0) /*!< Event 1 triggers injected group conversion start */
mbed_official 610:813dcc80987e 284 #define ADC_EXTERNALTRIGINJEC_T2_TRGO ((uint32_t)ADC_JSQR_JEXTSEL_1) /*!< Event 2 triggers injected group conversion start */
mbed_official 610:813dcc80987e 285 #define ADC_EXTERNALTRIGINJEC_T2_CC1 ((uint32_t)(ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0)) /*!< Event 3 triggers injected group conversion start */
mbed_official 610:813dcc80987e 286 #define ADC_EXTERNALTRIGINJEC_T3_CC4 ((uint32_t)ADC_JSQR_JEXTSEL_2) /*!< Event 4 triggers injected group conversion start */
mbed_official 610:813dcc80987e 287 #define ADC_EXTERNALTRIGINJEC_T4_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0)) /*!< Event 5 triggers injected group conversion start */
mbed_official 610:813dcc80987e 288 #define ADC_EXTERNALTRIGINJEC_EXT_IT15 ((uint32_t)(ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1)) /*!< Event 6 triggers injected group conversion start */
mbed_official 610:813dcc80987e 289 #define ADC_EXTERNALTRIGINJEC_T8_CC4 ((uint32_t)(ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0)) /*!< Event 7 triggers injected group conversion start */
mbed_official 610:813dcc80987e 290 #define ADC_EXTERNALTRIGINJEC_T1_TRGO2 ((uint32_t)ADC_JSQR_JEXTSEL_3) /*!< Event 8 triggers injected group conversion start */
mbed_official 610:813dcc80987e 291 #define ADC_EXTERNALTRIGINJEC_T8_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_0)) /*!< Event 9 triggers injected group conversion start */
mbed_official 610:813dcc80987e 292 #define ADC_EXTERNALTRIGINJEC_T8_TRGO2 ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1)) /*!< Event 10 triggers injected group conversion start */
mbed_official 610:813dcc80987e 293 #define ADC_EXTERNALTRIGINJEC_T3_CC3 ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0)) /*!< Event 11 triggers injected group conversion start */
mbed_official 610:813dcc80987e 294 #define ADC_EXTERNALTRIGINJEC_T3_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2)) /*!< Event 12 triggers injected group conversion start */
mbed_official 610:813dcc80987e 295 #define ADC_EXTERNALTRIGINJEC_T3_CC1 ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0)) /*!< Event 13 triggers injected group conversion start */
mbed_official 610:813dcc80987e 296 #define ADC_EXTERNALTRIGINJEC_T6_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1)) /*!< Event 14 triggers injected group conversion start */
mbed_official 610:813dcc80987e 297 #define ADC_EXTERNALTRIGINJEC_T15_TRGO ((uint32_t)ADC_JSQR_JEXTSEL) /*!< Event 15 triggers injected group conversion start */
mbed_official 610:813dcc80987e 298
mbed_official 610:813dcc80987e 299 #define ADC_INJECTED_SOFTWARE_START ((uint32_t)0x00000001) /*!< Software triggers injected group conversion start */
mbed_official 610:813dcc80987e 300 /**
mbed_official 610:813dcc80987e 301 * @}
mbed_official 610:813dcc80987e 302 */
mbed_official 610:813dcc80987e 303
mbed_official 610:813dcc80987e 304 /** @defgroup ADCEx_Common_mode ADC Extended Dual ADC Mode
mbed_official 610:813dcc80987e 305 * @{
mbed_official 610:813dcc80987e 306 */
mbed_official 610:813dcc80987e 307 #define ADC_MODE_INDEPENDENT ((uint32_t)(0x00000000)) /*!< Independent ADC conversions mode */
mbed_official 610:813dcc80987e 308 #define ADC_DUALMODE_REGSIMULT_INJECSIMULT ((uint32_t)(ADC_CCR_DUAL_0)) /*!< Combined regular simultaneous + injected simultaneous mode */
mbed_official 610:813dcc80987e 309 #define ADC_DUALMODE_REGSIMULT_ALTERTRIG ((uint32_t)(ADC_CCR_DUAL_1)) /*!< Combined regular simultaneous + alternate trigger mode */
mbed_official 610:813dcc80987e 310 #define ADC_DUALMODE_REGINTERL_INJECSIMULT ((uint32_t)(ADC_CCR_DUAL_1 | ADC_CCR_DUAL_0)) /*!< Combined Interleaved mode + injected simultaneous mode */
mbed_official 610:813dcc80987e 311 #define ADC_DUALMODE_INJECSIMULT ((uint32_t)(ADC_CCR_DUAL_2 | ADC_CCR_DUAL_0)) /*!< Injected simultaneous mode only */
mbed_official 610:813dcc80987e 312 #define ADC_DUALMODE_REGSIMULT ((uint32_t)(ADC_CCR_DUAL_2 | ADC_CCR_DUAL_1)) /*!< Regular simultaneous mode only */
mbed_official 610:813dcc80987e 313 #define ADC_DUALMODE_INTERL ((uint32_t)(ADC_CCR_DUAL_2 | ADC_CCR_DUAL_1 | ADC_CCR_DUAL_0)) /*!< Interleaved mode only */
mbed_official 610:813dcc80987e 314 #define ADC_DUALMODE_ALTERTRIG ((uint32_t)(ADC_CCR_DUAL_3 | ADC_CCR_DUAL_0)) /*!< Alternate trigger mode only */
mbed_official 610:813dcc80987e 315 /**
mbed_official 610:813dcc80987e 316 * @}
mbed_official 610:813dcc80987e 317 */
mbed_official 610:813dcc80987e 318
mbed_official 610:813dcc80987e 319
mbed_official 610:813dcc80987e 320 /** @defgroup ADCEx_Direct_memory_access_mode_for_multimode ADC Extended DMA Mode for Dual ADC Mode
mbed_official 610:813dcc80987e 321 * @{
mbed_official 610:813dcc80987e 322 */
mbed_official 610:813dcc80987e 323 #define ADC_DMAACCESSMODE_DISABLED ((uint32_t)0x00000000) /*!< DMA multimode disabled: each ADC uses its own DMA channel */
mbed_official 610:813dcc80987e 324 #define ADC_DMAACCESSMODE_12_10_BITS ((uint32_t)ADC_CCR_MDMA_1) /*!< DMA multimode enabled (one DMA channel for both ADC, DMA of ADC master) for 12 and 10 bits resolution */
mbed_official 610:813dcc80987e 325 #define ADC_DMAACCESSMODE_8_6_BITS ((uint32_t)ADC_CCR_MDMA) /*!< DMA multimode enabled (one DMA channel for both ADC, DMA of ADC master) for 8 and 6 bits resolution */
mbed_official 610:813dcc80987e 326 /**
mbed_official 610:813dcc80987e 327 * @}
mbed_official 610:813dcc80987e 328 */
mbed_official 610:813dcc80987e 329
mbed_official 610:813dcc80987e 330 /** @defgroup ADCEx_delay_between_2_sampling_phases ADC Extended Delay Between 2 Sampling Phases
mbed_official 610:813dcc80987e 331 * @{
mbed_official 610:813dcc80987e 332 */
mbed_official 610:813dcc80987e 333 #define ADC_TWOSAMPLINGDELAY_1CYCLE ((uint32_t)(0x00000000)) /*!< 1 ADC clock cycle delay */
mbed_official 610:813dcc80987e 334 #define ADC_TWOSAMPLINGDELAY_2CYCLES ((uint32_t)(ADC_CCR_DELAY_0)) /*!< 2 ADC clock cycles delay */
mbed_official 610:813dcc80987e 335 #define ADC_TWOSAMPLINGDELAY_3CYCLES ((uint32_t)(ADC_CCR_DELAY_1)) /*!< 3 ADC clock cycles delay */
mbed_official 610:813dcc80987e 336 #define ADC_TWOSAMPLINGDELAY_4CYCLES ((uint32_t)(ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0)) /*!< 4 ADC clock cycles delay */
mbed_official 610:813dcc80987e 337 #define ADC_TWOSAMPLINGDELAY_5CYCLES ((uint32_t)(ADC_CCR_DELAY_2)) /*!< 5 ADC clock cycles delay */
mbed_official 610:813dcc80987e 338 #define ADC_TWOSAMPLINGDELAY_6CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0)) /*!< 6 ADC clock cycles delay */
mbed_official 610:813dcc80987e 339 #define ADC_TWOSAMPLINGDELAY_7CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1)) /*!< 7 ADC clock cycles delay (lower for non 12-bit resolution) */
mbed_official 610:813dcc80987e 340 #define ADC_TWOSAMPLINGDELAY_8CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0)) /*!< 8 ADC clock cycles delay (lower for non 12-bit resolution) */
mbed_official 610:813dcc80987e 341 #define ADC_TWOSAMPLINGDELAY_9CYCLES ((uint32_t)(ADC_CCR_DELAY_3)) /*!< 9 ADC clock cycles delay (lower for non 12-bit resolution) */
mbed_official 610:813dcc80987e 342 #define ADC_TWOSAMPLINGDELAY_10CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_0)) /*!< 10 ADC clock cycles delay (lower for non 12-bit resolution) */
mbed_official 610:813dcc80987e 343 #define ADC_TWOSAMPLINGDELAY_11CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1)) /*!< 11 ADC clock cycles delay (lower for non 12-bit resolution) */
mbed_official 610:813dcc80987e 344 #define ADC_TWOSAMPLINGDELAY_12CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0)) /*!< 12 ADC clock cycles delay (lower for non 12-bit resolution) */
mbed_official 610:813dcc80987e 345 /**
mbed_official 610:813dcc80987e 346 * @}
mbed_official 610:813dcc80987e 347 */
mbed_official 610:813dcc80987e 348
mbed_official 610:813dcc80987e 349 /** @defgroup ADCEx_analog_watchdog_number ADC Extended Analog Watchdog Selection
mbed_official 610:813dcc80987e 350 * @{
mbed_official 610:813dcc80987e 351 */
mbed_official 610:813dcc80987e 352 #define ADC_ANALOGWATCHDOG_1 ((uint32_t)0x00000001) /*!< Analog watchdog 1 selection */
mbed_official 610:813dcc80987e 353 #define ADC_ANALOGWATCHDOG_2 ((uint32_t)0x00000002) /*!< Analog watchdog 2 selection */
mbed_official 610:813dcc80987e 354 #define ADC_ANALOGWATCHDOG_3 ((uint32_t)0x00000003) /*!< Analog watchdog 3 selection */
mbed_official 610:813dcc80987e 355 /**
mbed_official 610:813dcc80987e 356 * @}
mbed_official 610:813dcc80987e 357 */
mbed_official 610:813dcc80987e 358
mbed_official 610:813dcc80987e 359 /** @defgroup ADCEx_analog_watchdog_mode ADC Extended Analog Watchdog Mode
mbed_official 610:813dcc80987e 360 * @{
mbed_official 610:813dcc80987e 361 */
mbed_official 610:813dcc80987e 362 #define ADC_ANALOGWATCHDOG_NONE ((uint32_t) 0x00000000) /*!< No analog watchdog selected */
mbed_official 610:813dcc80987e 363 #define ADC_ANALOGWATCHDOG_SINGLE_REG ((uint32_t)(ADC_CFGR_AWD1SGL | ADC_CFGR_AWD1EN)) /*!< Analog watchdog applied to a regular group single channel */
mbed_official 610:813dcc80987e 364 #define ADC_ANALOGWATCHDOG_SINGLE_INJEC ((uint32_t)(ADC_CFGR_AWD1SGL | ADC_CFGR_JAWD1EN)) /*!< Analog watchdog applied to an injected group single channel */
mbed_official 610:813dcc80987e 365 #define ADC_ANALOGWATCHDOG_SINGLE_REGINJEC ((uint32_t)(ADC_CFGR_AWD1SGL | ADC_CFGR_AWD1EN | ADC_CFGR_JAWD1EN)) /*!< Analog watchdog applied to a regular and injected groups single channel */
mbed_official 610:813dcc80987e 366 #define ADC_ANALOGWATCHDOG_ALL_REG ((uint32_t) ADC_CFGR_AWD1EN) /*!< Analog watchdog applied to regular group all channels */
mbed_official 610:813dcc80987e 367 #define ADC_ANALOGWATCHDOG_ALL_INJEC ((uint32_t) ADC_CFGR_JAWD1EN) /*!< Analog watchdog applied to injected group all channels */
mbed_official 610:813dcc80987e 368 #define ADC_ANALOGWATCHDOG_ALL_REGINJEC ((uint32_t)(ADC_CFGR_AWD1EN | ADC_CFGR_JAWD1EN)) /*!< Analog watchdog applied to regular and injected groups all channels */
mbed_official 610:813dcc80987e 369 /**
mbed_official 610:813dcc80987e 370 * @}
mbed_official 610:813dcc80987e 371 */
mbed_official 610:813dcc80987e 372
mbed_official 610:813dcc80987e 373 /** @defgroup ADCEx_conversion_group ADC Extended Conversion Group
mbed_official 610:813dcc80987e 374 * @{
mbed_official 610:813dcc80987e 375 */
mbed_official 610:813dcc80987e 376 #define ADC_REGULAR_GROUP ((uint32_t)(ADC_FLAG_EOC | ADC_FLAG_EOS)) /*!< ADC regular group selection */
mbed_official 610:813dcc80987e 377 #define ADC_INJECTED_GROUP ((uint32_t)(ADC_FLAG_JEOC | ADC_FLAG_JEOS)) /*!< ADC injected group selection */
mbed_official 610:813dcc80987e 378 #define ADC_REGULAR_INJECTED_GROUP ((uint32_t)(ADC_FLAG_EOC | ADC_FLAG_EOS | ADC_FLAG_JEOC | ADC_FLAG_JEOS)) /*!< ADC regular and injected groups selection */
mbed_official 610:813dcc80987e 379 /**
mbed_official 610:813dcc80987e 380 * @}
mbed_official 610:813dcc80987e 381 */
mbed_official 610:813dcc80987e 382
mbed_official 610:813dcc80987e 383 /** @defgroup ADCEx_Event_type ADC Extended Event Type
mbed_official 610:813dcc80987e 384 * @{
mbed_official 610:813dcc80987e 385 */
mbed_official 610:813dcc80987e 386 #define ADC_EOSMP_EVENT ((uint32_t)ADC_FLAG_EOSMP) /*!< ADC End of Sampling event */
mbed_official 610:813dcc80987e 387 #define ADC_AWD1_EVENT ((uint32_t)ADC_FLAG_AWD1) /*!< ADC Analog watchdog 1 event (main analog watchdog) */
mbed_official 610:813dcc80987e 388 #define ADC_AWD2_EVENT ((uint32_t)ADC_FLAG_AWD2) /*!< ADC Analog watchdog 2 event (additional analog watchdog) */
mbed_official 610:813dcc80987e 389 #define ADC_AWD3_EVENT ((uint32_t)ADC_FLAG_AWD3) /*!< ADC Analog watchdog 3 event (additional analog watchdog) */
mbed_official 610:813dcc80987e 390 #define ADC_OVR_EVENT ((uint32_t)ADC_FLAG_OVR) /*!< ADC overrun event */
mbed_official 610:813dcc80987e 391 #define ADC_JQOVF_EVENT ((uint32_t)ADC_FLAG_JQOVF) /*!< ADC Injected Context Queue Overflow event */
mbed_official 610:813dcc80987e 392
mbed_official 610:813dcc80987e 393 #define ADC_AWD_EVENT ADC_AWD1_EVENT /*!< ADC Analog watchdog 1 event: Naming for compatibility with other STM32 devices having only one analog watchdog */
mbed_official 610:813dcc80987e 394 /**
mbed_official 610:813dcc80987e 395 * @}
mbed_official 610:813dcc80987e 396 */
mbed_official 610:813dcc80987e 397
mbed_official 610:813dcc80987e 398 /** @defgroup ADCEx_interrupts_definition ADC Extended Interrupts Definition
mbed_official 610:813dcc80987e 399 * @{
mbed_official 610:813dcc80987e 400 */
mbed_official 610:813dcc80987e 401 #define ADC_IT_RDY ADC_IER_ADRDY /*!< ADC Ready (ADRDY) interrupt source */
mbed_official 610:813dcc80987e 402 #define ADC_IT_EOSMP ADC_IER_EOSMP /*!< ADC End of sampling interrupt source */
mbed_official 610:813dcc80987e 403 #define ADC_IT_EOC ADC_IER_EOC /*!< ADC End of regular conversion interrupt source */
mbed_official 610:813dcc80987e 404 #define ADC_IT_EOS ADC_IER_EOS /*!< ADC End of regular sequence of conversions interrupt source */
mbed_official 610:813dcc80987e 405 #define ADC_IT_OVR ADC_IER_OVR /*!< ADC overrun interrupt source */
mbed_official 610:813dcc80987e 406 #define ADC_IT_JEOC ADC_IER_JEOC /*!< ADC End of injected conversion interrupt source */
mbed_official 610:813dcc80987e 407 #define ADC_IT_JEOS ADC_IER_JEOS /*!< ADC End of injected sequence of conversions interrupt source */
mbed_official 610:813dcc80987e 408 #define ADC_IT_AWD1 ADC_IER_AWD1 /*!< ADC Analog watchdog 1 interrupt source (main analog watchdog) */
mbed_official 610:813dcc80987e 409 #define ADC_IT_AWD2 ADC_IER_AWD2 /*!< ADC Analog watchdog 2 interrupt source (additional analog watchdog) */
mbed_official 610:813dcc80987e 410 #define ADC_IT_AWD3 ADC_IER_AWD3 /*!< ADC Analog watchdog 3 interrupt source (additional analog watchdog) */
mbed_official 610:813dcc80987e 411 #define ADC_IT_JQOVF ADC_IER_JQOVF /*!< ADC Injected Context Queue Overflow interrupt source */
mbed_official 610:813dcc80987e 412
mbed_official 610:813dcc80987e 413 #define ADC_IT_AWD ADC_IT_AWD1 /*!< ADC Analog watchdog 1 interrupt source: naming for compatibility with other STM32 devices having only one analog watchdog */
mbed_official 610:813dcc80987e 414
mbed_official 610:813dcc80987e 415 /**
mbed_official 610:813dcc80987e 416 * @}
mbed_official 610:813dcc80987e 417 */
mbed_official 610:813dcc80987e 418
mbed_official 610:813dcc80987e 419 /** @defgroup ADCEx_flags_definition ADC Extended Flags Definition
mbed_official 610:813dcc80987e 420 * @{
mbed_official 610:813dcc80987e 421 */
mbed_official 610:813dcc80987e 422 #define ADC_FLAG_RDY ADC_ISR_ADRDY /*!< ADC Ready (ADRDY) flag */
mbed_official 610:813dcc80987e 423 #define ADC_FLAG_EOSMP ADC_ISR_EOSMP /*!< ADC End of Sampling flag */
mbed_official 610:813dcc80987e 424 #define ADC_FLAG_EOC ADC_ISR_EOC /*!< ADC End of Regular Conversion flag */
mbed_official 610:813dcc80987e 425 #define ADC_FLAG_EOS ADC_ISR_EOS /*!< ADC End of Regular sequence of Conversions flag */
mbed_official 610:813dcc80987e 426 #define ADC_FLAG_OVR ADC_ISR_OVR /*!< ADC overrun flag */
mbed_official 610:813dcc80987e 427 #define ADC_FLAG_JEOC ADC_ISR_JEOC /*!< ADC End of Injected Conversion flag */
mbed_official 610:813dcc80987e 428 #define ADC_FLAG_JEOS ADC_ISR_JEOS /*!< ADC End of Injected sequence of Conversions flag */
mbed_official 610:813dcc80987e 429 #define ADC_FLAG_AWD1 ADC_ISR_AWD1 /*!< ADC Analog watchdog 1 flag (main analog watchdog) */
mbed_official 610:813dcc80987e 430 #define ADC_FLAG_AWD2 ADC_ISR_AWD2 /*!< ADC Analog watchdog 2 flag (additional analog watchdog) */
mbed_official 610:813dcc80987e 431 #define ADC_FLAG_AWD3 ADC_ISR_AWD3 /*!< ADC Analog watchdog 3 flag (additional analog watchdog) */
mbed_official 610:813dcc80987e 432 #define ADC_FLAG_JQOVF ADC_ISR_JQOVF /*!< ADC Injected Context Queue Overflow flag */
mbed_official 610:813dcc80987e 433
mbed_official 610:813dcc80987e 434 #define ADC_FLAG_AWD ADC_FLAG_AWD1 /*!< ADC Analog watchdog 1 flag: Naming for compatibility with other STM32 devices having only one analog watchdog */
mbed_official 610:813dcc80987e 435
mbed_official 610:813dcc80987e 436 #define ADC_FLAG_ALL (ADC_FLAG_RDY | ADC_FLAG_EOSMP | ADC_FLAG_EOC | ADC_FLAG_EOS | \
mbed_official 610:813dcc80987e 437 ADC_FLAG_JEOC | ADC_FLAG_JEOS | ADC_FLAG_OVR | ADC_FLAG_AWD1 | \
mbed_official 610:813dcc80987e 438 ADC_FLAG_AWD2 | ADC_FLAG_AWD3 | ADC_FLAG_JQOVF) /*!< ADC all flags */
mbed_official 610:813dcc80987e 439
mbed_official 610:813dcc80987e 440 /* Combination of all post-conversion flags bits: EOC/EOS, JEOC/JEOS, OVR, AWDx, JQOVF */
mbed_official 610:813dcc80987e 441 #define ADC_FLAG_POSTCONV_ALL (ADC_FLAG_EOC | ADC_FLAG_EOS | ADC_FLAG_JEOC | ADC_FLAG_JEOS | \
mbed_official 610:813dcc80987e 442 ADC_FLAG_OVR | ADC_FLAG_AWD1 | ADC_FLAG_AWD2 | ADC_FLAG_AWD3 | \
mbed_official 610:813dcc80987e 443 ADC_FLAG_JQOVF) /*!< ADC post-conversion all flags */
mbed_official 610:813dcc80987e 444
mbed_official 610:813dcc80987e 445 /**
mbed_official 610:813dcc80987e 446 * @}
mbed_official 610:813dcc80987e 447 */
mbed_official 610:813dcc80987e 448
mbed_official 610:813dcc80987e 449
mbed_official 610:813dcc80987e 450 /** @defgroup ADCEx_injected_rank ADC Extended Injected Channel Rank
mbed_official 610:813dcc80987e 451 * @{
mbed_official 610:813dcc80987e 452 */
mbed_official 610:813dcc80987e 453 #define ADC_INJECTED_RANK_1 ((uint32_t)0x00000001) /*!< ADC injected conversion rank 1 */
mbed_official 610:813dcc80987e 454 #define ADC_INJECTED_RANK_2 ((uint32_t)0x00000002) /*!< ADC injected conversion rank 2 */
mbed_official 610:813dcc80987e 455 #define ADC_INJECTED_RANK_3 ((uint32_t)0x00000003) /*!< ADC injected conversion rank 3 */
mbed_official 610:813dcc80987e 456 #define ADC_INJECTED_RANK_4 ((uint32_t)0x00000004) /*!< ADC injected conversion rank 4 */
mbed_official 610:813dcc80987e 457 /**
mbed_official 610:813dcc80987e 458 * @}
mbed_official 610:813dcc80987e 459 */
mbed_official 610:813dcc80987e 460
mbed_official 610:813dcc80987e 461
mbed_official 610:813dcc80987e 462
mbed_official 610:813dcc80987e 463 /** @defgroup ADCEx_Oversampling_Ratio ADC Extended Oversampling Ratio
mbed_official 610:813dcc80987e 464 * @{
mbed_official 610:813dcc80987e 465 */
mbed_official 610:813dcc80987e 466
mbed_official 610:813dcc80987e 467 #define ADC_OVERSAMPLING_RATIO_2 ((uint32_t)0x00000000) /*!< ADC Oversampling ratio 2x */
mbed_official 610:813dcc80987e 468 #define ADC_OVERSAMPLING_RATIO_4 ((uint32_t)ADC_CFGR2_OVSR_0) /*!< ADC Oversampling ratio 4x */
mbed_official 610:813dcc80987e 469 #define ADC_OVERSAMPLING_RATIO_8 ((uint32_t)ADC_CFGR2_OVSR_1) /*!< ADC Oversampling ratio 8x */
mbed_official 610:813dcc80987e 470 #define ADC_OVERSAMPLING_RATIO_16 ((uint32_t)(ADC_CFGR2_OVSR_1 | ADC_CFGR2_OVSR_0)) /*!< ADC Oversampling ratio 16x */
mbed_official 610:813dcc80987e 471 #define ADC_OVERSAMPLING_RATIO_32 ((uint32_t)ADC_CFGR2_OVSR_2) /*!< ADC Oversampling ratio 32x */
mbed_official 610:813dcc80987e 472 #define ADC_OVERSAMPLING_RATIO_64 ((uint32_t)(ADC_CFGR2_OVSR_2 | ADC_CFGR2_OVSR_0)) /*!< ADC Oversampling ratio 64x */
mbed_official 610:813dcc80987e 473 #define ADC_OVERSAMPLING_RATIO_128 ((uint32_t)(ADC_CFGR2_OVSR_2 | ADC_CFGR2_OVSR_1)) /*!< ADC Oversampling ratio 128x */
mbed_official 610:813dcc80987e 474 #define ADC_OVERSAMPLING_RATIO_256 ((uint32_t)(ADC_CFGR2_OVSR)) /*!< ADC Oversampling ratio 256x */
mbed_official 610:813dcc80987e 475 /**
mbed_official 610:813dcc80987e 476 * @}
mbed_official 610:813dcc80987e 477 */
mbed_official 610:813dcc80987e 478
mbed_official 610:813dcc80987e 479 /** @defgroup ADCEx_Right_Bit_Shift ADC Extended Oversampling Right Shift
mbed_official 610:813dcc80987e 480 * @{
mbed_official 610:813dcc80987e 481 */
mbed_official 610:813dcc80987e 482 #define ADC_RIGHTBITSHIFT_NONE ((uint32_t)0x00000000) /*!< ADC No bit shift for oversampling */
mbed_official 610:813dcc80987e 483 #define ADC_RIGHTBITSHIFT_1 ((uint32_t)ADC_CFGR2_OVSS_0) /*!< ADC 1 bit shift for oversampling */
mbed_official 610:813dcc80987e 484 #define ADC_RIGHTBITSHIFT_2 ((uint32_t)ADC_CFGR2_OVSS_1) /*!< ADC 2 bits shift for oversampling */
mbed_official 610:813dcc80987e 485 #define ADC_RIGHTBITSHIFT_3 ((uint32_t)(ADC_CFGR2_OVSS_1 | ADC_CFGR2_OVSS_0)) /*!< ADC 3 bits shift for oversampling */
mbed_official 610:813dcc80987e 486 #define ADC_RIGHTBITSHIFT_4 ((uint32_t)ADC_CFGR2_OVSS_2) /*!< ADC 4 bits shift for oversampling */
mbed_official 610:813dcc80987e 487 #define ADC_RIGHTBITSHIFT_5 ((uint32_t)(ADC_CFGR2_OVSS_2 | ADC_CFGR2_OVSS_0)) /*!< ADC 5 bits shift for oversampling */
mbed_official 610:813dcc80987e 488 #define ADC_RIGHTBITSHIFT_6 ((uint32_t)(ADC_CFGR2_OVSS_2 | ADC_CFGR2_OVSS_1)) /*!< ADC 6 bits shift for oversampling */
mbed_official 610:813dcc80987e 489 #define ADC_RIGHTBITSHIFT_7 ((uint32_t)(ADC_CFGR2_OVSS_2 | ADC_CFGR2_OVSS_1 | ADC_CFGR2_OVSS_0)) /*!< ADC 7 bits shift for oversampling */
mbed_official 610:813dcc80987e 490 #define ADC_RIGHTBITSHIFT_8 ((uint32_t)ADC_CFGR2_OVSS_3) /*!< ADC 8 bits shift for oversampling */
mbed_official 610:813dcc80987e 491 /**
mbed_official 610:813dcc80987e 492 * @}
mbed_official 610:813dcc80987e 493 */
mbed_official 610:813dcc80987e 494
mbed_official 610:813dcc80987e 495 /** @defgroup ADCEx_Triggered_Oversampling_Mode ADC Extended Triggered Regular Oversampling
mbed_official 610:813dcc80987e 496 * @{
mbed_official 610:813dcc80987e 497 */
mbed_official 610:813dcc80987e 498 #define ADC_TRIGGEREDMODE_SINGLE_TRIGGER ((uint32_t)0x00000000) /*!< A single trigger for all channel oversampled conversions */
mbed_official 610:813dcc80987e 499 #define ADC_TRIGGEREDMODE_MULTI_TRIGGER ((uint32_t)ADC_CFGR2_TROVS) /*!< A trigger for each oversampled conversion */
mbed_official 610:813dcc80987e 500 /**
mbed_official 610:813dcc80987e 501 * @}
mbed_official 610:813dcc80987e 502 */
mbed_official 610:813dcc80987e 503
mbed_official 610:813dcc80987e 504 /** @defgroup ADCEx_Regular_Oversampling_Mode ADC Extended Regular Oversampling Continued or Resumed Mode
mbed_official 610:813dcc80987e 505 * @{
mbed_official 610:813dcc80987e 506 */
mbed_official 610:813dcc80987e 507 #define ADC_REGOVERSAMPLING_CONTINUED_MODE ((uint32_t)0x00000000) /*!< Oversampling buffer maintained during injection sequence */
mbed_official 610:813dcc80987e 508 #define ADC_REGOVERSAMPLING_RESUMED_MODE ((uint32_t)ADC_CFGR2_ROVSM) /*!< Oversampling buffer zeroed during injection sequence */
mbed_official 610:813dcc80987e 509 /**
mbed_official 610:813dcc80987e 510 * @}
mbed_official 610:813dcc80987e 511 */
mbed_official 610:813dcc80987e 512
mbed_official 610:813dcc80987e 513 /**
mbed_official 610:813dcc80987e 514 * @}
mbed_official 610:813dcc80987e 515 */
mbed_official 610:813dcc80987e 516
mbed_official 610:813dcc80987e 517
mbed_official 610:813dcc80987e 518
mbed_official 610:813dcc80987e 519 /* Private macros -----------------------------------------------------------*/
mbed_official 610:813dcc80987e 520
mbed_official 610:813dcc80987e 521 /** @defgroup ADCEx_Private_Macro_internal_HAL_driver ADC Extended Private Macros
mbed_official 610:813dcc80987e 522 * @{
mbed_official 610:813dcc80987e 523 */
mbed_official 610:813dcc80987e 524
mbed_official 610:813dcc80987e 525 /**
mbed_official 610:813dcc80987e 526 * @brief Test if conversion trigger of injected group is software start
mbed_official 610:813dcc80987e 527 * or external trigger.
mbed_official 610:813dcc80987e 528 * @param __HANDLE__: ADC handle.
mbed_official 610:813dcc80987e 529 * @retval SET (software start) or RESET (external trigger).
mbed_official 610:813dcc80987e 530 */
mbed_official 610:813dcc80987e 531 #define ADC_IS_SOFTWARE_START_INJECTED(__HANDLE__) \
mbed_official 610:813dcc80987e 532 (((__HANDLE__)->Instance->JSQR & ADC_JSQR_JEXTEN) == RESET)
mbed_official 610:813dcc80987e 533
mbed_official 610:813dcc80987e 534 /**
mbed_official 610:813dcc80987e 535 * @brief Check if conversion is on going on regular or injected groups.
mbed_official 610:813dcc80987e 536 * @param __HANDLE__: ADC handle.
mbed_official 610:813dcc80987e 537 * @retval SET (conversion is on going) or RESET (no conversion is on going).
mbed_official 610:813dcc80987e 538 */
mbed_official 610:813dcc80987e 539 #define ADC_IS_CONVERSION_ONGOING_REGULAR_INJECTED(__HANDLE__) \
mbed_official 610:813dcc80987e 540 (( (((__HANDLE__)->Instance->CR) & (ADC_CR_ADSTART | ADC_CR_JADSTART)) == RESET \
mbed_official 610:813dcc80987e 541 ) ? RESET : SET)
mbed_official 610:813dcc80987e 542
mbed_official 610:813dcc80987e 543
mbed_official 610:813dcc80987e 544 /**
mbed_official 610:813dcc80987e 545 * @brief Check if conversion is on going on injected group.
mbed_official 610:813dcc80987e 546 * @param __HANDLE__: ADC handle.
mbed_official 610:813dcc80987e 547 * @retval SET (conversion is on going) or RESET (no conversion is on going).
mbed_official 610:813dcc80987e 548 */
mbed_official 610:813dcc80987e 549 #define ADC_IS_CONVERSION_ONGOING_INJECTED(__HANDLE__) \
mbed_official 610:813dcc80987e 550 (( (((__HANDLE__)->Instance->CR) & ADC_CR_JADSTART) == RESET \
mbed_official 610:813dcc80987e 551 ) ? RESET : SET)
mbed_official 610:813dcc80987e 552
mbed_official 610:813dcc80987e 553
mbed_official 610:813dcc80987e 554 /**
mbed_official 610:813dcc80987e 555 * @brief Check whether or not ADC is independent.
mbed_official 610:813dcc80987e 556 * @param __HANDLE__: ADC handle.
mbed_official 610:813dcc80987e 557 * @retval SET (ADC is independent) or RESET (ADC is not).
mbed_official 610:813dcc80987e 558 */
mbed_official 610:813dcc80987e 559 #define ADC_IS_INDEPENDENT(__HANDLE__) \
mbed_official 610:813dcc80987e 560 ( ( ( ((__HANDLE__)->Instance) == ADC3) \
mbed_official 610:813dcc80987e 561 )? \
mbed_official 610:813dcc80987e 562 SET \
mbed_official 610:813dcc80987e 563 : \
mbed_official 610:813dcc80987e 564 RESET \
mbed_official 610:813dcc80987e 565 )
mbed_official 610:813dcc80987e 566
mbed_official 610:813dcc80987e 567
mbed_official 610:813dcc80987e 568
mbed_official 610:813dcc80987e 569 /**
mbed_official 610:813dcc80987e 570 * @brief Set the sample time for Channels numbers between 0 and 9.
mbed_official 610:813dcc80987e 571 * @param __SAMPLETIME__: Sample time parameter.
mbed_official 610:813dcc80987e 572 * @param __CHANNELNB__: Channel number.
mbed_official 610:813dcc80987e 573 * @retval None
mbed_official 610:813dcc80987e 574 */
mbed_official 610:813dcc80987e 575 #define ADC_SMPR1(__SAMPLETIME__, __CHANNELNB__) ((__SAMPLETIME__) << (POSITION_VAL(ADC_SMPR1_SMP1) * (__CHANNELNB__)))
mbed_official 610:813dcc80987e 576
mbed_official 610:813dcc80987e 577 /**
mbed_official 610:813dcc80987e 578 * @brief Set the sample time for Channels numbers between 10 and 18.
mbed_official 610:813dcc80987e 579 * @param __SAMPLETIME__: Sample time parameter.
mbed_official 610:813dcc80987e 580 * @param __CHANNELNB__: Channel number.
mbed_official 610:813dcc80987e 581 * @retval None
mbed_official 610:813dcc80987e 582 */
mbed_official 610:813dcc80987e 583 #define ADC_SMPR2(__SAMPLETIME__, __CHANNELNB__) ((__SAMPLETIME__) << ((POSITION_VAL(ADC_SMPR2_SMP11) * ((__CHANNELNB__) - 10))))
mbed_official 610:813dcc80987e 584
mbed_official 610:813dcc80987e 585
mbed_official 610:813dcc80987e 586 /**
mbed_official 610:813dcc80987e 587 * @brief Set the selected regular Channel rank for rank between 1 and 4.
mbed_official 610:813dcc80987e 588 * @param __CHANNELNB__: Channel number.
mbed_official 610:813dcc80987e 589 * @param __RANKNB__: Rank number.
mbed_official 610:813dcc80987e 590 * @retval None
mbed_official 610:813dcc80987e 591 */
mbed_official 610:813dcc80987e 592 #define ADC_SQR1_RK(__CHANNELNB__, __RANKNB__) ((__CHANNELNB__) << (POSITION_VAL(ADC_SQR1_SQ1) * (__RANKNB__)))
mbed_official 610:813dcc80987e 593
mbed_official 610:813dcc80987e 594 /**
mbed_official 610:813dcc80987e 595 * @brief Set the selected regular Channel rank for rank between 5 and 9.
mbed_official 610:813dcc80987e 596 * @param __CHANNELNB__: Channel number.
mbed_official 610:813dcc80987e 597 * @param __RANKNB__: Rank number.
mbed_official 610:813dcc80987e 598 * @retval None
mbed_official 610:813dcc80987e 599 */
mbed_official 610:813dcc80987e 600 #define ADC_SQR2_RK(__CHANNELNB__, __RANKNB__) ((__CHANNELNB__) << (POSITION_VAL(ADC_SQR2_SQ6) * ((__RANKNB__) - 5)))
mbed_official 610:813dcc80987e 601
mbed_official 610:813dcc80987e 602 /**
mbed_official 610:813dcc80987e 603 * @brief Set the selected regular Channel rank for rank between 10 and 14.
mbed_official 610:813dcc80987e 604 * @param __CHANNELNB__: Channel number.
mbed_official 610:813dcc80987e 605 * @param __RANKNB__: Rank number.
mbed_official 610:813dcc80987e 606 * @retval None
mbed_official 610:813dcc80987e 607 */
mbed_official 610:813dcc80987e 608 #define ADC_SQR3_RK(__CHANNELNB__, __RANKNB__) ((__CHANNELNB__) << (POSITION_VAL(ADC_SQR3_SQ11) * ((__RANKNB__) - 10)))
mbed_official 610:813dcc80987e 609
mbed_official 610:813dcc80987e 610 /**
mbed_official 610:813dcc80987e 611 * @brief Set the selected regular Channel rank for rank between 15 and 16.
mbed_official 610:813dcc80987e 612 * @param __CHANNELNB__: Channel number.
mbed_official 610:813dcc80987e 613 * @param __RANKNB__: Rank number.
mbed_official 610:813dcc80987e 614 * @retval None
mbed_official 610:813dcc80987e 615 */
mbed_official 610:813dcc80987e 616 #define ADC_SQR4_RK(__CHANNELNB__, __RANKNB__) ((__CHANNELNB__) << (POSITION_VAL(ADC_SQR4_SQ16) * ((__RANKNB__) - 15)))
mbed_official 610:813dcc80987e 617
mbed_official 610:813dcc80987e 618 /**
mbed_official 610:813dcc80987e 619 * @brief Set the selected injected Channel rank.
mbed_official 610:813dcc80987e 620 * @param __CHANNELNB__: Channel number.
mbed_official 610:813dcc80987e 621 * @param __RANKNB__: Rank number.
mbed_official 610:813dcc80987e 622 * @retval None
mbed_official 610:813dcc80987e 623 */
mbed_official 610:813dcc80987e 624 #define ADC_JSQR_RK(__CHANNELNB__, __RANKNB__) ((__CHANNELNB__) << ((POSITION_VAL(ADC_JSQR_JSQ1)-2) * (__RANKNB__) +2))
mbed_official 610:813dcc80987e 625
mbed_official 610:813dcc80987e 626
mbed_official 610:813dcc80987e 627 /**
mbed_official 610:813dcc80987e 628 * @brief Set the Analog Watchdog 1 channel.
mbed_official 610:813dcc80987e 629 * @param __CHANNEL__: channel to be monitored by Analog Watchdog 1.
mbed_official 610:813dcc80987e 630 * @retval None
mbed_official 610:813dcc80987e 631 */
mbed_official 610:813dcc80987e 632 #define ADC_CFGR_SET_AWD1CH(__CHANNEL__) ((__CHANNEL__) << POSITION_VAL(ADC_CFGR_AWD1CH))
mbed_official 610:813dcc80987e 633
mbed_official 610:813dcc80987e 634 /**
mbed_official 610:813dcc80987e 635 * @brief Configure the channel number in Analog Watchdog 2 or 3.
mbed_official 610:813dcc80987e 636 * @param __CHANNEL__: ADC Channel
mbed_official 610:813dcc80987e 637 * @retval None
mbed_official 610:813dcc80987e 638 */
mbed_official 610:813dcc80987e 639 #define ADC_CFGR_SET_AWD23CR(__CHANNEL__) (1U << (__CHANNEL__))
mbed_official 610:813dcc80987e 640
mbed_official 610:813dcc80987e 641 /**
mbed_official 610:813dcc80987e 642 * @brief Configure ADC injected context queue
mbed_official 610:813dcc80987e 643 * @param __INJECT_CONTEXT_QUEUE_MODE__: Injected context queue mode.
mbed_official 610:813dcc80987e 644 * @retval None
mbed_official 610:813dcc80987e 645 */
mbed_official 610:813dcc80987e 646 #define ADC_CFGR_INJECT_CONTEXT_QUEUE(__INJECT_CONTEXT_QUEUE_MODE__) ((__INJECT_CONTEXT_QUEUE_MODE__) << POSITION_VAL(ADC_CFGR_JQM))
mbed_official 610:813dcc80987e 647
mbed_official 610:813dcc80987e 648 /**
mbed_official 610:813dcc80987e 649 * @brief Configure ADC discontinuous conversion mode for injected group
mbed_official 610:813dcc80987e 650 * @param __INJECT_DISCONTINUOUS_MODE__: Injected discontinuous mode.
mbed_official 610:813dcc80987e 651 * @retval None
mbed_official 610:813dcc80987e 652 */
mbed_official 610:813dcc80987e 653 #define ADC_CFGR_INJECT_DISCCONTINUOUS(__INJECT_DISCONTINUOUS_MODE__) ((__INJECT_DISCONTINUOUS_MODE__) << POSITION_VAL(ADC_CFGR_JDISCEN))
mbed_official 610:813dcc80987e 654
mbed_official 610:813dcc80987e 655 /**
mbed_official 610:813dcc80987e 656 * @brief Configure ADC discontinuous conversion mode for regular group
mbed_official 610:813dcc80987e 657 * @param __REG_DISCONTINUOUS_MODE__: Regular discontinuous mode.
mbed_official 610:813dcc80987e 658 * @retval None
mbed_official 610:813dcc80987e 659 */
mbed_official 610:813dcc80987e 660 #define ADC_CFGR_REG_DISCONTINUOUS(__REG_DISCONTINUOUS_MODE__) ((__REG_DISCONTINUOUS_MODE__) << POSITION_VAL(ADC_CFGR_DISCEN))
mbed_official 610:813dcc80987e 661 /**
mbed_official 610:813dcc80987e 662 * @brief Configure the number of discontinuous conversions for regular group.
mbed_official 610:813dcc80987e 663 * @param __NBR_DISCONTINUOUS_CONV__: Number of discontinuous conversions.
mbed_official 610:813dcc80987e 664 * @retval None
mbed_official 610:813dcc80987e 665 */
mbed_official 610:813dcc80987e 666 #define ADC_CFGR_DISCONTINUOUS_NUM(__NBR_DISCONTINUOUS_CONV__) (((__NBR_DISCONTINUOUS_CONV__) - 1) << POSITION_VAL(ADC_CFGR_DISCNUM))
mbed_official 610:813dcc80987e 667
mbed_official 610:813dcc80987e 668 /**
mbed_official 610:813dcc80987e 669 * @brief Configure the ADC auto delay mode.
mbed_official 610:813dcc80987e 670 * @param __AUTOWAIT__: Auto delay bit enable or disable.
mbed_official 610:813dcc80987e 671 * @retval None
mbed_official 610:813dcc80987e 672 */
mbed_official 610:813dcc80987e 673 #define ADC_CFGR_AUTOWAIT(__AUTOWAIT__) ((__AUTOWAIT__) << POSITION_VAL(ADC_CFGR_AUTDLY))
mbed_official 610:813dcc80987e 674
mbed_official 610:813dcc80987e 675 /**
mbed_official 610:813dcc80987e 676 * @brief Configure ADC continuous conversion mode.
mbed_official 610:813dcc80987e 677 * @param __CONTINUOUS_MODE__: Continuous mode.
mbed_official 610:813dcc80987e 678 * @retval None
mbed_official 610:813dcc80987e 679 */
mbed_official 610:813dcc80987e 680 #define ADC_CFGR_CONTINUOUS(__CONTINUOUS_MODE__) ((__CONTINUOUS_MODE__) << POSITION_VAL(ADC_CFGR_CONT))
mbed_official 610:813dcc80987e 681
mbed_official 610:813dcc80987e 682 /**
mbed_official 610:813dcc80987e 683 * @brief Configure the ADC DMA continuous request.
mbed_official 610:813dcc80987e 684 * @param __DMACONTREQ_MODE__: DMA continuous request mode.
mbed_official 610:813dcc80987e 685 * @retval None
mbed_official 610:813dcc80987e 686 */
mbed_official 610:813dcc80987e 687 #define ADC_CFGR_DMACONTREQ(__DMACONTREQ_MODE__) ((__DMACONTREQ_MODE__) << POSITION_VAL(ADC_CFGR_DMACFG))
mbed_official 610:813dcc80987e 688
mbed_official 610:813dcc80987e 689
mbed_official 610:813dcc80987e 690 /**
mbed_official 610:813dcc80987e 691 * @brief Configure the channel number into offset OFRx register.
mbed_official 610:813dcc80987e 692 * @param __CHANNEL__: ADC Channel.
mbed_official 610:813dcc80987e 693 * @retval None
mbed_official 610:813dcc80987e 694 */
mbed_official 610:813dcc80987e 695 #define ADC_OFR_CHANNEL(__CHANNEL__) ((__CHANNEL__) << POSITION_VAL(ADC_OFR1_OFFSET1_CH))
mbed_official 610:813dcc80987e 696
mbed_official 610:813dcc80987e 697 /**
mbed_official 610:813dcc80987e 698 * @brief Configure the channel number into differential mode selection register.
mbed_official 610:813dcc80987e 699 * @param __CHANNEL__: ADC Channel.
mbed_official 610:813dcc80987e 700 * @retval None
mbed_official 610:813dcc80987e 701 */
mbed_official 610:813dcc80987e 702 #define ADC_DIFSEL_CHANNEL(__CHANNEL__) (1U << (__CHANNEL__))
mbed_official 610:813dcc80987e 703
mbed_official 610:813dcc80987e 704 /**
mbed_official 610:813dcc80987e 705 * @brief Configure calibration factor in differential mode to be set into calibration register.
mbed_official 610:813dcc80987e 706 * @param __CALIBRATION_FACTOR__: Calibration factor value.
mbed_official 610:813dcc80987e 707 * @retval None
mbed_official 610:813dcc80987e 708 */
mbed_official 610:813dcc80987e 709 #define ADC_CALFACT_DIFF_SET(__CALIBRATION_FACTOR__) (((__CALIBRATION_FACTOR__) & (ADC_CALFACT_CALFACT_D >> POSITION_VAL(ADC_CALFACT_CALFACT_D)) ) << POSITION_VAL(ADC_CALFACT_CALFACT_D))
mbed_official 610:813dcc80987e 710 /**
mbed_official 610:813dcc80987e 711 * @brief Calibration factor in differential mode to be retrieved from calibration register.
mbed_official 610:813dcc80987e 712 * @param __CALIBRATION_FACTOR__: Calibration factor value.
mbed_official 610:813dcc80987e 713 * @retval None
mbed_official 610:813dcc80987e 714 */
mbed_official 610:813dcc80987e 715 #define ADC_CALFACT_DIFF_GET(__CALIBRATION_FACTOR__) ((__CALIBRATION_FACTOR__) >> POSITION_VAL(ADC_CALFACT_CALFACT_D))
mbed_official 610:813dcc80987e 716
mbed_official 610:813dcc80987e 717 /**
mbed_official 610:813dcc80987e 718 * @brief Configure the analog watchdog high threshold into registers TR1, TR2 or TR3.
mbed_official 610:813dcc80987e 719 * @param __THRESHOLD__: Threshold value.
mbed_official 610:813dcc80987e 720 * @retval None
mbed_official 610:813dcc80987e 721 */
mbed_official 610:813dcc80987e 722 #define ADC_TRX_HIGHTHRESHOLD(__THRESHOLD__) ((__THRESHOLD__) << 16)
mbed_official 610:813dcc80987e 723
mbed_official 610:813dcc80987e 724 /**
mbed_official 610:813dcc80987e 725 * @brief Configure the ADC DMA continuous request for ADC multimode.
mbed_official 610:813dcc80987e 726 * @param __DMACONTREQ_MODE__: DMA continuous request mode.
mbed_official 610:813dcc80987e 727 * @retval None
mbed_official 610:813dcc80987e 728 */
mbed_official 610:813dcc80987e 729 #define ADC_CCR_MULTI_DMACONTREQ(__DMACONTREQ_MODE__) ((__DMACONTREQ_MODE__) << POSITION_VAL(ADC_CCR_DMACFG))
mbed_official 610:813dcc80987e 730
mbed_official 610:813dcc80987e 731
mbed_official 610:813dcc80987e 732 /**
mbed_official 610:813dcc80987e 733 * @brief Enable the ADC peripheral.
mbed_official 610:813dcc80987e 734 * @param __HANDLE__: ADC handle.
mbed_official 610:813dcc80987e 735 * @retval None
mbed_official 610:813dcc80987e 736 */
mbed_official 610:813dcc80987e 737 #define ADC_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= ADC_CR_ADEN)
mbed_official 610:813dcc80987e 738
mbed_official 610:813dcc80987e 739 /**
mbed_official 610:813dcc80987e 740 * @brief Verification of hardware constraints before ADC can be enabled.
mbed_official 610:813dcc80987e 741 * @param __HANDLE__: ADC handle.
mbed_official 610:813dcc80987e 742 * @retval SET (ADC can be enabled) or RESET (ADC cannot be enabled)
mbed_official 610:813dcc80987e 743 */
mbed_official 610:813dcc80987e 744 #define ADC_ENABLING_CONDITIONS(__HANDLE__) \
mbed_official 610:813dcc80987e 745 (( ( ((__HANDLE__)->Instance->CR) & \
mbed_official 610:813dcc80987e 746 (ADC_CR_ADCAL | ADC_CR_JADSTP | ADC_CR_ADSTP | ADC_CR_JADSTART | \
mbed_official 610:813dcc80987e 747 ADC_CR_ADSTART | ADC_CR_ADDIS | ADC_CR_ADEN ) \
mbed_official 610:813dcc80987e 748 ) == RESET \
mbed_official 610:813dcc80987e 749 ) ? SET : RESET)
mbed_official 610:813dcc80987e 750
mbed_official 610:813dcc80987e 751 /**
mbed_official 610:813dcc80987e 752 * @brief Disable the ADC peripheral.
mbed_official 610:813dcc80987e 753 * @param __HANDLE__: ADC handle.
mbed_official 610:813dcc80987e 754 * @retval None
mbed_official 610:813dcc80987e 755 */
mbed_official 610:813dcc80987e 756 #define ADC_DISABLE(__HANDLE__) \
mbed_official 610:813dcc80987e 757 do{ \
mbed_official 610:813dcc80987e 758 (__HANDLE__)->Instance->CR |= ADC_CR_ADDIS; \
mbed_official 610:813dcc80987e 759 __HAL_ADC_CLEAR_FLAG((__HANDLE__), (ADC_FLAG_EOSMP | ADC_FLAG_RDY)); \
mbed_official 610:813dcc80987e 760 } while(0)
mbed_official 610:813dcc80987e 761
mbed_official 610:813dcc80987e 762 /**
mbed_official 610:813dcc80987e 763 * @brief Verification of hardware constraints before ADC can be disabled.
mbed_official 610:813dcc80987e 764 * @param __HANDLE__: ADC handle.
mbed_official 610:813dcc80987e 765 * @retval SET (ADC can be disabled) or RESET (ADC cannot be disabled)
mbed_official 610:813dcc80987e 766 */
mbed_official 610:813dcc80987e 767 #define ADC_DISABLING_CONDITIONS(__HANDLE__) \
mbed_official 610:813dcc80987e 768 (( ( ((__HANDLE__)->Instance->CR) & \
mbed_official 610:813dcc80987e 769 (ADC_CR_JADSTART | ADC_CR_ADSTART | ADC_CR_ADEN)) == ADC_CR_ADEN \
mbed_official 610:813dcc80987e 770 ) ? SET : RESET)
mbed_official 610:813dcc80987e 771
mbed_official 610:813dcc80987e 772
mbed_official 610:813dcc80987e 773 /**
mbed_official 610:813dcc80987e 774 * @brief Shift the offset with respect to the selected ADC resolution.
mbed_official 610:813dcc80987e 775 * @note Offset has to be left-aligned on bit 11, the LSB (right bits) are set to 0.
mbed_official 610:813dcc80987e 776 * If resolution 12 bits, no shift.
mbed_official 610:813dcc80987e 777 * If resolution 10 bits, shift of 2 ranks on the left.
mbed_official 610:813dcc80987e 778 * If resolution 8 bits, shift of 4 ranks on the left.
mbed_official 610:813dcc80987e 779 * If resolution 6 bits, shift of 6 ranks on the left.
mbed_official 610:813dcc80987e 780 * Therefore, shift = (12 - resolution) = 12 - (12- (((RES[1:0]) >> 3)*2)).
mbed_official 610:813dcc80987e 781 * @param __HANDLE__: ADC handle
mbed_official 610:813dcc80987e 782 * @param __OFFSET__: Value to be shifted
mbed_official 610:813dcc80987e 783 * @retval None
mbed_official 610:813dcc80987e 784 */
mbed_official 610:813dcc80987e 785 #define ADC_OFFSET_SHIFT_RESOLUTION(__HANDLE__, __OFFSET__) \
mbed_official 610:813dcc80987e 786 ((__OFFSET__) << ((((__HANDLE__)->Instance->CFGR & ADC_CFGR_RES) >> 3)*2))
mbed_official 610:813dcc80987e 787
mbed_official 610:813dcc80987e 788
mbed_official 610:813dcc80987e 789 /**
mbed_official 610:813dcc80987e 790 * @brief Shift the AWD1 threshold with respect to the selected ADC resolution.
mbed_official 610:813dcc80987e 791 * @note Thresholds have to be left-aligned on bit 11, the LSB (right bits) are set to 0.
mbed_official 610:813dcc80987e 792 * If resolution 12 bits, no shift.
mbed_official 610:813dcc80987e 793 * If resolution 10 bits, shift of 2 ranks on the left.
mbed_official 610:813dcc80987e 794 * If resolution 8 bits, shift of 4 ranks on the left.
mbed_official 610:813dcc80987e 795 * If resolution 6 bits, shift of 6 ranks on the left.
mbed_official 610:813dcc80987e 796 * Therefore, shift = (12 - resolution) = 12 - (12- (((RES[1:0]) >> 3)*2)).
mbed_official 610:813dcc80987e 797 * @param __HANDLE__: ADC handle
mbed_official 610:813dcc80987e 798 * @param __THRESHOLD__: Value to be shifted
mbed_official 610:813dcc80987e 799 * @retval None
mbed_official 610:813dcc80987e 800 */
mbed_official 610:813dcc80987e 801 #define ADC_AWD1THRESHOLD_SHIFT_RESOLUTION(__HANDLE__, __THRESHOLD__) \
mbed_official 610:813dcc80987e 802 ((__THRESHOLD__) << ((((__HANDLE__)->Instance->CFGR & ADC_CFGR_RES) >> 3)*2))
mbed_official 610:813dcc80987e 803
mbed_official 610:813dcc80987e 804 /**
mbed_official 610:813dcc80987e 805 * @brief Shift the AWD2 and AWD3 threshold with respect to the selected ADC resolution.
mbed_official 610:813dcc80987e 806 * @note Thresholds have to be left-aligned on bit 7.
mbed_official 610:813dcc80987e 807 * If resolution 12 bits, shift of 4 ranks on the right (the 4 LSB are discarded).
mbed_official 610:813dcc80987e 808 * If resolution 10 bits, shift of 2 ranks on the right (the 2 LSB are discarded).
mbed_official 610:813dcc80987e 809 * If resolution 8 bits, no shift.
mbed_official 610:813dcc80987e 810 * If resolution 6 bits, shift of 2 ranks on the left (the 2 LSB are set to 0).
mbed_official 610:813dcc80987e 811 * @param __HANDLE__: ADC handle
mbed_official 610:813dcc80987e 812 * @param __THRESHOLD__: Value to be shifted
mbed_official 610:813dcc80987e 813 * @retval None
mbed_official 610:813dcc80987e 814 */
mbed_official 610:813dcc80987e 815 #define ADC_AWD23THRESHOLD_SHIFT_RESOLUTION(__HANDLE__, __THRESHOLD__) \
mbed_official 610:813dcc80987e 816 ( ((__HANDLE__)->Instance->CFGR & ADC_CFGR_RES) != (ADC_CFGR_RES_1 | ADC_CFGR_RES_0) ? \
mbed_official 610:813dcc80987e 817 ((__THRESHOLD__) >> (4- ((((__HANDLE__)->Instance->CFGR & ADC_CFGR_RES) >> 3)*2))) : \
mbed_official 610:813dcc80987e 818 (__THRESHOLD__) << 2 )
mbed_official 610:813dcc80987e 819
mbed_official 610:813dcc80987e 820
mbed_official 610:813dcc80987e 821 /**
mbed_official 610:813dcc80987e 822 * @brief Report common register to ADC1, ADC2 and ADC3.
mbed_official 610:813dcc80987e 823 * @param __HANDLE__: ADC handle.
mbed_official 610:813dcc80987e 824 * @retval Common control register
mbed_official 610:813dcc80987e 825 */
mbed_official 610:813dcc80987e 826 #define ADC_COMMON_REGISTER(__HANDLE__) (ADC123_COMMON)
mbed_official 610:813dcc80987e 827
mbed_official 610:813dcc80987e 828
mbed_official 610:813dcc80987e 829 /**
mbed_official 610:813dcc80987e 830 * @brief Report Master Instance.
mbed_official 610:813dcc80987e 831 * @param __HANDLE__: ADC handle.
mbed_official 610:813dcc80987e 832 * @note return same instance if ADC of input handle is independent ADC.
mbed_official 610:813dcc80987e 833 * @retval Master Instance
mbed_official 610:813dcc80987e 834 */
mbed_official 610:813dcc80987e 835 #define ADC_MASTER_REGISTER(__HANDLE__) \
mbed_official 610:813dcc80987e 836 ( ( ((((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC3)) \
mbed_official 610:813dcc80987e 837 )? \
mbed_official 610:813dcc80987e 838 ((__HANDLE__)->Instance) \
mbed_official 610:813dcc80987e 839 : \
mbed_official 610:813dcc80987e 840 (ADC1) \
mbed_official 610:813dcc80987e 841 )
mbed_official 610:813dcc80987e 842
mbed_official 610:813dcc80987e 843 /**
mbed_official 610:813dcc80987e 844 * @brief Clear Common Control Register.
mbed_official 610:813dcc80987e 845 * @param __HANDLE__: ADC handle.
mbed_official 610:813dcc80987e 846 * @retval None
mbed_official 610:813dcc80987e 847 */
mbed_official 610:813dcc80987e 848 #define ADC_CLEAR_COMMON_CONTROL_REGISTER(__HANDLE__) CLEAR_BIT(ADC_COMMON_REGISTER(__HANDLE__)->CCR, ADC_CCR_CKMODE | \
mbed_official 610:813dcc80987e 849 ADC_CCR_PRESC | \
mbed_official 610:813dcc80987e 850 ADC_CCR_VBATEN | \
mbed_official 610:813dcc80987e 851 ADC_CCR_TSEN | \
mbed_official 610:813dcc80987e 852 ADC_CCR_VREFEN | \
mbed_official 610:813dcc80987e 853 ADC_CCR_MDMA | \
mbed_official 610:813dcc80987e 854 ADC_CCR_DMACFG | \
mbed_official 610:813dcc80987e 855 ADC_CCR_DELAY | \
mbed_official 610:813dcc80987e 856 ADC_CCR_DUAL )
mbed_official 610:813dcc80987e 857
mbed_official 610:813dcc80987e 858
mbed_official 610:813dcc80987e 859 /**
mbed_official 610:813dcc80987e 860 * @brief Check whether or not dual conversions are enabled.
mbed_official 610:813dcc80987e 861 * @param __HANDLE__: ADC handle.
mbed_official 610:813dcc80987e 862 * @note Return RESET if ADC of input handle is independent ADC.
mbed_official 610:813dcc80987e 863 * @retval SET (dual regular conversions are enabled) or RESET (ADC is independent or no dual regular conversions are enabled)
mbed_official 610:813dcc80987e 864 */
mbed_official 610:813dcc80987e 865 #define ADC_IS_DUAL_CONVERSION_ENABLE(__HANDLE__) \
mbed_official 610:813dcc80987e 866 ( ( ((((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC2)) \
mbed_official 610:813dcc80987e 867 )? \
mbed_official 610:813dcc80987e 868 ( ((ADC123_COMMON->CCR & ADC_CCR_DUAL) != ADC_MODE_INDEPENDENT) ) \
mbed_official 610:813dcc80987e 869 : \
mbed_official 610:813dcc80987e 870 RESET \
mbed_official 610:813dcc80987e 871 )
mbed_official 610:813dcc80987e 872
mbed_official 610:813dcc80987e 873 /**
mbed_official 610:813dcc80987e 874 * @brief Check whether or not dual regular conversions are enabled.
mbed_official 610:813dcc80987e 875 * @param __HANDLE__: ADC handle.
mbed_official 610:813dcc80987e 876 * @retval SET (dual regular conversions are enabled) or RESET (ADC is independent or no dual regular conversions are enabled)
mbed_official 610:813dcc80987e 877 */
mbed_official 610:813dcc80987e 878 #define ADC_IS_DUAL_REGULAR_CONVERSION_ENABLE(__HANDLE__) \
mbed_official 610:813dcc80987e 879 ( ( ((((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC2)) \
mbed_official 610:813dcc80987e 880 )? \
mbed_official 610:813dcc80987e 881 ( (((ADC_COMMON_REGISTER(__HANDLE__))->CCR & ADC_CCR_DUAL) != ADC_MODE_INDEPENDENT) && \
mbed_official 610:813dcc80987e 882 (((ADC_COMMON_REGISTER(__HANDLE__))->CCR & ADC_CCR_DUAL) != ADC_DUALMODE_INJECSIMULT) && \
mbed_official 610:813dcc80987e 883 (((ADC_COMMON_REGISTER(__HANDLE__))->CCR & ADC_CCR_DUAL) != ADC_DUALMODE_ALTERTRIG) ) \
mbed_official 610:813dcc80987e 884 : \
mbed_official 610:813dcc80987e 885 RESET \
mbed_official 610:813dcc80987e 886 )
mbed_official 610:813dcc80987e 887
mbed_official 610:813dcc80987e 888
mbed_official 610:813dcc80987e 889
mbed_official 610:813dcc80987e 890 /**
mbed_official 610:813dcc80987e 891 * @brief Verification of condition for ADC start conversion: ADC must be in non-multimode or multimode with handle of ADC master.
mbed_official 610:813dcc80987e 892 * @param __HANDLE__: ADC handle.
mbed_official 610:813dcc80987e 893 * @retval SET (non-MultiMode or Master handle) or RESET (handle of Slave ADC in MultiMode)
mbed_official 610:813dcc80987e 894 */
mbed_official 610:813dcc80987e 895 #define ADC_NONMULTIMODE_OR_MULTIMODEMASTER(__HANDLE__) \
mbed_official 610:813dcc80987e 896 ( ( ((__HANDLE__)->Instance == ADC1) || ((__HANDLE__)->Instance == ADC3) \
mbed_official 610:813dcc80987e 897 )? \
mbed_official 610:813dcc80987e 898 SET \
mbed_official 610:813dcc80987e 899 : \
mbed_official 610:813dcc80987e 900 ((ADC123_COMMON->CCR & ADC_CCR_DUAL) == RESET) \
mbed_official 610:813dcc80987e 901 )
mbed_official 610:813dcc80987e 902
mbed_official 610:813dcc80987e 903
mbed_official 610:813dcc80987e 904 /**
mbed_official 610:813dcc80987e 905 * @brief Ensure ADC Instance is Independent or Master, or is not Slave ADC with dual regular conversions enabled.
mbed_official 610:813dcc80987e 906 * @param __HANDLE__: ADC handle.
mbed_official 610:813dcc80987e 907 * @retval SET (Independent or Master, or Slave without dual regular conversions enabled) or RESET (Slave ADC with dual regular conversions enabled)
mbed_official 610:813dcc80987e 908 */
mbed_official 610:813dcc80987e 909 #define ADC_INDEPENDENT_OR_NONMULTIMODEREGULAR_SLAVE(__HANDLE__) \
mbed_official 610:813dcc80987e 910 ( ( ((__HANDLE__)->Instance == ADC1) || ((__HANDLE__)->Instance == ADC3) \
mbed_official 610:813dcc80987e 911 )? \
mbed_official 610:813dcc80987e 912 SET \
mbed_official 610:813dcc80987e 913 : \
mbed_official 610:813dcc80987e 914 ( ((ADC123_COMMON->CCR & ADC_CCR_DUAL) == ADC_MODE_INDEPENDENT) || \
mbed_official 610:813dcc80987e 915 ((ADC123_COMMON->CCR & ADC_CCR_DUAL) == ADC_DUALMODE_INJECSIMULT) || \
mbed_official 610:813dcc80987e 916 ((ADC123_COMMON->CCR & ADC_CCR_DUAL) == ADC_DUALMODE_ALTERTRIG) ))
mbed_official 610:813dcc80987e 917
mbed_official 610:813dcc80987e 918 /**
mbed_official 610:813dcc80987e 919 * @brief Ensure ADC Instance is Independent or Master, or is not Slave ADC with dual injected conversions enabled.
mbed_official 610:813dcc80987e 920 * @param __HANDLE__: ADC handle.
mbed_official 610:813dcc80987e 921 * @retval SET (non-MultiMode or Master, or Slave without dual injected conversions enabled) or RESET (Slave ADC with dual injected conversions enabled)
mbed_official 610:813dcc80987e 922 */
mbed_official 610:813dcc80987e 923 #define ADC_INDEPENDENT_OR_NONMULTIMODEINJECTED_SLAVE(__HANDLE__) \
mbed_official 610:813dcc80987e 924 ( ( ((__HANDLE__)->Instance == ADC1) || ((__HANDLE__)->Instance == ADC3) \
mbed_official 610:813dcc80987e 925 )? \
mbed_official 610:813dcc80987e 926 SET \
mbed_official 610:813dcc80987e 927 : \
mbed_official 610:813dcc80987e 928 ( ((ADC123_COMMON->CCR & ADC_CCR_DUAL) == ADC_MODE_INDEPENDENT) || \
mbed_official 610:813dcc80987e 929 ((ADC123_COMMON->CCR & ADC_CCR_DUAL) == ADC_DUALMODE_REGSIMULT) || \
mbed_official 610:813dcc80987e 930 ((ADC123_COMMON->CCR & ADC_CCR_DUAL) == ADC_DUALMODE_INTERL) ))
mbed_official 610:813dcc80987e 931
mbed_official 610:813dcc80987e 932 /**
mbed_official 610:813dcc80987e 933 * @brief Verification of ADC state: enabled or disabled, directly checked on instance as input parameter.
mbed_official 610:813dcc80987e 934 * @param __INSTANCE__: ADC instance.
mbed_official 610:813dcc80987e 935 * @retval SET (ADC enabled) or RESET (ADC disabled)
mbed_official 610:813dcc80987e 936 */
mbed_official 610:813dcc80987e 937 #define ADC_INSTANCE_IS_ENABLED(__INSTANCE__) \
mbed_official 610:813dcc80987e 938 (( ((((__INSTANCE__)->CR) & (ADC_CR_ADEN | ADC_CR_ADDIS)) == ADC_CR_ADEN) && \
mbed_official 610:813dcc80987e 939 ((((__INSTANCE__)->ISR) & ADC_FLAG_RDY) == ADC_FLAG_RDY) \
mbed_official 610:813dcc80987e 940 ) ? SET : RESET)
mbed_official 610:813dcc80987e 941
mbed_official 610:813dcc80987e 942 /**
mbed_official 610:813dcc80987e 943 * @brief Verification of enabled/disabled status of ADCs other than that associated to the input parameter handle.
mbed_official 610:813dcc80987e 944 * @param __HANDLE__: ADC handle.
mbed_official 610:813dcc80987e 945 * @retval SET (at least one other ADC is enabled) or RESET (no other ADC is enabled, all other ADCs are disabled)
mbed_official 610:813dcc80987e 946 */
mbed_official 610:813dcc80987e 947 #define ADC_ANY_OTHER_ENABLED(__HANDLE__) \
mbed_official 610:813dcc80987e 948 ( ( ((__HANDLE__)->Instance == ADC1) \
mbed_official 610:813dcc80987e 949 )? \
mbed_official 610:813dcc80987e 950 (ADC_INSTANCE_IS_ENABLED(ADC2)) || (ADC_INSTANCE_IS_ENABLED(ADC3)) \
mbed_official 610:813dcc80987e 951 : \
mbed_official 610:813dcc80987e 952 ( ( ((__HANDLE__)->Instance == ADC2) \
mbed_official 610:813dcc80987e 953 )? \
mbed_official 610:813dcc80987e 954 (ADC_INSTANCE_IS_ENABLED(ADC1)) || (ADC_INSTANCE_IS_ENABLED(ADC3)) \
mbed_official 610:813dcc80987e 955 : \
mbed_official 610:813dcc80987e 956 ADC_INSTANCE_IS_ENABLED(ADC1)) || (ADC_INSTANCE_IS_ENABLED(ADC2)) \
mbed_official 610:813dcc80987e 957 ) \
mbed_official 610:813dcc80987e 958
mbed_official 610:813dcc80987e 959
mbed_official 610:813dcc80987e 960
mbed_official 610:813dcc80987e 961
mbed_official 610:813dcc80987e 962 /**
mbed_official 610:813dcc80987e 963 * @brief Set handle instance of the ADC slave associated to the ADC master.
mbed_official 610:813dcc80987e 964 * @param __HANDLE_MASTER__: ADC master handle.
mbed_official 610:813dcc80987e 965 * @param __HANDLE_SLAVE__: ADC slave handle.
mbed_official 610:813dcc80987e 966 * @note if __HANDLE_MASTER__ is the handle of a slave ADC (ADC2) or an independent ADC (ADC3), __HANDLE_SLAVE__ instance is set to NULL.
mbed_official 610:813dcc80987e 967 * @retval None
mbed_official 610:813dcc80987e 968 */
mbed_official 610:813dcc80987e 969 #define ADC_MULTI_SLAVE(__HANDLE_MASTER__, __HANDLE_SLAVE__) \
mbed_official 610:813dcc80987e 970 ( (((__HANDLE_MASTER__)->Instance == ADC1)) ? ((__HANDLE_SLAVE__)->Instance = ADC2) : ((__HANDLE_SLAVE__)->Instance = NULL) )
mbed_official 610:813dcc80987e 971
mbed_official 610:813dcc80987e 972 /**
mbed_official 610:813dcc80987e 973 * @brief Check whether or not multimode is configured in DMA mode.
mbed_official 610:813dcc80987e 974 * @retval SET (multimode is configured in DMA mode) or RESET (DMA multimode is disabled)
mbed_official 610:813dcc80987e 975 */
mbed_official 610:813dcc80987e 976 #define ADC_MULTIMODE_DMA_ENABLED() \
mbed_official 610:813dcc80987e 977 ((READ_BIT(ADC123_COMMON->CCR, ADC_CCR_MDMA) == ADC_DMAACCESSMODE_12_10_BITS) \
mbed_official 610:813dcc80987e 978 || (READ_BIT(ADC123_COMMON->CCR, ADC_CCR_MDMA) == ADC_DMAACCESSMODE_8_6_BITS))
mbed_official 610:813dcc80987e 979
mbed_official 610:813dcc80987e 980 /**
mbed_official 610:813dcc80987e 981 * @brief Verify the length of scheduled injected conversions group.
mbed_official 610:813dcc80987e 982 * @param __LENGTH__: number of programmed conversions.
mbed_official 610:813dcc80987e 983 * @retval SET (__LENGTH__ is within the maximum number of possible programmable injected conversions) or RESET (__LENGTH__ is null or too large)
mbed_official 610:813dcc80987e 984 */
mbed_official 610:813dcc80987e 985 #define IS_ADC_INJECTED_NB_CONV(__LENGTH__) (((__LENGTH__) >= ((uint32_t)1)) && ((__LENGTH__) <= ((uint32_t)4)))
mbed_official 610:813dcc80987e 986
mbed_official 610:813dcc80987e 987
mbed_official 610:813dcc80987e 988 /**
mbed_official 610:813dcc80987e 989 * @brief Calibration factor size verification (7 bits maximum).
mbed_official 610:813dcc80987e 990 * @param __CALIBRATION_FACTOR__: Calibration factor value.
mbed_official 610:813dcc80987e 991 * @retval SET (__CALIBRATION_FACTOR__ is within the authorized size) or RESET (__CALIBRATION_FACTOR__ is too large)
mbed_official 610:813dcc80987e 992 */
mbed_official 610:813dcc80987e 993 #define IS_ADC_CALFACT(__CALIBRATION_FACTOR__) ((__CALIBRATION_FACTOR__) <= ((uint32_t)0x7F))
mbed_official 610:813dcc80987e 994
mbed_official 610:813dcc80987e 995
mbed_official 610:813dcc80987e 996 /**
mbed_official 610:813dcc80987e 997 * @brief Verify the ADC channel setting.
mbed_official 610:813dcc80987e 998 * @param __CHANNEL__: programmed ADC channel.
mbed_official 610:813dcc80987e 999 * @retval SET (__CHANNEL__ is valid) or RESET (__CHANNEL__ is invalid)
mbed_official 610:813dcc80987e 1000 */
mbed_official 610:813dcc80987e 1001 #define IS_ADC_CHANNEL(__CHANNEL__) (((__CHANNEL__) == ADC_CHANNEL_0) || \
mbed_official 610:813dcc80987e 1002 ((__CHANNEL__) == ADC_CHANNEL_1) || \
mbed_official 610:813dcc80987e 1003 ((__CHANNEL__) == ADC_CHANNEL_2) || \
mbed_official 610:813dcc80987e 1004 ((__CHANNEL__) == ADC_CHANNEL_3) || \
mbed_official 610:813dcc80987e 1005 ((__CHANNEL__) == ADC_CHANNEL_4) || \
mbed_official 610:813dcc80987e 1006 ((__CHANNEL__) == ADC_CHANNEL_5) || \
mbed_official 610:813dcc80987e 1007 ((__CHANNEL__) == ADC_CHANNEL_6) || \
mbed_official 610:813dcc80987e 1008 ((__CHANNEL__) == ADC_CHANNEL_7) || \
mbed_official 610:813dcc80987e 1009 ((__CHANNEL__) == ADC_CHANNEL_8) || \
mbed_official 610:813dcc80987e 1010 ((__CHANNEL__) == ADC_CHANNEL_9) || \
mbed_official 610:813dcc80987e 1011 ((__CHANNEL__) == ADC_CHANNEL_10) || \
mbed_official 610:813dcc80987e 1012 ((__CHANNEL__) == ADC_CHANNEL_11) || \
mbed_official 610:813dcc80987e 1013 ((__CHANNEL__) == ADC_CHANNEL_12) || \
mbed_official 610:813dcc80987e 1014 ((__CHANNEL__) == ADC_CHANNEL_13) || \
mbed_official 610:813dcc80987e 1015 ((__CHANNEL__) == ADC_CHANNEL_14) || \
mbed_official 610:813dcc80987e 1016 ((__CHANNEL__) == ADC_CHANNEL_15) || \
mbed_official 610:813dcc80987e 1017 ((__CHANNEL__) == ADC_CHANNEL_16) || \
mbed_official 610:813dcc80987e 1018 ((__CHANNEL__) == ADC_CHANNEL_TEMPSENSOR) || \
mbed_official 610:813dcc80987e 1019 ((__CHANNEL__) == ADC_CHANNEL_VBAT) || \
mbed_official 610:813dcc80987e 1020 ((__CHANNEL__) == ADC_CHANNEL_VREFINT) )
mbed_official 610:813dcc80987e 1021
mbed_official 610:813dcc80987e 1022
mbed_official 610:813dcc80987e 1023 /**
mbed_official 610:813dcc80987e 1024 * @brief Verify the ADC1 or ADC2 channel setting in differential mode.
mbed_official 610:813dcc80987e 1025 * @param __CHANNEL__: programmed ADC1 or ADC2 channel.
mbed_official 610:813dcc80987e 1026 * @retval SET (__CHANNEL__ is valid) or RESET (__CHANNEL__ is invalid)
mbed_official 610:813dcc80987e 1027 */
mbed_official 610:813dcc80987e 1028 #define IS_ADC12_DIFF_CHANNEL(__CHANNEL__) (((__CHANNEL__) == ADC_CHANNEL_1)|| \
mbed_official 610:813dcc80987e 1029 ((__CHANNEL__) == ADC_CHANNEL_2) || \
mbed_official 610:813dcc80987e 1030 ((__CHANNEL__) == ADC_CHANNEL_3) || \
mbed_official 610:813dcc80987e 1031 ((__CHANNEL__) == ADC_CHANNEL_4) || \
mbed_official 610:813dcc80987e 1032 ((__CHANNEL__) == ADC_CHANNEL_5) || \
mbed_official 610:813dcc80987e 1033 ((__CHANNEL__) == ADC_CHANNEL_6) || \
mbed_official 610:813dcc80987e 1034 ((__CHANNEL__) == ADC_CHANNEL_7) || \
mbed_official 610:813dcc80987e 1035 ((__CHANNEL__) == ADC_CHANNEL_8) || \
mbed_official 610:813dcc80987e 1036 ((__CHANNEL__) == ADC_CHANNEL_9) || \
mbed_official 610:813dcc80987e 1037 ((__CHANNEL__) == ADC_CHANNEL_10) || \
mbed_official 610:813dcc80987e 1038 ((__CHANNEL__) == ADC_CHANNEL_11) || \
mbed_official 610:813dcc80987e 1039 ((__CHANNEL__) == ADC_CHANNEL_12) || \
mbed_official 610:813dcc80987e 1040 ((__CHANNEL__) == ADC_CHANNEL_13) || \
mbed_official 610:813dcc80987e 1041 ((__CHANNEL__) == ADC_CHANNEL_14) || \
mbed_official 610:813dcc80987e 1042 ((__CHANNEL__) == ADC_CHANNEL_15) )
mbed_official 610:813dcc80987e 1043
mbed_official 610:813dcc80987e 1044 /**
mbed_official 610:813dcc80987e 1045 * @brief Verify the ADC3 channel setting in differential mode.
mbed_official 610:813dcc80987e 1046 * @param __CHANNEL__: programmed ADC3 channel.
mbed_official 610:813dcc80987e 1047 * @retval SET (__CHANNEL__ is valid) or RESET (__CHANNEL__ is invalid)
mbed_official 610:813dcc80987e 1048 */
mbed_official 610:813dcc80987e 1049 #define IS_ADC3_DIFF_CHANNEL(__CHANNEL__) (((__CHANNEL__) == ADC_CHANNEL_1) || \
mbed_official 610:813dcc80987e 1050 ((__CHANNEL__) == ADC_CHANNEL_2) || \
mbed_official 610:813dcc80987e 1051 ((__CHANNEL__) == ADC_CHANNEL_3) || \
mbed_official 610:813dcc80987e 1052 ((__CHANNEL__) == ADC_CHANNEL_4) || \
mbed_official 610:813dcc80987e 1053 ((__CHANNEL__) == ADC_CHANNEL_5) || \
mbed_official 610:813dcc80987e 1054 ((__CHANNEL__) == ADC_CHANNEL_6) || \
mbed_official 610:813dcc80987e 1055 ((__CHANNEL__) == ADC_CHANNEL_7) || \
mbed_official 610:813dcc80987e 1056 ((__CHANNEL__) == ADC_CHANNEL_8) || \
mbed_official 610:813dcc80987e 1057 ((__CHANNEL__) == ADC_CHANNEL_9) || \
mbed_official 610:813dcc80987e 1058 ((__CHANNEL__) == ADC_CHANNEL_10)|| \
mbed_official 610:813dcc80987e 1059 ((__CHANNEL__) == ADC_CHANNEL_11) )
mbed_official 610:813dcc80987e 1060
mbed_official 610:813dcc80987e 1061
mbed_official 610:813dcc80987e 1062 /**
mbed_official 610:813dcc80987e 1063 * @brief Verify the ADC single-ended input or differential mode setting.
mbed_official 610:813dcc80987e 1064 * @param __SING_DIFF__: programmed channel setting.
mbed_official 610:813dcc80987e 1065 * @retval SET (__SING_DIFF__ is valid) or RESET (__SING_DIFF__ is invalid)
mbed_official 610:813dcc80987e 1066 */
mbed_official 610:813dcc80987e 1067 #define IS_ADC_SINGLE_DIFFERENTIAL(__SING_DIFF__) (((__SING_DIFF__) == ADC_SINGLE_ENDED) || \
mbed_official 610:813dcc80987e 1068 ((__SING_DIFF__) == ADC_DIFFERENTIAL_ENDED) )
mbed_official 610:813dcc80987e 1069
mbed_official 610:813dcc80987e 1070
mbed_official 610:813dcc80987e 1071 /**
mbed_official 610:813dcc80987e 1072 * @brief Verify the ADC offset management setting.
mbed_official 610:813dcc80987e 1073 * @param __OFFSET_NUMBER__: ADC offset management.
mbed_official 610:813dcc80987e 1074 * @retval SET (__OFFSET_NUMBER__ is valid) or RESET (__OFFSET_NUMBER__ is invalid)
mbed_official 610:813dcc80987e 1075 */
mbed_official 610:813dcc80987e 1076 #define IS_ADC_OFFSET_NUMBER(__OFFSET_NUMBER__) (((__OFFSET_NUMBER__) == ADC_OFFSET_NONE) || \
mbed_official 610:813dcc80987e 1077 ((__OFFSET_NUMBER__) == ADC_OFFSET_1) || \
mbed_official 610:813dcc80987e 1078 ((__OFFSET_NUMBER__) == ADC_OFFSET_2) || \
mbed_official 610:813dcc80987e 1079 ((__OFFSET_NUMBER__) == ADC_OFFSET_3) || \
mbed_official 610:813dcc80987e 1080 ((__OFFSET_NUMBER__) == ADC_OFFSET_4) )
mbed_official 610:813dcc80987e 1081
mbed_official 610:813dcc80987e 1082 /**
mbed_official 610:813dcc80987e 1083 * @brief Verify the ADC regular channel setting.
mbed_official 610:813dcc80987e 1084 * @param __CHANNEL__: programmed ADC regular channel.
mbed_official 610:813dcc80987e 1085 * @retval SET (__CHANNEL__ is valid) or RESET (__CHANNEL__ is invalid)
mbed_official 610:813dcc80987e 1086 */
mbed_official 610:813dcc80987e 1087 #define IS_ADC_REGULAR_RANK(__CHANNEL__) (((__CHANNEL__) == ADC_REGULAR_RANK_1 ) || \
mbed_official 610:813dcc80987e 1088 ((__CHANNEL__) == ADC_REGULAR_RANK_2 ) || \
mbed_official 610:813dcc80987e 1089 ((__CHANNEL__) == ADC_REGULAR_RANK_3 ) || \
mbed_official 610:813dcc80987e 1090 ((__CHANNEL__) == ADC_REGULAR_RANK_4 ) || \
mbed_official 610:813dcc80987e 1091 ((__CHANNEL__) == ADC_REGULAR_RANK_5 ) || \
mbed_official 610:813dcc80987e 1092 ((__CHANNEL__) == ADC_REGULAR_RANK_6 ) || \
mbed_official 610:813dcc80987e 1093 ((__CHANNEL__) == ADC_REGULAR_RANK_7 ) || \
mbed_official 610:813dcc80987e 1094 ((__CHANNEL__) == ADC_REGULAR_RANK_8 ) || \
mbed_official 610:813dcc80987e 1095 ((__CHANNEL__) == ADC_REGULAR_RANK_9 ) || \
mbed_official 610:813dcc80987e 1096 ((__CHANNEL__) == ADC_REGULAR_RANK_10) || \
mbed_official 610:813dcc80987e 1097 ((__CHANNEL__) == ADC_REGULAR_RANK_11) || \
mbed_official 610:813dcc80987e 1098 ((__CHANNEL__) == ADC_REGULAR_RANK_12) || \
mbed_official 610:813dcc80987e 1099 ((__CHANNEL__) == ADC_REGULAR_RANK_13) || \
mbed_official 610:813dcc80987e 1100 ((__CHANNEL__) == ADC_REGULAR_RANK_14) || \
mbed_official 610:813dcc80987e 1101 ((__CHANNEL__) == ADC_REGULAR_RANK_15) || \
mbed_official 610:813dcc80987e 1102 ((__CHANNEL__) == ADC_REGULAR_RANK_16) )
mbed_official 610:813dcc80987e 1103
mbed_official 610:813dcc80987e 1104
mbed_official 610:813dcc80987e 1105 /**
mbed_official 610:813dcc80987e 1106 * @brief Verify the ADC injected channel setting.
mbed_official 610:813dcc80987e 1107 * @param __CHANNEL__: programmed ADC injected channel.
mbed_official 610:813dcc80987e 1108 * @retval SET (__CHANNEL__ is valid) or RESET (__CHANNEL__ is invalid)
mbed_official 610:813dcc80987e 1109 */
mbed_official 610:813dcc80987e 1110 #define IS_ADC_INJECTED_RANK(__CHANNEL__) (((__CHANNEL__) == ADC_INJECTED_RANK_1) || \
mbed_official 610:813dcc80987e 1111 ((__CHANNEL__) == ADC_INJECTED_RANK_2) || \
mbed_official 610:813dcc80987e 1112 ((__CHANNEL__) == ADC_INJECTED_RANK_3) || \
mbed_official 610:813dcc80987e 1113 ((__CHANNEL__) == ADC_INJECTED_RANK_4) )
mbed_official 610:813dcc80987e 1114
mbed_official 610:813dcc80987e 1115 /**
mbed_official 610:813dcc80987e 1116 * @brief Verify the ADC edge trigger setting for injected group.
mbed_official 610:813dcc80987e 1117 * @param __EDGE__: programmed ADC edge trigger setting.
mbed_official 610:813dcc80987e 1118 * @retval SET (__EDGE__ is a valid value) or RESET (__EDGE__ is invalid)
mbed_official 610:813dcc80987e 1119 */
mbed_official 610:813dcc80987e 1120 #define IS_ADC_EXTTRIGINJEC_EDGE(__EDGE__) (((__EDGE__) == ADC_EXTERNALTRIGINJECCONV_EDGE_NONE) || \
mbed_official 610:813dcc80987e 1121 ((__EDGE__) == ADC_EXTERNALTRIGINJECCONV_EDGE_RISING) || \
mbed_official 610:813dcc80987e 1122 ((__EDGE__) == ADC_EXTERNALTRIGINJECCONV_EDGE_FALLING) || \
mbed_official 610:813dcc80987e 1123 ((__EDGE__) == ADC_EXTERNALTRIGINJECCONV_EDGE_RISINGFALLING) )
mbed_official 610:813dcc80987e 1124
mbed_official 610:813dcc80987e 1125
mbed_official 610:813dcc80987e 1126 /**
mbed_official 610:813dcc80987e 1127 * @brief Verify the ADC injected conversions external trigger.
mbed_official 610:813dcc80987e 1128 * @param __INJTRIG__: programmed ADC injected conversions external trigger.
mbed_official 610:813dcc80987e 1129 * @retval SET (__INJTRIG__ is a valid value) or RESET (__INJTRIG__ is invalid)
mbed_official 610:813dcc80987e 1130 */
mbed_official 610:813dcc80987e 1131 #define IS_ADC_EXTTRIGINJEC(__INJTRIG__) (((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T1_TRGO) || \
mbed_official 610:813dcc80987e 1132 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T1_CC4) || \
mbed_official 610:813dcc80987e 1133 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T2_TRGO) || \
mbed_official 610:813dcc80987e 1134 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T2_CC1) || \
mbed_official 610:813dcc80987e 1135 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T3_CC4) || \
mbed_official 610:813dcc80987e 1136 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T4_TRGO) || \
mbed_official 610:813dcc80987e 1137 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_EXT_IT15) || \
mbed_official 610:813dcc80987e 1138 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T8_CC4) || \
mbed_official 610:813dcc80987e 1139 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T1_TRGO2) || \
mbed_official 610:813dcc80987e 1140 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T8_TRGO) || \
mbed_official 610:813dcc80987e 1141 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T8_TRGO2) || \
mbed_official 610:813dcc80987e 1142 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T3_CC3) || \
mbed_official 610:813dcc80987e 1143 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T3_TRGO) || \
mbed_official 610:813dcc80987e 1144 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T3_CC1) || \
mbed_official 610:813dcc80987e 1145 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T6_TRGO) || \
mbed_official 610:813dcc80987e 1146 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T15_TRGO) || \
mbed_official 610:813dcc80987e 1147 \
mbed_official 610:813dcc80987e 1148 ((__INJTRIG__) == ADC_SOFTWARE_START) )
mbed_official 610:813dcc80987e 1149
mbed_official 610:813dcc80987e 1150
mbed_official 610:813dcc80987e 1151 /**
mbed_official 610:813dcc80987e 1152 * @brief Verify the ADC multimode setting.
mbed_official 610:813dcc80987e 1153 * @param __MODE__: programmed ADC multimode setting.
mbed_official 610:813dcc80987e 1154 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
mbed_official 610:813dcc80987e 1155 */
mbed_official 610:813dcc80987e 1156 #define IS_ADC_MULTIMODE(__MODE__) (((__MODE__) == ADC_MODE_INDEPENDENT) || \
mbed_official 610:813dcc80987e 1157 ((__MODE__) == ADC_DUALMODE_REGSIMULT_INJECSIMULT) || \
mbed_official 610:813dcc80987e 1158 ((__MODE__) == ADC_DUALMODE_REGSIMULT_ALTERTRIG) || \
mbed_official 610:813dcc80987e 1159 ((__MODE__) == ADC_DUALMODE_REGINTERL_INJECSIMULT) || \
mbed_official 610:813dcc80987e 1160 ((__MODE__) == ADC_DUALMODE_INJECSIMULT) || \
mbed_official 610:813dcc80987e 1161 ((__MODE__) == ADC_DUALMODE_REGSIMULT) || \
mbed_official 610:813dcc80987e 1162 ((__MODE__) == ADC_DUALMODE_INTERL) || \
mbed_official 610:813dcc80987e 1163 ((__MODE__) == ADC_DUALMODE_ALTERTRIG) )
mbed_official 610:813dcc80987e 1164
mbed_official 610:813dcc80987e 1165
mbed_official 610:813dcc80987e 1166 /**
mbed_official 610:813dcc80987e 1167 * @brief Verify the ADC multimode DMA access setting.
mbed_official 610:813dcc80987e 1168 * @param __MODE__: programmed ADC multimode DMA access setting.
mbed_official 610:813dcc80987e 1169 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
mbed_official 610:813dcc80987e 1170 */
mbed_official 610:813dcc80987e 1171 #define IS_ADC_DMA_ACCESS_MULTIMODE(__MODE__) (((__MODE__) == ADC_DMAACCESSMODE_DISABLED) || \
mbed_official 610:813dcc80987e 1172 ((__MODE__) == ADC_DMAACCESSMODE_12_10_BITS) || \
mbed_official 610:813dcc80987e 1173 ((__MODE__) == ADC_DMAACCESSMODE_8_6_BITS) )
mbed_official 610:813dcc80987e 1174
mbed_official 610:813dcc80987e 1175 /**
mbed_official 610:813dcc80987e 1176 * @brief Verify the ADC multimode delay setting.
mbed_official 610:813dcc80987e 1177 * @param __DELAY__: programmed ADC multimode delay setting.
mbed_official 610:813dcc80987e 1178 * @retval SET (__DELAY__ is a valid value) or RESET (__DELAY__ is invalid)
mbed_official 610:813dcc80987e 1179 */
mbed_official 610:813dcc80987e 1180 #define IS_ADC_SAMPLING_DELAY(__DELAY__) (((__DELAY__) == ADC_TWOSAMPLINGDELAY_1CYCLE) || \
mbed_official 610:813dcc80987e 1181 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_2CYCLES) || \
mbed_official 610:813dcc80987e 1182 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_3CYCLES) || \
mbed_official 610:813dcc80987e 1183 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_4CYCLES) || \
mbed_official 610:813dcc80987e 1184 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_5CYCLES) || \
mbed_official 610:813dcc80987e 1185 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_6CYCLES) || \
mbed_official 610:813dcc80987e 1186 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_7CYCLES) || \
mbed_official 610:813dcc80987e 1187 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_8CYCLES) || \
mbed_official 610:813dcc80987e 1188 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_9CYCLES) || \
mbed_official 610:813dcc80987e 1189 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_10CYCLES) || \
mbed_official 610:813dcc80987e 1190 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_11CYCLES) || \
mbed_official 610:813dcc80987e 1191 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_12CYCLES) )
mbed_official 610:813dcc80987e 1192
mbed_official 610:813dcc80987e 1193
mbed_official 610:813dcc80987e 1194 /**
mbed_official 610:813dcc80987e 1195 * @brief Verify the ADC analog watchdog setting.
mbed_official 610:813dcc80987e 1196 * @param __WATCHDOG__: programmed ADC analog watchdog setting.
mbed_official 610:813dcc80987e 1197 * @retval SET (__WATCHDOG__ is valid) or RESET (__WATCHDOG__ is invalid)
mbed_official 610:813dcc80987e 1198 */
mbed_official 610:813dcc80987e 1199 #define IS_ADC_ANALOG_WATCHDOG_NUMBER(__WATCHDOG__) (((__WATCHDOG__) == ADC_ANALOGWATCHDOG_1) || \
mbed_official 610:813dcc80987e 1200 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_2) || \
mbed_official 610:813dcc80987e 1201 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_3) )
mbed_official 610:813dcc80987e 1202
mbed_official 610:813dcc80987e 1203 /**
mbed_official 610:813dcc80987e 1204 * @brief Verify the ADC analog watchdog mode setting.
mbed_official 610:813dcc80987e 1205 * @param __WATCHDOG_MODE__: programmed ADC analog watchdog mode setting.
mbed_official 610:813dcc80987e 1206 * @retval SET (__WATCHDOG_MODE__ is valid) or RESET (__WATCHDOG_MODE__ is invalid)
mbed_official 610:813dcc80987e 1207 */
mbed_official 610:813dcc80987e 1208 #define IS_ADC_ANALOG_WATCHDOG_MODE(__WATCHDOG_MODE__) (((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_NONE) || \
mbed_official 610:813dcc80987e 1209 ((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_SINGLE_REG) || \
mbed_official 610:813dcc80987e 1210 ((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_SINGLE_INJEC) || \
mbed_official 610:813dcc80987e 1211 ((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC) || \
mbed_official 610:813dcc80987e 1212 ((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_ALL_REG) || \
mbed_official 610:813dcc80987e 1213 ((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_ALL_INJEC) || \
mbed_official 610:813dcc80987e 1214 ((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_ALL_REGINJEC) )
mbed_official 610:813dcc80987e 1215
mbed_official 610:813dcc80987e 1216 /**
mbed_official 610:813dcc80987e 1217 * @brief Verify the ADC conversion (regular or injected or both).
mbed_official 610:813dcc80987e 1218 * @param __CONVERSION__: ADC conversion group.
mbed_official 610:813dcc80987e 1219 * @retval SET (__CONVERSION__ is valid) or RESET (__CONVERSION__ is invalid)
mbed_official 610:813dcc80987e 1220 */
mbed_official 610:813dcc80987e 1221 #define IS_ADC_CONVERSION_GROUP(__CONVERSION__) (((__CONVERSION__) == ADC_REGULAR_GROUP) || \
mbed_official 610:813dcc80987e 1222 ((__CONVERSION__) == ADC_INJECTED_GROUP) || \
mbed_official 610:813dcc80987e 1223 ((__CONVERSION__) == ADC_REGULAR_INJECTED_GROUP) )
mbed_official 610:813dcc80987e 1224
mbed_official 610:813dcc80987e 1225 /**
mbed_official 610:813dcc80987e 1226 * @brief Verify the ADC event type.
mbed_official 610:813dcc80987e 1227 * @param __EVENT__: ADC event.
mbed_official 610:813dcc80987e 1228 * @retval SET (__EVENT__ is valid) or RESET (__EVENT__ is invalid)
mbed_official 610:813dcc80987e 1229 */
mbed_official 610:813dcc80987e 1230 #define IS_ADC_EVENT_TYPE(__EVENT__) (((__EVENT__) == ADC_EOSMP_EVENT) || \
mbed_official 610:813dcc80987e 1231 ((__EVENT__) == ADC_AWD_EVENT) || \
mbed_official 610:813dcc80987e 1232 ((__EVENT__) == ADC_AWD2_EVENT) || \
mbed_official 610:813dcc80987e 1233 ((__EVENT__) == ADC_AWD3_EVENT) || \
mbed_official 610:813dcc80987e 1234 ((__EVENT__) == ADC_OVR_EVENT) || \
mbed_official 610:813dcc80987e 1235 ((__EVENT__) == ADC_JQOVF_EVENT) )
mbed_official 610:813dcc80987e 1236
mbed_official 610:813dcc80987e 1237 /**
mbed_official 610:813dcc80987e 1238 * @brief Verify the ADC oversampling ratio.
mbed_official 610:813dcc80987e 1239 * @param __RATIO__: programmed ADC oversampling ratio.
mbed_official 610:813dcc80987e 1240 * @retval SET (__RATIO__ is a valid value) or RESET (__RATIO__ is invalid)
mbed_official 610:813dcc80987e 1241 */
mbed_official 610:813dcc80987e 1242 #define IS_ADC_OVERSAMPLING_RATIO(__RATIO__) (((__RATIO__) == ADC_OVERSAMPLING_RATIO_2 ) || \
mbed_official 610:813dcc80987e 1243 ((__RATIO__) == ADC_OVERSAMPLING_RATIO_4 ) || \
mbed_official 610:813dcc80987e 1244 ((__RATIO__) == ADC_OVERSAMPLING_RATIO_8 ) || \
mbed_official 610:813dcc80987e 1245 ((__RATIO__) == ADC_OVERSAMPLING_RATIO_16 ) || \
mbed_official 610:813dcc80987e 1246 ((__RATIO__) == ADC_OVERSAMPLING_RATIO_32 ) || \
mbed_official 610:813dcc80987e 1247 ((__RATIO__) == ADC_OVERSAMPLING_RATIO_64 ) || \
mbed_official 610:813dcc80987e 1248 ((__RATIO__) == ADC_OVERSAMPLING_RATIO_128 ) || \
mbed_official 610:813dcc80987e 1249 ((__RATIO__) == ADC_OVERSAMPLING_RATIO_256 ))
mbed_official 610:813dcc80987e 1250
mbed_official 610:813dcc80987e 1251 /**
mbed_official 610:813dcc80987e 1252 * @brief Verify the ADC oversampling shift.
mbed_official 610:813dcc80987e 1253 * @param __SHIFT__: programmed ADC oversampling shift.
mbed_official 610:813dcc80987e 1254 * @retval SET (__SHIFT__ is a valid value) or RESET (__SHIFT__ is invalid)
mbed_official 610:813dcc80987e 1255 */
mbed_official 610:813dcc80987e 1256 #define IS_ADC_RIGHT_BIT_SHIFT(__SHIFT__) (((__SHIFT__) == ADC_RIGHTBITSHIFT_NONE) || \
mbed_official 610:813dcc80987e 1257 ((__SHIFT__) == ADC_RIGHTBITSHIFT_1 ) || \
mbed_official 610:813dcc80987e 1258 ((__SHIFT__) == ADC_RIGHTBITSHIFT_2 ) || \
mbed_official 610:813dcc80987e 1259 ((__SHIFT__) == ADC_RIGHTBITSHIFT_3 ) || \
mbed_official 610:813dcc80987e 1260 ((__SHIFT__) == ADC_RIGHTBITSHIFT_4 ) || \
mbed_official 610:813dcc80987e 1261 ((__SHIFT__) == ADC_RIGHTBITSHIFT_5 ) || \
mbed_official 610:813dcc80987e 1262 ((__SHIFT__) == ADC_RIGHTBITSHIFT_6 ) || \
mbed_official 610:813dcc80987e 1263 ((__SHIFT__) == ADC_RIGHTBITSHIFT_7 ) || \
mbed_official 610:813dcc80987e 1264 ((__SHIFT__) == ADC_RIGHTBITSHIFT_8 ))
mbed_official 610:813dcc80987e 1265
mbed_official 610:813dcc80987e 1266 /**
mbed_official 610:813dcc80987e 1267 * @brief Verify the ADC oversampling triggered mode.
mbed_official 610:813dcc80987e 1268 * @param __MODE__: programmed ADC oversampling triggered mode.
mbed_official 610:813dcc80987e 1269 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
mbed_official 610:813dcc80987e 1270 */
mbed_official 610:813dcc80987e 1271 #define IS_ADC_TRIGGERED_OVERSAMPLING_MODE(__MODE__) (((__MODE__) == ADC_TRIGGEREDMODE_SINGLE_TRIGGER) || \
mbed_official 610:813dcc80987e 1272 ((__MODE__) == ADC_TRIGGEREDMODE_MULTI_TRIGGER) )
mbed_official 610:813dcc80987e 1273
mbed_official 610:813dcc80987e 1274 /**
mbed_official 610:813dcc80987e 1275 * @brief Verify the ADC oversampling regular conversion resumed or continued mode.
mbed_official 610:813dcc80987e 1276 * @param __MODE__: programmed ADC oversampling regular conversion resumed or continued mode.
mbed_official 610:813dcc80987e 1277 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
mbed_official 610:813dcc80987e 1278 */
mbed_official 610:813dcc80987e 1279 #define IS_ADC_REGOVERSAMPLING_MODE(__MODE__) (((__MODE__) == ADC_REGOVERSAMPLING_CONTINUED_MODE) || \
mbed_official 610:813dcc80987e 1280 ((__MODE__) == ADC_REGOVERSAMPLING_RESUMED_MODE) )
mbed_official 610:813dcc80987e 1281
mbed_official 610:813dcc80987e 1282 /**
mbed_official 610:813dcc80987e 1283 * @}
mbed_official 610:813dcc80987e 1284 */
mbed_official 610:813dcc80987e 1285
mbed_official 610:813dcc80987e 1286
mbed_official 610:813dcc80987e 1287 /* Exported functions --------------------------------------------------------*/
mbed_official 610:813dcc80987e 1288 /** @addtogroup ADCEx_Exported_Functions ADC Extended Exported Functions
mbed_official 610:813dcc80987e 1289 * @{
mbed_official 610:813dcc80987e 1290 */
mbed_official 610:813dcc80987e 1291
mbed_official 610:813dcc80987e 1292 /* Initialization/de-initialization functions *********************************/
mbed_official 610:813dcc80987e 1293
mbed_official 610:813dcc80987e 1294 /** @addtogroup ADCEx_Exported_Functions_Group1 Extended Input and Output operation functions
mbed_official 610:813dcc80987e 1295 * @brief Extended IO operation functions
mbed_official 610:813dcc80987e 1296 * @{
mbed_official 610:813dcc80987e 1297 */
mbed_official 610:813dcc80987e 1298 /* I/O operation functions ****************************************************/
mbed_official 610:813dcc80987e 1299
mbed_official 610:813dcc80987e 1300 /* ADC calibration */
mbed_official 610:813dcc80987e 1301
mbed_official 610:813dcc80987e 1302 HAL_StatusTypeDef HAL_ADCEx_Calibration_Start(ADC_HandleTypeDef* hadc, uint32_t SingleDiff);
mbed_official 610:813dcc80987e 1303 uint32_t HAL_ADCEx_Calibration_GetValue(ADC_HandleTypeDef *hadc, uint32_t SingleDiff);
mbed_official 610:813dcc80987e 1304 HAL_StatusTypeDef HAL_ADCEx_Calibration_SetValue(ADC_HandleTypeDef *hadc, uint32_t SingleDiff, uint32_t CalibrationFactor);
mbed_official 610:813dcc80987e 1305
mbed_official 610:813dcc80987e 1306
mbed_official 610:813dcc80987e 1307
mbed_official 610:813dcc80987e 1308 /* Blocking mode: Polling */
mbed_official 610:813dcc80987e 1309 HAL_StatusTypeDef HAL_ADCEx_InjectedStart(ADC_HandleTypeDef* hadc);
mbed_official 610:813dcc80987e 1310 HAL_StatusTypeDef HAL_ADCEx_InjectedStop(ADC_HandleTypeDef* hadc);
mbed_official 610:813dcc80987e 1311 HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
mbed_official 610:813dcc80987e 1312
mbed_official 610:813dcc80987e 1313 /* Non-blocking mode: Interruption */
mbed_official 610:813dcc80987e 1314 HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT(ADC_HandleTypeDef* hadc);
mbed_official 610:813dcc80987e 1315 HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT(ADC_HandleTypeDef* hadc);
mbed_official 610:813dcc80987e 1316
mbed_official 610:813dcc80987e 1317
mbed_official 610:813dcc80987e 1318 /* ADC multimode */
mbed_official 610:813dcc80987e 1319 HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef *hadc, uint32_t *pData, uint32_t Length);
mbed_official 610:813dcc80987e 1320 HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA(ADC_HandleTypeDef *hadc);
mbed_official 610:813dcc80987e 1321 uint32_t HAL_ADCEx_MultiModeGetValue(ADC_HandleTypeDef *hadc);
mbed_official 610:813dcc80987e 1322
mbed_official 610:813dcc80987e 1323
mbed_official 610:813dcc80987e 1324 /* ADC retrieve conversion value intended to be used with polling or interruption */
mbed_official 610:813dcc80987e 1325 uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t InjectedRank);
mbed_official 610:813dcc80987e 1326
mbed_official 610:813dcc80987e 1327 /* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption) */
mbed_official 610:813dcc80987e 1328 void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc);
mbed_official 610:813dcc80987e 1329 void HAL_ADCEx_InjectedQueueOverflowCallback(ADC_HandleTypeDef* hadc);
mbed_official 610:813dcc80987e 1330 void HAL_ADCEx_LevelOutOfWindow2Callback(ADC_HandleTypeDef* hadc);
mbed_official 610:813dcc80987e 1331 void HAL_ADCEx_LevelOutOfWindow3Callback(ADC_HandleTypeDef* hadc);
mbed_official 610:813dcc80987e 1332 void HAL_ADCEx_EndOfSamplingCallback(ADC_HandleTypeDef* hadc);
mbed_official 610:813dcc80987e 1333
mbed_official 610:813dcc80987e 1334
mbed_official 610:813dcc80987e 1335 /* ADC Regular conversions stop */
mbed_official 610:813dcc80987e 1336 HAL_StatusTypeDef HAL_ADCEx_RegularStop(ADC_HandleTypeDef* hadc);
mbed_official 610:813dcc80987e 1337 HAL_StatusTypeDef HAL_ADCEx_RegularStop_IT(ADC_HandleTypeDef* hadc);
mbed_official 610:813dcc80987e 1338 HAL_StatusTypeDef HAL_ADCEx_RegularStop_DMA(ADC_HandleTypeDef* hadc);
mbed_official 610:813dcc80987e 1339 HAL_StatusTypeDef HAL_ADCEx_RegularMultiModeStop_DMA(ADC_HandleTypeDef* hadc);
mbed_official 610:813dcc80987e 1340
mbed_official 610:813dcc80987e 1341 /**
mbed_official 610:813dcc80987e 1342 * @}
mbed_official 610:813dcc80987e 1343 */
mbed_official 610:813dcc80987e 1344
mbed_official 610:813dcc80987e 1345 /** @addtogroup ADCEx_Exported_Functions_Group2 Extended Peripheral Control functions
mbed_official 610:813dcc80987e 1346 * @brief Extended Peripheral Control functions
mbed_official 610:813dcc80987e 1347 * @{
mbed_official 610:813dcc80987e 1348 */
mbed_official 610:813dcc80987e 1349 /* Peripheral Control functions ***********************************************/
mbed_official 610:813dcc80987e 1350 HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef* hadc,ADC_InjectionConfTypeDef* sConfigInjected);
mbed_official 610:813dcc80987e 1351 HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel(ADC_HandleTypeDef *hadc, ADC_MultiModeTypeDef *multimode);
mbed_official 610:813dcc80987e 1352 HAL_StatusTypeDef HAL_ADCEx_EnableInjectedQueue(ADC_HandleTypeDef* hadc);
mbed_official 610:813dcc80987e 1353 HAL_StatusTypeDef HAL_ADCEx_DisableInjectedQueue(ADC_HandleTypeDef* hadc);
mbed_official 610:813dcc80987e 1354 HAL_StatusTypeDef HAL_ADCEx_DisableVoltageRegulator(ADC_HandleTypeDef* hadc);
mbed_official 610:813dcc80987e 1355 HAL_StatusTypeDef HAL_ADCEx_EnterADCDeepPowerDownMode(ADC_HandleTypeDef* hadc);
mbed_official 610:813dcc80987e 1356
mbed_official 610:813dcc80987e 1357 /**
mbed_official 610:813dcc80987e 1358 * @}
mbed_official 610:813dcc80987e 1359 */
mbed_official 610:813dcc80987e 1360
mbed_official 610:813dcc80987e 1361 /**
mbed_official 610:813dcc80987e 1362 * @}
mbed_official 610:813dcc80987e 1363 */
mbed_official 610:813dcc80987e 1364
mbed_official 610:813dcc80987e 1365 /**
mbed_official 610:813dcc80987e 1366 * @}
mbed_official 610:813dcc80987e 1367 */
mbed_official 610:813dcc80987e 1368
mbed_official 610:813dcc80987e 1369 /**
mbed_official 610:813dcc80987e 1370 * @}
mbed_official 610:813dcc80987e 1371 */
mbed_official 610:813dcc80987e 1372
mbed_official 610:813dcc80987e 1373 #ifdef __cplusplus
mbed_official 610:813dcc80987e 1374 }
mbed_official 610:813dcc80987e 1375 #endif
mbed_official 610:813dcc80987e 1376
mbed_official 610:813dcc80987e 1377 #endif /*__STM32L4xx_ADC_EX_H */
mbed_official 610:813dcc80987e 1378
mbed_official 610:813dcc80987e 1379
mbed_official 610:813dcc80987e 1380 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/