cc y / mbed

Fork of mbed by mbed official

Committer:
Kojto
Date:
Thu Jul 07 14:34:11 2016 +0100
Revision:
122:f9eeca106725
Parent:
110:165afa46840b
Release 122 of the mbed library

Changes:
- new targets - Nucleo L432KC, Beetle, Nucleo F446ZE, Nucleo L011K4
- Thread safety addition - mbed API should contain a statement about thread safety
- critical section API addition
- CAS API (core_util_atomic_incr/decr)
- DEVICE_ are generated from targets.json file, device.h deprecated
- Callback replaces FunctionPointer to provide std like interface
- mbed HAL API docs improvements
- toolchain - prexif attributes with MBED_
- add new attributes - packed, weak, forcedinline, align
- target.json - contains targets definitions
- ST - L1XX - Cube update to 1.5
- SPI clock selection fix (clock from APB domain)
- F7 - Cube update v1.4.0
- L0 - baudrate init fix
- L1 - Cube update v1.5
- F3 - baudrate init fix, 3 targets CAN support
- F4 - Cube update v1.12.0, 3 targets CAN support
- L4XX - Cube update v1.5.1
- F0 - update Cube to v1.5.0
- L4 - 2 targets (L476RG/VG) CAN support
- NXP - pwm clock fix for KSDK2 MCU
- LPC2368 - remove ARM toolchain support - due to regression
- KSDK2 - fix SPI , I2C address and repeat start
- Silabs - some fixes backported from mbed 3
- Renesas - RZ_A1H - SystemCoreClockUpdate addition

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 108:34e6b704fe68 1 /**
Kojto 108:34e6b704fe68 2 ******************************************************************************
Kojto 108:34e6b704fe68 3 * @file stm32f4xx_hal_adc.h
Kojto 108:34e6b704fe68 4 * @author MCD Application Team
Kojto 122:f9eeca106725 5 * @version V1.5.0
Kojto 122:f9eeca106725 6 * @date 06-May-2016
Kojto 110:165afa46840b 7 * @brief Header file containing functions prototypes of ADC HAL library.
Kojto 108:34e6b704fe68 8 ******************************************************************************
Kojto 108:34e6b704fe68 9 * @attention
Kojto 108:34e6b704fe68 10 *
Kojto 122:f9eeca106725 11 * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
Kojto 108:34e6b704fe68 12 *
Kojto 108:34e6b704fe68 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 108:34e6b704fe68 14 * are permitted provided that the following conditions are met:
Kojto 108:34e6b704fe68 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 108:34e6b704fe68 16 * this list of conditions and the following disclaimer.
Kojto 108:34e6b704fe68 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 108:34e6b704fe68 18 * this list of conditions and the following disclaimer in the documentation
Kojto 108:34e6b704fe68 19 * and/or other materials provided with the distribution.
Kojto 108:34e6b704fe68 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 108:34e6b704fe68 21 * may be used to endorse or promote products derived from this software
Kojto 108:34e6b704fe68 22 * without specific prior written permission.
Kojto 108:34e6b704fe68 23 *
Kojto 108:34e6b704fe68 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 108:34e6b704fe68 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 108:34e6b704fe68 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 108:34e6b704fe68 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 108:34e6b704fe68 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 108:34e6b704fe68 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 108:34e6b704fe68 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 108:34e6b704fe68 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 108:34e6b704fe68 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 108:34e6b704fe68 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 108:34e6b704fe68 34 *
Kojto 108:34e6b704fe68 35 ******************************************************************************
Kojto 108:34e6b704fe68 36 */
Kojto 108:34e6b704fe68 37
Kojto 108:34e6b704fe68 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 108:34e6b704fe68 39 #ifndef __STM32F4xx_ADC_H
Kojto 108:34e6b704fe68 40 #define __STM32F4xx_ADC_H
Kojto 108:34e6b704fe68 41
Kojto 108:34e6b704fe68 42 #ifdef __cplusplus
Kojto 108:34e6b704fe68 43 extern "C" {
Kojto 108:34e6b704fe68 44 #endif
Kojto 108:34e6b704fe68 45
Kojto 108:34e6b704fe68 46 /* Includes ------------------------------------------------------------------*/
Kojto 108:34e6b704fe68 47 #include "stm32f4xx_hal_def.h"
Kojto 108:34e6b704fe68 48
Kojto 108:34e6b704fe68 49 /** @addtogroup STM32F4xx_HAL_Driver
Kojto 108:34e6b704fe68 50 * @{
Kojto 108:34e6b704fe68 51 */
Kojto 108:34e6b704fe68 52
Kojto 108:34e6b704fe68 53 /** @addtogroup ADC
Kojto 108:34e6b704fe68 54 * @{
Kojto 108:34e6b704fe68 55 */
Kojto 108:34e6b704fe68 56
Kojto 108:34e6b704fe68 57 /* Exported types ------------------------------------------------------------*/
Kojto 108:34e6b704fe68 58 /** @defgroup ADC_Exported_Types ADC Exported Types
Kojto 108:34e6b704fe68 59 * @{
Kojto 108:34e6b704fe68 60 */
Kojto 108:34e6b704fe68 61
Kojto 108:34e6b704fe68 62 /**
Kojto 122:f9eeca106725 63 * @brief Structure definition of ADC and regular group initialization
Kojto 122:f9eeca106725 64 * @note Parameters of this structure are shared within 2 scopes:
Kojto 122:f9eeca106725 65 * - Scope entire ADC (affects regular and injected groups): ClockPrescaler, Resolution, ScanConvMode, DataAlign, ScanConvMode, EOCSelection, LowPowerAutoWait, LowPowerAutoPowerOff, ChannelsBank.
Kojto 122:f9eeca106725 66 * - Scope regular group: ContinuousConvMode, NbrOfConversion, DiscontinuousConvMode, NbrOfDiscConversion, ExternalTrigConvEdge, ExternalTrigConv.
Kojto 122:f9eeca106725 67 * @note The setting of these parameters with function HAL_ADC_Init() is conditioned to ADC state.
Kojto 122:f9eeca106725 68 * ADC state can be either:
Kojto 122:f9eeca106725 69 * - For all parameters: ADC disabled
Kojto 122:f9eeca106725 70 * - For all parameters except 'Resolution', 'ScanConvMode', 'DiscontinuousConvMode', 'NbrOfDiscConversion' : ADC enabled without conversion on going on regular group.
Kojto 122:f9eeca106725 71 * - For parameters 'ExternalTrigConv' and 'ExternalTrigConvEdge': ADC enabled, even with conversion on going.
Kojto 122:f9eeca106725 72 * If ADC is not in the appropriate state to modify some parameters, these parameters setting is bypassed
Kojto 122:f9eeca106725 73 * without error reporting (as it can be the expected behaviour in case of intended action to update another parameter (which fulfills the ADC state condition) on the fly).
Kojto 122:f9eeca106725 74 */
Kojto 108:34e6b704fe68 75 typedef struct
Kojto 108:34e6b704fe68 76 {
Kojto 122:f9eeca106725 77 uint32_t ClockPrescaler; /*!< Select ADC clock prescaler. The clock is common for
Kojto 108:34e6b704fe68 78 all the ADCs.
Kojto 108:34e6b704fe68 79 This parameter can be a value of @ref ADC_ClockPrescaler */
Kojto 122:f9eeca106725 80 uint32_t Resolution; /*!< Configures the ADC resolution.
Kojto 108:34e6b704fe68 81 This parameter can be a value of @ref ADC_Resolution */
Kojto 122:f9eeca106725 82 uint32_t DataAlign; /*!< Specifies ADC data alignment to right (MSB on register bit 11 and LSB on register bit 0) (default setting)
Kojto 122:f9eeca106725 83 or to left (if regular group: MSB on register bit 15 and LSB on register bit 4, if injected group (MSB kept as signed value due to potential negative value after offset application): MSB on register bit 14 and LSB on register bit 3).
Kojto 122:f9eeca106725 84 This parameter can be a value of @ref ADC_Data_align */
Kojto 122:f9eeca106725 85 uint32_t ScanConvMode; /*!< Configures the sequencer of regular and injected groups.
Kojto 122:f9eeca106725 86 This parameter can be associated to parameter 'DiscontinuousConvMode' to have main sequence subdivided in successive parts.
Kojto 122:f9eeca106725 87 If disabled: Conversion is performed in single mode (one channel converted, the one defined in rank 1).
Kojto 122:f9eeca106725 88 Parameters 'NbrOfConversion' and 'InjectedNbrOfConversion' are discarded (equivalent to set to 1).
Kojto 122:f9eeca106725 89 If enabled: Conversions are performed in sequence mode (multiple ranks defined by 'NbrOfConversion'/'InjectedNbrOfConversion' and each channel rank).
Kojto 122:f9eeca106725 90 Scan direction is upward: from rank1 to rank 'n'.
Kojto 122:f9eeca106725 91 This parameter can be set to ENABLE or DISABLE */
Kojto 122:f9eeca106725 92 uint32_t EOCSelection; /*!< Specifies what EOC (End Of Conversion) flag is used for conversion by polling and interruption: end of conversion of each rank or complete sequence.
Kojto 122:f9eeca106725 93 This parameter can be a value of @ref ADC_EOCSelection.
Kojto 122:f9eeca106725 94 Note: For injected group, end of conversion (flag&IT) is raised only at the end of the sequence.
Kojto 122:f9eeca106725 95 Therefore, if end of conversion is set to end of each conversion, injected group should not be used with interruption (HAL_ADCEx_InjectedStart_IT)
Kojto 122:f9eeca106725 96 or polling (HAL_ADCEx_InjectedStart and HAL_ADCEx_InjectedPollForConversion). By the way, polling is still possible since driver will use an estimated timing for end of injected conversion.
Kojto 122:f9eeca106725 97 Note: If overrun feature is intended to be used, use ADC in mode 'interruption' (function HAL_ADC_Start_IT() ) with parameter EOCSelection set to end of each conversion or in mode 'transfer by DMA' (function HAL_ADC_Start_DMA()).
Kojto 122:f9eeca106725 98 If overrun feature is intended to be bypassed, use ADC in mode 'polling' or 'interruption' with parameter EOCSelection must be set to end of sequence */
Kojto 122:f9eeca106725 99 uint32_t ContinuousConvMode; /*!< Specifies whether the conversion is performed in single mode (one conversion) or continuous mode for regular group,
Kojto 122:f9eeca106725 100 after the selected trigger occurred (software start or external trigger).
Kojto 108:34e6b704fe68 101 This parameter can be set to ENABLE or DISABLE. */
Kojto 122:f9eeca106725 102 uint32_t NbrOfConversion; /*!< Specifies the number of ranks that will be converted within the regular group sequencer.
Kojto 122:f9eeca106725 103 To use regular group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
Kojto 108:34e6b704fe68 104 This parameter must be a number between Min_Data = 1 and Max_Data = 16. */
Kojto 122:f9eeca106725 105 uint32_t DiscontinuousConvMode; /*!< Specifies whether the conversions sequence of regular group is performed in Complete-sequence/Discontinuous-sequence (main sequence subdivided in successive parts).
Kojto 122:f9eeca106725 106 Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
Kojto 122:f9eeca106725 107 Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
Kojto 108:34e6b704fe68 108 This parameter can be set to ENABLE or DISABLE. */
Kojto 122:f9eeca106725 109 uint32_t NbrOfDiscConversion; /*!< Specifies the number of discontinuous conversions in which the main sequence of regular group (parameter NbrOfConversion) will be subdivided.
Kojto 122:f9eeca106725 110 If parameter 'DiscontinuousConvMode' is disabled, this parameter is discarded.
Kojto 108:34e6b704fe68 111 This parameter must be a number between Min_Data = 1 and Max_Data = 8. */
Kojto 108:34e6b704fe68 112 uint32_t ExternalTrigConv; /*!< Selects the external event used to trigger the conversion start of regular group.
Kojto 108:34e6b704fe68 113 If set to ADC_SOFTWARE_START, external triggers are disabled.
Kojto 122:f9eeca106725 114 If set to external trigger source, triggering is on event rising edge by default.
Kojto 122:f9eeca106725 115 This parameter can be a value of @ref ADC_External_trigger_Source_Regular */
Kojto 108:34e6b704fe68 116 uint32_t ExternalTrigConvEdge; /*!< Selects the external trigger edge of regular group.
Kojto 108:34e6b704fe68 117 If trigger is set to ADC_SOFTWARE_START, this parameter is discarded.
Kojto 122:f9eeca106725 118 This parameter can be a value of @ref ADC_External_trigger_edge_Regular */
Kojto 122:f9eeca106725 119 uint32_t DMAContinuousRequests; /*!< Specifies whether the DMA requests are performed in one shot mode (DMA transfer stop when number of conversions is reached)
Kojto 122:f9eeca106725 120 or in Continuous mode (DMA transfer unlimited, whatever number of conversions).
Kojto 122:f9eeca106725 121 Note: In continuous mode, DMA must be configured in circular mode. Otherwise an overrun will be triggered when DMA buffer maximum pointer is reached.
Kojto 122:f9eeca106725 122 Note: This parameter must be modified when no conversion is on going on both regular and injected groups (ADC disabled, or ADC enabled without continuous mode or external trigger that could launch a conversion).
Kojto 122:f9eeca106725 123 This parameter can be set to ENABLE or DISABLE. */
Kojto 108:34e6b704fe68 124 }ADC_InitTypeDef;
Kojto 108:34e6b704fe68 125
Kojto 122:f9eeca106725 126
Kojto 122:f9eeca106725 127
Kojto 108:34e6b704fe68 128 /**
Kojto 122:f9eeca106725 129 * @brief Structure definition of ADC channel for regular group
Kojto 122:f9eeca106725 130 * @note The setting of these parameters with function HAL_ADC_ConfigChannel() is conditioned to ADC state.
Kojto 122:f9eeca106725 131 * ADC can be either disabled or enabled without conversion on going on regular group.
Kojto 108:34e6b704fe68 132 */
Kojto 108:34e6b704fe68 133 typedef struct
Kojto 108:34e6b704fe68 134 {
Kojto 122:f9eeca106725 135 uint32_t Channel; /*!< Specifies the channel to configure into ADC regular group.
Kojto 122:f9eeca106725 136 This parameter can be a value of @ref ADC_channels */
Kojto 122:f9eeca106725 137 uint32_t Rank; /*!< Specifies the rank in the regular group sequencer.
Kojto 122:f9eeca106725 138 This parameter must be a number between Min_Data = 1 and Max_Data = 16 */
Kojto 122:f9eeca106725 139 uint32_t SamplingTime; /*!< Sampling time value to be set for the selected channel.
Kojto 122:f9eeca106725 140 Unit: ADC clock cycles
Kojto 122:f9eeca106725 141 Conversion time is the addition of sampling time and processing time (12 ADC clock cycles at ADC resolution 12 bits, 11 cycles at 10 bits, 9 cycles at 8 bits, 7 cycles at 6 bits).
Kojto 122:f9eeca106725 142 This parameter can be a value of @ref ADC_sampling_times
Kojto 122:f9eeca106725 143 Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups.
Kojto 122:f9eeca106725 144 If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting.
Kojto 122:f9eeca106725 145 Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor),
Kojto 122:f9eeca106725 146 sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
Kojto 122:f9eeca106725 147 Refer to device datasheet for timings values, parameters TS_vrefint, TS_temp (values rough order: 4us min). */
Kojto 122:f9eeca106725 148 uint32_t Offset; /*!< Reserved for future use, can be set to 0 */
Kojto 108:34e6b704fe68 149 }ADC_ChannelConfTypeDef;
Kojto 108:34e6b704fe68 150
Kojto 108:34e6b704fe68 151 /**
Kojto 108:34e6b704fe68 152 * @brief ADC Configuration multi-mode structure definition
Kojto 108:34e6b704fe68 153 */
Kojto 108:34e6b704fe68 154 typedef struct
Kojto 108:34e6b704fe68 155 {
Kojto 108:34e6b704fe68 156 uint32_t WatchdogMode; /*!< Configures the ADC analog watchdog mode.
Kojto 108:34e6b704fe68 157 This parameter can be a value of @ref ADC_analog_watchdog_selection */
Kojto 108:34e6b704fe68 158 uint32_t HighThreshold; /*!< Configures the ADC analog watchdog High threshold value.
Kojto 108:34e6b704fe68 159 This parameter must be a 12-bit value. */
Kojto 108:34e6b704fe68 160 uint32_t LowThreshold; /*!< Configures the ADC analog watchdog High threshold value.
Kojto 108:34e6b704fe68 161 This parameter must be a 12-bit value. */
Kojto 108:34e6b704fe68 162 uint32_t Channel; /*!< Configures ADC channel for the analog watchdog.
Kojto 108:34e6b704fe68 163 This parameter has an effect only if watchdog mode is configured on single channel
Kojto 108:34e6b704fe68 164 This parameter can be a value of @ref ADC_channels */
Kojto 108:34e6b704fe68 165 uint32_t ITMode; /*!< Specifies whether the analog watchdog is configured
Kojto 108:34e6b704fe68 166 is interrupt mode or in polling mode.
Kojto 108:34e6b704fe68 167 This parameter can be set to ENABLE or DISABLE */
Kojto 108:34e6b704fe68 168 uint32_t WatchdogNumber; /*!< Reserved for future use, can be set to 0 */
Kojto 108:34e6b704fe68 169 }ADC_AnalogWDGConfTypeDef;
Kojto 122:f9eeca106725 170
Kojto 122:f9eeca106725 171 /**
Kojto 122:f9eeca106725 172 * @brief HAL ADC state machine: ADC states definition (bitfields)
Kojto 122:f9eeca106725 173 */
Kojto 122:f9eeca106725 174 /* States of ADC global scope */
Kojto 122:f9eeca106725 175 #define HAL_ADC_STATE_RESET ((uint32_t)0x00000000U) /*!< ADC not yet initialized or disabled */
Kojto 122:f9eeca106725 176 #define HAL_ADC_STATE_READY ((uint32_t)0x00000001U) /*!< ADC peripheral ready for use */
Kojto 122:f9eeca106725 177 #define HAL_ADC_STATE_BUSY_INTERNAL ((uint32_t)0x00000002U) /*!< ADC is busy to internal process (initialization, calibration) */
Kojto 122:f9eeca106725 178 #define HAL_ADC_STATE_TIMEOUT ((uint32_t)0x00000004U) /*!< TimeOut occurrence */
Kojto 122:f9eeca106725 179
Kojto 122:f9eeca106725 180 /* States of ADC errors */
Kojto 122:f9eeca106725 181 #define HAL_ADC_STATE_ERROR_INTERNAL ((uint32_t)0x00000010U) /*!< Internal error occurrence */
Kojto 122:f9eeca106725 182 #define HAL_ADC_STATE_ERROR_CONFIG ((uint32_t)0x00000020U) /*!< Configuration error occurrence */
Kojto 122:f9eeca106725 183 #define HAL_ADC_STATE_ERROR_DMA ((uint32_t)0x00000040U) /*!< DMA error occurrence */
Kojto 122:f9eeca106725 184
Kojto 122:f9eeca106725 185 /* States of ADC group regular */
Kojto 122:f9eeca106725 186 #define HAL_ADC_STATE_REG_BUSY ((uint32_t)0x00000100U) /*!< A conversion on group regular is ongoing or can occur (either by continuous mode,
Kojto 122:f9eeca106725 187 external trigger, low power auto power-on (if feature available), multimode ADC master control (if feature available)) */
Kojto 122:f9eeca106725 188 #define HAL_ADC_STATE_REG_EOC ((uint32_t)0x00000200U) /*!< Conversion data available on group regular */
Kojto 122:f9eeca106725 189 #define HAL_ADC_STATE_REG_OVR ((uint32_t)0x00000400U) /*!< Overrun occurrence */
Kojto 122:f9eeca106725 190
Kojto 122:f9eeca106725 191 /* States of ADC group injected */
Kojto 122:f9eeca106725 192 #define HAL_ADC_STATE_INJ_BUSY ((uint32_t)0x00001000U) /*!< A conversion on group injected is ongoing or can occur (either by auto-injection mode,
Kojto 122:f9eeca106725 193 external trigger, low power auto power-on (if feature available), multimode ADC master control (if feature available)) */
Kojto 122:f9eeca106725 194 #define HAL_ADC_STATE_INJ_EOC ((uint32_t)0x00002000U) /*!< Conversion data available on group injected */
Kojto 122:f9eeca106725 195
Kojto 122:f9eeca106725 196 /* States of ADC analog watchdogs */
Kojto 122:f9eeca106725 197 #define HAL_ADC_STATE_AWD1 ((uint32_t)0x00010000U) /*!< Out-of-window occurrence of analog watchdog 1 */
Kojto 122:f9eeca106725 198 #define HAL_ADC_STATE_AWD2 ((uint32_t)0x00020000U) /*!< Not available on STM32F4 device: Out-of-window occurrence of analog watchdog 2 */
Kojto 122:f9eeca106725 199 #define HAL_ADC_STATE_AWD3 ((uint32_t)0x00040000U) /*!< Not available on STM32F4 device: Out-of-window occurrence of analog watchdog 3 */
Kojto 122:f9eeca106725 200
Kojto 122:f9eeca106725 201 /* States of ADC multi-mode */
Kojto 122:f9eeca106725 202 #define HAL_ADC_STATE_MULTIMODE_SLAVE ((uint32_t)0x00100000U) /*!< Not available on STM32F4 device: ADC in multimode slave state, controlled by another ADC master ( */
Kojto 122:f9eeca106725 203
Kojto 122:f9eeca106725 204
Kojto 122:f9eeca106725 205 /**
Kojto 122:f9eeca106725 206 * @brief ADC handle Structure definition
Kojto 122:f9eeca106725 207 */
Kojto 122:f9eeca106725 208 typedef struct
Kojto 122:f9eeca106725 209 {
Kojto 122:f9eeca106725 210 ADC_TypeDef *Instance; /*!< Register base address */
Kojto 122:f9eeca106725 211
Kojto 122:f9eeca106725 212 ADC_InitTypeDef Init; /*!< ADC required parameters */
Kojto 122:f9eeca106725 213
Kojto 122:f9eeca106725 214 __IO uint32_t NbrOfCurrentConversionRank; /*!< ADC number of current conversion rank */
Kojto 122:f9eeca106725 215
Kojto 122:f9eeca106725 216 DMA_HandleTypeDef *DMA_Handle; /*!< Pointer DMA Handler */
Kojto 122:f9eeca106725 217
Kojto 122:f9eeca106725 218 HAL_LockTypeDef Lock; /*!< ADC locking object */
Kojto 122:f9eeca106725 219
Kojto 122:f9eeca106725 220 __IO uint32_t State; /*!< ADC communication state */
Kojto 122:f9eeca106725 221
Kojto 122:f9eeca106725 222 __IO uint32_t ErrorCode; /*!< ADC Error code */
Kojto 122:f9eeca106725 223 }ADC_HandleTypeDef;
Kojto 108:34e6b704fe68 224 /**
Kojto 108:34e6b704fe68 225 * @}
Kojto 108:34e6b704fe68 226 */
Kojto 108:34e6b704fe68 227
Kojto 108:34e6b704fe68 228 /* Exported constants --------------------------------------------------------*/
Kojto 108:34e6b704fe68 229 /** @defgroup ADC_Exported_Constants ADC Exported Constants
Kojto 108:34e6b704fe68 230 * @{
Kojto 108:34e6b704fe68 231 */
Kojto 108:34e6b704fe68 232
Kojto 108:34e6b704fe68 233 /** @defgroup ADC_Error_Code ADC Error Code
Kojto 108:34e6b704fe68 234 * @{
Kojto 108:34e6b704fe68 235 */
Kojto 122:f9eeca106725 236 #define HAL_ADC_ERROR_NONE ((uint32_t)0x00U) /*!< No error */
Kojto 122:f9eeca106725 237 #define HAL_ADC_ERROR_INTERNAL ((uint32_t)0x01U) /*!< ADC IP internal error: if problem of clocking,
Kojto 122:f9eeca106725 238 enable/disable, erroneous state */
Kojto 122:f9eeca106725 239 #define HAL_ADC_ERROR_OVR ((uint32_t)0x02U) /*!< Overrun error */
Kojto 122:f9eeca106725 240 #define HAL_ADC_ERROR_DMA ((uint32_t)0x04U) /*!< DMA transfer error */
Kojto 108:34e6b704fe68 241 /**
Kojto 108:34e6b704fe68 242 * @}
Kojto 122:f9eeca106725 243 */
Kojto 108:34e6b704fe68 244
Kojto 108:34e6b704fe68 245
Kojto 108:34e6b704fe68 246 /** @defgroup ADC_ClockPrescaler ADC Clock Prescaler
Kojto 108:34e6b704fe68 247 * @{
Kojto 108:34e6b704fe68 248 */
Kojto 122:f9eeca106725 249 #define ADC_CLOCK_SYNC_PCLK_DIV2 ((uint32_t)0x00000000U)
Kojto 110:165afa46840b 250 #define ADC_CLOCK_SYNC_PCLK_DIV4 ((uint32_t)ADC_CCR_ADCPRE_0)
Kojto 110:165afa46840b 251 #define ADC_CLOCK_SYNC_PCLK_DIV6 ((uint32_t)ADC_CCR_ADCPRE_1)
Kojto 110:165afa46840b 252 #define ADC_CLOCK_SYNC_PCLK_DIV8 ((uint32_t)ADC_CCR_ADCPRE)
Kojto 108:34e6b704fe68 253 /**
Kojto 108:34e6b704fe68 254 * @}
Kojto 108:34e6b704fe68 255 */
Kojto 108:34e6b704fe68 256
Kojto 108:34e6b704fe68 257 /** @defgroup ADC_delay_between_2_sampling_phases ADC Delay Between 2 Sampling Phases
Kojto 108:34e6b704fe68 258 * @{
Kojto 108:34e6b704fe68 259 */
Kojto 122:f9eeca106725 260 #define ADC_TWOSAMPLINGDELAY_5CYCLES ((uint32_t)0x00000000U)
Kojto 108:34e6b704fe68 261 #define ADC_TWOSAMPLINGDELAY_6CYCLES ((uint32_t)ADC_CCR_DELAY_0)
Kojto 108:34e6b704fe68 262 #define ADC_TWOSAMPLINGDELAY_7CYCLES ((uint32_t)ADC_CCR_DELAY_1)
Kojto 108:34e6b704fe68 263 #define ADC_TWOSAMPLINGDELAY_8CYCLES ((uint32_t)(ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
Kojto 108:34e6b704fe68 264 #define ADC_TWOSAMPLINGDELAY_9CYCLES ((uint32_t)ADC_CCR_DELAY_2)
Kojto 108:34e6b704fe68 265 #define ADC_TWOSAMPLINGDELAY_10CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0))
Kojto 108:34e6b704fe68 266 #define ADC_TWOSAMPLINGDELAY_11CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1))
Kojto 108:34e6b704fe68 267 #define ADC_TWOSAMPLINGDELAY_12CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
Kojto 108:34e6b704fe68 268 #define ADC_TWOSAMPLINGDELAY_13CYCLES ((uint32_t)ADC_CCR_DELAY_3)
Kojto 108:34e6b704fe68 269 #define ADC_TWOSAMPLINGDELAY_14CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_0))
Kojto 108:34e6b704fe68 270 #define ADC_TWOSAMPLINGDELAY_15CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1))
Kojto 108:34e6b704fe68 271 #define ADC_TWOSAMPLINGDELAY_16CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
Kojto 108:34e6b704fe68 272 #define ADC_TWOSAMPLINGDELAY_17CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2))
Kojto 108:34e6b704fe68 273 #define ADC_TWOSAMPLINGDELAY_18CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0))
Kojto 108:34e6b704fe68 274 #define ADC_TWOSAMPLINGDELAY_19CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1))
Kojto 108:34e6b704fe68 275 #define ADC_TWOSAMPLINGDELAY_20CYCLES ((uint32_t)ADC_CCR_DELAY)
Kojto 108:34e6b704fe68 276 /**
Kojto 108:34e6b704fe68 277 * @}
Kojto 108:34e6b704fe68 278 */
Kojto 108:34e6b704fe68 279
Kojto 108:34e6b704fe68 280 /** @defgroup ADC_Resolution ADC Resolution
Kojto 108:34e6b704fe68 281 * @{
Kojto 108:34e6b704fe68 282 */
Kojto 122:f9eeca106725 283 #define ADC_RESOLUTION_12B ((uint32_t)0x00000000U)
Kojto 108:34e6b704fe68 284 #define ADC_RESOLUTION_10B ((uint32_t)ADC_CR1_RES_0)
Kojto 108:34e6b704fe68 285 #define ADC_RESOLUTION_8B ((uint32_t)ADC_CR1_RES_1)
Kojto 108:34e6b704fe68 286 #define ADC_RESOLUTION_6B ((uint32_t)ADC_CR1_RES)
Kojto 108:34e6b704fe68 287 /**
Kojto 108:34e6b704fe68 288 * @}
Kojto 108:34e6b704fe68 289 */
Kojto 108:34e6b704fe68 290
Kojto 108:34e6b704fe68 291 /** @defgroup ADC_External_trigger_edge_Regular ADC External Trigger Edge Regular
Kojto 108:34e6b704fe68 292 * @{
Kojto 108:34e6b704fe68 293 */
Kojto 122:f9eeca106725 294 #define ADC_EXTERNALTRIGCONVEDGE_NONE ((uint32_t)0x00000000U)
Kojto 108:34e6b704fe68 295 #define ADC_EXTERNALTRIGCONVEDGE_RISING ((uint32_t)ADC_CR2_EXTEN_0)
Kojto 108:34e6b704fe68 296 #define ADC_EXTERNALTRIGCONVEDGE_FALLING ((uint32_t)ADC_CR2_EXTEN_1)
Kojto 108:34e6b704fe68 297 #define ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING ((uint32_t)ADC_CR2_EXTEN)
Kojto 108:34e6b704fe68 298 /**
Kojto 108:34e6b704fe68 299 * @}
Kojto 108:34e6b704fe68 300 */
Kojto 108:34e6b704fe68 301
Kojto 108:34e6b704fe68 302 /** @defgroup ADC_External_trigger_Source_Regular ADC External Trigger Source Regular
Kojto 108:34e6b704fe68 303 * @{
Kojto 108:34e6b704fe68 304 */
Kojto 108:34e6b704fe68 305 /* Note: Parameter ADC_SOFTWARE_START is a software parameter used for */
Kojto 108:34e6b704fe68 306 /* compatibility with other STM32 devices. */
Kojto 122:f9eeca106725 307 #define ADC_EXTERNALTRIGCONV_T1_CC1 ((uint32_t)0x00000000U)
Kojto 108:34e6b704fe68 308 #define ADC_EXTERNALTRIGCONV_T1_CC2 ((uint32_t)ADC_CR2_EXTSEL_0)
Kojto 108:34e6b704fe68 309 #define ADC_EXTERNALTRIGCONV_T1_CC3 ((uint32_t)ADC_CR2_EXTSEL_1)
Kojto 108:34e6b704fe68 310 #define ADC_EXTERNALTRIGCONV_T2_CC2 ((uint32_t)(ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
Kojto 108:34e6b704fe68 311 #define ADC_EXTERNALTRIGCONV_T2_CC3 ((uint32_t)ADC_CR2_EXTSEL_2)
Kojto 108:34e6b704fe68 312 #define ADC_EXTERNALTRIGCONV_T2_CC4 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
Kojto 108:34e6b704fe68 313 #define ADC_EXTERNALTRIGCONV_T2_TRGO ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1))
Kojto 108:34e6b704fe68 314 #define ADC_EXTERNALTRIGCONV_T3_CC1 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
Kojto 108:34e6b704fe68 315 #define ADC_EXTERNALTRIGCONV_T3_TRGO ((uint32_t)ADC_CR2_EXTSEL_3)
Kojto 108:34e6b704fe68 316 #define ADC_EXTERNALTRIGCONV_T4_CC4 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_0))
Kojto 108:34e6b704fe68 317 #define ADC_EXTERNALTRIGCONV_T5_CC1 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1))
Kojto 108:34e6b704fe68 318 #define ADC_EXTERNALTRIGCONV_T5_CC2 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
Kojto 108:34e6b704fe68 319 #define ADC_EXTERNALTRIGCONV_T5_CC3 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2))
Kojto 108:34e6b704fe68 320 #define ADC_EXTERNALTRIGCONV_T8_CC1 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
Kojto 108:34e6b704fe68 321 #define ADC_EXTERNALTRIGCONV_T8_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1))
Kojto 108:34e6b704fe68 322 #define ADC_EXTERNALTRIGCONV_Ext_IT11 ((uint32_t)ADC_CR2_EXTSEL)
Kojto 122:f9eeca106725 323 #define ADC_SOFTWARE_START ((uint32_t)ADC_CR2_EXTSEL + 1U)
Kojto 108:34e6b704fe68 324 /**
Kojto 108:34e6b704fe68 325 * @}
Kojto 108:34e6b704fe68 326 */
Kojto 108:34e6b704fe68 327
Kojto 122:f9eeca106725 328 /** @defgroup ADC_Data_align ADC Data Align
Kojto 108:34e6b704fe68 329 * @{
Kojto 108:34e6b704fe68 330 */
Kojto 122:f9eeca106725 331 #define ADC_DATAALIGN_RIGHT ((uint32_t)0x00000000U)
Kojto 108:34e6b704fe68 332 #define ADC_DATAALIGN_LEFT ((uint32_t)ADC_CR2_ALIGN)
Kojto 108:34e6b704fe68 333 /**
Kojto 108:34e6b704fe68 334 * @}
Kojto 108:34e6b704fe68 335 */
Kojto 108:34e6b704fe68 336
Kojto 108:34e6b704fe68 337 /** @defgroup ADC_channels ADC Common Channels
Kojto 108:34e6b704fe68 338 * @{
Kojto 108:34e6b704fe68 339 */
Kojto 122:f9eeca106725 340 #define ADC_CHANNEL_0 ((uint32_t)0x00000000U)
Kojto 108:34e6b704fe68 341 #define ADC_CHANNEL_1 ((uint32_t)ADC_CR1_AWDCH_0)
Kojto 108:34e6b704fe68 342 #define ADC_CHANNEL_2 ((uint32_t)ADC_CR1_AWDCH_1)
Kojto 108:34e6b704fe68 343 #define ADC_CHANNEL_3 ((uint32_t)(ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 108:34e6b704fe68 344 #define ADC_CHANNEL_4 ((uint32_t)ADC_CR1_AWDCH_2)
Kojto 108:34e6b704fe68 345 #define ADC_CHANNEL_5 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0))
Kojto 108:34e6b704fe68 346 #define ADC_CHANNEL_6 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1))
Kojto 108:34e6b704fe68 347 #define ADC_CHANNEL_7 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 108:34e6b704fe68 348 #define ADC_CHANNEL_8 ((uint32_t)ADC_CR1_AWDCH_3)
Kojto 108:34e6b704fe68 349 #define ADC_CHANNEL_9 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0))
Kojto 108:34e6b704fe68 350 #define ADC_CHANNEL_10 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1))
Kojto 108:34e6b704fe68 351 #define ADC_CHANNEL_11 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 108:34e6b704fe68 352 #define ADC_CHANNEL_12 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2))
Kojto 108:34e6b704fe68 353 #define ADC_CHANNEL_13 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0))
Kojto 108:34e6b704fe68 354 #define ADC_CHANNEL_14 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1))
Kojto 108:34e6b704fe68 355 #define ADC_CHANNEL_15 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 108:34e6b704fe68 356 #define ADC_CHANNEL_16 ((uint32_t)ADC_CR1_AWDCH_4)
Kojto 108:34e6b704fe68 357 #define ADC_CHANNEL_17 ((uint32_t)(ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_0))
Kojto 108:34e6b704fe68 358 #define ADC_CHANNEL_18 ((uint32_t)(ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_1))
Kojto 108:34e6b704fe68 359
Kojto 108:34e6b704fe68 360 #define ADC_CHANNEL_VREFINT ((uint32_t)ADC_CHANNEL_17)
Kojto 122:f9eeca106725 361 #define ADC_CHANNEL_VBAT ((uint32_t)ADC_CHANNEL_18)
Kojto 108:34e6b704fe68 362 /**
Kojto 108:34e6b704fe68 363 * @}
Kojto 108:34e6b704fe68 364 */
Kojto 108:34e6b704fe68 365
Kojto 108:34e6b704fe68 366 /** @defgroup ADC_sampling_times ADC Sampling Times
Kojto 108:34e6b704fe68 367 * @{
Kojto 108:34e6b704fe68 368 */
Kojto 122:f9eeca106725 369 #define ADC_SAMPLETIME_3CYCLES ((uint32_t)0x00000000U)
Kojto 108:34e6b704fe68 370 #define ADC_SAMPLETIME_15CYCLES ((uint32_t)ADC_SMPR1_SMP10_0)
Kojto 108:34e6b704fe68 371 #define ADC_SAMPLETIME_28CYCLES ((uint32_t)ADC_SMPR1_SMP10_1)
Kojto 108:34e6b704fe68 372 #define ADC_SAMPLETIME_56CYCLES ((uint32_t)(ADC_SMPR1_SMP10_1 | ADC_SMPR1_SMP10_0))
Kojto 108:34e6b704fe68 373 #define ADC_SAMPLETIME_84CYCLES ((uint32_t)ADC_SMPR1_SMP10_2)
Kojto 108:34e6b704fe68 374 #define ADC_SAMPLETIME_112CYCLES ((uint32_t)(ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_0))
Kojto 108:34e6b704fe68 375 #define ADC_SAMPLETIME_144CYCLES ((uint32_t)(ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_1))
Kojto 108:34e6b704fe68 376 #define ADC_SAMPLETIME_480CYCLES ((uint32_t)ADC_SMPR1_SMP10)
Kojto 108:34e6b704fe68 377 /**
Kojto 108:34e6b704fe68 378 * @}
Kojto 108:34e6b704fe68 379 */
Kojto 108:34e6b704fe68 380
Kojto 108:34e6b704fe68 381 /** @defgroup ADC_EOCSelection ADC EOC Selection
Kojto 108:34e6b704fe68 382 * @{
Kojto 108:34e6b704fe68 383 */
Kojto 122:f9eeca106725 384 #define ADC_EOC_SEQ_CONV ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 385 #define ADC_EOC_SINGLE_CONV ((uint32_t)0x00000001U)
Kojto 122:f9eeca106725 386 #define ADC_EOC_SINGLE_SEQ_CONV ((uint32_t)0x00000002U) /*!< reserved for future use */
Kojto 108:34e6b704fe68 387 /**
Kojto 108:34e6b704fe68 388 * @}
Kojto 108:34e6b704fe68 389 */
Kojto 108:34e6b704fe68 390
Kojto 108:34e6b704fe68 391 /** @defgroup ADC_Event_type ADC Event Type
Kojto 108:34e6b704fe68 392 * @{
Kojto 108:34e6b704fe68 393 */
Kojto 108:34e6b704fe68 394 #define ADC_AWD_EVENT ((uint32_t)ADC_FLAG_AWD)
Kojto 108:34e6b704fe68 395 #define ADC_OVR_EVENT ((uint32_t)ADC_FLAG_OVR)
Kojto 108:34e6b704fe68 396 /**
Kojto 108:34e6b704fe68 397 * @}
Kojto 108:34e6b704fe68 398 */
Kojto 108:34e6b704fe68 399
Kojto 108:34e6b704fe68 400 /** @defgroup ADC_analog_watchdog_selection ADC Analog Watchdog Selection
Kojto 108:34e6b704fe68 401 * @{
Kojto 108:34e6b704fe68 402 */
Kojto 108:34e6b704fe68 403 #define ADC_ANALOGWATCHDOG_SINGLE_REG ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN))
Kojto 108:34e6b704fe68 404 #define ADC_ANALOGWATCHDOG_SINGLE_INJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_JAWDEN))
Kojto 108:34e6b704fe68 405 #define ADC_ANALOGWATCHDOG_SINGLE_REGINJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
Kojto 108:34e6b704fe68 406 #define ADC_ANALOGWATCHDOG_ALL_REG ((uint32_t)ADC_CR1_AWDEN)
Kojto 108:34e6b704fe68 407 #define ADC_ANALOGWATCHDOG_ALL_INJEC ((uint32_t)ADC_CR1_JAWDEN)
Kojto 108:34e6b704fe68 408 #define ADC_ANALOGWATCHDOG_ALL_REGINJEC ((uint32_t)(ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
Kojto 122:f9eeca106725 409 #define ADC_ANALOGWATCHDOG_NONE ((uint32_t)0x00000000U)
Kojto 108:34e6b704fe68 410 /**
Kojto 108:34e6b704fe68 411 * @}
Kojto 108:34e6b704fe68 412 */
Kojto 108:34e6b704fe68 413
Kojto 108:34e6b704fe68 414 /** @defgroup ADC_interrupts_definition ADC Interrupts Definition
Kojto 108:34e6b704fe68 415 * @{
Kojto 108:34e6b704fe68 416 */
Kojto 122:f9eeca106725 417 #define ADC_IT_EOC ((uint32_t)ADC_CR1_EOCIE)
Kojto 122:f9eeca106725 418 #define ADC_IT_AWD ((uint32_t)ADC_CR1_AWDIE)
Kojto 108:34e6b704fe68 419 #define ADC_IT_JEOC ((uint32_t)ADC_CR1_JEOCIE)
Kojto 122:f9eeca106725 420 #define ADC_IT_OVR ((uint32_t)ADC_CR1_OVRIE)
Kojto 108:34e6b704fe68 421 /**
Kojto 108:34e6b704fe68 422 * @}
Kojto 108:34e6b704fe68 423 */
Kojto 108:34e6b704fe68 424
Kojto 108:34e6b704fe68 425 /** @defgroup ADC_flags_definition ADC Flags Definition
Kojto 108:34e6b704fe68 426 * @{
Kojto 108:34e6b704fe68 427 */
Kojto 108:34e6b704fe68 428 #define ADC_FLAG_AWD ((uint32_t)ADC_SR_AWD)
Kojto 108:34e6b704fe68 429 #define ADC_FLAG_EOC ((uint32_t)ADC_SR_EOC)
Kojto 108:34e6b704fe68 430 #define ADC_FLAG_JEOC ((uint32_t)ADC_SR_JEOC)
Kojto 108:34e6b704fe68 431 #define ADC_FLAG_JSTRT ((uint32_t)ADC_SR_JSTRT)
Kojto 108:34e6b704fe68 432 #define ADC_FLAG_STRT ((uint32_t)ADC_SR_STRT)
Kojto 108:34e6b704fe68 433 #define ADC_FLAG_OVR ((uint32_t)ADC_SR_OVR)
Kojto 108:34e6b704fe68 434 /**
Kojto 108:34e6b704fe68 435 * @}
Kojto 108:34e6b704fe68 436 */
Kojto 108:34e6b704fe68 437
Kojto 108:34e6b704fe68 438 /** @defgroup ADC_channels_type ADC Channels Type
Kojto 108:34e6b704fe68 439 * @{
Kojto 108:34e6b704fe68 440 */
Kojto 122:f9eeca106725 441 #define ADC_ALL_CHANNELS ((uint32_t)0x00000001U)
Kojto 122:f9eeca106725 442 #define ADC_REGULAR_CHANNELS ((uint32_t)0x00000002U) /*!< reserved for future use */
Kojto 122:f9eeca106725 443 #define ADC_INJECTED_CHANNELS ((uint32_t)0x00000003U) /*!< reserved for future use */
Kojto 108:34e6b704fe68 444 /**
Kojto 108:34e6b704fe68 445 * @}
Kojto 108:34e6b704fe68 446 */
Kojto 108:34e6b704fe68 447
Kojto 108:34e6b704fe68 448 /**
Kojto 108:34e6b704fe68 449 * @}
Kojto 108:34e6b704fe68 450 */
Kojto 108:34e6b704fe68 451
Kojto 108:34e6b704fe68 452 /* Exported macro ------------------------------------------------------------*/
Kojto 108:34e6b704fe68 453 /** @defgroup ADC_Exported_Macros ADC Exported Macros
Kojto 108:34e6b704fe68 454 * @{
Kojto 108:34e6b704fe68 455 */
Kojto 108:34e6b704fe68 456
Kojto 108:34e6b704fe68 457 /** @brief Reset ADC handle state
Kojto 108:34e6b704fe68 458 * @param __HANDLE__: ADC handle
Kojto 108:34e6b704fe68 459 * @retval None
Kojto 108:34e6b704fe68 460 */
Kojto 108:34e6b704fe68 461 #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
Kojto 108:34e6b704fe68 462
Kojto 108:34e6b704fe68 463 /**
Kojto 108:34e6b704fe68 464 * @brief Enable the ADC peripheral.
Kojto 108:34e6b704fe68 465 * @param __HANDLE__: ADC handle
Kojto 108:34e6b704fe68 466 * @retval None
Kojto 108:34e6b704fe68 467 */
Kojto 108:34e6b704fe68 468 #define __HAL_ADC_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR2 |= ADC_CR2_ADON)
Kojto 108:34e6b704fe68 469
Kojto 108:34e6b704fe68 470 /**
Kojto 108:34e6b704fe68 471 * @brief Disable the ADC peripheral.
Kojto 108:34e6b704fe68 472 * @param __HANDLE__: ADC handle
Kojto 108:34e6b704fe68 473 * @retval None
Kojto 108:34e6b704fe68 474 */
Kojto 108:34e6b704fe68 475 #define __HAL_ADC_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR2 &= ~ADC_CR2_ADON)
Kojto 108:34e6b704fe68 476
Kojto 108:34e6b704fe68 477 /**
Kojto 108:34e6b704fe68 478 * @brief Enable the ADC end of conversion interrupt.
Kojto 108:34e6b704fe68 479 * @param __HANDLE__: specifies the ADC Handle.
Kojto 108:34e6b704fe68 480 * @param __INTERRUPT__: ADC Interrupt.
Kojto 108:34e6b704fe68 481 * @retval None
Kojto 108:34e6b704fe68 482 */
Kojto 108:34e6b704fe68 483 #define __HAL_ADC_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1) |= (__INTERRUPT__))
Kojto 108:34e6b704fe68 484
Kojto 108:34e6b704fe68 485 /**
Kojto 108:34e6b704fe68 486 * @brief Disable the ADC end of conversion interrupt.
Kojto 108:34e6b704fe68 487 * @param __HANDLE__: specifies the ADC Handle.
Kojto 108:34e6b704fe68 488 * @param __INTERRUPT__: ADC interrupt.
Kojto 108:34e6b704fe68 489 * @retval None
Kojto 108:34e6b704fe68 490 */
Kojto 108:34e6b704fe68 491 #define __HAL_ADC_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1) &= ~(__INTERRUPT__))
Kojto 108:34e6b704fe68 492
Kojto 108:34e6b704fe68 493 /** @brief Check if the specified ADC interrupt source is enabled or disabled.
Kojto 108:34e6b704fe68 494 * @param __HANDLE__: specifies the ADC Handle.
Kojto 108:34e6b704fe68 495 * @param __INTERRUPT__: specifies the ADC interrupt source to check.
Kojto 108:34e6b704fe68 496 * @retval The new state of __IT__ (TRUE or FALSE).
Kojto 108:34e6b704fe68 497 */
Kojto 108:34e6b704fe68 498 #define __HAL_ADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__))
Kojto 108:34e6b704fe68 499
Kojto 108:34e6b704fe68 500 /**
Kojto 108:34e6b704fe68 501 * @brief Clear the ADC's pending flags.
Kojto 108:34e6b704fe68 502 * @param __HANDLE__: specifies the ADC Handle.
Kojto 108:34e6b704fe68 503 * @param __FLAG__: ADC flag.
Kojto 108:34e6b704fe68 504 * @retval None
Kojto 108:34e6b704fe68 505 */
Kojto 108:34e6b704fe68 506 #define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) = ~(__FLAG__))
Kojto 108:34e6b704fe68 507
Kojto 108:34e6b704fe68 508 /**
Kojto 108:34e6b704fe68 509 * @brief Get the selected ADC's flag status.
Kojto 108:34e6b704fe68 510 * @param __HANDLE__: specifies the ADC Handle.
Kojto 108:34e6b704fe68 511 * @param __FLAG__: ADC flag.
Kojto 108:34e6b704fe68 512 * @retval None
Kojto 108:34e6b704fe68 513 */
Kojto 108:34e6b704fe68 514 #define __HAL_ADC_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
Kojto 108:34e6b704fe68 515
Kojto 108:34e6b704fe68 516 /**
Kojto 108:34e6b704fe68 517 * @}
Kojto 108:34e6b704fe68 518 */
Kojto 108:34e6b704fe68 519
Kojto 108:34e6b704fe68 520 /* Include ADC HAL Extension module */
Kojto 108:34e6b704fe68 521 #include "stm32f4xx_hal_adc_ex.h"
Kojto 108:34e6b704fe68 522
Kojto 108:34e6b704fe68 523 /* Exported functions --------------------------------------------------------*/
Kojto 108:34e6b704fe68 524 /** @addtogroup ADC_Exported_Functions
Kojto 108:34e6b704fe68 525 * @{
Kojto 108:34e6b704fe68 526 */
Kojto 108:34e6b704fe68 527
Kojto 108:34e6b704fe68 528 /** @addtogroup ADC_Exported_Functions_Group1
Kojto 108:34e6b704fe68 529 * @{
Kojto 108:34e6b704fe68 530 */
Kojto 108:34e6b704fe68 531 /* Initialization/de-initialization functions ***********************************/
Kojto 108:34e6b704fe68 532 HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc);
Kojto 108:34e6b704fe68 533 HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
Kojto 108:34e6b704fe68 534 void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
Kojto 108:34e6b704fe68 535 void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
Kojto 108:34e6b704fe68 536 /**
Kojto 108:34e6b704fe68 537 * @}
Kojto 108:34e6b704fe68 538 */
Kojto 108:34e6b704fe68 539
Kojto 108:34e6b704fe68 540 /** @addtogroup ADC_Exported_Functions_Group2
Kojto 108:34e6b704fe68 541 * @{
Kojto 108:34e6b704fe68 542 */
Kojto 108:34e6b704fe68 543 /* I/O operation functions ******************************************************/
Kojto 108:34e6b704fe68 544 HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc);
Kojto 108:34e6b704fe68 545 HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc);
Kojto 108:34e6b704fe68 546 HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
Kojto 108:34e6b704fe68 547
Kojto 108:34e6b704fe68 548 HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout);
Kojto 108:34e6b704fe68 549
Kojto 108:34e6b704fe68 550 HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc);
Kojto 108:34e6b704fe68 551 HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc);
Kojto 108:34e6b704fe68 552
Kojto 108:34e6b704fe68 553 void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc);
Kojto 108:34e6b704fe68 554
Kojto 108:34e6b704fe68 555 HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length);
Kojto 108:34e6b704fe68 556 HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc);
Kojto 108:34e6b704fe68 557
Kojto 108:34e6b704fe68 558 uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc);
Kojto 108:34e6b704fe68 559
Kojto 108:34e6b704fe68 560 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc);
Kojto 108:34e6b704fe68 561 void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc);
Kojto 108:34e6b704fe68 562 void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc);
Kojto 108:34e6b704fe68 563 void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
Kojto 108:34e6b704fe68 564 /**
Kojto 108:34e6b704fe68 565 * @}
Kojto 108:34e6b704fe68 566 */
Kojto 108:34e6b704fe68 567
Kojto 108:34e6b704fe68 568 /** @addtogroup ADC_Exported_Functions_Group3
Kojto 108:34e6b704fe68 569 * @{
Kojto 108:34e6b704fe68 570 */
Kojto 108:34e6b704fe68 571 /* Peripheral Control functions *************************************************/
Kojto 108:34e6b704fe68 572 HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig);
Kojto 108:34e6b704fe68 573 HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig);
Kojto 108:34e6b704fe68 574 /**
Kojto 108:34e6b704fe68 575 * @}
Kojto 108:34e6b704fe68 576 */
Kojto 108:34e6b704fe68 577
Kojto 108:34e6b704fe68 578 /** @addtogroup ADC_Exported_Functions_Group4
Kojto 108:34e6b704fe68 579 * @{
Kojto 108:34e6b704fe68 580 */
Kojto 108:34e6b704fe68 581 /* Peripheral State functions ***************************************************/
Kojto 122:f9eeca106725 582 uint32_t HAL_ADC_GetState(ADC_HandleTypeDef* hadc);
Kojto 108:34e6b704fe68 583 uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc);
Kojto 108:34e6b704fe68 584 /**
Kojto 108:34e6b704fe68 585 * @}
Kojto 108:34e6b704fe68 586 */
Kojto 108:34e6b704fe68 587
Kojto 108:34e6b704fe68 588 /**
Kojto 108:34e6b704fe68 589 * @}
Kojto 108:34e6b704fe68 590 */
Kojto 108:34e6b704fe68 591 /* Private types -------------------------------------------------------------*/
Kojto 108:34e6b704fe68 592 /* Private variables ---------------------------------------------------------*/
Kojto 108:34e6b704fe68 593 /* Private constants ---------------------------------------------------------*/
Kojto 108:34e6b704fe68 594 /** @defgroup ADC_Private_Constants ADC Private Constants
Kojto 108:34e6b704fe68 595 * @{
Kojto 108:34e6b704fe68 596 */
Kojto 108:34e6b704fe68 597 /* Delay for ADC stabilization time. */
Kojto 108:34e6b704fe68 598 /* Maximum delay is 1us (refer to device datasheet, parameter tSTAB). */
Kojto 108:34e6b704fe68 599 /* Unit: us */
Kojto 122:f9eeca106725 600 #define ADC_STAB_DELAY_US ((uint32_t) 3U)
Kojto 108:34e6b704fe68 601 /* Delay for temperature sensor stabilization time. */
Kojto 108:34e6b704fe68 602 /* Maximum delay is 10us (refer to device datasheet, parameter tSTART). */
Kojto 108:34e6b704fe68 603 /* Unit: us */
Kojto 122:f9eeca106725 604 #define ADC_TEMPSENSOR_DELAY_US ((uint32_t) 10U)
Kojto 108:34e6b704fe68 605 /**
Kojto 108:34e6b704fe68 606 * @}
Kojto 108:34e6b704fe68 607 */
Kojto 108:34e6b704fe68 608
Kojto 122:f9eeca106725 609 /* Private macro ------------------------------------------------------------*/
Kojto 122:f9eeca106725 610
Kojto 108:34e6b704fe68 611 /** @defgroup ADC_Private_Macros ADC Private Macros
Kojto 108:34e6b704fe68 612 * @{
Kojto 108:34e6b704fe68 613 */
Kojto 122:f9eeca106725 614 /* Macro reserved for internal HAL driver usage, not intended to be used in
Kojto 122:f9eeca106725 615 code of final user */
Kojto 122:f9eeca106725 616
Kojto 122:f9eeca106725 617 /**
Kojto 122:f9eeca106725 618 * @brief Verification of ADC state: enabled or disabled
Kojto 122:f9eeca106725 619 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 620 * @retval SET (ADC enabled) or RESET (ADC disabled)
Kojto 122:f9eeca106725 621 */
Kojto 122:f9eeca106725 622 #define ADC_IS_ENABLE(__HANDLE__) \
Kojto 122:f9eeca106725 623 ((( ((__HANDLE__)->Instance->SR & ADC_SR_ADONS) == ADC_SR_ADONS ) \
Kojto 122:f9eeca106725 624 ) ? SET : RESET)
Kojto 122:f9eeca106725 625
Kojto 122:f9eeca106725 626 /**
Kojto 122:f9eeca106725 627 * @brief Test if conversion trigger of regular group is software start
Kojto 122:f9eeca106725 628 * or external trigger.
Kojto 122:f9eeca106725 629 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 630 * @retval SET (software start) or RESET (external trigger)
Kojto 122:f9eeca106725 631 */
Kojto 122:f9eeca106725 632 #define ADC_IS_SOFTWARE_START_REGULAR(__HANDLE__) \
Kojto 122:f9eeca106725 633 (((__HANDLE__)->Instance->CR2 & ADC_CR2_EXTEN) == RESET)
Kojto 122:f9eeca106725 634
Kojto 122:f9eeca106725 635 /**
Kojto 122:f9eeca106725 636 * @brief Test if conversion trigger of injected group is software start
Kojto 122:f9eeca106725 637 * or external trigger.
Kojto 122:f9eeca106725 638 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 639 * @retval SET (software start) or RESET (external trigger)
Kojto 122:f9eeca106725 640 */
Kojto 122:f9eeca106725 641 #define ADC_IS_SOFTWARE_START_INJECTED(__HANDLE__) \
Kojto 122:f9eeca106725 642 (((__HANDLE__)->Instance->CR2 & ADC_CR2_JEXTEN) == RESET)
Kojto 122:f9eeca106725 643
Kojto 122:f9eeca106725 644 /**
Kojto 122:f9eeca106725 645 * @brief Simultaneously clears and sets specific bits of the handle State
Kojto 122:f9eeca106725 646 * @note: ADC_STATE_CLR_SET() macro is merely aliased to generic macro MODIFY_REG(),
Kojto 122:f9eeca106725 647 * the first parameter is the ADC handle State, the second parameter is the
Kojto 122:f9eeca106725 648 * bit field to clear, the third and last parameter is the bit field to set.
Kojto 122:f9eeca106725 649 * @retval None
Kojto 122:f9eeca106725 650 */
Kojto 122:f9eeca106725 651 #define ADC_STATE_CLR_SET MODIFY_REG
Kojto 122:f9eeca106725 652
Kojto 122:f9eeca106725 653 /**
Kojto 122:f9eeca106725 654 * @brief Clear ADC error code (set it to error code: "no error")
Kojto 122:f9eeca106725 655 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 656 * @retval None
Kojto 122:f9eeca106725 657 */
Kojto 122:f9eeca106725 658 #define ADC_CLEAR_ERRORCODE(__HANDLE__) \
Kojto 122:f9eeca106725 659 ((__HANDLE__)->ErrorCode = HAL_ADC_ERROR_NONE)
Kojto 122:f9eeca106725 660
Kojto 122:f9eeca106725 661
Kojto 110:165afa46840b 662 #define IS_ADC_CLOCKPRESCALER(ADC_CLOCK) (((ADC_CLOCK) == ADC_CLOCK_SYNC_PCLK_DIV2) || \
Kojto 110:165afa46840b 663 ((ADC_CLOCK) == ADC_CLOCK_SYNC_PCLK_DIV4) || \
Kojto 110:165afa46840b 664 ((ADC_CLOCK) == ADC_CLOCK_SYNC_PCLK_DIV6) || \
Kojto 110:165afa46840b 665 ((ADC_CLOCK) == ADC_CLOCK_SYNC_PCLK_DIV8))
Kojto 108:34e6b704fe68 666 #define IS_ADC_SAMPLING_DELAY(DELAY) (((DELAY) == ADC_TWOSAMPLINGDELAY_5CYCLES) || \
Kojto 108:34e6b704fe68 667 ((DELAY) == ADC_TWOSAMPLINGDELAY_6CYCLES) || \
Kojto 108:34e6b704fe68 668 ((DELAY) == ADC_TWOSAMPLINGDELAY_7CYCLES) || \
Kojto 108:34e6b704fe68 669 ((DELAY) == ADC_TWOSAMPLINGDELAY_8CYCLES) || \
Kojto 108:34e6b704fe68 670 ((DELAY) == ADC_TWOSAMPLINGDELAY_9CYCLES) || \
Kojto 108:34e6b704fe68 671 ((DELAY) == ADC_TWOSAMPLINGDELAY_10CYCLES) || \
Kojto 108:34e6b704fe68 672 ((DELAY) == ADC_TWOSAMPLINGDELAY_11CYCLES) || \
Kojto 108:34e6b704fe68 673 ((DELAY) == ADC_TWOSAMPLINGDELAY_12CYCLES) || \
Kojto 108:34e6b704fe68 674 ((DELAY) == ADC_TWOSAMPLINGDELAY_13CYCLES) || \
Kojto 108:34e6b704fe68 675 ((DELAY) == ADC_TWOSAMPLINGDELAY_14CYCLES) || \
Kojto 108:34e6b704fe68 676 ((DELAY) == ADC_TWOSAMPLINGDELAY_15CYCLES) || \
Kojto 108:34e6b704fe68 677 ((DELAY) == ADC_TWOSAMPLINGDELAY_16CYCLES) || \
Kojto 108:34e6b704fe68 678 ((DELAY) == ADC_TWOSAMPLINGDELAY_17CYCLES) || \
Kojto 108:34e6b704fe68 679 ((DELAY) == ADC_TWOSAMPLINGDELAY_18CYCLES) || \
Kojto 108:34e6b704fe68 680 ((DELAY) == ADC_TWOSAMPLINGDELAY_19CYCLES) || \
Kojto 108:34e6b704fe68 681 ((DELAY) == ADC_TWOSAMPLINGDELAY_20CYCLES))
Kojto 108:34e6b704fe68 682 #define IS_ADC_RESOLUTION(RESOLUTION) (((RESOLUTION) == ADC_RESOLUTION_12B) || \
Kojto 108:34e6b704fe68 683 ((RESOLUTION) == ADC_RESOLUTION_10B) || \
Kojto 108:34e6b704fe68 684 ((RESOLUTION) == ADC_RESOLUTION_8B) || \
Kojto 108:34e6b704fe68 685 ((RESOLUTION) == ADC_RESOLUTION_6B))
Kojto 108:34e6b704fe68 686 #define IS_ADC_EXT_TRIG_EDGE(EDGE) (((EDGE) == ADC_EXTERNALTRIGCONVEDGE_NONE) || \
Kojto 108:34e6b704fe68 687 ((EDGE) == ADC_EXTERNALTRIGCONVEDGE_RISING) || \
Kojto 108:34e6b704fe68 688 ((EDGE) == ADC_EXTERNALTRIGCONVEDGE_FALLING) || \
Kojto 108:34e6b704fe68 689 ((EDGE) == ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING))
Kojto 108:34e6b704fe68 690 #define IS_ADC_EXT_TRIG(REGTRIG) (((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
Kojto 108:34e6b704fe68 691 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
Kojto 108:34e6b704fe68 692 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T1_CC3) || \
Kojto 108:34e6b704fe68 693 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
Kojto 108:34e6b704fe68 694 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC3) || \
Kojto 108:34e6b704fe68 695 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_CC4) || \
Kojto 108:34e6b704fe68 696 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T2_TRGO) || \
Kojto 108:34e6b704fe68 697 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_CC1) || \
Kojto 108:34e6b704fe68 698 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T3_TRGO) || \
Kojto 108:34e6b704fe68 699 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
Kojto 108:34e6b704fe68 700 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T5_CC1) || \
Kojto 108:34e6b704fe68 701 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T5_CC2) || \
Kojto 108:34e6b704fe68 702 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T5_CC3) || \
Kojto 108:34e6b704fe68 703 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_CC1) || \
Kojto 108:34e6b704fe68 704 ((REGTRIG) == ADC_EXTERNALTRIGCONV_T8_TRGO) || \
Kojto 108:34e6b704fe68 705 ((REGTRIG) == ADC_EXTERNALTRIGCONV_Ext_IT11)|| \
Kojto 108:34e6b704fe68 706 ((REGTRIG) == ADC_SOFTWARE_START))
Kojto 108:34e6b704fe68 707 #define IS_ADC_DATA_ALIGN(ALIGN) (((ALIGN) == ADC_DATAALIGN_RIGHT) || \
Kojto 108:34e6b704fe68 708 ((ALIGN) == ADC_DATAALIGN_LEFT))
Kojto 108:34e6b704fe68 709 #define IS_ADC_SAMPLE_TIME(TIME) (((TIME) == ADC_SAMPLETIME_3CYCLES) || \
Kojto 108:34e6b704fe68 710 ((TIME) == ADC_SAMPLETIME_15CYCLES) || \
Kojto 108:34e6b704fe68 711 ((TIME) == ADC_SAMPLETIME_28CYCLES) || \
Kojto 108:34e6b704fe68 712 ((TIME) == ADC_SAMPLETIME_56CYCLES) || \
Kojto 108:34e6b704fe68 713 ((TIME) == ADC_SAMPLETIME_84CYCLES) || \
Kojto 108:34e6b704fe68 714 ((TIME) == ADC_SAMPLETIME_112CYCLES) || \
Kojto 108:34e6b704fe68 715 ((TIME) == ADC_SAMPLETIME_144CYCLES) || \
Kojto 108:34e6b704fe68 716 ((TIME) == ADC_SAMPLETIME_480CYCLES))
Kojto 108:34e6b704fe68 717 #define IS_ADC_EOCSelection(EOCSelection) (((EOCSelection) == ADC_EOC_SINGLE_CONV) || \
Kojto 108:34e6b704fe68 718 ((EOCSelection) == ADC_EOC_SEQ_CONV) || \
Kojto 108:34e6b704fe68 719 ((EOCSelection) == ADC_EOC_SINGLE_SEQ_CONV))
Kojto 108:34e6b704fe68 720 #define IS_ADC_EVENT_TYPE(EVENT) (((EVENT) == ADC_AWD_EVENT) || \
Kojto 108:34e6b704fe68 721 ((EVENT) == ADC_OVR_EVENT))
Kojto 108:34e6b704fe68 722 #define IS_ADC_ANALOG_WATCHDOG(WATCHDOG) (((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_REG) || \
Kojto 108:34e6b704fe68 723 ((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_INJEC) || \
Kojto 108:34e6b704fe68 724 ((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC) || \
Kojto 108:34e6b704fe68 725 ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_REG) || \
Kojto 108:34e6b704fe68 726 ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_INJEC) || \
Kojto 108:34e6b704fe68 727 ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_REGINJEC) || \
Kojto 108:34e6b704fe68 728 ((WATCHDOG) == ADC_ANALOGWATCHDOG_NONE))
Kojto 108:34e6b704fe68 729 #define IS_ADC_CHANNELS_TYPE(CHANNEL_TYPE) (((CHANNEL_TYPE) == ADC_ALL_CHANNELS) || \
Kojto 108:34e6b704fe68 730 ((CHANNEL_TYPE) == ADC_REGULAR_CHANNELS) || \
Kojto 108:34e6b704fe68 731 ((CHANNEL_TYPE) == ADC_INJECTED_CHANNELS))
Kojto 122:f9eeca106725 732 #define IS_ADC_THRESHOLD(THRESHOLD) ((THRESHOLD) <= ((uint32_t)0xFFFU))
Kojto 108:34e6b704fe68 733
Kojto 122:f9eeca106725 734 #define IS_ADC_REGULAR_LENGTH(LENGTH) (((LENGTH) >= ((uint32_t)1U)) && ((LENGTH) <= ((uint32_t)16U)))
Kojto 122:f9eeca106725 735 #define IS_ADC_REGULAR_RANK(RANK) (((RANK) >= ((uint32_t)1U)) && ((RANK) <= ((uint32_t)16U)))
Kojto 122:f9eeca106725 736 #define IS_ADC_REGULAR_DISC_NUMBER(NUMBER) (((NUMBER) >= ((uint32_t)1U)) && ((NUMBER) <= ((uint32_t)8U)))
Kojto 108:34e6b704fe68 737 #define IS_ADC_RANGE(RESOLUTION, ADC_VALUE) \
Kojto 122:f9eeca106725 738 ((((RESOLUTION) == ADC_RESOLUTION_12B) && ((ADC_VALUE) <= ((uint32_t)0x0FFFU))) || \
Kojto 122:f9eeca106725 739 (((RESOLUTION) == ADC_RESOLUTION_10B) && ((ADC_VALUE) <= ((uint32_t)0x03FFU))) || \
Kojto 122:f9eeca106725 740 (((RESOLUTION) == ADC_RESOLUTION_8B) && ((ADC_VALUE) <= ((uint32_t)0x00FFU))) || \
Kojto 122:f9eeca106725 741 (((RESOLUTION) == ADC_RESOLUTION_6B) && ((ADC_VALUE) <= ((uint32_t)0x003FU))))
Kojto 108:34e6b704fe68 742
Kojto 108:34e6b704fe68 743 /**
Kojto 108:34e6b704fe68 744 * @brief Set ADC Regular channel sequence length.
Kojto 108:34e6b704fe68 745 * @param _NbrOfConversion_: Regular channel sequence length.
Kojto 108:34e6b704fe68 746 * @retval None
Kojto 108:34e6b704fe68 747 */
Kojto 122:f9eeca106725 748 #define ADC_SQR1(_NbrOfConversion_) (((_NbrOfConversion_) - (uint8_t)1U) << 20U)
Kojto 108:34e6b704fe68 749
Kojto 108:34e6b704fe68 750 /**
Kojto 108:34e6b704fe68 751 * @brief Set the ADC's sample time for channel numbers between 10 and 18.
Kojto 108:34e6b704fe68 752 * @param _SAMPLETIME_: Sample time parameter.
Kojto 108:34e6b704fe68 753 * @param _CHANNELNB_: Channel number.
Kojto 108:34e6b704fe68 754 * @retval None
Kojto 108:34e6b704fe68 755 */
Kojto 122:f9eeca106725 756 #define ADC_SMPR1(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3U * (((uint32_t)((uint16_t)(_CHANNELNB_))) - 10U)))
Kojto 108:34e6b704fe68 757
Kojto 108:34e6b704fe68 758 /**
Kojto 108:34e6b704fe68 759 * @brief Set the ADC's sample time for channel numbers between 0 and 9.
Kojto 108:34e6b704fe68 760 * @param _SAMPLETIME_: Sample time parameter.
Kojto 108:34e6b704fe68 761 * @param _CHANNELNB_: Channel number.
Kojto 108:34e6b704fe68 762 * @retval None
Kojto 108:34e6b704fe68 763 */
Kojto 122:f9eeca106725 764 #define ADC_SMPR2(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3U * ((uint32_t)((uint16_t)(_CHANNELNB_)))))
Kojto 108:34e6b704fe68 765
Kojto 108:34e6b704fe68 766 /**
Kojto 108:34e6b704fe68 767 * @brief Set the selected regular channel rank for rank between 1 and 6.
Kojto 108:34e6b704fe68 768 * @param _CHANNELNB_: Channel number.
Kojto 108:34e6b704fe68 769 * @param _RANKNB_: Rank number.
Kojto 108:34e6b704fe68 770 * @retval None
Kojto 108:34e6b704fe68 771 */
Kojto 122:f9eeca106725 772 #define ADC_SQR3_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5U * ((_RANKNB_) - 1U)))
Kojto 108:34e6b704fe68 773
Kojto 108:34e6b704fe68 774 /**
Kojto 108:34e6b704fe68 775 * @brief Set the selected regular channel rank for rank between 7 and 12.
Kojto 108:34e6b704fe68 776 * @param _CHANNELNB_: Channel number.
Kojto 108:34e6b704fe68 777 * @param _RANKNB_: Rank number.
Kojto 108:34e6b704fe68 778 * @retval None
Kojto 108:34e6b704fe68 779 */
Kojto 122:f9eeca106725 780 #define ADC_SQR2_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5U * ((_RANKNB_) - 7U)))
Kojto 108:34e6b704fe68 781
Kojto 108:34e6b704fe68 782 /**
Kojto 108:34e6b704fe68 783 * @brief Set the selected regular channel rank for rank between 13 and 16.
Kojto 108:34e6b704fe68 784 * @param _CHANNELNB_: Channel number.
Kojto 108:34e6b704fe68 785 * @param _RANKNB_: Rank number.
Kojto 108:34e6b704fe68 786 * @retval None
Kojto 108:34e6b704fe68 787 */
Kojto 122:f9eeca106725 788 #define ADC_SQR1_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5U * ((_RANKNB_) - 13U)))
Kojto 108:34e6b704fe68 789
Kojto 108:34e6b704fe68 790 /**
Kojto 108:34e6b704fe68 791 * @brief Enable ADC continuous conversion mode.
Kojto 108:34e6b704fe68 792 * @param _CONTINUOUS_MODE_: Continuous mode.
Kojto 108:34e6b704fe68 793 * @retval None
Kojto 108:34e6b704fe68 794 */
Kojto 122:f9eeca106725 795 #define ADC_CR2_CONTINUOUS(_CONTINUOUS_MODE_) ((_CONTINUOUS_MODE_) << 1U)
Kojto 108:34e6b704fe68 796
Kojto 108:34e6b704fe68 797 /**
Kojto 108:34e6b704fe68 798 * @brief Configures the number of discontinuous conversions for the regular group channels.
Kojto 108:34e6b704fe68 799 * @param _NBR_DISCONTINUOUSCONV_: Number of discontinuous conversions.
Kojto 108:34e6b704fe68 800 * @retval None
Kojto 108:34e6b704fe68 801 */
Kojto 122:f9eeca106725 802 #define ADC_CR1_DISCONTINUOUS(_NBR_DISCONTINUOUSCONV_) (((_NBR_DISCONTINUOUSCONV_) - 1U) << POSITION_VAL(ADC_CR1_DISCNUM))
Kojto 108:34e6b704fe68 803
Kojto 108:34e6b704fe68 804 /**
Kojto 108:34e6b704fe68 805 * @brief Enable ADC scan mode.
Kojto 108:34e6b704fe68 806 * @param _SCANCONV_MODE_: Scan conversion mode.
Kojto 108:34e6b704fe68 807 * @retval None
Kojto 108:34e6b704fe68 808 */
Kojto 122:f9eeca106725 809 #define ADC_CR1_SCANCONV(_SCANCONV_MODE_) ((_SCANCONV_MODE_) << 8U)
Kojto 108:34e6b704fe68 810
Kojto 108:34e6b704fe68 811 /**
Kojto 108:34e6b704fe68 812 * @brief Enable the ADC end of conversion selection.
Kojto 108:34e6b704fe68 813 * @param _EOCSelection_MODE_: End of conversion selection mode.
Kojto 108:34e6b704fe68 814 * @retval None
Kojto 108:34e6b704fe68 815 */
Kojto 122:f9eeca106725 816 #define ADC_CR2_EOCSelection(_EOCSelection_MODE_) ((_EOCSelection_MODE_) << 10U)
Kojto 108:34e6b704fe68 817
Kojto 108:34e6b704fe68 818 /**
Kojto 108:34e6b704fe68 819 * @brief Enable the ADC DMA continuous request.
Kojto 108:34e6b704fe68 820 * @param _DMAContReq_MODE_: DMA continuous request mode.
Kojto 108:34e6b704fe68 821 * @retval None
Kojto 108:34e6b704fe68 822 */
Kojto 122:f9eeca106725 823 #define ADC_CR2_DMAContReq(_DMAContReq_MODE_) ((_DMAContReq_MODE_) << 9U)
Kojto 108:34e6b704fe68 824
Kojto 108:34e6b704fe68 825 /**
Kojto 108:34e6b704fe68 826 * @brief Return resolution bits in CR1 register.
Kojto 108:34e6b704fe68 827 * @param __HANDLE__: ADC handle
Kojto 108:34e6b704fe68 828 * @retval None
Kojto 108:34e6b704fe68 829 */
Kojto 108:34e6b704fe68 830 #define ADC_GET_RESOLUTION(__HANDLE__) (((__HANDLE__)->Instance->CR1) & ADC_CR1_RES)
Kojto 108:34e6b704fe68 831
Kojto 108:34e6b704fe68 832 /**
Kojto 108:34e6b704fe68 833 * @}
Kojto 108:34e6b704fe68 834 */
Kojto 108:34e6b704fe68 835
Kojto 108:34e6b704fe68 836 /* Private functions ---------------------------------------------------------*/
Kojto 108:34e6b704fe68 837 /** @defgroup ADC_Private_Functions ADC Private Functions
Kojto 108:34e6b704fe68 838 * @{
Kojto 108:34e6b704fe68 839 */
Kojto 108:34e6b704fe68 840
Kojto 108:34e6b704fe68 841 /**
Kojto 108:34e6b704fe68 842 * @}
Kojto 108:34e6b704fe68 843 */
Kojto 108:34e6b704fe68 844
Kojto 108:34e6b704fe68 845 /**
Kojto 108:34e6b704fe68 846 * @}
Kojto 108:34e6b704fe68 847 */
Kojto 108:34e6b704fe68 848
Kojto 108:34e6b704fe68 849 /**
Kojto 108:34e6b704fe68 850 * @}
Kojto 108:34e6b704fe68 851 */
Kojto 108:34e6b704fe68 852
Kojto 108:34e6b704fe68 853 #ifdef __cplusplus
Kojto 108:34e6b704fe68 854 }
Kojto 108:34e6b704fe68 855 #endif
Kojto 108:34e6b704fe68 856
Kojto 108:34e6b704fe68 857 #endif /*__STM32F4xx_ADC_H */
Kojto 108:34e6b704fe68 858
Kojto 108:34e6b704fe68 859
Kojto 108:34e6b704fe68 860 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/