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

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

mbed 2

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

Committer:
<>
Date:
Wed Apr 12 16:07:08 2017 +0100
Revision:
140:97feb9bacc10
Parent:
128:9bcdf88f62b0
Child:
145:64910690c574
Release 140 of the mbed library

Ports for Upcoming Targets

3841: Add nRf52840 target https://github.com/ARMmbed/mbed-os/pull/3841
3992: Introducing UBLOX_C030 platform. https://github.com/ARMmbed/mbed-os/pull/3992

Fixes and Changes

3951: [NUCLEO_F303ZE] Correct ARDUINO pin https://github.com/ARMmbed/mbed-os/pull/3951
4021: Fixing a macro to detect when RTOS was in use for the NRF52840_DK https://github.com/ARMmbed/mbed-os/pull/4021
3979: KW24D: Add missing SPI defines and Arduino connector definitions https://github.com/ARMmbed/mbed-os/pull/3979
3990: UBLOX_C027: construct a ticker-based wait, rather than calling wait_ms(), in the https://github.com/ARMmbed/mbed-os/pull/3990
4003: Fixed OBOE in async serial tx for NRF52 target, fixes #4002 https://github.com/ARMmbed/mbed-os/pull/4003
4012: STM32: Correct I2C master error handling https://github.com/ARMmbed/mbed-os/pull/4012
4020: NUCLEO_L011K4 remove unsupported tool chain files https://github.com/ARMmbed/mbed-os/pull/4020
4065: K66F: Move bss section to m_data_2 Section https://github.com/ARMmbed/mbed-os/pull/4065
4014: Issue 3763: Reduce heap allocation in the GCC linker file https://github.com/ARMmbed/mbed-os/pull/4014
4030: [STM32L0] reduce IAR heap and stack size for small targets https://github.com/ARMmbed/mbed-os/pull/4030
4109: NUCLEO_L476RG : minor serial pin update https://github.com/ARMmbed/mbed-os/pull/4109
3982: Ticker - kl25z bugfix for handling events in the past https://github.com/ARMmbed/mbed-os/pull/3982

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 122:f9eeca106725 1 /**
Kojto 122:f9eeca106725 2 ******************************************************************************
Kojto 122:f9eeca106725 3 * @file stm32l4xx_hal_adc_ex.h
Kojto 122:f9eeca106725 4 * @author MCD Application Team
Kojto 122:f9eeca106725 5 * @version V1.5.1
Kojto 122:f9eeca106725 6 * @date 31-May-2016
Kojto 122:f9eeca106725 7 * @brief Header file of ADC HAL extended module.
Kojto 122:f9eeca106725 8 ******************************************************************************
Kojto 122:f9eeca106725 9 * @attention
Kojto 122:f9eeca106725 10 *
Kojto 122:f9eeca106725 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Kojto 122:f9eeca106725 12 *
Kojto 122:f9eeca106725 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 122:f9eeca106725 14 * are permitted provided that the following conditions are met:
Kojto 122:f9eeca106725 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 122:f9eeca106725 16 * this list of conditions and the following disclaimer.
Kojto 122:f9eeca106725 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 122:f9eeca106725 18 * this list of conditions and the following disclaimer in the documentation
Kojto 122:f9eeca106725 19 * and/or other materials provided with the distribution.
Kojto 122:f9eeca106725 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 122:f9eeca106725 21 * may be used to endorse or promote products derived from this software
Kojto 122:f9eeca106725 22 * without specific prior written permission.
Kojto 122:f9eeca106725 23 *
Kojto 122:f9eeca106725 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 122:f9eeca106725 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 122:f9eeca106725 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 122:f9eeca106725 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 122:f9eeca106725 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 122:f9eeca106725 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 122:f9eeca106725 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 122:f9eeca106725 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 122:f9eeca106725 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 122:f9eeca106725 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 122:f9eeca106725 34 *
Kojto 122:f9eeca106725 35 ******************************************************************************
Kojto 122:f9eeca106725 36 */
Kojto 122:f9eeca106725 37
Kojto 122:f9eeca106725 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 122:f9eeca106725 39 #ifndef __STM32L4xx_ADC_EX_H
Kojto 122:f9eeca106725 40 #define __STM32L4xx_ADC_EX_H
Kojto 122:f9eeca106725 41
Kojto 122:f9eeca106725 42 #ifdef __cplusplus
Kojto 122:f9eeca106725 43 extern "C" {
Kojto 122:f9eeca106725 44 #endif
Kojto 122:f9eeca106725 45
Kojto 122:f9eeca106725 46 /* Includes ------------------------------------------------------------------*/
Kojto 122:f9eeca106725 47 #include "stm32l4xx_hal_def.h"
Kojto 122:f9eeca106725 48
Kojto 122:f9eeca106725 49 /** @addtogroup STM32L4xx_HAL_Driver
Kojto 122:f9eeca106725 50 * @{
Kojto 122:f9eeca106725 51 */
Kojto 122:f9eeca106725 52
Kojto 122:f9eeca106725 53 /** @addtogroup ADCEx ADCEx
Kojto 122:f9eeca106725 54 * @{
Kojto 122:f9eeca106725 55 */
Kojto 122:f9eeca106725 56
Kojto 122:f9eeca106725 57 /* Exported types ------------------------------------------------------------*/
Kojto 122:f9eeca106725 58 /** @defgroup ADCEx_Exported_Types ADC Extended Exported Types
Kojto 122:f9eeca106725 59 * @{
Kojto 122:f9eeca106725 60 */
Kojto 122:f9eeca106725 61
Kojto 122:f9eeca106725 62 /**
Kojto 122:f9eeca106725 63 * @brief Structure definition of ADC initialization and regular group
Kojto 122:f9eeca106725 64 * @note Parameters of this structure are shared within 2 scopes:
Kojto 122:f9eeca106725 65 * - Scope entire ADC (affects regular and injected groups): ClockPrescaler and ClockDivider, Resolution, DataAlign,
Kojto 122:f9eeca106725 66 * ScanConvMode, EOCSelection, LowPowerAutoWait.
Kojto 122:f9eeca106725 67 * - Scope regular group: ContinuousConvMode, NbrOfConversion, DiscontinuousConvMode, NbrOfDiscConversion, ExternalTrigConvEdge,
Kojto 122:f9eeca106725 68 * ExternalTrigConv, DMAContinuousRequests, Overrun, OversamplingMode, Oversampling.
Kojto 122:f9eeca106725 69 * @note The setting of these parameters by function HAL_ADC_Init() is conditioned by ADC state.
Kojto 122:f9eeca106725 70 * ADC state can be either:
Kojto 122:f9eeca106725 71 * - For all parameters: ADC disabled
Kojto 122:f9eeca106725 72 * - For all parameters except 'LowPowerAutoWait', 'DMAContinuousRequests' and 'Oversampling': ADC enabled without conversion on going on regular group.
Kojto 122:f9eeca106725 73 * - For parameters 'LowPowerAutoWait' and 'DMAContinuousRequests': ADC enabled without conversion on going on regular and injected groups.
Kojto 122:f9eeca106725 74 * If ADC is not in the appropriate state to modify some parameters, these parameters setting is bypassed
Kojto 122:f9eeca106725 75 * without error reporting (as it can be the expected behaviour in case of intended action to update another parameter
Kojto 122:f9eeca106725 76 * (which fulfills the ADC state condition) on the fly).
Kojto 122:f9eeca106725 77 */
Kojto 122:f9eeca106725 78 typedef struct
Kojto 122:f9eeca106725 79 {
Kojto 122:f9eeca106725 80 uint32_t ClockPrescaler; /*!< Selects ADC clock source (asynchronous System/PLLSAI1/PLLSAI2 clocks or synchronous AHB clock) as well as
Kojto 122:f9eeca106725 81 the division factor applied to the clock.
Kojto 122:f9eeca106725 82 This parameter can be a value of @ref ADC_ClockPrescaler.
Kojto 122:f9eeca106725 83 Note: The clock is common for all the ADCs.
Kojto 122:f9eeca106725 84 Note: In case of usage of channels on injected group, ADC frequency should be lower than AHB clock frequency /4 for resolution 12 or 10 bits,
Kojto 122:f9eeca106725 85 AHB clock frequency /3 for resolution 8 bits, AHB clock frequency /2 for resolution 6 bits.
Kojto 122:f9eeca106725 86 Note: In case of usage of the ADC dedicated PLL clock, this clock must be preliminarily enabled and prescaler set at RCC top level.
Kojto 122:f9eeca106725 87 Note: In case of synchronous clock mode based on HCLK/1, the configuration must be enabled only if the AHB clock prescaler is set to 1
Kojto 122:f9eeca106725 88 and if the system clock has a 50% duty cycle.
Kojto 122:f9eeca106725 89 Note: This parameter can be modified only if all ADCs are disabled. */
Kojto 122:f9eeca106725 90
Kojto 122:f9eeca106725 91 uint32_t Resolution; /*!< Configures the ADC resolution.
Kojto 122:f9eeca106725 92 This parameter can be a value of @ref ADC_Resolution */
Kojto 122:f9eeca106725 93
Kojto 122:f9eeca106725 94 uint32_t DataAlign; /*!< Specifies ADC data alignment (right or left).
Kojto 122:f9eeca106725 95 See reference manual for alignments formats versus resolutions.
Kojto 122:f9eeca106725 96 This parameter can be a value of @ref ADC_Data_align */
Kojto 122:f9eeca106725 97
Kojto 122:f9eeca106725 98 uint32_t ScanConvMode; /*!< Configures the sequencer of regular and injected groups.
Kojto 122:f9eeca106725 99 This parameter can be associated to parameter 'DiscontinuousConvMode' to have main sequence subdivided in successive parts.
Kojto 122:f9eeca106725 100 If disabled: Conversion is performed in single mode (one channel converted, that defined in rank 1).
Kojto 122:f9eeca106725 101 Parameters 'NbrOfConversion' and 'InjectedNbrOfConversion' are discarded (equivalent to set to 1).
Kojto 122:f9eeca106725 102 If enabled: Conversions are performed in sequence mode (multiple ranks defined by 'NbrOfConversion' or'InjectedNbrOfConversion').
Kojto 122:f9eeca106725 103 Scan direction is upward: from rank 1 to rank 'n'.
Kojto 122:f9eeca106725 104 This parameter can be a value of @ref ADC_Scan_mode */
Kojto 122:f9eeca106725 105
Kojto 122:f9eeca106725 106 uint32_t EOCSelection; /*!< Specifies which EOC (End Of Conversion) flag is used for conversion by polling and interruption: end of conversion of each rank or complete sequence.
Kojto 122:f9eeca106725 107 This parameter can be a value of @ref ADC_EOCSelection. */
Kojto 122:f9eeca106725 108
Kojto 122:f9eeca106725 109 uint32_t LowPowerAutoWait; /*!< Selects the dynamic low power Auto Delay: new conversion start only when the previous
Kojto 122:f9eeca106725 110 conversion (for regular group) or previous sequence (for injected group) has been processed by user software
Kojto 122:f9eeca106725 111 (EOC bit cleared or DR read for regular conversions, JEOS cleared for injected conversions).
Kojto 122:f9eeca106725 112 This feature automatically adapts the speed of ADC to the speed of the system that reads the data. Moreover, this avoids risk of overrun
Kojto 122:f9eeca106725 113 for low frequency applications.
Kojto 122:f9eeca106725 114 This parameter can be set to ENABLE or DISABLE.
Kojto 122:f9eeca106725 115 Note: Do not use with interruption or DMA (HAL_ADC_Start_IT(), HAL_ADC_Start_DMA(), HAL_ADCEx_InjectedStart_IT()) when it is necessary
Kojto 122:f9eeca106725 116 to clear immediately the EOC flag to free the IRQ vector sequencer.
Kojto 122:f9eeca106725 117 Do use with polling: 1. Start conversion with HAL_ADC_Start() or HAL_ADCEx_InjectedStart(), 2. When conversion data is available: use
Kojto 122:f9eeca106725 118 HAL_ADC_PollForConversion() to ensure that conversion is completed and HAL_ADC_GetValue() to retrieve conversion result and trig another
Kojto 122:f9eeca106725 119 conversion. For injected conversion, resort to HAL_ADCEx_InjectedPollForConversion() then HAL_ADCEx_InjectedGetValue() */
Kojto 122:f9eeca106725 120
Kojto 122:f9eeca106725 121 uint32_t ContinuousConvMode; /*!< Specifies whether the conversion is performed in single mode (one conversion) or continuous mode for regular group,
Kojto 122:f9eeca106725 122 after software start or external trigger occurred.
Kojto 122:f9eeca106725 123 This parameter can be set to ENABLE or DISABLE. */
Kojto 122:f9eeca106725 124
Kojto 122:f9eeca106725 125 uint32_t NbrOfConversion; /*!< Specifies the number of ranks that will be converted within the regular group sequencer.
Kojto 122:f9eeca106725 126 To use the regular group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
Kojto 122:f9eeca106725 127 This parameter must be a number between Min_Data = 1 and Max_Data = 16.
Kojto 122:f9eeca106725 128 Note: This parameter must be modified when no conversion is on going on regular group (ADC disabled, or ADC enabled without
Kojto 122:f9eeca106725 129 continuous mode or external trigger that could launch a conversion). */
Kojto 122:f9eeca106725 130
Kojto 122:f9eeca106725 131 uint32_t DiscontinuousConvMode; /*!< Specifies whether the conversions sequence of regular group is performed in Complete-sequence/Discontinuous-sequence (main sequence
Kojto 122:f9eeca106725 132 subdivided in successive parts).
Kojto 122:f9eeca106725 133 Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
Kojto 122:f9eeca106725 134 Discontinuous mode can be enabled only if continuous mode is disabled.
Kojto 122:f9eeca106725 135 This parameter can be set to ENABLE or DISABLE. */
Kojto 122:f9eeca106725 136
Kojto 122:f9eeca106725 137 uint32_t NbrOfDiscConversion; /*!< Specifies the number of discontinuous conversions in which the main sequence of regular group (parameter NbrOfConversion) will be subdivided.
Kojto 122:f9eeca106725 138 If parameter 'DiscontinuousConvMode' is disabled, this parameter is discarded.
Kojto 122:f9eeca106725 139 This parameter must be a number between Min_Data = 1 and Max_Data = 8. */
Kojto 122:f9eeca106725 140
Kojto 122:f9eeca106725 141 uint32_t ExternalTrigConv; /*!< Selects the external event used to trigger the conversion start of regular group.
Kojto 122:f9eeca106725 142 If set to ADC_SOFTWARE_START, external triggers are disabled and software trigger is used instead.
Kojto 122:f9eeca106725 143 This parameter can be a value of @ref ADC_Regular_External_Trigger_Source.
Kojto 122:f9eeca106725 144 Caution: external trigger source is common to ADCs. */
Kojto 122:f9eeca106725 145
Kojto 122:f9eeca106725 146 uint32_t ExternalTrigConvEdge; /*!< Selects the external trigger edge of regular group.
Kojto 122:f9eeca106725 147 If set to ADC_EXTERNALTRIGCONVEDGE_NONE, external triggers are disabled and software trigger is used instead.
Kojto 122:f9eeca106725 148 This parameter can be a value of @ref ADC_Regular_External_Trigger_Source_Edge */
Kojto 122:f9eeca106725 149
Kojto 122:f9eeca106725 150 uint32_t DMAContinuousRequests; /*!< Specifies whether the DMA requests are performed in one shot mode (DMA transfer stops when number of conversions is reached)
Kojto 122:f9eeca106725 151 or in Continuous mode (DMA transfer unlimited, whatever number of conversions).
Kojto 122:f9eeca106725 152 Note: In continuous mode, DMA must be configured in circular mode. Otherwise an overrun will be triggered when DMA buffer maximum pointer is reached.
Kojto 122:f9eeca106725 153 This parameter can be set to ENABLE or DISABLE.
Kojto 122:f9eeca106725 154 Note: This parameter must be modified when no conversion is on going on both regular and injected groups
Kojto 122:f9eeca106725 155 (ADC disabled, or ADC enabled without continuous mode or external trigger that could launch a conversion). */
Kojto 122:f9eeca106725 156
Kojto 122:f9eeca106725 157 uint32_t Overrun; /*!< Select the behaviour in case of overrun: data overwritten or preserved (default).
Kojto 122:f9eeca106725 158 This parameter applies to regular group only.
Kojto 122:f9eeca106725 159 This parameter can be a value of @ref ADC_Overrun.
Kojto 122:f9eeca106725 160 Note: Case of overrun set to data preserved and usage with end on conversion interruption (HAL_Start_IT()): ADC IRQ handler has to clear
Kojto 122:f9eeca106725 161 end of conversion flags, this induces the release of the preserved data. If needed, this data can be saved by user-developped function
Kojto 122:f9eeca106725 162 HAL_ADC_ConvCpltCallback() (called before end of conversion flags clear).
Kojto 122:f9eeca106725 163 Note: Error reporting with respect to the conversion mode:
Kojto 122:f9eeca106725 164 - Usage with ADC conversion by polling for event or interruption: Error is reported only if overrun is set to data preserved. If overrun is set to data
Kojto 122:f9eeca106725 165 overwritten, user can willingly not read all the converted data, this is not considered as an erroneous case.
Kojto 122:f9eeca106725 166 - Usage with ADC conversion by DMA: Error is reported whatever overrun setting (DMA is expected to process all data from data register). */
Kojto 122:f9eeca106725 167
Kojto 122:f9eeca106725 168 uint32_t OversamplingMode; /*!< Specifies whether the oversampling feature is enabled or disabled.
Kojto 122:f9eeca106725 169 This parameter can be set to ENABLE or DISABLE.
Kojto 122:f9eeca106725 170 Note: This parameter can be modified only if there is no conversion is ongoing (both ADSTART and JADSTART cleared). */
Kojto 122:f9eeca106725 171
Kojto 122:f9eeca106725 172 ADC_OversamplingTypeDef Oversampling; /*!< Specifies the Oversampling parameters.
Kojto 122:f9eeca106725 173 Caution: this setting overwrites the previous oversampling configuration if oversampling already enabled.
Kojto 122:f9eeca106725 174 Note: This parameter can be modified only if there is no conversion is ongoing (both ADSTART and JADSTART cleared). */
Kojto 122:f9eeca106725 175 }ADC_InitTypeDef;
Kojto 122:f9eeca106725 176
Kojto 122:f9eeca106725 177
Kojto 122:f9eeca106725 178 /**
Kojto 122:f9eeca106725 179 * @brief ADC handle Structure definition
Kojto 122:f9eeca106725 180 */
Kojto 122:f9eeca106725 181 typedef struct
Kojto 122:f9eeca106725 182 {
Kojto 122:f9eeca106725 183 ADC_TypeDef *Instance; /*!< Register base address */
Kojto 122:f9eeca106725 184
Kojto 122:f9eeca106725 185 ADC_InitTypeDef Init; /*!< ADC initialization parameters and regular conversions setting */
Kojto 122:f9eeca106725 186
Kojto 122:f9eeca106725 187 DMA_HandleTypeDef *DMA_Handle; /*!< Pointer DMA Handler */
Kojto 122:f9eeca106725 188
Kojto 122:f9eeca106725 189 HAL_LockTypeDef Lock; /*!< ADC locking object */
Kojto 122:f9eeca106725 190
Kojto 122:f9eeca106725 191 __IO uint32_t State; /*!< ADC communication state (bit-map of ADC states) */
Kojto 122:f9eeca106725 192
Kojto 122:f9eeca106725 193 __IO uint32_t ErrorCode; /*!< ADC Error code */
Kojto 122:f9eeca106725 194
Kojto 122:f9eeca106725 195 ADC_InjectionConfigTypeDef InjectionConfig ; /*!< ADC injected channel configuration build-up structure */
Kojto 122:f9eeca106725 196 }ADC_HandleTypeDef;
Kojto 122:f9eeca106725 197
Kojto 122:f9eeca106725 198
Kojto 122:f9eeca106725 199 /**
Kojto 122:f9eeca106725 200 * @brief ADC Injected Conversion Oversampling structure definition
Kojto 122:f9eeca106725 201 */
Kojto 122:f9eeca106725 202 typedef struct
Kojto 122:f9eeca106725 203 {
Kojto 122:f9eeca106725 204 uint32_t Ratio; /*!< Configures the oversampling ratio.
Kojto 122:f9eeca106725 205 This parameter can be a value of @ref ADCEx_Oversampling_Ratio */
Kojto 122:f9eeca106725 206
Kojto 122:f9eeca106725 207 uint32_t RightBitShift; /*!< Configures the division coefficient for the Oversampler.
Kojto 122:f9eeca106725 208 This parameter can be a value of @ref ADCEx_Right_Bit_Shift */
Kojto 122:f9eeca106725 209 }ADC_InjOversamplingTypeDef;
Kojto 122:f9eeca106725 210
Kojto 122:f9eeca106725 211
Kojto 122:f9eeca106725 212
Kojto 122:f9eeca106725 213 /**
Kojto 122:f9eeca106725 214 * @brief Structure definition of ADC injected group and ADC channel for injected group
Kojto 122:f9eeca106725 215 * @note Parameters of this structure are shared within 2 scopes:
Kojto 122:f9eeca106725 216 * - Scope channel: InjectedChannel, InjectedRank, InjectedSamplingTime , InjectedSingleDiff, InjectedOffsetNumber, InjectedOffset
Kojto 122:f9eeca106725 217 * - Scope injected group (affects all channels of injected group): InjectedNbrOfConversion, InjectedDiscontinuousConvMode,
Kojto 122:f9eeca106725 218 * AutoInjectedConv, QueueInjectedContext, ExternalTrigInjecConvEdge, ExternalTrigInjecConv, InjecOversamplingMode, InjecOversampling.
Kojto 122:f9eeca106725 219 * @note The setting of these parameters by function HAL_ADCEx_InjectedConfigChannel() is conditioned by ADC state.
Kojto 122:f9eeca106725 220 * ADC state can be either:
Kojto 122:f9eeca106725 221 * - For all parameters: ADC disabled (this is the only possible ADC state to modify parameter 'InjectedSingleDiff')
Kojto 122:f9eeca106725 222 * - For parameters 'InjectedDiscontinuousConvMode', 'QueueInjectedContext', 'InjecOversampling': ADC enabled without conversion on going on injected group.
Kojto 122:f9eeca106725 223 * - For parameters 'InjectedSamplingTime', 'InjectedOffset', 'InjectedOffsetNumber', 'AutoInjectedConv': ADC enabled without conversion on going on regular and injected groups.
Kojto 122:f9eeca106725 224 * - For parameters 'InjectedChannel', 'InjectedRank', 'InjectedNbrOfConversion', 'ExternalTrigInjecConv', 'ExternalTrigInjecConvEdge': ADC enabled and while conversion on going
Kojto 122:f9eeca106725 225 * on regular and injected groups.
Kojto 122:f9eeca106725 226 * If ADC is not in the appropriate state to modify some parameters, these parameters setting is bypassed
Kojto 122:f9eeca106725 227 * 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).
Kojto 122:f9eeca106725 228 */
Kojto 122:f9eeca106725 229 typedef struct
Kojto 122:f9eeca106725 230 {
Kojto 122:f9eeca106725 231 uint32_t InjectedChannel; /*!< Configure the ADC injected channel.
Kojto 122:f9eeca106725 232 This parameter can be a value of @ref ADC_channels
Kojto 122:f9eeca106725 233 Note: Depending on devices and ADC instances, some channels may not be available. Refer to device DataSheet for channels availability. */
Kojto 122:f9eeca106725 234 uint32_t InjectedRank; /*!< The rank in the injected group sequencer.
Kojto 122:f9eeca106725 235 This parameter must be a value of @ref ADCEx_injected_rank.
Kojto 122:f9eeca106725 236 Note: to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by
Kojto 122:f9eeca106725 237 the new channel setting (or parameter number of conversions adjusted). */
Kojto 122:f9eeca106725 238 uint32_t InjectedSamplingTime; /*!< Sampling time value to be set for the selected channel.
Kojto 122:f9eeca106725 239 Unit: ADC clock cycles.
Kojto 122:f9eeca106725 240 Conversion time is the addition of sampling time and processing time (12.5 ADC clock cycles at ADC resolution 12 bits, 10.5 cycles at 10 bits,
Kojto 122:f9eeca106725 241 8.5 cycles at 8 bits, 6.5 cycles at 6 bits).
Kojto 122:f9eeca106725 242 This parameter can be a value of @ref ADC_sampling_times.
Kojto 122:f9eeca106725 243 Caution: This parameter applies to a channel that can be used in a regular and/or injected group.
Kojto 122:f9eeca106725 244 It overwrites the last setting.
Kojto 122:f9eeca106725 245 Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor),
Kojto 122:f9eeca106725 246 sampling time constraints must be respected (sampling time can be adjusted with respect to the ADC clock frequency and sampling time
Kojto 122:f9eeca106725 247 setting). Refer to device DataSheet for timings values. */
Kojto 122:f9eeca106725 248 uint32_t InjectedSingleDiff; /*!< Selection of single-ended or differential input.
Kojto 122:f9eeca106725 249 In differential mode: Differential measurement is between the selected channel 'i' (positive input) and channel 'i+1' (negative input).
Kojto 122:f9eeca106725 250 Only channel 'i' has to be configured, channel 'i+1' is configured automatically.
Kojto 122:f9eeca106725 251 This parameter must be a value of @ref ADCEx_SingleDifferential.
Kojto 122:f9eeca106725 252 Caution: This parameter applies to a channel that can be used in a regular and/or injected group.
Kojto 122:f9eeca106725 253 It overwrites the last setting.
Kojto 122:f9eeca106725 254 Note: Refer to Reference Manual to ensure the selected channel is available in differential mode.
Kojto 122:f9eeca106725 255 Note: When configuring a channel 'i' in differential mode, the channel 'i+1' is not usable separately.
Kojto 122:f9eeca106725 256 Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion).
Kojto 122:f9eeca106725 257 If ADC is enabled, this parameter setting is bypassed without error reporting (as it can be the expected behaviour in case
Kojto 122:f9eeca106725 258 of another parameter update on the fly) */
Kojto 122:f9eeca106725 259 uint32_t InjectedOffsetNumber; /*!< Selects the offset number.
Kojto 122:f9eeca106725 260 This parameter can be a value of @ref ADCEx_OffsetNumber.
Kojto 122:f9eeca106725 261 Caution: Only one offset is allowed per channel. This parameter overwrites the last setting. */
Kojto 122:f9eeca106725 262 uint32_t InjectedOffset; /*!< Defines the offset to be subtracted from the raw converted data.
Kojto 122:f9eeca106725 263 Offset value must be a positive number.
Kojto 122:f9eeca106725 264 Depending of ADC resolution selected (12, 10, 8 or 6 bits), this parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF,
Kojto 122:f9eeca106725 265 0x3FF, 0xFF or 0x3F respectively.
Kojto 122:f9eeca106725 266 Note: This parameter must be modified when no conversion is on going on both regular and injected groups (ADC disabled, or ADC enabled
Kojto 122:f9eeca106725 267 without continuous mode or external trigger that could launch a conversion). */
Kojto 122:f9eeca106725 268 uint32_t InjectedNbrOfConversion; /*!< Specifies the number of ranks that will be converted within the injected group sequencer.
Kojto 122:f9eeca106725 269 To use the injected group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
Kojto 122:f9eeca106725 270 This parameter must be a number between Min_Data = 1 and Max_Data = 4.
Kojto 122:f9eeca106725 271 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
Kojto 122:f9eeca106725 272 configure a channel on injected group can impact the configuration of other channels previously set. */
Kojto 122:f9eeca106725 273 uint32_t InjectedDiscontinuousConvMode; /*!< Specifies whether the conversions sequence of injected group is performed in Complete-sequence/Discontinuous-sequence (main sequence
Kojto 122:f9eeca106725 274 subdivided in successive parts).
Kojto 122:f9eeca106725 275 Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
Kojto 122:f9eeca106725 276 Discontinuous mode can be enabled only if continuous mode is disabled.
Kojto 122:f9eeca106725 277 This parameter can be set to ENABLE or DISABLE.
Kojto 122:f9eeca106725 278 Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion).
Kojto 122:f9eeca106725 279 Note: For injected group, discontinuous mode converts the sequence channel by channel (only one channel at a time).
Kojto 122:f9eeca106725 280 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
Kojto 122:f9eeca106725 281 configure a channel on injected group can impact the configuration of other channels previously set. */
Kojto 122:f9eeca106725 282 uint32_t AutoInjectedConv; /*!< Enables or disables the selected ADC automatic injected group conversion after regular one
Kojto 122:f9eeca106725 283 This parameter can be set to ENABLE or DISABLE.
Kojto 122:f9eeca106725 284 Note: To use Automatic injected conversion, discontinuous mode must be disabled ('DiscontinuousConvMode' and 'InjectedDiscontinuousConvMode' set to DISABLE)
Kojto 122:f9eeca106725 285 Note: To use Automatic injected conversion, injected group external triggers must be disabled.
Kojto 122:f9eeca106725 286 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.
Kojto 122:f9eeca106725 287 To maintain JAUTO always enabled, DMA must be configured in circular mode.
Kojto 122:f9eeca106725 288 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
Kojto 122:f9eeca106725 289 configure a channel on injected group can impact the configuration of other channels previously set. */
Kojto 122:f9eeca106725 290 uint32_t QueueInjectedContext; /*!< Specifies whether the context queue feature is enabled.
Kojto 122:f9eeca106725 291 This parameter can be set to ENABLE or DISABLE.
Kojto 122:f9eeca106725 292 If context queue is enabled, injected sequencer&channels configurations are queued on up to 2 contexts. If a
Kojto 122:f9eeca106725 293 new injected context is set when queue is full, error is triggered by interruption and through function
Kojto 122:f9eeca106725 294 'HAL_ADCEx_InjectedQueueOverflowCallback'.
Kojto 122:f9eeca106725 295 Caution: This feature request that the sequence is fully configured before injected conversion start.
Kojto 122:f9eeca106725 296 Therefore, configure channels with as many calls to HAL_ADCEx_InjectedConfigChannel() as the 'InjectedNbrOfConversion' parameter.
Kojto 122:f9eeca106725 297 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
Kojto 122:f9eeca106725 298 configure a channel on injected group can impact the configuration of other channels previously set.
Kojto 122:f9eeca106725 299 Note: This parameter must be modified when ADC is disabled (before ADC start conversion or after ADC stop conversion). */
Kojto 122:f9eeca106725 300 uint32_t ExternalTrigInjecConv; /*!< Selects the external event used to trigger the conversion start of injected group.
Kojto 122:f9eeca106725 301 If set to ADC_INJECTED_SOFTWARE_START, external triggers are disabled and software trigger is used instead.
Kojto 122:f9eeca106725 302 This parameter can be a value of @ref ADCEx_Injected_External_Trigger_Source.
Kojto 122:f9eeca106725 303 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
Kojto 122:f9eeca106725 304 configure a channel on injected group can impact the configuration of other channels previously set. */
Kojto 122:f9eeca106725 305 uint32_t ExternalTrigInjecConvEdge; /*!< Selects the external trigger edge of injected group.
Kojto 122:f9eeca106725 306 This parameter can be a value of @ref ADCEx_Injected_External_Trigger_Source_Edge.
Kojto 122:f9eeca106725 307 If trigger edge is set to ADC_EXTERNALTRIGINJECCONV_EDGE_NONE, external triggers are disabled and software trigger is used instead.
Kojto 122:f9eeca106725 308 Caution: this setting impacts the entire injected group. Therefore, call of HAL_ADCEx_InjectedConfigChannel() to
Kojto 122:f9eeca106725 309 configure a channel on injected group can impact the configuration of other channels previously set. */
Kojto 122:f9eeca106725 310
Kojto 122:f9eeca106725 311 uint32_t InjecOversamplingMode; /*!< Specifies whether the oversampling feature is enabled or disabled.
Kojto 122:f9eeca106725 312 This parameter can be set to ENABLE or DISABLE.
Kojto 122:f9eeca106725 313 Note: This parameter can be modified only if there is no conversion is ongoing (both ADSTART and JADSTART cleared). */
Kojto 122:f9eeca106725 314
Kojto 122:f9eeca106725 315 ADC_InjOversamplingTypeDef InjecOversampling; /*!< Specifies the Oversampling parameters.
Kojto 122:f9eeca106725 316 Caution: this setting overwrites the previous oversampling configuration if oversampling already enabled.
Kojto 122:f9eeca106725 317 Note: This parameter can be modified only if there is no conversion is ongoing (both ADSTART and JADSTART cleared). */
Kojto 122:f9eeca106725 318 }ADC_InjectionConfTypeDef;
Kojto 122:f9eeca106725 319
Kojto 122:f9eeca106725 320
Kojto 122:f9eeca106725 321 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 322 /**
Kojto 122:f9eeca106725 323 * @brief Structure definition of ADC multimode
Kojto 122:f9eeca106725 324 * @note The setting of these parameters by function HAL_ADCEx_MultiModeConfigChannel() is conditioned by ADCs state (both Master and Slave ADCs).
Kojto 122:f9eeca106725 325 * Both Master and Slave ADCs must be disabled.
Kojto 122:f9eeca106725 326 */
Kojto 122:f9eeca106725 327 typedef struct
Kojto 122:f9eeca106725 328 {
Kojto 122:f9eeca106725 329 uint32_t Mode; /*!< Configures the ADC to operate in independent or multimode.
Kojto 122:f9eeca106725 330 This parameter can be a value of @ref ADCEx_Common_mode. */
Kojto 122:f9eeca106725 331 uint32_t DMAAccessMode; /*!< Configures the DMA mode for multimode ADC:
Kojto 122:f9eeca106725 332 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)
Kojto 122:f9eeca106725 333 This parameter can be a value of @ref ADCEx_Direct_memory_access_mode_for_multimode. */
Kojto 122:f9eeca106725 334 uint32_t TwoSamplingDelay; /*!< Configures the Delay between 2 sampling phases.
Kojto 122:f9eeca106725 335 This parameter can be a value of @ref ADCEx_delay_between_2_sampling_phases.
Kojto 122:f9eeca106725 336 Delay range depends on selected resolution:
Kojto 122:f9eeca106725 337 from 1 to 12 clock cycles for 12 bits, from 1 to 10 clock cycles for 10 bits,
Kojto 122:f9eeca106725 338 from 1 to 8 clock cycles for 8 bits, from 1 to 6 clock cycles for 6 bits. */
Kojto 122:f9eeca106725 339 }ADC_MultiModeTypeDef;
Kojto 122:f9eeca106725 340 #endif /* defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) */
Kojto 122:f9eeca106725 341
Kojto 122:f9eeca106725 342 /**
Kojto 122:f9eeca106725 343 * @}
Kojto 122:f9eeca106725 344 */
Kojto 122:f9eeca106725 345
Kojto 122:f9eeca106725 346 /* Exported constants --------------------------------------------------------*/
Kojto 122:f9eeca106725 347
Kojto 122:f9eeca106725 348 /** @defgroup ADCEx_Exported_Constants ADC Extended Exported Constants
Kojto 122:f9eeca106725 349 * @{
Kojto 122:f9eeca106725 350 */
Kojto 122:f9eeca106725 351
Kojto 122:f9eeca106725 352 /** @defgroup ADCEx_SingleDifferential ADC Extended Single-ended/Differential input mode
Kojto 122:f9eeca106725 353 * @{
Kojto 122:f9eeca106725 354 */
Kojto 122:f9eeca106725 355 #define ADC_SINGLE_ENDED ((uint32_t)0x00000000) /*!< ADC channel set in single-ended input mode */
Kojto 122:f9eeca106725 356 #define ADC_DIFFERENTIAL_ENDED ((uint32_t)ADC_CR_ADCALDIF) /*!< ADC channel set in differential mode */
Kojto 122:f9eeca106725 357 /**
Kojto 122:f9eeca106725 358 * @}
Kojto 122:f9eeca106725 359 */
Kojto 122:f9eeca106725 360
Kojto 122:f9eeca106725 361 /** @defgroup ADCEx_OffsetNumber ADC Extended Offset Number
Kojto 122:f9eeca106725 362 * @{
Kojto 122:f9eeca106725 363 */
Kojto 122:f9eeca106725 364 #define ADC_OFFSET_NONE ((uint32_t)0x00) /*!< No offset correction */
Kojto 122:f9eeca106725 365 #define ADC_OFFSET_1 ((uint32_t)0x01) /*!< Offset correction to apply to a first channel */
Kojto 122:f9eeca106725 366 #define ADC_OFFSET_2 ((uint32_t)0x02) /*!< Offset correction to apply to a second channel */
Kojto 122:f9eeca106725 367 #define ADC_OFFSET_3 ((uint32_t)0x03) /*!< Offset correction to apply to a third channel */
Kojto 122:f9eeca106725 368 #define ADC_OFFSET_4 ((uint32_t)0x04) /*!< Offset correction to apply to a fourth channel */
Kojto 122:f9eeca106725 369 /**
Kojto 122:f9eeca106725 370 * @}
Kojto 122:f9eeca106725 371 */
Kojto 122:f9eeca106725 372
Kojto 122:f9eeca106725 373 /** @defgroup ADCEx_regular_rank ADC Extended Regular Channel Rank
Kojto 122:f9eeca106725 374 * @{
Kojto 122:f9eeca106725 375 */
Kojto 122:f9eeca106725 376 #define ADC_REGULAR_RANK_1 ((uint32_t)0x00000001) /*!< ADC regular conversion rank 1 */
Kojto 122:f9eeca106725 377 #define ADC_REGULAR_RANK_2 ((uint32_t)0x00000002) /*!< ADC regular conversion rank 2 */
Kojto 122:f9eeca106725 378 #define ADC_REGULAR_RANK_3 ((uint32_t)0x00000003) /*!< ADC regular conversion rank 3 */
Kojto 122:f9eeca106725 379 #define ADC_REGULAR_RANK_4 ((uint32_t)0x00000004) /*!< ADC regular conversion rank 4 */
Kojto 122:f9eeca106725 380 #define ADC_REGULAR_RANK_5 ((uint32_t)0x00000005) /*!< ADC regular conversion rank 5 */
Kojto 122:f9eeca106725 381 #define ADC_REGULAR_RANK_6 ((uint32_t)0x00000006) /*!< ADC regular conversion rank 6 */
Kojto 122:f9eeca106725 382 #define ADC_REGULAR_RANK_7 ((uint32_t)0x00000007) /*!< ADC regular conversion rank 7 */
Kojto 122:f9eeca106725 383 #define ADC_REGULAR_RANK_8 ((uint32_t)0x00000008) /*!< ADC regular conversion rank 8 */
Kojto 122:f9eeca106725 384 #define ADC_REGULAR_RANK_9 ((uint32_t)0x00000009) /*!< ADC regular conversion rank 9 */
Kojto 122:f9eeca106725 385 #define ADC_REGULAR_RANK_10 ((uint32_t)0x0000000A) /*!< ADC regular conversion rank 10 */
Kojto 122:f9eeca106725 386 #define ADC_REGULAR_RANK_11 ((uint32_t)0x0000000B) /*!< ADC regular conversion rank 11 */
Kojto 122:f9eeca106725 387 #define ADC_REGULAR_RANK_12 ((uint32_t)0x0000000C) /*!< ADC regular conversion rank 12 */
Kojto 122:f9eeca106725 388 #define ADC_REGULAR_RANK_13 ((uint32_t)0x0000000D) /*!< ADC regular conversion rank 13 */
Kojto 122:f9eeca106725 389 #define ADC_REGULAR_RANK_14 ((uint32_t)0x0000000E) /*!< ADC regular conversion rank 14 */
Kojto 122:f9eeca106725 390 #define ADC_REGULAR_RANK_15 ((uint32_t)0x0000000F) /*!< ADC regular conversion rank 15 */
Kojto 122:f9eeca106725 391 #define ADC_REGULAR_RANK_16 ((uint32_t)0x00000010) /*!< ADC regular conversion rank 16 */
Kojto 122:f9eeca106725 392 /**
Kojto 122:f9eeca106725 393 * @}
Kojto 122:f9eeca106725 394 */
Kojto 122:f9eeca106725 395
Kojto 122:f9eeca106725 396 /** @defgroup ADCEx_injected_rank ADC Extended Injected Channel Rank
Kojto 122:f9eeca106725 397 * @{
Kojto 122:f9eeca106725 398 */
Kojto 122:f9eeca106725 399 #define ADC_INJECTED_RANK_1 ((uint32_t)0x00000001) /*!< ADC injected conversion rank 1 */
Kojto 122:f9eeca106725 400 #define ADC_INJECTED_RANK_2 ((uint32_t)0x00000002) /*!< ADC injected conversion rank 2 */
Kojto 122:f9eeca106725 401 #define ADC_INJECTED_RANK_3 ((uint32_t)0x00000003) /*!< ADC injected conversion rank 3 */
Kojto 122:f9eeca106725 402 #define ADC_INJECTED_RANK_4 ((uint32_t)0x00000004) /*!< ADC injected conversion rank 4 */
Kojto 122:f9eeca106725 403 /**injected
Kojto 122:f9eeca106725 404 * @}
Kojto 122:f9eeca106725 405 */
Kojto 122:f9eeca106725 406
Kojto 122:f9eeca106725 407 /** @defgroup ADCEx_Injected_External_Trigger_Source_Edge ADC External Trigger Source Edge for Injected Group
Kojto 122:f9eeca106725 408 * @{
Kojto 122:f9eeca106725 409 */
Kojto 122:f9eeca106725 410 #define ADC_EXTERNALTRIGINJECCONV_EDGE_NONE ((uint32_t)0x00000000) /*!< Injected conversions hardware trigger detection disabled */
Kojto 122:f9eeca106725 411 #define ADC_EXTERNALTRIGINJECCONV_EDGE_RISING ((uint32_t)ADC_JSQR_JEXTEN_0) /*!< Injected conversions hardware trigger detection on the rising edge */
Kojto 122:f9eeca106725 412 #define ADC_EXTERNALTRIGINJECCONV_EDGE_FALLING ((uint32_t)ADC_JSQR_JEXTEN_1) /*!< Injected conversions hardware trigger detection on the falling edge */
Kojto 122:f9eeca106725 413 #define ADC_EXTERNALTRIGINJECCONV_EDGE_RISINGFALLING ((uint32_t)ADC_JSQR_JEXTEN) /*!< Injected conversions hardware trigger detection on both the rising and falling edges */
Kojto 122:f9eeca106725 414 /**
Kojto 122:f9eeca106725 415 * @}
Kojto 122:f9eeca106725 416 */
Kojto 122:f9eeca106725 417
Kojto 122:f9eeca106725 418 /** @defgroup ADCEx_Injected_External_Trigger_Source ADC Extended External Trigger Source for Injected Group
Kojto 122:f9eeca106725 419 * @{
Kojto 122:f9eeca106725 420 */
Kojto 122:f9eeca106725 421 #define ADC_EXTERNALTRIGINJEC_T1_TRGO ((uint32_t)0x00000000) /*!< Event 0 triggers injected group conversion start */
Kojto 122:f9eeca106725 422 #define ADC_EXTERNALTRIGINJEC_T1_CC4 ((uint32_t)ADC_JSQR_JEXTSEL_0) /*!< Event 1 triggers injected group conversion start */
Kojto 122:f9eeca106725 423 #define ADC_EXTERNALTRIGINJEC_T2_TRGO ((uint32_t)ADC_JSQR_JEXTSEL_1) /*!< Event 2 triggers injected group conversion start */
Kojto 122:f9eeca106725 424 #define ADC_EXTERNALTRIGINJEC_T2_CC1 ((uint32_t)(ADC_JSQR_JEXTSEL_1 | ADC_JSQR_JEXTSEL_0)) /*!< Event 3 triggers injected group conversion start */
Kojto 122:f9eeca106725 425 #define ADC_EXTERNALTRIGINJEC_T3_CC4 ((uint32_t)ADC_JSQR_JEXTSEL_2) /*!< Event 4 triggers injected group conversion start */
Kojto 122:f9eeca106725 426 #define ADC_EXTERNALTRIGINJEC_T4_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_0)) /*!< Event 5 triggers injected group conversion start */
Kojto 122:f9eeca106725 427 #define ADC_EXTERNALTRIGINJEC_EXT_IT15 ((uint32_t)(ADC_JSQR_JEXTSEL_2 | ADC_JSQR_JEXTSEL_1)) /*!< Event 6 triggers injected group conversion start */
Kojto 122:f9eeca106725 428 #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 */
Kojto 122:f9eeca106725 429 #define ADC_EXTERNALTRIGINJEC_T1_TRGO2 ((uint32_t)ADC_JSQR_JEXTSEL_3) /*!< Event 8 triggers injected group conversion start */
Kojto 122:f9eeca106725 430 #define ADC_EXTERNALTRIGINJEC_T8_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_0)) /*!< Event 9 triggers injected group conversion start */
Kojto 122:f9eeca106725 431 #define ADC_EXTERNALTRIGINJEC_T8_TRGO2 ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_1)) /*!< Event 10 triggers injected group conversion start */
Kojto 122:f9eeca106725 432 #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 */
Kojto 122:f9eeca106725 433 #define ADC_EXTERNALTRIGINJEC_T3_TRGO ((uint32_t)(ADC_JSQR_JEXTSEL_3 | ADC_JSQR_JEXTSEL_2)) /*!< Event 12 triggers injected group conversion start */
Kojto 122:f9eeca106725 434 #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 */
Kojto 122:f9eeca106725 435 #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 */
Kojto 122:f9eeca106725 436 #define ADC_EXTERNALTRIGINJEC_T15_TRGO ((uint32_t)ADC_JSQR_JEXTSEL) /*!< Event 15 triggers injected group conversion start */
Kojto 122:f9eeca106725 437
Kojto 122:f9eeca106725 438 #define ADC_INJECTED_SOFTWARE_START ((uint32_t)0x00000001) /*!< Software triggers injected group conversion start */
Kojto 122:f9eeca106725 439 /**
Kojto 122:f9eeca106725 440 * @}
Kojto 122:f9eeca106725 441 */
Kojto 122:f9eeca106725 442
Kojto 122:f9eeca106725 443 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 444 /** @defgroup ADCEx_Common_mode ADC Extended Dual ADC Mode
Kojto 122:f9eeca106725 445 * @{
Kojto 122:f9eeca106725 446 */
Kojto 122:f9eeca106725 447 #define ADC_MODE_INDEPENDENT ((uint32_t)(0x00000000)) /*!< Independent ADC conversions mode */
Kojto 122:f9eeca106725 448 #define ADC_DUALMODE_REGSIMULT_INJECSIMULT ((uint32_t)(ADC_CCR_DUAL_0)) /*!< Combined regular simultaneous + injected simultaneous mode */
Kojto 122:f9eeca106725 449 #define ADC_DUALMODE_REGSIMULT_ALTERTRIG ((uint32_t)(ADC_CCR_DUAL_1)) /*!< Combined regular simultaneous + alternate trigger mode */
Kojto 122:f9eeca106725 450 #define ADC_DUALMODE_REGINTERL_INJECSIMULT ((uint32_t)(ADC_CCR_DUAL_1 | ADC_CCR_DUAL_0)) /*!< Combined Interleaved mode + injected simultaneous mode */
Kojto 122:f9eeca106725 451 #define ADC_DUALMODE_INJECSIMULT ((uint32_t)(ADC_CCR_DUAL_2 | ADC_CCR_DUAL_0)) /*!< Injected simultaneous mode only */
Kojto 122:f9eeca106725 452 #define ADC_DUALMODE_REGSIMULT ((uint32_t)(ADC_CCR_DUAL_2 | ADC_CCR_DUAL_1)) /*!< Regular simultaneous mode only */
Kojto 122:f9eeca106725 453 #define ADC_DUALMODE_INTERL ((uint32_t)(ADC_CCR_DUAL_2 | ADC_CCR_DUAL_1 | ADC_CCR_DUAL_0)) /*!< Interleaved mode only */
Kojto 122:f9eeca106725 454 #define ADC_DUALMODE_ALTERTRIG ((uint32_t)(ADC_CCR_DUAL_3 | ADC_CCR_DUAL_0)) /*!< Alternate trigger mode only */
Kojto 122:f9eeca106725 455 /**
Kojto 122:f9eeca106725 456 * @}
Kojto 122:f9eeca106725 457 */
Kojto 122:f9eeca106725 458
Kojto 122:f9eeca106725 459 /** @defgroup ADCEx_Direct_memory_access_mode_for_multimode ADC Extended DMA Mode for Dual ADC Mode
Kojto 122:f9eeca106725 460 * @{
Kojto 122:f9eeca106725 461 */
Kojto 122:f9eeca106725 462 #define ADC_DMAACCESSMODE_DISABLED ((uint32_t)0x00000000) /*!< DMA multimode disabled: each ADC uses its own DMA channel */
Kojto 122:f9eeca106725 463 #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 */
Kojto 122:f9eeca106725 464 #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 */
Kojto 122:f9eeca106725 465 /**
Kojto 122:f9eeca106725 466 * @}
Kojto 122:f9eeca106725 467 */
Kojto 122:f9eeca106725 468
Kojto 122:f9eeca106725 469 /** @defgroup ADCEx_delay_between_2_sampling_phases ADC Extended Delay Between 2 Sampling Phases
Kojto 122:f9eeca106725 470 * @{
Kojto 122:f9eeca106725 471 */
Kojto 122:f9eeca106725 472 #define ADC_TWOSAMPLINGDELAY_1CYCLE ((uint32_t)(0x00000000)) /*!< 1 ADC clock cycle delay */
Kojto 122:f9eeca106725 473 #define ADC_TWOSAMPLINGDELAY_2CYCLES ((uint32_t)(ADC_CCR_DELAY_0)) /*!< 2 ADC clock cycles delay */
Kojto 122:f9eeca106725 474 #define ADC_TWOSAMPLINGDELAY_3CYCLES ((uint32_t)(ADC_CCR_DELAY_1)) /*!< 3 ADC clock cycles delay */
Kojto 122:f9eeca106725 475 #define ADC_TWOSAMPLINGDELAY_4CYCLES ((uint32_t)(ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0)) /*!< 4 ADC clock cycles delay */
Kojto 122:f9eeca106725 476 #define ADC_TWOSAMPLINGDELAY_5CYCLES ((uint32_t)(ADC_CCR_DELAY_2)) /*!< 5 ADC clock cycles delay */
Kojto 122:f9eeca106725 477 #define ADC_TWOSAMPLINGDELAY_6CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0)) /*!< 6 ADC clock cycles delay */
Kojto 122:f9eeca106725 478 #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) */
Kojto 122:f9eeca106725 479 #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) */
Kojto 122:f9eeca106725 480 #define ADC_TWOSAMPLINGDELAY_9CYCLES ((uint32_t)(ADC_CCR_DELAY_3)) /*!< 9 ADC clock cycles delay (lower for non 12-bit resolution) */
Kojto 122:f9eeca106725 481 #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) */
Kojto 122:f9eeca106725 482 #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) */
Kojto 122:f9eeca106725 483 #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) */
Kojto 122:f9eeca106725 484 /**
Kojto 122:f9eeca106725 485 * @}
Kojto 122:f9eeca106725 486 */
Kojto 122:f9eeca106725 487 #elif defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 488 /** @defgroup ADCEx_Common_mode ADC Extended Independent ADC Mode
Kojto 122:f9eeca106725 489 * @{
Kojto 122:f9eeca106725 490 */
Kojto 122:f9eeca106725 491 #define ADC_MODE_INDEPENDENT ((uint32_t)(0x00000000)) /*!< Independent ADC conversions mode */
Kojto 122:f9eeca106725 492 /**
Kojto 122:f9eeca106725 493 * @}
Kojto 122:f9eeca106725 494 */
Kojto 122:f9eeca106725 495
Kojto 122:f9eeca106725 496 #endif /* defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) */
Kojto 122:f9eeca106725 497
Kojto 122:f9eeca106725 498 /** @defgroup ADCEx_analog_watchdog_number ADC Extended Analog Watchdog Selection
Kojto 122:f9eeca106725 499 * @{
Kojto 122:f9eeca106725 500 */
Kojto 122:f9eeca106725 501 #define ADC_ANALOGWATCHDOG_1 ((uint32_t)0x00000001) /*!< Analog watchdog 1 selection */
Kojto 122:f9eeca106725 502 #define ADC_ANALOGWATCHDOG_2 ((uint32_t)0x00000002) /*!< Analog watchdog 2 selection */
Kojto 122:f9eeca106725 503 #define ADC_ANALOGWATCHDOG_3 ((uint32_t)0x00000003) /*!< Analog watchdog 3 selection */
Kojto 122:f9eeca106725 504 /**
Kojto 122:f9eeca106725 505 * @}
Kojto 122:f9eeca106725 506 */
Kojto 122:f9eeca106725 507
Kojto 122:f9eeca106725 508 /** @defgroup ADCEx_analog_watchdog_mode ADC Extended Analog Watchdog Mode
Kojto 122:f9eeca106725 509 * @{
Kojto 122:f9eeca106725 510 */
Kojto 122:f9eeca106725 511 #define ADC_ANALOGWATCHDOG_NONE ((uint32_t) 0x00000000) /*!< No analog watchdog selected */
Kojto 122:f9eeca106725 512 #define ADC_ANALOGWATCHDOG_SINGLE_REG ((uint32_t)(ADC_CFGR_AWD1SGL | ADC_CFGR_AWD1EN)) /*!< Analog watchdog applied to a regular group single channel */
Kojto 122:f9eeca106725 513 #define ADC_ANALOGWATCHDOG_SINGLE_INJEC ((uint32_t)(ADC_CFGR_AWD1SGL | ADC_CFGR_JAWD1EN)) /*!< Analog watchdog applied to an injected group single channel */
Kojto 122:f9eeca106725 514 #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 */
Kojto 122:f9eeca106725 515 #define ADC_ANALOGWATCHDOG_ALL_REG ((uint32_t) ADC_CFGR_AWD1EN) /*!< Analog watchdog applied to regular group all channels */
Kojto 122:f9eeca106725 516 #define ADC_ANALOGWATCHDOG_ALL_INJEC ((uint32_t) ADC_CFGR_JAWD1EN) /*!< Analog watchdog applied to injected group all channels */
Kojto 122:f9eeca106725 517 #define ADC_ANALOGWATCHDOG_ALL_REGINJEC ((uint32_t)(ADC_CFGR_AWD1EN | ADC_CFGR_JAWD1EN)) /*!< Analog watchdog applied to regular and injected groups all channels */
Kojto 122:f9eeca106725 518 /**
Kojto 122:f9eeca106725 519 * @}
Kojto 122:f9eeca106725 520 */
Kojto 122:f9eeca106725 521
Kojto 122:f9eeca106725 522 /** @defgroup ADCEx_conversion_group ADC Extended Conversion Group
Kojto 122:f9eeca106725 523 * @{
Kojto 122:f9eeca106725 524 */
Kojto 122:f9eeca106725 525 #define ADC_REGULAR_GROUP ((uint32_t)(ADC_FLAG_EOC | ADC_FLAG_EOS)) /*!< ADC regular group selection */
Kojto 122:f9eeca106725 526 #define ADC_INJECTED_GROUP ((uint32_t)(ADC_FLAG_JEOC | ADC_FLAG_JEOS)) /*!< ADC injected group selection */
Kojto 122:f9eeca106725 527 #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 */
Kojto 122:f9eeca106725 528 /**
Kojto 122:f9eeca106725 529 * @}
Kojto 122:f9eeca106725 530 */
Kojto 122:f9eeca106725 531
Kojto 122:f9eeca106725 532 /** @defgroup ADCEx_Event_type ADC Extended Event Type
Kojto 122:f9eeca106725 533 * @{
Kojto 122:f9eeca106725 534 */
Kojto 122:f9eeca106725 535 #define ADC_EOSMP_EVENT ((uint32_t)ADC_FLAG_EOSMP) /*!< ADC End of Sampling event */
Kojto 122:f9eeca106725 536 #define ADC_AWD1_EVENT ((uint32_t)ADC_FLAG_AWD1) /*!< ADC Analog watchdog 1 event (main analog watchdog) */
Kojto 122:f9eeca106725 537 #define ADC_AWD2_EVENT ((uint32_t)ADC_FLAG_AWD2) /*!< ADC Analog watchdog 2 event (additional analog watchdog) */
Kojto 122:f9eeca106725 538 #define ADC_AWD3_EVENT ((uint32_t)ADC_FLAG_AWD3) /*!< ADC Analog watchdog 3 event (additional analog watchdog) */
Kojto 122:f9eeca106725 539 #define ADC_OVR_EVENT ((uint32_t)ADC_FLAG_OVR) /*!< ADC overrun event */
Kojto 122:f9eeca106725 540 #define ADC_JQOVF_EVENT ((uint32_t)ADC_FLAG_JQOVF) /*!< ADC Injected Context Queue Overflow event */
Kojto 122:f9eeca106725 541
Kojto 122:f9eeca106725 542 #define ADC_AWD_EVENT ADC_AWD1_EVENT /*!< ADC Analog watchdog 1 event: Naming for compatibility with other STM32 devices having only one analog watchdog */
Kojto 122:f9eeca106725 543 /**
Kojto 122:f9eeca106725 544 * @}
Kojto 122:f9eeca106725 545 */
Kojto 122:f9eeca106725 546
Kojto 122:f9eeca106725 547 /** @defgroup ADCEx_interrupts_definition ADC Extended Interrupts Definition
Kojto 122:f9eeca106725 548 * @{
Kojto 122:f9eeca106725 549 */
Kojto 122:f9eeca106725 550 #define ADC_IT_RDY ADC_IER_ADRDY /*!< ADC Ready (ADRDY) interrupt source */
Kojto 122:f9eeca106725 551 #define ADC_IT_EOSMP ADC_IER_EOSMP /*!< ADC End of sampling interrupt source */
Kojto 122:f9eeca106725 552 #define ADC_IT_EOC ADC_IER_EOC /*!< ADC End of regular conversion interrupt source */
Kojto 122:f9eeca106725 553 #define ADC_IT_EOS ADC_IER_EOS /*!< ADC End of regular sequence of conversions interrupt source */
Kojto 122:f9eeca106725 554 #define ADC_IT_OVR ADC_IER_OVR /*!< ADC overrun interrupt source */
Kojto 122:f9eeca106725 555 #define ADC_IT_JEOC ADC_IER_JEOC /*!< ADC End of injected conversion interrupt source */
Kojto 122:f9eeca106725 556 #define ADC_IT_JEOS ADC_IER_JEOS /*!< ADC End of injected sequence of conversions interrupt source */
Kojto 122:f9eeca106725 557 #define ADC_IT_AWD1 ADC_IER_AWD1 /*!< ADC Analog watchdog 1 interrupt source (main analog watchdog) */
Kojto 122:f9eeca106725 558 #define ADC_IT_AWD2 ADC_IER_AWD2 /*!< ADC Analog watchdog 2 interrupt source (additional analog watchdog) */
Kojto 122:f9eeca106725 559 #define ADC_IT_AWD3 ADC_IER_AWD3 /*!< ADC Analog watchdog 3 interrupt source (additional analog watchdog) */
Kojto 122:f9eeca106725 560 #define ADC_IT_JQOVF ADC_IER_JQOVF /*!< ADC Injected Context Queue Overflow interrupt source */
Kojto 122:f9eeca106725 561
Kojto 122:f9eeca106725 562 #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 */
Kojto 122:f9eeca106725 563
Kojto 122:f9eeca106725 564 /**
Kojto 122:f9eeca106725 565 * @}
Kojto 122:f9eeca106725 566 */
Kojto 122:f9eeca106725 567
Kojto 122:f9eeca106725 568 /** @defgroup ADCEx_flags_definition ADC Extended Flags Definition
Kojto 122:f9eeca106725 569 * @{
Kojto 122:f9eeca106725 570 */
Kojto 122:f9eeca106725 571 #define ADC_FLAG_RDY ADC_ISR_ADRDY /*!< ADC Ready (ADRDY) flag */
Kojto 122:f9eeca106725 572 #define ADC_FLAG_EOSMP ADC_ISR_EOSMP /*!< ADC End of Sampling flag */
Kojto 122:f9eeca106725 573 #define ADC_FLAG_EOC ADC_ISR_EOC /*!< ADC End of Regular Conversion flag */
Kojto 122:f9eeca106725 574 #define ADC_FLAG_EOS ADC_ISR_EOS /*!< ADC End of Regular sequence of Conversions flag */
Kojto 122:f9eeca106725 575 #define ADC_FLAG_OVR ADC_ISR_OVR /*!< ADC overrun flag */
Kojto 122:f9eeca106725 576 #define ADC_FLAG_JEOC ADC_ISR_JEOC /*!< ADC End of Injected Conversion flag */
Kojto 122:f9eeca106725 577 #define ADC_FLAG_JEOS ADC_ISR_JEOS /*!< ADC End of Injected sequence of Conversions flag */
Kojto 122:f9eeca106725 578 #define ADC_FLAG_AWD1 ADC_ISR_AWD1 /*!< ADC Analog watchdog 1 flag (main analog watchdog) */
Kojto 122:f9eeca106725 579 #define ADC_FLAG_AWD2 ADC_ISR_AWD2 /*!< ADC Analog watchdog 2 flag (additional analog watchdog) */
Kojto 122:f9eeca106725 580 #define ADC_FLAG_AWD3 ADC_ISR_AWD3 /*!< ADC Analog watchdog 3 flag (additional analog watchdog) */
Kojto 122:f9eeca106725 581 #define ADC_FLAG_JQOVF ADC_ISR_JQOVF /*!< ADC Injected Context Queue Overflow flag */
Kojto 122:f9eeca106725 582
Kojto 122:f9eeca106725 583 #define ADC_FLAG_AWD ADC_FLAG_AWD1 /*!< ADC Analog watchdog 1 flag: Naming for compatibility with other STM32 devices having only one analog watchdog */
Kojto 122:f9eeca106725 584
Kojto 122:f9eeca106725 585 #define ADC_FLAG_ALL (ADC_FLAG_RDY | ADC_FLAG_EOSMP | ADC_FLAG_EOC | ADC_FLAG_EOS | \
Kojto 122:f9eeca106725 586 ADC_FLAG_JEOC | ADC_FLAG_JEOS | ADC_FLAG_OVR | ADC_FLAG_AWD1 | \
Kojto 122:f9eeca106725 587 ADC_FLAG_AWD2 | ADC_FLAG_AWD3 | ADC_FLAG_JQOVF) /*!< ADC all flags */
Kojto 122:f9eeca106725 588
Kojto 122:f9eeca106725 589 /* Combination of all post-conversion flags bits: EOC/EOS, JEOC/JEOS, OVR, AWDx, JQOVF */
Kojto 122:f9eeca106725 590 #define ADC_FLAG_POSTCONV_ALL (ADC_FLAG_EOC | ADC_FLAG_EOS | ADC_FLAG_JEOC | ADC_FLAG_JEOS | \
Kojto 122:f9eeca106725 591 ADC_FLAG_OVR | ADC_FLAG_AWD1 | ADC_FLAG_AWD2 | ADC_FLAG_AWD3 | \
Kojto 122:f9eeca106725 592 ADC_FLAG_JQOVF) /*!< ADC post-conversion all flags */
Kojto 122:f9eeca106725 593
Kojto 122:f9eeca106725 594 /**
Kojto 122:f9eeca106725 595 * @}
Kojto 122:f9eeca106725 596 */
Kojto 122:f9eeca106725 597
Kojto 122:f9eeca106725 598
Kojto 122:f9eeca106725 599 /** @defgroup ADCEx_injected_rank ADC Extended Injected Channel Rank
Kojto 122:f9eeca106725 600 * @{
Kojto 122:f9eeca106725 601 */
Kojto 122:f9eeca106725 602 #define ADC_INJECTED_RANK_1 ((uint32_t)0x00000001) /*!< ADC injected conversion rank 1 */
Kojto 122:f9eeca106725 603 #define ADC_INJECTED_RANK_2 ((uint32_t)0x00000002) /*!< ADC injected conversion rank 2 */
Kojto 122:f9eeca106725 604 #define ADC_INJECTED_RANK_3 ((uint32_t)0x00000003) /*!< ADC injected conversion rank 3 */
Kojto 122:f9eeca106725 605 #define ADC_INJECTED_RANK_4 ((uint32_t)0x00000004) /*!< ADC injected conversion rank 4 */
Kojto 122:f9eeca106725 606 /**
Kojto 122:f9eeca106725 607 * @}
Kojto 122:f9eeca106725 608 */
Kojto 122:f9eeca106725 609
Kojto 122:f9eeca106725 610
Kojto 122:f9eeca106725 611
Kojto 122:f9eeca106725 612 /** @defgroup ADCEx_Oversampling_Ratio ADC Extended Oversampling Ratio
Kojto 122:f9eeca106725 613 * @{
Kojto 122:f9eeca106725 614 */
Kojto 122:f9eeca106725 615
Kojto 122:f9eeca106725 616 #define ADC_OVERSAMPLING_RATIO_2 ((uint32_t)0x00000000) /*!< ADC Oversampling ratio 2x */
Kojto 122:f9eeca106725 617 #define ADC_OVERSAMPLING_RATIO_4 ((uint32_t)ADC_CFGR2_OVSR_0) /*!< ADC Oversampling ratio 4x */
Kojto 122:f9eeca106725 618 #define ADC_OVERSAMPLING_RATIO_8 ((uint32_t)ADC_CFGR2_OVSR_1) /*!< ADC Oversampling ratio 8x */
Kojto 122:f9eeca106725 619 #define ADC_OVERSAMPLING_RATIO_16 ((uint32_t)(ADC_CFGR2_OVSR_1 | ADC_CFGR2_OVSR_0)) /*!< ADC Oversampling ratio 16x */
Kojto 122:f9eeca106725 620 #define ADC_OVERSAMPLING_RATIO_32 ((uint32_t)ADC_CFGR2_OVSR_2) /*!< ADC Oversampling ratio 32x */
Kojto 122:f9eeca106725 621 #define ADC_OVERSAMPLING_RATIO_64 ((uint32_t)(ADC_CFGR2_OVSR_2 | ADC_CFGR2_OVSR_0)) /*!< ADC Oversampling ratio 64x */
Kojto 122:f9eeca106725 622 #define ADC_OVERSAMPLING_RATIO_128 ((uint32_t)(ADC_CFGR2_OVSR_2 | ADC_CFGR2_OVSR_1)) /*!< ADC Oversampling ratio 128x */
Kojto 122:f9eeca106725 623 #define ADC_OVERSAMPLING_RATIO_256 ((uint32_t)(ADC_CFGR2_OVSR)) /*!< ADC Oversampling ratio 256x */
Kojto 122:f9eeca106725 624 /**
Kojto 122:f9eeca106725 625 * @}
Kojto 122:f9eeca106725 626 */
Kojto 122:f9eeca106725 627
Kojto 122:f9eeca106725 628 /** @defgroup ADCEx_Right_Bit_Shift ADC Extended Oversampling Right Shift
Kojto 122:f9eeca106725 629 * @{
Kojto 122:f9eeca106725 630 */
Kojto 122:f9eeca106725 631 #define ADC_RIGHTBITSHIFT_NONE ((uint32_t)0x00000000) /*!< ADC No bit shift for oversampling */
Kojto 122:f9eeca106725 632 #define ADC_RIGHTBITSHIFT_1 ((uint32_t)ADC_CFGR2_OVSS_0) /*!< ADC 1 bit shift for oversampling */
Kojto 122:f9eeca106725 633 #define ADC_RIGHTBITSHIFT_2 ((uint32_t)ADC_CFGR2_OVSS_1) /*!< ADC 2 bits shift for oversampling */
Kojto 122:f9eeca106725 634 #define ADC_RIGHTBITSHIFT_3 ((uint32_t)(ADC_CFGR2_OVSS_1 | ADC_CFGR2_OVSS_0)) /*!< ADC 3 bits shift for oversampling */
Kojto 122:f9eeca106725 635 #define ADC_RIGHTBITSHIFT_4 ((uint32_t)ADC_CFGR2_OVSS_2) /*!< ADC 4 bits shift for oversampling */
Kojto 122:f9eeca106725 636 #define ADC_RIGHTBITSHIFT_5 ((uint32_t)(ADC_CFGR2_OVSS_2 | ADC_CFGR2_OVSS_0)) /*!< ADC 5 bits shift for oversampling */
Kojto 122:f9eeca106725 637 #define ADC_RIGHTBITSHIFT_6 ((uint32_t)(ADC_CFGR2_OVSS_2 | ADC_CFGR2_OVSS_1)) /*!< ADC 6 bits shift for oversampling */
Kojto 122:f9eeca106725 638 #define ADC_RIGHTBITSHIFT_7 ((uint32_t)(ADC_CFGR2_OVSS_2 | ADC_CFGR2_OVSS_1 | ADC_CFGR2_OVSS_0)) /*!< ADC 7 bits shift for oversampling */
Kojto 122:f9eeca106725 639 #define ADC_RIGHTBITSHIFT_8 ((uint32_t)ADC_CFGR2_OVSS_3) /*!< ADC 8 bits shift for oversampling */
Kojto 122:f9eeca106725 640 /**
Kojto 122:f9eeca106725 641 * @}
Kojto 122:f9eeca106725 642 */
Kojto 122:f9eeca106725 643
Kojto 122:f9eeca106725 644 /** @defgroup ADCEx_Triggered_Oversampling_Mode ADC Extended Triggered Regular Oversampling
Kojto 122:f9eeca106725 645 * @{
Kojto 122:f9eeca106725 646 */
Kojto 122:f9eeca106725 647 #define ADC_TRIGGEREDMODE_SINGLE_TRIGGER ((uint32_t)0x00000000) /*!< A single trigger for all channel oversampled conversions */
Kojto 122:f9eeca106725 648 #define ADC_TRIGGEREDMODE_MULTI_TRIGGER ((uint32_t)ADC_CFGR2_TROVS) /*!< A trigger for each oversampled conversion */
Kojto 122:f9eeca106725 649 /**
Kojto 122:f9eeca106725 650 * @}
Kojto 122:f9eeca106725 651 */
Kojto 122:f9eeca106725 652
Kojto 122:f9eeca106725 653 /** @defgroup ADCEx_Regular_Oversampling_Mode ADC Extended Regular Oversampling Continued or Resumed Mode
Kojto 122:f9eeca106725 654 * @{
Kojto 122:f9eeca106725 655 */
Kojto 122:f9eeca106725 656 #define ADC_REGOVERSAMPLING_CONTINUED_MODE ((uint32_t)0x00000000) /*!< Oversampling buffer maintained during injection sequence */
Kojto 122:f9eeca106725 657 #define ADC_REGOVERSAMPLING_RESUMED_MODE ((uint32_t)ADC_CFGR2_ROVSM) /*!< Oversampling buffer zeroed during injection sequence */
Kojto 122:f9eeca106725 658 /**
Kojto 122:f9eeca106725 659 * @}
Kojto 122:f9eeca106725 660 */
Kojto 122:f9eeca106725 661
Kojto 122:f9eeca106725 662 /** @defgroup ADC_sampling_times ADC Sampling Times
Kojto 122:f9eeca106725 663 * @{
Kojto 122:f9eeca106725 664 */
Kojto 122:f9eeca106725 665 #define ADC_SAMPLETIME_2CYCLES_5 ((uint32_t)0x00000000) /*!< Sampling time 2.5 ADC clock cycle */
Kojto 122:f9eeca106725 666 #define ADC_SAMPLETIME_6CYCLES_5 ((uint32_t)ADC_SMPR2_SMP10_0) /*!< Sampling time 6.5 ADC clock cycles */
Kojto 122:f9eeca106725 667 #define ADC_SAMPLETIME_12CYCLES_5 ((uint32_t)ADC_SMPR2_SMP10_1) /*!< Sampling time 12.5 ADC clock cycles */
Kojto 122:f9eeca106725 668 #define ADC_SAMPLETIME_24CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP10_1 | ADC_SMPR2_SMP10_0)) /*!< Sampling time 24.5 ADC clock cycles */
Kojto 122:f9eeca106725 669 #define ADC_SAMPLETIME_47CYCLES_5 ((uint32_t)ADC_SMPR2_SMP10_2) /*!< Sampling time 47.5 ADC clock cycles */
Kojto 122:f9eeca106725 670 #define ADC_SAMPLETIME_92CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_0)) /*!< Sampling time 92.5 ADC clock cycles */
Kojto 122:f9eeca106725 671 #define ADC_SAMPLETIME_247CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP10_2 | ADC_SMPR2_SMP10_1)) /*!< Sampling time 247.5 ADC clock cycles */
Kojto 122:f9eeca106725 672 #define ADC_SAMPLETIME_640CYCLES_5 ((uint32_t)ADC_SMPR2_SMP10) /*!< Sampling time 640.5 ADC clock cycles */
Kojto 122:f9eeca106725 673 /**
Kojto 122:f9eeca106725 674 * @}
Kojto 122:f9eeca106725 675 */
Kojto 122:f9eeca106725 676
Kojto 122:f9eeca106725 677 /** @defgroup ADC_CFGR_fields ADCx CFGR fields
Kojto 122:f9eeca106725 678 * @{
Kojto 122:f9eeca106725 679 */
Kojto 122:f9eeca106725 680 #define ADC_CFGR_FIELDS (ADC_CFGR_AWD1CH | ADC_CFGR_JAUTO | ADC_CFGR_JAWD1EN |\
Kojto 122:f9eeca106725 681 ADC_CFGR_AWD1EN | ADC_CFGR_AWD1SGL | ADC_CFGR_JQM |\
Kojto 122:f9eeca106725 682 ADC_CFGR_JDISCEN | ADC_CFGR_DISCNUM | ADC_CFGR_DISCEN |\
Kojto 122:f9eeca106725 683 ADC_CFGR_AUTDLY | ADC_CFGR_CONT | ADC_CFGR_OVRMOD |\
Kojto 122:f9eeca106725 684 ADC_CFGR_EXTEN | ADC_CFGR_EXTSEL | ADC_CFGR_ALIGN |\
Kojto 122:f9eeca106725 685 ADC_CFGR_RES | ADC_CFGR_DMACFG | ADC_CFGR_DMAEN )
Kojto 122:f9eeca106725 686 /**
Kojto 122:f9eeca106725 687 * @}
Kojto 122:f9eeca106725 688 */
Kojto 122:f9eeca106725 689
Kojto 122:f9eeca106725 690 /** @defgroup ADC_SMPR1_fields ADCx SMPR1 fields
Kojto 122:f9eeca106725 691 * @{
Kojto 122:f9eeca106725 692 */
Kojto 122:f9eeca106725 693 #define ADC_SMPR1_FIELDS (ADC_SMPR1_SMP9 | ADC_SMPR1_SMP8 | ADC_SMPR1_SMP7 |\
Kojto 122:f9eeca106725 694 ADC_SMPR1_SMP6 | ADC_SMPR1_SMP5 | ADC_SMPR1_SMP4 |\
Kojto 122:f9eeca106725 695 ADC_SMPR1_SMP3 | ADC_SMPR1_SMP2 | ADC_SMPR1_SMP1 |\
Kojto 122:f9eeca106725 696 ADC_SMPR1_SMP0)
Kojto 122:f9eeca106725 697 /**
Kojto 122:f9eeca106725 698 * @}
Kojto 122:f9eeca106725 699 */
Kojto 122:f9eeca106725 700
Kojto 122:f9eeca106725 701 /** @defgroup ADC_CFGR_fields_2 ADCx CFGR sub fields
Kojto 122:f9eeca106725 702 * @{
Kojto 122:f9eeca106725 703 */
Kojto 122:f9eeca106725 704 /* ADC_CFGR fields of parameters that can be updated when no conversion
Kojto 122:f9eeca106725 705 (neither regular nor injected) is on-going */
Kojto 122:f9eeca106725 706 #define ADC_CFGR_FIELDS_2 ((uint32_t)(ADC_CFGR_DMACFG | ADC_CFGR_AUTDLY))
Kojto 122:f9eeca106725 707 /**
Kojto 122:f9eeca106725 708 * @}
Kojto 122:f9eeca106725 709 */
Kojto 122:f9eeca106725 710
Kojto 122:f9eeca106725 711 /**
Kojto 122:f9eeca106725 712 * @}
Kojto 122:f9eeca106725 713 */
Kojto 122:f9eeca106725 714
Kojto 122:f9eeca106725 715
Kojto 122:f9eeca106725 716
Kojto 122:f9eeca106725 717 /* Private macros -----------------------------------------------------------*/
Kojto 122:f9eeca106725 718
Kojto 122:f9eeca106725 719 /** @defgroup ADCEx_Private_Macro_internal_HAL_driver ADC Extended Private Macros
Kojto 122:f9eeca106725 720 * @{
Kojto 122:f9eeca106725 721 */
Kojto 122:f9eeca106725 722
Kojto 122:f9eeca106725 723 /**
Kojto 122:f9eeca106725 724 * @brief Test if conversion trigger of injected group is software start
Kojto 122:f9eeca106725 725 * or external trigger.
Kojto 122:f9eeca106725 726 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 727 * @retval SET (software start) or RESET (external trigger).
Kojto 122:f9eeca106725 728 */
Kojto 122:f9eeca106725 729 #define ADC_IS_SOFTWARE_START_INJECTED(__HANDLE__) \
Kojto 122:f9eeca106725 730 (((__HANDLE__)->Instance->JSQR & ADC_JSQR_JEXTEN) == RESET)
Kojto 122:f9eeca106725 731
Kojto 122:f9eeca106725 732 /**
Kojto 122:f9eeca106725 733 * @brief Check if conversion is on going on regular or injected groups.
Kojto 122:f9eeca106725 734 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 735 * @retval SET (conversion is on going) or RESET (no conversion is on going).
Kojto 122:f9eeca106725 736 */
Kojto 122:f9eeca106725 737 #define ADC_IS_CONVERSION_ONGOING_REGULAR_INJECTED(__HANDLE__) \
Kojto 122:f9eeca106725 738 (( (((__HANDLE__)->Instance->CR) & (ADC_CR_ADSTART | ADC_CR_JADSTART)) == RESET \
Kojto 122:f9eeca106725 739 ) ? RESET : SET)
Kojto 122:f9eeca106725 740
Kojto 122:f9eeca106725 741
Kojto 122:f9eeca106725 742 /**
Kojto 122:f9eeca106725 743 * @brief Check if conversion is on going on injected group.
Kojto 122:f9eeca106725 744 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 745 * @retval SET (conversion is on going) or RESET (no conversion is on going).
Kojto 122:f9eeca106725 746 */
Kojto 122:f9eeca106725 747 #define ADC_IS_CONVERSION_ONGOING_INJECTED(__HANDLE__) \
Kojto 122:f9eeca106725 748 (( (((__HANDLE__)->Instance->CR) & ADC_CR_JADSTART) == RESET \
Kojto 122:f9eeca106725 749 ) ? RESET : SET)
Kojto 122:f9eeca106725 750
Kojto 122:f9eeca106725 751
Kojto 122:f9eeca106725 752
Kojto 122:f9eeca106725 753 /**
Kojto 122:f9eeca106725 754 * @brief Check whether or not ADC is independent.
Kojto 122:f9eeca106725 755 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 756 * @note When multimode feature is not available, the macro always returns SET.
Kojto 122:f9eeca106725 757 * @retval SET (ADC is independent) or RESET (ADC is not).
Kojto 122:f9eeca106725 758 */
Kojto 122:f9eeca106725 759 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 760 #define ADC_IS_INDEPENDENT(__HANDLE__) \
Kojto 122:f9eeca106725 761 ( ( ( ((__HANDLE__)->Instance) == ADC3) \
Kojto 122:f9eeca106725 762 )? \
Kojto 122:f9eeca106725 763 SET \
Kojto 122:f9eeca106725 764 : \
Kojto 122:f9eeca106725 765 RESET \
Kojto 122:f9eeca106725 766 )
Kojto 122:f9eeca106725 767 #elif defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 768 #define ADC_IS_INDEPENDENT(__HANDLE__) (SET)
Kojto 122:f9eeca106725 769 #endif
Kojto 122:f9eeca106725 770
Kojto 122:f9eeca106725 771
Kojto 122:f9eeca106725 772 /**
Kojto 122:f9eeca106725 773 * @brief Set the sample time for Channels numbers between 0 and 9.
Kojto 122:f9eeca106725 774 * @param __SAMPLETIME__: Sample time parameter.
Kojto 122:f9eeca106725 775 * @param __CHANNELNB__: Channel number.
Kojto 122:f9eeca106725 776 * @retval None
Kojto 122:f9eeca106725 777 */
Kojto 122:f9eeca106725 778 #define ADC_SMPR1(__SAMPLETIME__, __CHANNELNB__) ((__SAMPLETIME__) << (POSITION_VAL(ADC_SMPR1_SMP1) * (__CHANNELNB__)))
Kojto 122:f9eeca106725 779
Kojto 122:f9eeca106725 780 /**
Kojto 122:f9eeca106725 781 * @brief Set the sample time for Channels numbers between 10 and 18.
Kojto 122:f9eeca106725 782 * @param __SAMPLETIME__: Sample time parameter.
Kojto 122:f9eeca106725 783 * @param __CHANNELNB__: Channel number.
Kojto 122:f9eeca106725 784 * @retval None
Kojto 122:f9eeca106725 785 */
Kojto 122:f9eeca106725 786 #define ADC_SMPR2(__SAMPLETIME__, __CHANNELNB__) ((__SAMPLETIME__) << ((POSITION_VAL(ADC_SMPR2_SMP11) * ((__CHANNELNB__) - 10))))
Kojto 122:f9eeca106725 787
Kojto 122:f9eeca106725 788 /**
Kojto 122:f9eeca106725 789 * @brief Write SMPR1 register.
Kojto 122:f9eeca106725 790 * @param __HANDLE__ : ADC handle.
Kojto 122:f9eeca106725 791 * @param __SAMPLETIME__: Sample time parameter.
Kojto 122:f9eeca106725 792 * @param __CHANNELNB__ : Channel number.
Kojto 122:f9eeca106725 793 * @retval None
Kojto 122:f9eeca106725 794 */
Kojto 122:f9eeca106725 795 #define ADC_SMPR1_SETTING(__HANDLE__, __SAMPLETIME__, __CHANNELNB__) \
Kojto 122:f9eeca106725 796 MODIFY_REG((__HANDLE__)->Instance->SMPR1, \
Kojto 122:f9eeca106725 797 ADC_SMPR1(ADC_SMPR1_SMP0, (__CHANNELNB__)), \
Kojto 122:f9eeca106725 798 ADC_SMPR1((__SAMPLETIME__), (__CHANNELNB__)))
Kojto 122:f9eeca106725 799
Kojto 122:f9eeca106725 800 /**
Kojto 122:f9eeca106725 801 * @brief Write SMPR2 register.
Kojto 122:f9eeca106725 802 * @param __HANDLE__ : ADC handle.
Kojto 122:f9eeca106725 803 * @param __SAMPLETIME__: Sample time parameter.
Kojto 122:f9eeca106725 804 * @param __CHANNELNB__ : Channel number.
Kojto 122:f9eeca106725 805 * @retval None
Kojto 122:f9eeca106725 806 */
Kojto 122:f9eeca106725 807 #define ADC_SMPR2_SETTING(__HANDLE__, __SAMPLETIME__, __CHANNELNB__) \
Kojto 122:f9eeca106725 808 MODIFY_REG((__HANDLE__)->Instance->SMPR2, \
Kojto 122:f9eeca106725 809 ADC_SMPR2(ADC_SMPR2_SMP10, (__CHANNELNB__)), \
Kojto 122:f9eeca106725 810 ADC_SMPR2((__SAMPLETIME__), (__CHANNELNB__)))
Kojto 122:f9eeca106725 811
Kojto 122:f9eeca106725 812
Kojto 122:f9eeca106725 813 /**
Kojto 122:f9eeca106725 814 * @brief Set the selected regular Channel rank for rank between 1 and 4.
Kojto 122:f9eeca106725 815 * @param __CHANNELNB__: Channel number.
Kojto 122:f9eeca106725 816 * @param __RANKNB__: Rank number.
Kojto 122:f9eeca106725 817 * @retval None
Kojto 122:f9eeca106725 818 */
Kojto 122:f9eeca106725 819 #define ADC_SQR1_RK(__CHANNELNB__, __RANKNB__) ((__CHANNELNB__) << (POSITION_VAL(ADC_SQR1_SQ1) * (__RANKNB__)))
Kojto 122:f9eeca106725 820
Kojto 122:f9eeca106725 821 /**
Kojto 122:f9eeca106725 822 * @brief Set the selected regular Channel rank for rank between 5 and 9.
Kojto 122:f9eeca106725 823 * @param __CHANNELNB__: Channel number.
Kojto 122:f9eeca106725 824 * @param __RANKNB__: Rank number.
Kojto 122:f9eeca106725 825 * @retval None
Kojto 122:f9eeca106725 826 */
Kojto 122:f9eeca106725 827 #define ADC_SQR2_RK(__CHANNELNB__, __RANKNB__) ((__CHANNELNB__) << (POSITION_VAL(ADC_SQR2_SQ6) * ((__RANKNB__) - 5)))
Kojto 122:f9eeca106725 828
Kojto 122:f9eeca106725 829 /**
Kojto 122:f9eeca106725 830 * @brief Set the selected regular Channel rank for rank between 10 and 14.
Kojto 122:f9eeca106725 831 * @param __CHANNELNB__: Channel number.
Kojto 122:f9eeca106725 832 * @param __RANKNB__: Rank number.
Kojto 122:f9eeca106725 833 * @retval None
Kojto 122:f9eeca106725 834 */
Kojto 122:f9eeca106725 835 #define ADC_SQR3_RK(__CHANNELNB__, __RANKNB__) ((__CHANNELNB__) << (POSITION_VAL(ADC_SQR3_SQ11) * ((__RANKNB__) - 10)))
Kojto 122:f9eeca106725 836
Kojto 122:f9eeca106725 837 /**
Kojto 122:f9eeca106725 838 * @brief Set the selected regular Channel rank for rank between 15 and 16.
Kojto 122:f9eeca106725 839 * @param __CHANNELNB__: Channel number.
Kojto 122:f9eeca106725 840 * @param __RANKNB__: Rank number.
Kojto 122:f9eeca106725 841 * @retval None
Kojto 122:f9eeca106725 842 */
Kojto 122:f9eeca106725 843 #define ADC_SQR4_RK(__CHANNELNB__, __RANKNB__) ((__CHANNELNB__) << (POSITION_VAL(ADC_SQR4_SQ16) * ((__RANKNB__) - 15)))
Kojto 122:f9eeca106725 844
Kojto 122:f9eeca106725 845 /**
Kojto 122:f9eeca106725 846 * @brief Set the selected injected Channel rank.
Kojto 122:f9eeca106725 847 * @param __CHANNELNB__: Channel number.
Kojto 122:f9eeca106725 848 * @param __RANKNB__: Rank number.
Kojto 122:f9eeca106725 849 * @retval None
Kojto 122:f9eeca106725 850 */
Kojto 122:f9eeca106725 851 #define ADC_JSQR_RK(__CHANNELNB__, __RANKNB__) ((__CHANNELNB__) << ((POSITION_VAL(ADC_JSQR_JSQ1)-2) * (__RANKNB__) +2))
Kojto 122:f9eeca106725 852
Kojto 122:f9eeca106725 853
Kojto 122:f9eeca106725 854 /**
Kojto 122:f9eeca106725 855 * @brief Set the Analog Watchdog 1 channel.
Kojto 122:f9eeca106725 856 * @param __CHANNEL__: channel to be monitored by Analog Watchdog 1.
Kojto 122:f9eeca106725 857 * @retval None
Kojto 122:f9eeca106725 858 */
Kojto 122:f9eeca106725 859 #define ADC_CFGR_SET_AWD1CH(__CHANNEL__) ((__CHANNEL__) << POSITION_VAL(ADC_CFGR_AWD1CH))
Kojto 122:f9eeca106725 860
Kojto 122:f9eeca106725 861 /**
Kojto 122:f9eeca106725 862 * @brief Configure the channel number in Analog Watchdog 2 or 3.
Kojto 122:f9eeca106725 863 * @param __CHANNEL__: ADC Channel
Kojto 122:f9eeca106725 864 * @retval None
Kojto 122:f9eeca106725 865 */
Kojto 122:f9eeca106725 866 #define ADC_CFGR_SET_AWD23CR(__CHANNEL__) (1U << (__CHANNEL__))
Kojto 122:f9eeca106725 867
Kojto 122:f9eeca106725 868 /**
Kojto 122:f9eeca106725 869 * @brief Configure ADC injected context queue
Kojto 122:f9eeca106725 870 * @param __INJECT_CONTEXT_QUEUE_MODE__: Injected context queue mode.
Kojto 122:f9eeca106725 871 * @retval None
Kojto 122:f9eeca106725 872 */
Kojto 122:f9eeca106725 873 #define ADC_CFGR_INJECT_CONTEXT_QUEUE(__INJECT_CONTEXT_QUEUE_MODE__) ((__INJECT_CONTEXT_QUEUE_MODE__) << POSITION_VAL(ADC_CFGR_JQM))
Kojto 122:f9eeca106725 874
Kojto 122:f9eeca106725 875 /**
Kojto 122:f9eeca106725 876 * @brief Configure ADC discontinuous conversion mode for injected group
Kojto 122:f9eeca106725 877 * @param __INJECT_DISCONTINUOUS_MODE__: Injected discontinuous mode.
Kojto 122:f9eeca106725 878 * @retval None
Kojto 122:f9eeca106725 879 */
Kojto 122:f9eeca106725 880 #define ADC_CFGR_INJECT_DISCCONTINUOUS(__INJECT_DISCONTINUOUS_MODE__) ((__INJECT_DISCONTINUOUS_MODE__) << POSITION_VAL(ADC_CFGR_JDISCEN))
Kojto 122:f9eeca106725 881
Kojto 122:f9eeca106725 882 /**
Kojto 122:f9eeca106725 883 * @brief Configure ADC discontinuous conversion mode for regular group
Kojto 122:f9eeca106725 884 * @param __REG_DISCONTINUOUS_MODE__: Regular discontinuous mode.
Kojto 122:f9eeca106725 885 * @retval None
Kojto 122:f9eeca106725 886 */
Kojto 122:f9eeca106725 887 #define ADC_CFGR_REG_DISCONTINUOUS(__REG_DISCONTINUOUS_MODE__) ((__REG_DISCONTINUOUS_MODE__) << POSITION_VAL(ADC_CFGR_DISCEN))
Kojto 122:f9eeca106725 888 /**
Kojto 122:f9eeca106725 889 * @brief Configure the number of discontinuous conversions for regular group.
Kojto 122:f9eeca106725 890 * @param __NBR_DISCONTINUOUS_CONV__: Number of discontinuous conversions.
Kojto 122:f9eeca106725 891 * @retval None
Kojto 122:f9eeca106725 892 */
Kojto 122:f9eeca106725 893 #define ADC_CFGR_DISCONTINUOUS_NUM(__NBR_DISCONTINUOUS_CONV__) (((__NBR_DISCONTINUOUS_CONV__) - 1) << POSITION_VAL(ADC_CFGR_DISCNUM))
Kojto 122:f9eeca106725 894
Kojto 122:f9eeca106725 895 /**
Kojto 122:f9eeca106725 896 * @brief Configure the ADC auto delay mode.
Kojto 122:f9eeca106725 897 * @param __AUTOWAIT__: Auto delay bit enable or disable.
Kojto 122:f9eeca106725 898 * @retval None
Kojto 122:f9eeca106725 899 */
Kojto 122:f9eeca106725 900 #define ADC_CFGR_AUTOWAIT(__AUTOWAIT__) ((__AUTOWAIT__) << POSITION_VAL(ADC_CFGR_AUTDLY))
Kojto 122:f9eeca106725 901
Kojto 122:f9eeca106725 902 /**
Kojto 122:f9eeca106725 903 * @brief Configure ADC continuous conversion mode.
Kojto 122:f9eeca106725 904 * @param __CONTINUOUS_MODE__: Continuous mode.
Kojto 122:f9eeca106725 905 * @retval None
Kojto 122:f9eeca106725 906 */
Kojto 122:f9eeca106725 907 #define ADC_CFGR_CONTINUOUS(__CONTINUOUS_MODE__) ((__CONTINUOUS_MODE__) << POSITION_VAL(ADC_CFGR_CONT))
Kojto 122:f9eeca106725 908
Kojto 122:f9eeca106725 909 /**
Kojto 122:f9eeca106725 910 * @brief Configure the ADC DMA continuous request.
Kojto 122:f9eeca106725 911 * @param __DMACONTREQ_MODE__: DMA continuous request mode.
Kojto 122:f9eeca106725 912 * @retval None
Kojto 122:f9eeca106725 913 */
Kojto 122:f9eeca106725 914 #define ADC_CFGR_DMACONTREQ(__DMACONTREQ_MODE__) ((__DMACONTREQ_MODE__) << POSITION_VAL(ADC_CFGR_DMACFG))
Kojto 122:f9eeca106725 915
Kojto 122:f9eeca106725 916
Kojto 122:f9eeca106725 917 /**
Kojto 122:f9eeca106725 918 * @brief Configure the channel number into offset OFRx register.
Kojto 122:f9eeca106725 919 * @param __CHANNEL__: ADC Channel.
Kojto 122:f9eeca106725 920 * @retval None
Kojto 122:f9eeca106725 921 */
Kojto 122:f9eeca106725 922 #define ADC_OFR_CHANNEL(__CHANNEL__) ((__CHANNEL__) << POSITION_VAL(ADC_OFR1_OFFSET1_CH))
Kojto 122:f9eeca106725 923
Kojto 122:f9eeca106725 924 /**
Kojto 122:f9eeca106725 925 * @brief Configure the channel number into differential mode selection register.
Kojto 122:f9eeca106725 926 * @param __CHANNEL__: ADC Channel.
Kojto 122:f9eeca106725 927 * @retval None
Kojto 122:f9eeca106725 928 */
Kojto 122:f9eeca106725 929 #define ADC_DIFSEL_CHANNEL(__CHANNEL__) (1U << (__CHANNEL__))
Kojto 122:f9eeca106725 930
Kojto 122:f9eeca106725 931 /**
Kojto 122:f9eeca106725 932 * @brief Configure calibration factor in differential mode to be set into calibration register.
Kojto 122:f9eeca106725 933 * @param __CALIBRATION_FACTOR__: Calibration factor value.
Kojto 122:f9eeca106725 934 * @retval None
Kojto 122:f9eeca106725 935 */
Kojto 122:f9eeca106725 936 #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))
Kojto 122:f9eeca106725 937 /**
Kojto 122:f9eeca106725 938 * @brief Calibration factor in differential mode to be retrieved from calibration register.
Kojto 122:f9eeca106725 939 * @param __CALIBRATION_FACTOR__: Calibration factor value.
Kojto 122:f9eeca106725 940 * @retval None
Kojto 122:f9eeca106725 941 */
Kojto 122:f9eeca106725 942 #define ADC_CALFACT_DIFF_GET(__CALIBRATION_FACTOR__) ((__CALIBRATION_FACTOR__) >> POSITION_VAL(ADC_CALFACT_CALFACT_D))
Kojto 122:f9eeca106725 943
Kojto 122:f9eeca106725 944 /**
Kojto 122:f9eeca106725 945 * @brief Configure the analog watchdog high threshold into registers TR1, TR2 or TR3.
Kojto 122:f9eeca106725 946 * @param __THRESHOLD__: Threshold value.
Kojto 122:f9eeca106725 947 * @retval None
Kojto 122:f9eeca106725 948 */
Kojto 122:f9eeca106725 949 #define ADC_TRX_HIGHTHRESHOLD(__THRESHOLD__) ((__THRESHOLD__) << 16)
Kojto 122:f9eeca106725 950
Kojto 122:f9eeca106725 951 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 952 /**
Kojto 122:f9eeca106725 953 * @brief Configure the ADC DMA continuous request for ADC multimode.
Kojto 122:f9eeca106725 954 * @param __DMACONTREQ_MODE__: DMA continuous request mode.
Kojto 122:f9eeca106725 955 * @retval None
Kojto 122:f9eeca106725 956 */
Kojto 122:f9eeca106725 957 #define ADC_CCR_MULTI_DMACONTREQ(__DMACONTREQ_MODE__) ((__DMACONTREQ_MODE__) << POSITION_VAL(ADC_CCR_DMACFG))
Kojto 122:f9eeca106725 958 #endif /* defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) */
Kojto 122:f9eeca106725 959
Kojto 122:f9eeca106725 960 /**
Kojto 122:f9eeca106725 961 * @brief Enable the ADC peripheral.
Kojto 122:f9eeca106725 962 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 963 * @retval None
Kojto 122:f9eeca106725 964 */
Kojto 122:f9eeca106725 965 #define ADC_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR |= ADC_CR_ADEN)
Kojto 122:f9eeca106725 966
Kojto 122:f9eeca106725 967 /**
Kojto 122:f9eeca106725 968 * @brief Verification of hardware constraints before ADC can be enabled.
Kojto 122:f9eeca106725 969 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 970 * @retval SET (ADC can be enabled) or RESET (ADC cannot be enabled)
Kojto 122:f9eeca106725 971 */
Kojto 122:f9eeca106725 972 #define ADC_ENABLING_CONDITIONS(__HANDLE__) \
Kojto 122:f9eeca106725 973 (( ( ((__HANDLE__)->Instance->CR) & \
Kojto 122:f9eeca106725 974 (ADC_CR_ADCAL | ADC_CR_JADSTP | ADC_CR_ADSTP | ADC_CR_JADSTART | \
Kojto 122:f9eeca106725 975 ADC_CR_ADSTART | ADC_CR_ADDIS | ADC_CR_ADEN ) \
Kojto 122:f9eeca106725 976 ) == RESET \
Kojto 122:f9eeca106725 977 ) ? SET : RESET)
Kojto 122:f9eeca106725 978
Kojto 122:f9eeca106725 979 /**
Kojto 122:f9eeca106725 980 * @brief Disable the ADC peripheral.
Kojto 122:f9eeca106725 981 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 982 * @retval None
Kojto 122:f9eeca106725 983 */
Kojto 122:f9eeca106725 984 #define ADC_DISABLE(__HANDLE__) \
Kojto 122:f9eeca106725 985 do{ \
Kojto 122:f9eeca106725 986 (__HANDLE__)->Instance->CR |= ADC_CR_ADDIS; \
Kojto 122:f9eeca106725 987 __HAL_ADC_CLEAR_FLAG((__HANDLE__), (ADC_FLAG_EOSMP | ADC_FLAG_RDY)); \
Kojto 122:f9eeca106725 988 } while(0)
Kojto 122:f9eeca106725 989
Kojto 122:f9eeca106725 990 /**
Kojto 122:f9eeca106725 991 * @brief Verification of hardware constraints before ADC can be disabled.
Kojto 122:f9eeca106725 992 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 993 * @retval SET (ADC can be disabled) or RESET (ADC cannot be disabled)
Kojto 122:f9eeca106725 994 */
Kojto 122:f9eeca106725 995 #define ADC_DISABLING_CONDITIONS(__HANDLE__) \
Kojto 122:f9eeca106725 996 (( ( ((__HANDLE__)->Instance->CR) & \
Kojto 122:f9eeca106725 997 (ADC_CR_JADSTART | ADC_CR_ADSTART | ADC_CR_ADEN)) == ADC_CR_ADEN \
Kojto 122:f9eeca106725 998 ) ? SET : RESET)
Kojto 122:f9eeca106725 999
Kojto 122:f9eeca106725 1000
Kojto 122:f9eeca106725 1001 /**
Kojto 122:f9eeca106725 1002 * @brief Shift the offset with respect to the selected ADC resolution.
Kojto 122:f9eeca106725 1003 * @note Offset has to be left-aligned on bit 11, the LSB (right bits) are set to 0.
Kojto 122:f9eeca106725 1004 * If resolution 12 bits, no shift.
Kojto 122:f9eeca106725 1005 * If resolution 10 bits, shift of 2 ranks on the left.
Kojto 122:f9eeca106725 1006 * If resolution 8 bits, shift of 4 ranks on the left.
Kojto 122:f9eeca106725 1007 * If resolution 6 bits, shift of 6 ranks on the left.
Kojto 122:f9eeca106725 1008 * Therefore, shift = (12 - resolution) = 12 - (12- (((RES[1:0]) >> 3)*2)).
Kojto 122:f9eeca106725 1009 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 1010 * @param __OFFSET__: Value to be shifted
Kojto 122:f9eeca106725 1011 * @retval None
Kojto 122:f9eeca106725 1012 */
Kojto 122:f9eeca106725 1013 #define ADC_OFFSET_SHIFT_RESOLUTION(__HANDLE__, __OFFSET__) \
Kojto 122:f9eeca106725 1014 ((__OFFSET__) << ((((__HANDLE__)->Instance->CFGR & ADC_CFGR_RES) >> 3)*2))
Kojto 122:f9eeca106725 1015
Kojto 122:f9eeca106725 1016
Kojto 122:f9eeca106725 1017 /**
Kojto 122:f9eeca106725 1018 * @brief Shift the AWD1 threshold with respect to the selected ADC resolution.
Kojto 122:f9eeca106725 1019 * @note Thresholds have to be left-aligned on bit 11, the LSB (right bits) are set to 0.
Kojto 122:f9eeca106725 1020 * If resolution 12 bits, no shift.
Kojto 122:f9eeca106725 1021 * If resolution 10 bits, shift of 2 ranks on the left.
Kojto 122:f9eeca106725 1022 * If resolution 8 bits, shift of 4 ranks on the left.
Kojto 122:f9eeca106725 1023 * If resolution 6 bits, shift of 6 ranks on the left.
Kojto 122:f9eeca106725 1024 * Therefore, shift = (12 - resolution) = 12 - (12- (((RES[1:0]) >> 3)*2)).
Kojto 122:f9eeca106725 1025 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 1026 * @param __THRESHOLD__: Value to be shifted
Kojto 122:f9eeca106725 1027 * @retval None
Kojto 122:f9eeca106725 1028 */
Kojto 122:f9eeca106725 1029 #define ADC_AWD1THRESHOLD_SHIFT_RESOLUTION(__HANDLE__, __THRESHOLD__) \
Kojto 122:f9eeca106725 1030 ((__THRESHOLD__) << ((((__HANDLE__)->Instance->CFGR & ADC_CFGR_RES) >> 3)*2))
Kojto 122:f9eeca106725 1031
Kojto 122:f9eeca106725 1032 /**
Kojto 122:f9eeca106725 1033 * @brief Shift the AWD2 and AWD3 threshold with respect to the selected ADC resolution.
Kojto 122:f9eeca106725 1034 * @note Thresholds have to be left-aligned on bit 7.
Kojto 122:f9eeca106725 1035 * If resolution 12 bits, shift of 4 ranks on the right (the 4 LSB are discarded).
Kojto 122:f9eeca106725 1036 * If resolution 10 bits, shift of 2 ranks on the right (the 2 LSB are discarded).
Kojto 122:f9eeca106725 1037 * If resolution 8 bits, no shift.
Kojto 122:f9eeca106725 1038 * If resolution 6 bits, shift of 2 ranks on the left (the 2 LSB are set to 0).
Kojto 122:f9eeca106725 1039 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 1040 * @param __THRESHOLD__: Value to be shifted
Kojto 122:f9eeca106725 1041 * @retval None
Kojto 122:f9eeca106725 1042 */
Kojto 122:f9eeca106725 1043 #define ADC_AWD23THRESHOLD_SHIFT_RESOLUTION(__HANDLE__, __THRESHOLD__) \
Kojto 122:f9eeca106725 1044 ( ((__HANDLE__)->Instance->CFGR & ADC_CFGR_RES) != (ADC_CFGR_RES_1 | ADC_CFGR_RES_0) ? \
Kojto 122:f9eeca106725 1045 ((__THRESHOLD__) >> (4- ((((__HANDLE__)->Instance->CFGR & ADC_CFGR_RES) >> 3)*2))) : \
Kojto 122:f9eeca106725 1046 (__THRESHOLD__) << 2 )
Kojto 122:f9eeca106725 1047
Kojto 122:f9eeca106725 1048
Kojto 122:f9eeca106725 1049 /**
Kojto 122:f9eeca106725 1050 * @brief Report ADC common register.
Kojto 122:f9eeca106725 1051 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 1052 * @retval Common control register
Kojto 122:f9eeca106725 1053 */
Kojto 122:f9eeca106725 1054 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1055 #define ADC_COMMON_REGISTER(__HANDLE__) (ADC123_COMMON)
Kojto 122:f9eeca106725 1056 #elif defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 1057 #define ADC_COMMON_REGISTER(__HANDLE__) (ADC1_COMMON)
Kojto 122:f9eeca106725 1058 #endif
Kojto 122:f9eeca106725 1059
Kojto 122:f9eeca106725 1060 /**
Kojto 122:f9eeca106725 1061 * @brief Report Master Instance.
Kojto 122:f9eeca106725 1062 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 1063 * @note Return same instance if ADC of input handle is independent ADC or if
Kojto 122:f9eeca106725 1064 * multimode feature is not available.
Kojto 122:f9eeca106725 1065 * @retval Master Instance
Kojto 122:f9eeca106725 1066 */
Kojto 122:f9eeca106725 1067 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1068 #define ADC_MASTER_REGISTER(__HANDLE__) \
Kojto 122:f9eeca106725 1069 ( ( ((((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC3)) \
Kojto 122:f9eeca106725 1070 )? \
Kojto 122:f9eeca106725 1071 ((__HANDLE__)->Instance) \
Kojto 122:f9eeca106725 1072 : \
Kojto 122:f9eeca106725 1073 (ADC1) \
Kojto 122:f9eeca106725 1074 )
Kojto 122:f9eeca106725 1075 #elif defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 1076 #define ADC_MASTER_REGISTER(__HANDLE__) ((__HANDLE__)->Instance)
Kojto 122:f9eeca106725 1077 #endif
Kojto 122:f9eeca106725 1078
Kojto 122:f9eeca106725 1079
Kojto 122:f9eeca106725 1080 /**
Kojto 122:f9eeca106725 1081 * @brief Clear Common Control Register.
Kojto 122:f9eeca106725 1082 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 1083 * @retval None
Kojto 122:f9eeca106725 1084 */
Kojto 122:f9eeca106725 1085 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1086 #define ADC_CLEAR_COMMON_CONTROL_REGISTER(__HANDLE__) CLEAR_BIT(ADC_COMMON_REGISTER(__HANDLE__)->CCR, ADC_CCR_CKMODE | \
Kojto 122:f9eeca106725 1087 ADC_CCR_PRESC | \
Kojto 122:f9eeca106725 1088 ADC_CCR_VBATEN | \
Kojto 122:f9eeca106725 1089 ADC_CCR_TSEN | \
Kojto 122:f9eeca106725 1090 ADC_CCR_VREFEN | \
Kojto 122:f9eeca106725 1091 ADC_CCR_MDMA | \
Kojto 122:f9eeca106725 1092 ADC_CCR_DMACFG | \
Kojto 122:f9eeca106725 1093 ADC_CCR_DELAY | \
Kojto 122:f9eeca106725 1094 ADC_CCR_DUAL )
Kojto 122:f9eeca106725 1095 #elif defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 1096 #define ADC_CLEAR_COMMON_CONTROL_REGISTER(__HANDLE__) CLEAR_BIT(ADC_COMMON_REGISTER(__HANDLE__)->CCR, ADC_CCR_CKMODE | \
Kojto 122:f9eeca106725 1097 ADC_CCR_PRESC | \
Kojto 122:f9eeca106725 1098 ADC_CCR_VBATEN | \
Kojto 122:f9eeca106725 1099 ADC_CCR_TSEN | \
Kojto 122:f9eeca106725 1100 ADC_CCR_VREFEN )
Kojto 122:f9eeca106725 1101 #endif
Kojto 122:f9eeca106725 1102
Kojto 122:f9eeca106725 1103
Kojto 122:f9eeca106725 1104 /**
Kojto 122:f9eeca106725 1105 * @brief Check whether or not dual conversions are enabled.
Kojto 122:f9eeca106725 1106 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 1107 * @note Return RESET if ADC of input handle is independent ADC or if multimode feature is not available.
Kojto 122:f9eeca106725 1108 * @retval SET (dual regular conversions are enabled) or RESET (ADC is independent or no dual regular conversions are enabled)
Kojto 122:f9eeca106725 1109 */
Kojto 122:f9eeca106725 1110 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1111 #define ADC_IS_DUAL_CONVERSION_ENABLE(__HANDLE__) \
Kojto 122:f9eeca106725 1112 ( ( ((((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC2)) \
Kojto 122:f9eeca106725 1113 )? \
Kojto 122:f9eeca106725 1114 ( ((ADC123_COMMON->CCR & ADC_CCR_DUAL) != ADC_MODE_INDEPENDENT) ) \
Kojto 122:f9eeca106725 1115 : \
Kojto 122:f9eeca106725 1116 RESET \
Kojto 122:f9eeca106725 1117 )
Kojto 122:f9eeca106725 1118 #elif defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 1119 #define ADC_IS_DUAL_CONVERSION_ENABLE(__HANDLE__) (RESET)
Kojto 122:f9eeca106725 1120 #endif
Kojto 122:f9eeca106725 1121
Kojto 122:f9eeca106725 1122 /**
Kojto 122:f9eeca106725 1123 * @brief Check whether or not dual regular conversions are enabled.
Kojto 122:f9eeca106725 1124 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 1125 * @note Return RESET if ADC of input handle is independent ADC or if multimode feature is not available.
Kojto 122:f9eeca106725 1126 * @retval SET (dual regular conversions are enabled) or RESET (ADC is independent or no dual regular conversions are enabled)
Kojto 122:f9eeca106725 1127 */
Kojto 122:f9eeca106725 1128 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1129 #define ADC_IS_DUAL_REGULAR_CONVERSION_ENABLE(__HANDLE__) \
Kojto 122:f9eeca106725 1130 ( ( ((((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC2)) \
Kojto 122:f9eeca106725 1131 )? \
Kojto 122:f9eeca106725 1132 ( (((ADC_COMMON_REGISTER(__HANDLE__))->CCR & ADC_CCR_DUAL) != ADC_MODE_INDEPENDENT) && \
Kojto 122:f9eeca106725 1133 (((ADC_COMMON_REGISTER(__HANDLE__))->CCR & ADC_CCR_DUAL) != ADC_DUALMODE_INJECSIMULT) && \
Kojto 122:f9eeca106725 1134 (((ADC_COMMON_REGISTER(__HANDLE__))->CCR & ADC_CCR_DUAL) != ADC_DUALMODE_ALTERTRIG) ) \
Kojto 122:f9eeca106725 1135 : \
Kojto 122:f9eeca106725 1136 RESET \
Kojto 122:f9eeca106725 1137 )
Kojto 122:f9eeca106725 1138 #elif defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 1139 #define ADC_IS_DUAL_REGULAR_CONVERSION_ENABLE(__HANDLE__) (RESET)
Kojto 122:f9eeca106725 1140 #endif
Kojto 122:f9eeca106725 1141
Kojto 122:f9eeca106725 1142
Kojto 122:f9eeca106725 1143 /**
Kojto 122:f9eeca106725 1144 * @brief Verification of condition for ADC start conversion: ADC must be in non-multimode or multimode with handle of ADC master.
Kojto 122:f9eeca106725 1145 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 1146 * @note Return SET if multimode feature is not available.
Kojto 122:f9eeca106725 1147 * @retval SET (non-multimode or Master handle) or RESET (handle of Slave ADC in multimode)
Kojto 122:f9eeca106725 1148 */
Kojto 122:f9eeca106725 1149 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1150 #define ADC_NONMULTIMODE_OR_MULTIMODEMASTER(__HANDLE__) \
Kojto 122:f9eeca106725 1151 ( ( ((__HANDLE__)->Instance == ADC1) || ((__HANDLE__)->Instance == ADC3) \
Kojto 122:f9eeca106725 1152 )? \
Kojto 122:f9eeca106725 1153 SET \
Kojto 122:f9eeca106725 1154 : \
Kojto 122:f9eeca106725 1155 ((ADC123_COMMON->CCR & ADC_CCR_DUAL) == RESET) \
Kojto 122:f9eeca106725 1156 )
Kojto 122:f9eeca106725 1157 #elif defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 1158 #define ADC_NONMULTIMODE_OR_MULTIMODEMASTER(__HANDLE__) (SET)
Kojto 122:f9eeca106725 1159 #endif
Kojto 122:f9eeca106725 1160
Kojto 122:f9eeca106725 1161 /**
Kojto 122:f9eeca106725 1162 * @brief Ensure ADC Instance is Independent or Master, or is not Slave ADC with dual regular conversions enabled.
Kojto 122:f9eeca106725 1163 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 1164 * @note Return SET if multimode feature is not available.
Kojto 122:f9eeca106725 1165 * @retval SET (Independent or Master, or Slave without dual regular conversions enabled) or RESET (Slave ADC with dual regular conversions enabled)
Kojto 122:f9eeca106725 1166 */
Kojto 122:f9eeca106725 1167 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1168 #define ADC_INDEPENDENT_OR_NONMULTIMODEREGULAR_SLAVE(__HANDLE__) \
Kojto 122:f9eeca106725 1169 ( ( ((__HANDLE__)->Instance == ADC1) || ((__HANDLE__)->Instance == ADC3) \
Kojto 122:f9eeca106725 1170 )? \
Kojto 122:f9eeca106725 1171 SET \
Kojto 122:f9eeca106725 1172 : \
Kojto 122:f9eeca106725 1173 ( ((ADC123_COMMON->CCR & ADC_CCR_DUAL) == ADC_MODE_INDEPENDENT) || \
Kojto 122:f9eeca106725 1174 ((ADC123_COMMON->CCR & ADC_CCR_DUAL) == ADC_DUALMODE_INJECSIMULT) || \
Kojto 122:f9eeca106725 1175 ((ADC123_COMMON->CCR & ADC_CCR_DUAL) == ADC_DUALMODE_ALTERTRIG) ))
Kojto 122:f9eeca106725 1176 #elif defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 1177 #define ADC_INDEPENDENT_OR_NONMULTIMODEREGULAR_SLAVE(__HANDLE__) (SET)
Kojto 122:f9eeca106725 1178 #endif
Kojto 122:f9eeca106725 1179
Kojto 122:f9eeca106725 1180 /**
Kojto 122:f9eeca106725 1181 * @brief Ensure ADC Instance is Independent or Master, or is not Slave ADC with dual injected conversions enabled.
Kojto 122:f9eeca106725 1182 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 1183 * @note Return SET if multimode feature is not available.
Kojto 122:f9eeca106725 1184 * @retval SET (non-multimode or Master, or Slave without dual injected conversions enabled) or RESET (Slave ADC with dual injected conversions enabled)
Kojto 122:f9eeca106725 1185 */
Kojto 122:f9eeca106725 1186 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1187 #define ADC_INDEPENDENT_OR_NONMULTIMODEINJECTED_SLAVE(__HANDLE__) \
Kojto 122:f9eeca106725 1188 ( ( ((__HANDLE__)->Instance == ADC1) || ((__HANDLE__)->Instance == ADC3) \
Kojto 122:f9eeca106725 1189 )? \
Kojto 122:f9eeca106725 1190 SET \
Kojto 122:f9eeca106725 1191 : \
Kojto 122:f9eeca106725 1192 ( ((ADC123_COMMON->CCR & ADC_CCR_DUAL) == ADC_MODE_INDEPENDENT) || \
Kojto 122:f9eeca106725 1193 ((ADC123_COMMON->CCR & ADC_CCR_DUAL) == ADC_DUALMODE_REGSIMULT) || \
Kojto 122:f9eeca106725 1194 ((ADC123_COMMON->CCR & ADC_CCR_DUAL) == ADC_DUALMODE_INTERL) ))
Kojto 122:f9eeca106725 1195 #elif defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 1196 #define ADC_INDEPENDENT_OR_NONMULTIMODEINJECTED_SLAVE(__HANDLE__) (SET)
Kojto 122:f9eeca106725 1197 #endif
Kojto 122:f9eeca106725 1198
Kojto 122:f9eeca106725 1199 /**
Kojto 122:f9eeca106725 1200 * @brief Verification of ADC state: enabled or disabled, directly checked on instance as input parameter.
Kojto 122:f9eeca106725 1201 * @param __INSTANCE__: ADC instance.
Kojto 122:f9eeca106725 1202 * @retval SET (ADC enabled) or RESET (ADC disabled)
Kojto 122:f9eeca106725 1203 */
Kojto 122:f9eeca106725 1204 #define ADC_INSTANCE_IS_ENABLED(__INSTANCE__) \
Kojto 122:f9eeca106725 1205 (( ((((__INSTANCE__)->CR) & (ADC_CR_ADEN | ADC_CR_ADDIS)) == ADC_CR_ADEN) && \
Kojto 122:f9eeca106725 1206 ((((__INSTANCE__)->ISR) & ADC_FLAG_RDY) == ADC_FLAG_RDY) \
Kojto 122:f9eeca106725 1207 ) ? SET : RESET)
Kojto 122:f9eeca106725 1208
Kojto 122:f9eeca106725 1209 /**
Kojto 122:f9eeca106725 1210 * @brief Verification of enabled/disabled status of ADCs other than that associated to the input parameter handle.
Kojto 122:f9eeca106725 1211 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 1212 * @retval SET (at least one other ADC is enabled) or RESET (no other ADC is enabled, all other ADCs are disabled)
Kojto 122:f9eeca106725 1213 */
Kojto 122:f9eeca106725 1214 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1215 #define ADC_ANY_OTHER_ENABLED(__HANDLE__) \
Kojto 122:f9eeca106725 1216 ( ( ((__HANDLE__)->Instance == ADC1) \
Kojto 122:f9eeca106725 1217 )? \
Kojto 122:f9eeca106725 1218 (ADC_INSTANCE_IS_ENABLED(ADC2)) || (ADC_INSTANCE_IS_ENABLED(ADC3)) \
Kojto 122:f9eeca106725 1219 : \
Kojto 122:f9eeca106725 1220 ( ( ((__HANDLE__)->Instance == ADC2) \
Kojto 122:f9eeca106725 1221 )? \
Kojto 122:f9eeca106725 1222 (ADC_INSTANCE_IS_ENABLED(ADC1)) || (ADC_INSTANCE_IS_ENABLED(ADC3)) \
Kojto 122:f9eeca106725 1223 : \
Kojto 122:f9eeca106725 1224 ADC_INSTANCE_IS_ENABLED(ADC1)) || (ADC_INSTANCE_IS_ENABLED(ADC2)) \
Kojto 122:f9eeca106725 1225 )
Kojto 122:f9eeca106725 1226 #elif defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 1227 #define ADC_ANY_OTHER_ENABLED(__HANDLE__) (RESET)
Kojto 122:f9eeca106725 1228 #endif
Kojto 122:f9eeca106725 1229
Kojto 122:f9eeca106725 1230
Kojto 122:f9eeca106725 1231 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1232 /**
Kojto 122:f9eeca106725 1233 * @brief Set handle instance of the ADC slave associated to the ADC master.
Kojto 122:f9eeca106725 1234 * @param __HANDLE_MASTER__: ADC master handle.
Kojto 122:f9eeca106725 1235 * @param __HANDLE_SLAVE__: ADC slave handle.
Kojto 122:f9eeca106725 1236 * @note if __HANDLE_MASTER__ is the handle of a slave ADC (ADC2) or an independent ADC (ADC3), __HANDLE_SLAVE__ instance is set to NULL.
Kojto 122:f9eeca106725 1237 * @retval None
Kojto 122:f9eeca106725 1238 */
Kojto 122:f9eeca106725 1239 #define ADC_MULTI_SLAVE(__HANDLE_MASTER__, __HANDLE_SLAVE__) \
Kojto 122:f9eeca106725 1240 ( (((__HANDLE_MASTER__)->Instance == ADC1)) ? ((__HANDLE_SLAVE__)->Instance = ADC2) : ((__HANDLE_SLAVE__)->Instance = NULL) )
Kojto 122:f9eeca106725 1241 #endif /* defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) */
Kojto 122:f9eeca106725 1242
Kojto 122:f9eeca106725 1243
Kojto 122:f9eeca106725 1244 /**
Kojto 122:f9eeca106725 1245 * @brief Check whether or not multimode is configured in DMA mode.
Kojto 122:f9eeca106725 1246 * @note Return RESET if multimode feature is not available.
Kojto 122:f9eeca106725 1247 * @retval SET (multimode is configured in DMA mode) or RESET (DMA multimode is disabled)
Kojto 122:f9eeca106725 1248 */
Kojto 122:f9eeca106725 1249 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1250 #define ADC_MULTIMODE_DMA_ENABLED() \
Kojto 122:f9eeca106725 1251 ((READ_BIT(ADC123_COMMON->CCR, ADC_CCR_MDMA) == ADC_DMAACCESSMODE_12_10_BITS) \
Kojto 122:f9eeca106725 1252 || (READ_BIT(ADC123_COMMON->CCR, ADC_CCR_MDMA) == ADC_DMAACCESSMODE_8_6_BITS))
Kojto 122:f9eeca106725 1253 #elif defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 1254 #define ADC_MULTIMODE_DMA_ENABLED() (RESET)
Kojto 122:f9eeca106725 1255 #endif
Kojto 122:f9eeca106725 1256
Kojto 122:f9eeca106725 1257
Kojto 122:f9eeca106725 1258 /**
Kojto 122:f9eeca106725 1259 * @brief Verify the ADC instance connected to the temperature sensor.
Kojto 122:f9eeca106725 1260 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 1261 * @retval SET (ADC instance is valid) or RESET (ADC instance is invalid)
Kojto 122:f9eeca106725 1262 */
Kojto 122:f9eeca106725 1263 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 1264 /* The temperature sensor measurement path (channel 17) is available on ADC1 */
Kojto 122:f9eeca106725 1265 #define ADC_TEMPERATURE_SENSOR_INSTANCE(__HANDLE__) (((__HANDLE__)->Instance) == ADC1)
Kojto 122:f9eeca106725 1266 #elif defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1267 /* The temperature sensor measurement path (channel 17) is available on ADC1 and ADC3 */
Kojto 122:f9eeca106725 1268 #define ADC_TEMPERATURE_SENSOR_INSTANCE(__HANDLE__) ((((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC3))
Kojto 122:f9eeca106725 1269 #endif
Kojto 122:f9eeca106725 1270
Kojto 122:f9eeca106725 1271 /**
Kojto 122:f9eeca106725 1272 * @brief Verify the ADC instance connected to the battery voltage VBAT.
Kojto 122:f9eeca106725 1273 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 1274 * @retval SET (ADC instance is valid) or RESET (ADC instance is invalid)
Kojto 122:f9eeca106725 1275 */
Kojto 122:f9eeca106725 1276 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 1277 /* The battery voltage measurement path (channel 18) is available on ADC1 */
Kojto 122:f9eeca106725 1278 #define ADC_BATTERY_VOLTAGE_INSTANCE(__HANDLE__) (((__HANDLE__)->Instance) == ADC1)
Kojto 122:f9eeca106725 1279 #elif defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1280 /* The battery voltage measurement path (channel 18) is available on ADC1 and ADC3 */
Kojto 122:f9eeca106725 1281 #define ADC_BATTERY_VOLTAGE_INSTANCE(__HANDLE__) ((((__HANDLE__)->Instance) == ADC1) || (((__HANDLE__)->Instance) == ADC3))
Kojto 122:f9eeca106725 1282 #endif
Kojto 122:f9eeca106725 1283
Kojto 122:f9eeca106725 1284 /**
Kojto 122:f9eeca106725 1285 * @brief Verify the ADC instance connected to the internal voltage reference VREFINT.
Kojto 122:f9eeca106725 1286 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 1287 * @retval SET (ADC instance is valid) or RESET (ADC instance is invalid)
Kojto 122:f9eeca106725 1288 */
Kojto 122:f9eeca106725 1289 /* The internal voltage reference VREFINT measurement path (channel 0) is available on ADC1 */
Kojto 122:f9eeca106725 1290 #define ADC_VREFINT_INSTANCE(__HANDLE__) (((__HANDLE__)->Instance) == ADC1)
Kojto 122:f9eeca106725 1291
Kojto 122:f9eeca106725 1292
Kojto 122:f9eeca106725 1293 /**
Kojto 122:f9eeca106725 1294 * @brief Verify the length of scheduled injected conversions group.
Kojto 122:f9eeca106725 1295 * @param __LENGTH__: number of programmed conversions.
Kojto 122:f9eeca106725 1296 * @retval SET (__LENGTH__ is within the maximum number of possible programmable injected conversions) or RESET (__LENGTH__ is null or too large)
Kojto 122:f9eeca106725 1297 */
Kojto 122:f9eeca106725 1298 #define IS_ADC_INJECTED_NB_CONV(__LENGTH__) (((__LENGTH__) >= ((uint32_t)1)) && ((__LENGTH__) <= ((uint32_t)4)))
Kojto 122:f9eeca106725 1299
Kojto 122:f9eeca106725 1300
Kojto 122:f9eeca106725 1301 /**
Kojto 122:f9eeca106725 1302 * @brief Calibration factor size verification (7 bits maximum).
Kojto 122:f9eeca106725 1303 * @param __CALIBRATION_FACTOR__: Calibration factor value.
Kojto 122:f9eeca106725 1304 * @retval SET (__CALIBRATION_FACTOR__ is within the authorized size) or RESET (__CALIBRATION_FACTOR__ is too large)
Kojto 122:f9eeca106725 1305 */
Kojto 122:f9eeca106725 1306 #define IS_ADC_CALFACT(__CALIBRATION_FACTOR__) ((__CALIBRATION_FACTOR__) <= ((uint32_t)0x7F))
Kojto 122:f9eeca106725 1307
Kojto 122:f9eeca106725 1308
Kojto 122:f9eeca106725 1309 /**
Kojto 122:f9eeca106725 1310 * @brief Verify the ADC channel setting.
Kojto 122:f9eeca106725 1311 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 1312 * @param __CHANNEL__: programmed ADC channel.
Kojto 122:f9eeca106725 1313 * @retval SET (__CHANNEL__ is valid) or RESET (__CHANNEL__ is invalid)
Kojto 122:f9eeca106725 1314 */
Kojto 122:f9eeca106725 1315 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 1316 #define IS_ADC_CHANNEL(__HANDLE__, __CHANNEL__) ((((__HANDLE__)->Instance) == ADC1) && \
Kojto 122:f9eeca106725 1317 (((__CHANNEL__) == ADC_CHANNEL_VREFINT) || \
Kojto 122:f9eeca106725 1318 ((__CHANNEL__) == ADC_CHANNEL_1) || \
Kojto 122:f9eeca106725 1319 ((__CHANNEL__) == ADC_CHANNEL_2) || \
Kojto 122:f9eeca106725 1320 ((__CHANNEL__) == ADC_CHANNEL_3) || \
Kojto 122:f9eeca106725 1321 ((__CHANNEL__) == ADC_CHANNEL_4) || \
Kojto 122:f9eeca106725 1322 ((__CHANNEL__) == ADC_CHANNEL_5) || \
Kojto 122:f9eeca106725 1323 ((__CHANNEL__) == ADC_CHANNEL_6) || \
Kojto 122:f9eeca106725 1324 ((__CHANNEL__) == ADC_CHANNEL_7) || \
Kojto 122:f9eeca106725 1325 ((__CHANNEL__) == ADC_CHANNEL_8) || \
Kojto 122:f9eeca106725 1326 ((__CHANNEL__) == ADC_CHANNEL_9) || \
Kojto 122:f9eeca106725 1327 ((__CHANNEL__) == ADC_CHANNEL_10) || \
Kojto 122:f9eeca106725 1328 ((__CHANNEL__) == ADC_CHANNEL_11) || \
Kojto 122:f9eeca106725 1329 ((__CHANNEL__) == ADC_CHANNEL_12) || \
Kojto 122:f9eeca106725 1330 ((__CHANNEL__) == ADC_CHANNEL_13) || \
Kojto 122:f9eeca106725 1331 ((__CHANNEL__) == ADC_CHANNEL_14) || \
Kojto 122:f9eeca106725 1332 ((__CHANNEL__) == ADC_CHANNEL_15) || \
Kojto 122:f9eeca106725 1333 ((__CHANNEL__) == ADC_CHANNEL_16) || \
Kojto 122:f9eeca106725 1334 ((__CHANNEL__) == ADC_CHANNEL_17) || \
Kojto 122:f9eeca106725 1335 ((__CHANNEL__) == ADC_CHANNEL_18) || \
Kojto 122:f9eeca106725 1336 ((__CHANNEL__) == ADC_CHANNEL_TEMPSENSOR) || \
Kojto 122:f9eeca106725 1337 ((__CHANNEL__) == ADC_CHANNEL_VBAT)))
Kojto 122:f9eeca106725 1338 #elif defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1339 #define IS_ADC_CHANNEL(__HANDLE__, __CHANNEL__) (((((__HANDLE__)->Instance) == ADC1) && \
Kojto 122:f9eeca106725 1340 (((__CHANNEL__) == ADC_CHANNEL_VREFINT) || \
Kojto 122:f9eeca106725 1341 ((__CHANNEL__) == ADC_CHANNEL_1) || \
Kojto 122:f9eeca106725 1342 ((__CHANNEL__) == ADC_CHANNEL_2) || \
Kojto 122:f9eeca106725 1343 ((__CHANNEL__) == ADC_CHANNEL_3) || \
Kojto 122:f9eeca106725 1344 ((__CHANNEL__) == ADC_CHANNEL_4) || \
Kojto 122:f9eeca106725 1345 ((__CHANNEL__) == ADC_CHANNEL_5) || \
Kojto 122:f9eeca106725 1346 ((__CHANNEL__) == ADC_CHANNEL_6) || \
Kojto 122:f9eeca106725 1347 ((__CHANNEL__) == ADC_CHANNEL_7) || \
Kojto 122:f9eeca106725 1348 ((__CHANNEL__) == ADC_CHANNEL_8) || \
Kojto 122:f9eeca106725 1349 ((__CHANNEL__) == ADC_CHANNEL_9) || \
Kojto 122:f9eeca106725 1350 ((__CHANNEL__) == ADC_CHANNEL_10) || \
Kojto 122:f9eeca106725 1351 ((__CHANNEL__) == ADC_CHANNEL_11) || \
Kojto 122:f9eeca106725 1352 ((__CHANNEL__) == ADC_CHANNEL_12) || \
Kojto 122:f9eeca106725 1353 ((__CHANNEL__) == ADC_CHANNEL_13) || \
Kojto 122:f9eeca106725 1354 ((__CHANNEL__) == ADC_CHANNEL_14) || \
Kojto 122:f9eeca106725 1355 ((__CHANNEL__) == ADC_CHANNEL_15) || \
Kojto 122:f9eeca106725 1356 ((__CHANNEL__) == ADC_CHANNEL_16) || \
Kojto 122:f9eeca106725 1357 ((__CHANNEL__) == ADC_CHANNEL_TEMPSENSOR) || \
Kojto 122:f9eeca106725 1358 ((__CHANNEL__) == ADC_CHANNEL_VBAT))) || \
Kojto 122:f9eeca106725 1359 ((((__HANDLE__)->Instance) == ADC2) && \
Kojto 122:f9eeca106725 1360 (((__CHANNEL__) == ADC_CHANNEL_1) || \
Kojto 122:f9eeca106725 1361 ((__CHANNEL__) == ADC_CHANNEL_2) || \
Kojto 122:f9eeca106725 1362 ((__CHANNEL__) == ADC_CHANNEL_3) || \
Kojto 122:f9eeca106725 1363 ((__CHANNEL__) == ADC_CHANNEL_4) || \
Kojto 122:f9eeca106725 1364 ((__CHANNEL__) == ADC_CHANNEL_5) || \
Kojto 122:f9eeca106725 1365 ((__CHANNEL__) == ADC_CHANNEL_6) || \
Kojto 122:f9eeca106725 1366 ((__CHANNEL__) == ADC_CHANNEL_7) || \
Kojto 122:f9eeca106725 1367 ((__CHANNEL__) == ADC_CHANNEL_8) || \
Kojto 122:f9eeca106725 1368 ((__CHANNEL__) == ADC_CHANNEL_9) || \
Kojto 122:f9eeca106725 1369 ((__CHANNEL__) == ADC_CHANNEL_10) || \
Kojto 122:f9eeca106725 1370 ((__CHANNEL__) == ADC_CHANNEL_11) || \
Kojto 122:f9eeca106725 1371 ((__CHANNEL__) == ADC_CHANNEL_12) || \
Kojto 122:f9eeca106725 1372 ((__CHANNEL__) == ADC_CHANNEL_13) || \
Kojto 122:f9eeca106725 1373 ((__CHANNEL__) == ADC_CHANNEL_14) || \
Kojto 122:f9eeca106725 1374 ((__CHANNEL__) == ADC_CHANNEL_15) || \
Kojto 122:f9eeca106725 1375 ((__CHANNEL__) == ADC_CHANNEL_16) || \
Kojto 122:f9eeca106725 1376 ((__CHANNEL__) == ADC_CHANNEL_17) || \
Kojto 122:f9eeca106725 1377 ((__CHANNEL__) == ADC_CHANNEL_18))) || \
Kojto 122:f9eeca106725 1378 ((((__HANDLE__)->Instance) == ADC3) && \
Kojto 122:f9eeca106725 1379 (((__CHANNEL__) == ADC_CHANNEL_1) || \
Kojto 122:f9eeca106725 1380 ((__CHANNEL__) == ADC_CHANNEL_2) || \
Kojto 122:f9eeca106725 1381 ((__CHANNEL__) == ADC_CHANNEL_3) || \
Kojto 122:f9eeca106725 1382 ((__CHANNEL__) == ADC_CHANNEL_4) || \
Kojto 122:f9eeca106725 1383 ((__CHANNEL__) == ADC_CHANNEL_6) || \
Kojto 122:f9eeca106725 1384 ((__CHANNEL__) == ADC_CHANNEL_7) || \
Kojto 122:f9eeca106725 1385 ((__CHANNEL__) == ADC_CHANNEL_8) || \
Kojto 122:f9eeca106725 1386 ((__CHANNEL__) == ADC_CHANNEL_9) || \
Kojto 122:f9eeca106725 1387 ((__CHANNEL__) == ADC_CHANNEL_10) || \
Kojto 122:f9eeca106725 1388 ((__CHANNEL__) == ADC_CHANNEL_11) || \
Kojto 122:f9eeca106725 1389 ((__CHANNEL__) == ADC_CHANNEL_12) || \
Kojto 122:f9eeca106725 1390 ((__CHANNEL__) == ADC_CHANNEL_13) || \
Kojto 122:f9eeca106725 1391 ((__CHANNEL__) == ADC_CHANNEL_14) || \
Kojto 122:f9eeca106725 1392 ((__CHANNEL__) == ADC_CHANNEL_15) || \
Kojto 122:f9eeca106725 1393 ((__CHANNEL__) == ADC_CHANNEL_TEMPSENSOR) || \
Kojto 122:f9eeca106725 1394 ((__CHANNEL__) == ADC_CHANNEL_VBAT) )))
Kojto 122:f9eeca106725 1395 #endif
Kojto 122:f9eeca106725 1396
Kojto 122:f9eeca106725 1397 /**
Kojto 122:f9eeca106725 1398 * @brief Verify the ADC channel setting in differential mode.
Kojto 122:f9eeca106725 1399 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 1400 * @param __CHANNEL__: programmed ADC channel.
Kojto 122:f9eeca106725 1401 * @retval SET (__CHANNEL__ is valid) or RESET (__CHANNEL__ is invalid)
Kojto 122:f9eeca106725 1402 */
Kojto 122:f9eeca106725 1403 #if defined (STM32L431xx) || defined (STM32L432xx) || defined (STM32L433xx) || defined (STM32L442xx) || defined (STM32L443xx)
Kojto 122:f9eeca106725 1404 #define IS_ADC_DIFF_CHANNEL(__HANDLE__, __CHANNEL__) (((__CHANNEL__) == ADC_CHANNEL_1) || \
Kojto 122:f9eeca106725 1405 ((__CHANNEL__) == ADC_CHANNEL_2) || \
Kojto 122:f9eeca106725 1406 ((__CHANNEL__) == ADC_CHANNEL_3) || \
Kojto 122:f9eeca106725 1407 ((__CHANNEL__) == ADC_CHANNEL_4) || \
Kojto 122:f9eeca106725 1408 ((__CHANNEL__) == ADC_CHANNEL_5) || \
Kojto 122:f9eeca106725 1409 ((__CHANNEL__) == ADC_CHANNEL_6) || \
Kojto 122:f9eeca106725 1410 ((__CHANNEL__) == ADC_CHANNEL_7) || \
Kojto 122:f9eeca106725 1411 ((__CHANNEL__) == ADC_CHANNEL_8) || \
Kojto 122:f9eeca106725 1412 ((__CHANNEL__) == ADC_CHANNEL_9) || \
Kojto 122:f9eeca106725 1413 ((__CHANNEL__) == ADC_CHANNEL_10) || \
Kojto 122:f9eeca106725 1414 ((__CHANNEL__) == ADC_CHANNEL_11) || \
Kojto 122:f9eeca106725 1415 ((__CHANNEL__) == ADC_CHANNEL_12) || \
Kojto 122:f9eeca106725 1416 ((__CHANNEL__) == ADC_CHANNEL_13) || \
Kojto 122:f9eeca106725 1417 ((__CHANNEL__) == ADC_CHANNEL_14) || \
Kojto 122:f9eeca106725 1418 ((__CHANNEL__) == ADC_CHANNEL_15) )
Kojto 122:f9eeca106725 1419 #elif defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1420 /* For ADC1 and ADC2, channels 1 to 15 are available in differential mode,
Kojto 122:f9eeca106725 1421 channels 0, 16 to 18 can be only used in single-ended mode.
Kojto 122:f9eeca106725 1422 For ADC3, channels 1 to 3 and 6 to 12 are available in differential mode,
Kojto 122:f9eeca106725 1423 channels 4, 5 and 13 to 18 can only be used in single-ended mode. */
Kojto 122:f9eeca106725 1424 #define IS_ADC_DIFF_CHANNEL(__HANDLE__, __CHANNEL__) ((((((__HANDLE__)->Instance) == ADC1) || \
Kojto 122:f9eeca106725 1425 (((__HANDLE__)->Instance) == ADC2)) && \
Kojto 122:f9eeca106725 1426 (((__CHANNEL__) == ADC_CHANNEL_1) || \
Kojto 122:f9eeca106725 1427 ((__CHANNEL__) == ADC_CHANNEL_2) || \
Kojto 122:f9eeca106725 1428 ((__CHANNEL__) == ADC_CHANNEL_3) || \
Kojto 122:f9eeca106725 1429 ((__CHANNEL__) == ADC_CHANNEL_4) || \
Kojto 122:f9eeca106725 1430 ((__CHANNEL__) == ADC_CHANNEL_5) || \
Kojto 122:f9eeca106725 1431 ((__CHANNEL__) == ADC_CHANNEL_6) || \
Kojto 122:f9eeca106725 1432 ((__CHANNEL__) == ADC_CHANNEL_7) || \
Kojto 122:f9eeca106725 1433 ((__CHANNEL__) == ADC_CHANNEL_8) || \
Kojto 122:f9eeca106725 1434 ((__CHANNEL__) == ADC_CHANNEL_9) || \
Kojto 122:f9eeca106725 1435 ((__CHANNEL__) == ADC_CHANNEL_10) || \
Kojto 122:f9eeca106725 1436 ((__CHANNEL__) == ADC_CHANNEL_11) || \
Kojto 122:f9eeca106725 1437 ((__CHANNEL__) == ADC_CHANNEL_12) || \
Kojto 122:f9eeca106725 1438 ((__CHANNEL__) == ADC_CHANNEL_13) || \
Kojto 122:f9eeca106725 1439 ((__CHANNEL__) == ADC_CHANNEL_14) || \
Kojto 122:f9eeca106725 1440 ((__CHANNEL__) == ADC_CHANNEL_15))) || \
Kojto 122:f9eeca106725 1441 ((((__HANDLE__)->Instance) == ADC3) && \
Kojto 122:f9eeca106725 1442 (((__CHANNEL__) == ADC_CHANNEL_1) || \
Kojto 122:f9eeca106725 1443 ((__CHANNEL__) == ADC_CHANNEL_2) || \
Kojto 122:f9eeca106725 1444 ((__CHANNEL__) == ADC_CHANNEL_3) || \
Kojto 122:f9eeca106725 1445 ((__CHANNEL__) == ADC_CHANNEL_6) || \
Kojto 122:f9eeca106725 1446 ((__CHANNEL__) == ADC_CHANNEL_7) || \
Kojto 122:f9eeca106725 1447 ((__CHANNEL__) == ADC_CHANNEL_8) || \
Kojto 122:f9eeca106725 1448 ((__CHANNEL__) == ADC_CHANNEL_9) || \
Kojto 122:f9eeca106725 1449 ((__CHANNEL__) == ADC_CHANNEL_10) || \
Kojto 122:f9eeca106725 1450 ((__CHANNEL__) == ADC_CHANNEL_11) || \
Kojto 122:f9eeca106725 1451 ((__CHANNEL__) == ADC_CHANNEL_12) )))
Kojto 122:f9eeca106725 1452 #endif
Kojto 122:f9eeca106725 1453
Kojto 122:f9eeca106725 1454 /**
Kojto 122:f9eeca106725 1455 * @brief Verify the ADC single-ended input or differential mode setting.
Kojto 122:f9eeca106725 1456 * @param __SING_DIFF__: programmed channel setting.
Kojto 122:f9eeca106725 1457 * @retval SET (__SING_DIFF__ is valid) or RESET (__SING_DIFF__ is invalid)
Kojto 122:f9eeca106725 1458 */
Kojto 122:f9eeca106725 1459 #define IS_ADC_SINGLE_DIFFERENTIAL(__SING_DIFF__) (((__SING_DIFF__) == ADC_SINGLE_ENDED) || \
Kojto 122:f9eeca106725 1460 ((__SING_DIFF__) == ADC_DIFFERENTIAL_ENDED) )
Kojto 122:f9eeca106725 1461
Kojto 122:f9eeca106725 1462 /**
Kojto 122:f9eeca106725 1463 * @brief Verify the ADC offset management setting.
Kojto 122:f9eeca106725 1464 * @param __OFFSET_NUMBER__: ADC offset management.
Kojto 122:f9eeca106725 1465 * @retval SET (__OFFSET_NUMBER__ is valid) or RESET (__OFFSET_NUMBER__ is invalid)
Kojto 122:f9eeca106725 1466 */
Kojto 122:f9eeca106725 1467 #define IS_ADC_OFFSET_NUMBER(__OFFSET_NUMBER__) (((__OFFSET_NUMBER__) == ADC_OFFSET_NONE) || \
Kojto 122:f9eeca106725 1468 ((__OFFSET_NUMBER__) == ADC_OFFSET_1) || \
Kojto 122:f9eeca106725 1469 ((__OFFSET_NUMBER__) == ADC_OFFSET_2) || \
Kojto 122:f9eeca106725 1470 ((__OFFSET_NUMBER__) == ADC_OFFSET_3) || \
Kojto 122:f9eeca106725 1471 ((__OFFSET_NUMBER__) == ADC_OFFSET_4) )
Kojto 122:f9eeca106725 1472
Kojto 122:f9eeca106725 1473 /**
Kojto 122:f9eeca106725 1474 * @brief Verify the ADC regular channel setting.
Kojto 122:f9eeca106725 1475 * @param __CHANNEL__: programmed ADC regular channel.
Kojto 122:f9eeca106725 1476 * @retval SET (__CHANNEL__ is valid) or RESET (__CHANNEL__ is invalid)
Kojto 122:f9eeca106725 1477 */
Kojto 122:f9eeca106725 1478 #define IS_ADC_REGULAR_RANK(__CHANNEL__) (((__CHANNEL__) == ADC_REGULAR_RANK_1 ) || \
Kojto 122:f9eeca106725 1479 ((__CHANNEL__) == ADC_REGULAR_RANK_2 ) || \
Kojto 122:f9eeca106725 1480 ((__CHANNEL__) == ADC_REGULAR_RANK_3 ) || \
Kojto 122:f9eeca106725 1481 ((__CHANNEL__) == ADC_REGULAR_RANK_4 ) || \
Kojto 122:f9eeca106725 1482 ((__CHANNEL__) == ADC_REGULAR_RANK_5 ) || \
Kojto 122:f9eeca106725 1483 ((__CHANNEL__) == ADC_REGULAR_RANK_6 ) || \
Kojto 122:f9eeca106725 1484 ((__CHANNEL__) == ADC_REGULAR_RANK_7 ) || \
Kojto 122:f9eeca106725 1485 ((__CHANNEL__) == ADC_REGULAR_RANK_8 ) || \
Kojto 122:f9eeca106725 1486 ((__CHANNEL__) == ADC_REGULAR_RANK_9 ) || \
Kojto 122:f9eeca106725 1487 ((__CHANNEL__) == ADC_REGULAR_RANK_10) || \
Kojto 122:f9eeca106725 1488 ((__CHANNEL__) == ADC_REGULAR_RANK_11) || \
Kojto 122:f9eeca106725 1489 ((__CHANNEL__) == ADC_REGULAR_RANK_12) || \
Kojto 122:f9eeca106725 1490 ((__CHANNEL__) == ADC_REGULAR_RANK_13) || \
Kojto 122:f9eeca106725 1491 ((__CHANNEL__) == ADC_REGULAR_RANK_14) || \
Kojto 122:f9eeca106725 1492 ((__CHANNEL__) == ADC_REGULAR_RANK_15) || \
Kojto 122:f9eeca106725 1493 ((__CHANNEL__) == ADC_REGULAR_RANK_16) )
Kojto 122:f9eeca106725 1494
Kojto 122:f9eeca106725 1495
Kojto 122:f9eeca106725 1496 /**
Kojto 122:f9eeca106725 1497 * @brief Verify the ADC injected channel setting.
Kojto 122:f9eeca106725 1498 * @param __CHANNEL__: programmed ADC injected channel.
Kojto 122:f9eeca106725 1499 * @retval SET (__CHANNEL__ is valid) or RESET (__CHANNEL__ is invalid)
Kojto 122:f9eeca106725 1500 */
Kojto 122:f9eeca106725 1501 #define IS_ADC_INJECTED_RANK(__CHANNEL__) (((__CHANNEL__) == ADC_INJECTED_RANK_1) || \
Kojto 122:f9eeca106725 1502 ((__CHANNEL__) == ADC_INJECTED_RANK_2) || \
Kojto 122:f9eeca106725 1503 ((__CHANNEL__) == ADC_INJECTED_RANK_3) || \
Kojto 122:f9eeca106725 1504 ((__CHANNEL__) == ADC_INJECTED_RANK_4) )
Kojto 122:f9eeca106725 1505
Kojto 122:f9eeca106725 1506 /**
Kojto 122:f9eeca106725 1507 * @brief Verify the ADC edge trigger setting for injected group.
Kojto 122:f9eeca106725 1508 * @param __EDGE__: programmed ADC edge trigger setting.
Kojto 122:f9eeca106725 1509 * @retval SET (__EDGE__ is a valid value) or RESET (__EDGE__ is invalid)
Kojto 122:f9eeca106725 1510 */
Kojto 122:f9eeca106725 1511 #define IS_ADC_EXTTRIGINJEC_EDGE(__EDGE__) (((__EDGE__) == ADC_EXTERNALTRIGINJECCONV_EDGE_NONE) || \
Kojto 122:f9eeca106725 1512 ((__EDGE__) == ADC_EXTERNALTRIGINJECCONV_EDGE_RISING) || \
Kojto 122:f9eeca106725 1513 ((__EDGE__) == ADC_EXTERNALTRIGINJECCONV_EDGE_FALLING) || \
Kojto 122:f9eeca106725 1514 ((__EDGE__) == ADC_EXTERNALTRIGINJECCONV_EDGE_RISINGFALLING) )
Kojto 122:f9eeca106725 1515
Kojto 122:f9eeca106725 1516
Kojto 122:f9eeca106725 1517 /**
Kojto 122:f9eeca106725 1518 * @brief Verify the ADC injected conversions external trigger.
Kojto 122:f9eeca106725 1519 * @param __INJTRIG__: programmed ADC injected conversions external trigger.
Kojto 122:f9eeca106725 1520 * @retval SET (__INJTRIG__ is a valid value) or RESET (__INJTRIG__ is invalid)
Kojto 122:f9eeca106725 1521 */
Kojto 122:f9eeca106725 1522 #define IS_ADC_EXTTRIGINJEC(__INJTRIG__) (((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T1_TRGO) || \
Kojto 122:f9eeca106725 1523 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T1_CC4) || \
Kojto 122:f9eeca106725 1524 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T2_TRGO) || \
Kojto 122:f9eeca106725 1525 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T2_CC1) || \
Kojto 122:f9eeca106725 1526 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T3_CC4) || \
Kojto 122:f9eeca106725 1527 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T4_TRGO) || \
Kojto 122:f9eeca106725 1528 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_EXT_IT15) || \
Kojto 122:f9eeca106725 1529 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T8_CC4) || \
Kojto 122:f9eeca106725 1530 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T1_TRGO2) || \
Kojto 122:f9eeca106725 1531 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T8_TRGO) || \
Kojto 122:f9eeca106725 1532 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T8_TRGO2) || \
Kojto 122:f9eeca106725 1533 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T3_CC3) || \
Kojto 122:f9eeca106725 1534 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T3_TRGO) || \
Kojto 122:f9eeca106725 1535 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T3_CC1) || \
Kojto 122:f9eeca106725 1536 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T6_TRGO) || \
Kojto 122:f9eeca106725 1537 ((__INJTRIG__) == ADC_EXTERNALTRIGINJEC_T15_TRGO) || \
Kojto 122:f9eeca106725 1538 \
Kojto 122:f9eeca106725 1539 ((__INJTRIG__) == ADC_SOFTWARE_START) )
Kojto 122:f9eeca106725 1540
Kojto 122:f9eeca106725 1541
Kojto 122:f9eeca106725 1542 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1543 /**
Kojto 122:f9eeca106725 1544 * @brief Verify the ADC multimode setting.
Kojto 122:f9eeca106725 1545 * @param __MODE__: programmed ADC multimode setting.
Kojto 122:f9eeca106725 1546 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
Kojto 122:f9eeca106725 1547 */
Kojto 122:f9eeca106725 1548 #define IS_ADC_MULTIMODE(__MODE__) (((__MODE__) == ADC_MODE_INDEPENDENT) || \
Kojto 122:f9eeca106725 1549 ((__MODE__) == ADC_DUALMODE_REGSIMULT_INJECSIMULT) || \
Kojto 122:f9eeca106725 1550 ((__MODE__) == ADC_DUALMODE_REGSIMULT_ALTERTRIG) || \
Kojto 122:f9eeca106725 1551 ((__MODE__) == ADC_DUALMODE_REGINTERL_INJECSIMULT) || \
Kojto 122:f9eeca106725 1552 ((__MODE__) == ADC_DUALMODE_INJECSIMULT) || \
Kojto 122:f9eeca106725 1553 ((__MODE__) == ADC_DUALMODE_REGSIMULT) || \
Kojto 122:f9eeca106725 1554 ((__MODE__) == ADC_DUALMODE_INTERL) || \
Kojto 122:f9eeca106725 1555 ((__MODE__) == ADC_DUALMODE_ALTERTRIG) )
Kojto 122:f9eeca106725 1556
Kojto 122:f9eeca106725 1557 /**
Kojto 122:f9eeca106725 1558 * @brief Verify the ADC multimode DMA access setting.
Kojto 122:f9eeca106725 1559 * @param __MODE__: programmed ADC multimode DMA access setting.
Kojto 122:f9eeca106725 1560 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
Kojto 122:f9eeca106725 1561 */
Kojto 122:f9eeca106725 1562 #define IS_ADC_DMA_ACCESS_MULTIMODE(__MODE__) (((__MODE__) == ADC_DMAACCESSMODE_DISABLED) || \
Kojto 122:f9eeca106725 1563 ((__MODE__) == ADC_DMAACCESSMODE_12_10_BITS) || \
Kojto 122:f9eeca106725 1564 ((__MODE__) == ADC_DMAACCESSMODE_8_6_BITS) )
Kojto 122:f9eeca106725 1565
Kojto 122:f9eeca106725 1566 /**
Kojto 122:f9eeca106725 1567 * @brief Verify the ADC multimode delay setting.
Kojto 122:f9eeca106725 1568 * @param __DELAY__: programmed ADC multimode delay setting.
Kojto 122:f9eeca106725 1569 * @retval SET (__DELAY__ is a valid value) or RESET (__DELAY__ is invalid)
Kojto 122:f9eeca106725 1570 */
Kojto 122:f9eeca106725 1571 #define IS_ADC_SAMPLING_DELAY(__DELAY__) (((__DELAY__) == ADC_TWOSAMPLINGDELAY_1CYCLE) || \
Kojto 122:f9eeca106725 1572 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_2CYCLES) || \
Kojto 122:f9eeca106725 1573 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_3CYCLES) || \
Kojto 122:f9eeca106725 1574 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_4CYCLES) || \
Kojto 122:f9eeca106725 1575 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_5CYCLES) || \
Kojto 122:f9eeca106725 1576 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_6CYCLES) || \
Kojto 122:f9eeca106725 1577 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_7CYCLES) || \
Kojto 122:f9eeca106725 1578 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_8CYCLES) || \
Kojto 122:f9eeca106725 1579 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_9CYCLES) || \
Kojto 122:f9eeca106725 1580 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_10CYCLES) || \
Kojto 122:f9eeca106725 1581 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_11CYCLES) || \
Kojto 122:f9eeca106725 1582 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_12CYCLES) )
Kojto 122:f9eeca106725 1583 #endif /* defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) */
Kojto 122:f9eeca106725 1584
Kojto 122:f9eeca106725 1585 /**
Kojto 122:f9eeca106725 1586 * @brief Verify the ADC analog watchdog setting.
Kojto 122:f9eeca106725 1587 * @param __WATCHDOG__: programmed ADC analog watchdog setting.
Kojto 122:f9eeca106725 1588 * @retval SET (__WATCHDOG__ is valid) or RESET (__WATCHDOG__ is invalid)
Kojto 122:f9eeca106725 1589 */
Kojto 122:f9eeca106725 1590 #define IS_ADC_ANALOG_WATCHDOG_NUMBER(__WATCHDOG__) (((__WATCHDOG__) == ADC_ANALOGWATCHDOG_1) || \
Kojto 122:f9eeca106725 1591 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_2) || \
Kojto 122:f9eeca106725 1592 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_3) )
Kojto 122:f9eeca106725 1593
Kojto 122:f9eeca106725 1594 /**
Kojto 122:f9eeca106725 1595 * @brief Verify the ADC analog watchdog mode setting.
Kojto 122:f9eeca106725 1596 * @param __WATCHDOG_MODE__: programmed ADC analog watchdog mode setting.
Kojto 122:f9eeca106725 1597 * @retval SET (__WATCHDOG_MODE__ is valid) or RESET (__WATCHDOG_MODE__ is invalid)
Kojto 122:f9eeca106725 1598 */
Kojto 122:f9eeca106725 1599 #define IS_ADC_ANALOG_WATCHDOG_MODE(__WATCHDOG_MODE__) (((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_NONE) || \
Kojto 122:f9eeca106725 1600 ((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_SINGLE_REG) || \
Kojto 122:f9eeca106725 1601 ((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_SINGLE_INJEC) || \
Kojto 122:f9eeca106725 1602 ((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC) || \
Kojto 122:f9eeca106725 1603 ((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_ALL_REG) || \
Kojto 122:f9eeca106725 1604 ((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_ALL_INJEC) || \
Kojto 122:f9eeca106725 1605 ((__WATCHDOG_MODE__) == ADC_ANALOGWATCHDOG_ALL_REGINJEC) )
Kojto 122:f9eeca106725 1606
Kojto 122:f9eeca106725 1607 /**
Kojto 122:f9eeca106725 1608 * @brief Verify the ADC conversion (regular or injected or both).
Kojto 122:f9eeca106725 1609 * @param __CONVERSION__: ADC conversion group.
Kojto 122:f9eeca106725 1610 * @retval SET (__CONVERSION__ is valid) or RESET (__CONVERSION__ is invalid)
Kojto 122:f9eeca106725 1611 */
Kojto 122:f9eeca106725 1612 #define IS_ADC_CONVERSION_GROUP(__CONVERSION__) (((__CONVERSION__) == ADC_REGULAR_GROUP) || \
Kojto 122:f9eeca106725 1613 ((__CONVERSION__) == ADC_INJECTED_GROUP) || \
Kojto 122:f9eeca106725 1614 ((__CONVERSION__) == ADC_REGULAR_INJECTED_GROUP) )
Kojto 122:f9eeca106725 1615
Kojto 122:f9eeca106725 1616 /**
Kojto 122:f9eeca106725 1617 * @brief Verify the ADC event type.
Kojto 122:f9eeca106725 1618 * @param __EVENT__: ADC event.
Kojto 122:f9eeca106725 1619 * @retval SET (__EVENT__ is valid) or RESET (__EVENT__ is invalid)
Kojto 122:f9eeca106725 1620 */
Kojto 122:f9eeca106725 1621 #define IS_ADC_EVENT_TYPE(__EVENT__) (((__EVENT__) == ADC_EOSMP_EVENT) || \
Kojto 122:f9eeca106725 1622 ((__EVENT__) == ADC_AWD_EVENT) || \
Kojto 122:f9eeca106725 1623 ((__EVENT__) == ADC_AWD2_EVENT) || \
Kojto 122:f9eeca106725 1624 ((__EVENT__) == ADC_AWD3_EVENT) || \
Kojto 122:f9eeca106725 1625 ((__EVENT__) == ADC_OVR_EVENT) || \
Kojto 122:f9eeca106725 1626 ((__EVENT__) == ADC_JQOVF_EVENT) )
Kojto 122:f9eeca106725 1627
Kojto 122:f9eeca106725 1628 /**
Kojto 122:f9eeca106725 1629 * @brief Verify the ADC oversampling ratio.
Kojto 122:f9eeca106725 1630 * @param __RATIO__: programmed ADC oversampling ratio.
Kojto 122:f9eeca106725 1631 * @retval SET (__RATIO__ is a valid value) or RESET (__RATIO__ is invalid)
Kojto 122:f9eeca106725 1632 */
Kojto 122:f9eeca106725 1633 #define IS_ADC_OVERSAMPLING_RATIO(__RATIO__) (((__RATIO__) == ADC_OVERSAMPLING_RATIO_2 ) || \
Kojto 122:f9eeca106725 1634 ((__RATIO__) == ADC_OVERSAMPLING_RATIO_4 ) || \
Kojto 122:f9eeca106725 1635 ((__RATIO__) == ADC_OVERSAMPLING_RATIO_8 ) || \
Kojto 122:f9eeca106725 1636 ((__RATIO__) == ADC_OVERSAMPLING_RATIO_16 ) || \
Kojto 122:f9eeca106725 1637 ((__RATIO__) == ADC_OVERSAMPLING_RATIO_32 ) || \
Kojto 122:f9eeca106725 1638 ((__RATIO__) == ADC_OVERSAMPLING_RATIO_64 ) || \
Kojto 122:f9eeca106725 1639 ((__RATIO__) == ADC_OVERSAMPLING_RATIO_128 ) || \
Kojto 122:f9eeca106725 1640 ((__RATIO__) == ADC_OVERSAMPLING_RATIO_256 ))
Kojto 122:f9eeca106725 1641
Kojto 122:f9eeca106725 1642 /**
Kojto 122:f9eeca106725 1643 * @brief Verify the ADC oversampling shift.
Kojto 122:f9eeca106725 1644 * @param __SHIFT__: programmed ADC oversampling shift.
Kojto 122:f9eeca106725 1645 * @retval SET (__SHIFT__ is a valid value) or RESET (__SHIFT__ is invalid)
Kojto 122:f9eeca106725 1646 */
Kojto 122:f9eeca106725 1647 #define IS_ADC_RIGHT_BIT_SHIFT(__SHIFT__) (((__SHIFT__) == ADC_RIGHTBITSHIFT_NONE) || \
Kojto 122:f9eeca106725 1648 ((__SHIFT__) == ADC_RIGHTBITSHIFT_1 ) || \
Kojto 122:f9eeca106725 1649 ((__SHIFT__) == ADC_RIGHTBITSHIFT_2 ) || \
Kojto 122:f9eeca106725 1650 ((__SHIFT__) == ADC_RIGHTBITSHIFT_3 ) || \
Kojto 122:f9eeca106725 1651 ((__SHIFT__) == ADC_RIGHTBITSHIFT_4 ) || \
Kojto 122:f9eeca106725 1652 ((__SHIFT__) == ADC_RIGHTBITSHIFT_5 ) || \
Kojto 122:f9eeca106725 1653 ((__SHIFT__) == ADC_RIGHTBITSHIFT_6 ) || \
Kojto 122:f9eeca106725 1654 ((__SHIFT__) == ADC_RIGHTBITSHIFT_7 ) || \
Kojto 122:f9eeca106725 1655 ((__SHIFT__) == ADC_RIGHTBITSHIFT_8 ))
Kojto 122:f9eeca106725 1656
Kojto 122:f9eeca106725 1657 /**
Kojto 122:f9eeca106725 1658 * @brief Verify the ADC oversampling triggered mode.
Kojto 122:f9eeca106725 1659 * @param __MODE__: programmed ADC oversampling triggered mode.
Kojto 122:f9eeca106725 1660 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
Kojto 122:f9eeca106725 1661 */
Kojto 122:f9eeca106725 1662 #define IS_ADC_TRIGGERED_OVERSAMPLING_MODE(__MODE__) (((__MODE__) == ADC_TRIGGEREDMODE_SINGLE_TRIGGER) || \
Kojto 122:f9eeca106725 1663 ((__MODE__) == ADC_TRIGGEREDMODE_MULTI_TRIGGER) )
Kojto 122:f9eeca106725 1664
Kojto 122:f9eeca106725 1665 /**
Kojto 122:f9eeca106725 1666 * @brief Verify the ADC oversampling regular conversion resumed or continued mode.
Kojto 122:f9eeca106725 1667 * @param __MODE__: programmed ADC oversampling regular conversion resumed or continued mode.
Kojto 122:f9eeca106725 1668 * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
Kojto 122:f9eeca106725 1669 */
Kojto 122:f9eeca106725 1670 #define IS_ADC_REGOVERSAMPLING_MODE(__MODE__) (((__MODE__) == ADC_REGOVERSAMPLING_CONTINUED_MODE) || \
Kojto 122:f9eeca106725 1671 ((__MODE__) == ADC_REGOVERSAMPLING_RESUMED_MODE) )
Kojto 122:f9eeca106725 1672
Kojto 122:f9eeca106725 1673
Kojto 122:f9eeca106725 1674 /**
Kojto 122:f9eeca106725 1675 * @brief Verify the DFSDM mode configuration.
Kojto 122:f9eeca106725 1676 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 1677 * @note When DMSDFM configuration is not supported, the macro systematically reports SET. For
Kojto 122:f9eeca106725 1678 * this reason, the input parameter is the ADC handle and not the configuration parameter
Kojto 122:f9eeca106725 1679 * directly.
Kojto 122:f9eeca106725 1680 * @retval SET (DFSDM mode configuration is valid) or RESET (DFSDM mode configuration is invalid)
Kojto 122:f9eeca106725 1681 */
Kojto 122:f9eeca106725 1682 #define IS_ADC_DFSDMCFG_MODE(__HANDLE__) (SET)
Kojto 122:f9eeca106725 1683
Kojto 122:f9eeca106725 1684 /**
Kojto 122:f9eeca106725 1685 * @brief Return the DFSDM configuration mode.
Kojto 122:f9eeca106725 1686 * @param __HANDLE__: ADC handle.
Kojto 122:f9eeca106725 1687 * @note When DMSDFM configuration is not supported, the macro systematically reports 0x0 (i.e disabled).
Kojto 122:f9eeca106725 1688 * For this reason, the input parameter is the ADC handle and not the configuration parameter
Kojto 122:f9eeca106725 1689 * directly.
Kojto 122:f9eeca106725 1690 * @retval DFSDM configuration mode
Kojto 122:f9eeca106725 1691 */
Kojto 122:f9eeca106725 1692 #define ADC_CFGR_DFSDM(__HANDLE__) (0x0)
Kojto 122:f9eeca106725 1693
Kojto 122:f9eeca106725 1694
Kojto 122:f9eeca106725 1695 /**
Kojto 122:f9eeca106725 1696 * @}
Kojto 122:f9eeca106725 1697 */
Kojto 122:f9eeca106725 1698
Kojto 122:f9eeca106725 1699
Kojto 122:f9eeca106725 1700 /* Exported functions --------------------------------------------------------*/
Kojto 122:f9eeca106725 1701 /** @addtogroup ADCEx_Exported_Functions ADC Extended Exported Functions
Kojto 122:f9eeca106725 1702 * @{
Kojto 122:f9eeca106725 1703 */
Kojto 122:f9eeca106725 1704
Kojto 122:f9eeca106725 1705 /* Initialization/de-initialization functions *********************************/
Kojto 122:f9eeca106725 1706
Kojto 122:f9eeca106725 1707 /** @addtogroup ADCEx_Exported_Functions_Group1 Extended Input and Output operation functions
Kojto 122:f9eeca106725 1708 * @brief Extended IO operation functions
Kojto 122:f9eeca106725 1709 * @{
Kojto 122:f9eeca106725 1710 */
Kojto 122:f9eeca106725 1711 /* I/O operation functions ****************************************************/
Kojto 122:f9eeca106725 1712
Kojto 122:f9eeca106725 1713 /* ADC calibration */
Kojto 122:f9eeca106725 1714
Kojto 122:f9eeca106725 1715 HAL_StatusTypeDef HAL_ADCEx_Calibration_Start(ADC_HandleTypeDef* hadc, uint32_t SingleDiff);
Kojto 122:f9eeca106725 1716 uint32_t HAL_ADCEx_Calibration_GetValue(ADC_HandleTypeDef *hadc, uint32_t SingleDiff);
Kojto 122:f9eeca106725 1717 HAL_StatusTypeDef HAL_ADCEx_Calibration_SetValue(ADC_HandleTypeDef *hadc, uint32_t SingleDiff, uint32_t CalibrationFactor);
Kojto 122:f9eeca106725 1718
Kojto 122:f9eeca106725 1719
Kojto 122:f9eeca106725 1720
Kojto 122:f9eeca106725 1721 /* Blocking mode: Polling */
Kojto 122:f9eeca106725 1722 HAL_StatusTypeDef HAL_ADCEx_InjectedStart(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 1723 HAL_StatusTypeDef HAL_ADCEx_InjectedStop(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 1724 HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
Kojto 122:f9eeca106725 1725
Kojto 122:f9eeca106725 1726 /* Non-blocking mode: Interruption */
Kojto 122:f9eeca106725 1727 HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 1728 HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 1729
Kojto 122:f9eeca106725 1730
Kojto 122:f9eeca106725 1731 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1732 /* ADC multimode */
Kojto 122:f9eeca106725 1733 HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef *hadc, uint32_t *pData, uint32_t Length);
Kojto 122:f9eeca106725 1734 HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA(ADC_HandleTypeDef *hadc);
Kojto 122:f9eeca106725 1735 uint32_t HAL_ADCEx_MultiModeGetValue(ADC_HandleTypeDef *hadc);
Kojto 122:f9eeca106725 1736 #endif /* defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) */
Kojto 122:f9eeca106725 1737
Kojto 122:f9eeca106725 1738 /* ADC retrieve conversion value intended to be used with polling or interruption */
Kojto 122:f9eeca106725 1739 uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t InjectedRank);
Kojto 122:f9eeca106725 1740
Kojto 122:f9eeca106725 1741 /* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption) */
Kojto 122:f9eeca106725 1742 void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 1743 void HAL_ADCEx_InjectedQueueOverflowCallback(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 1744 void HAL_ADCEx_LevelOutOfWindow2Callback(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 1745 void HAL_ADCEx_LevelOutOfWindow3Callback(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 1746 void HAL_ADCEx_EndOfSamplingCallback(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 1747
Kojto 122:f9eeca106725 1748
Kojto 122:f9eeca106725 1749 /* ADC Regular conversions stop */
Kojto 122:f9eeca106725 1750 HAL_StatusTypeDef HAL_ADCEx_RegularStop(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 1751 HAL_StatusTypeDef HAL_ADCEx_RegularStop_IT(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 1752 HAL_StatusTypeDef HAL_ADCEx_RegularStop_DMA(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 1753 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1754 HAL_StatusTypeDef HAL_ADCEx_RegularMultiModeStop_DMA(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 1755 #endif /* defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) */
Kojto 122:f9eeca106725 1756
Kojto 122:f9eeca106725 1757 /**
Kojto 122:f9eeca106725 1758 * @}
Kojto 122:f9eeca106725 1759 */
Kojto 122:f9eeca106725 1760
Kojto 122:f9eeca106725 1761 /** @addtogroup ADCEx_Exported_Functions_Group2 Extended Peripheral Control functions
Kojto 122:f9eeca106725 1762 * @brief Extended Peripheral Control functions
Kojto 122:f9eeca106725 1763 * @{
Kojto 122:f9eeca106725 1764 */
Kojto 122:f9eeca106725 1765 /* Peripheral Control functions ***********************************************/
Kojto 122:f9eeca106725 1766 HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef* hadc,ADC_InjectionConfTypeDef* sConfigInjected);
Kojto 122:f9eeca106725 1767 #if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx)
Kojto 122:f9eeca106725 1768 HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel(ADC_HandleTypeDef *hadc, ADC_MultiModeTypeDef *multimode);
Kojto 122:f9eeca106725 1769 #endif /* defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) */
Kojto 122:f9eeca106725 1770 HAL_StatusTypeDef HAL_ADCEx_EnableInjectedQueue(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 1771 HAL_StatusTypeDef HAL_ADCEx_DisableInjectedQueue(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 1772 HAL_StatusTypeDef HAL_ADCEx_DisableVoltageRegulator(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 1773 HAL_StatusTypeDef HAL_ADCEx_EnterADCDeepPowerDownMode(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 1774
Kojto 122:f9eeca106725 1775 /**
Kojto 122:f9eeca106725 1776 * @}
Kojto 122:f9eeca106725 1777 */
Kojto 122:f9eeca106725 1778
Kojto 122:f9eeca106725 1779 /**
Kojto 122:f9eeca106725 1780 * @}
Kojto 122:f9eeca106725 1781 */
Kojto 122:f9eeca106725 1782
Kojto 122:f9eeca106725 1783 /**
Kojto 122:f9eeca106725 1784 * @}
Kojto 122:f9eeca106725 1785 */
Kojto 122:f9eeca106725 1786
Kojto 122:f9eeca106725 1787 /**
Kojto 122:f9eeca106725 1788 * @}
Kojto 122:f9eeca106725 1789 */
Kojto 122:f9eeca106725 1790
Kojto 122:f9eeca106725 1791 #ifdef __cplusplus
Kojto 122:f9eeca106725 1792 }
Kojto 122:f9eeca106725 1793 #endif
Kojto 122:f9eeca106725 1794
Kojto 122:f9eeca106725 1795 #endif /*__STM32L4xx_ADC_EX_H */
Kojto 122:f9eeca106725 1796
Kojto 122:f9eeca106725 1797
Kojto 122:f9eeca106725 1798 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/