mbed library sources

Dependents:   Marvino mbot

Fork of mbed-src by mbed official

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

Who changed what in which revision?

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