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