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:
Thu Mar 30 13:26:47 2017 +0100
Revision:
139:856d2700e60b
Parent:
135:176b8275d35d
Child:
146:22da6e220af6
Release 139 of the mbed library

Ports for Upcoming Targets

3934: [Silicon Labs] Update to HAL and devices https://github.com/ARMmbed/mbed-os/pull/3934

Known Issues

There is an issue with LPC1768 failing the 'Semihost file system' test with this release.

Fixes and Changes

3691: [TLS / hw acceleration] AES ECB for NUCLEO_F439ZI https://github.com/ARMmbed/mbed-os/pull/3691
3869: NCS36510: Default range changed from 0 to 950mV - ADC https://github.com/ARMmbed/mbed-os/pull/3869
3893: [STM32F7] Update STM32 Cube version v1.6.0 https://github.com/ARMmbed/mbed-os/pull/3893
3917: Fix mistake register setting in serial_format() https://github.com/ARMmbed/mbed-os/pull/3917
3927: [DELTA_DFBM_NQ620] Add RC calibration setting and revise mbed_overrides.c https://github.com/ARMmbed/mbed-os/pull/3927
3918: [NUC472/M453] Support unique locally administered MAC address and other driver updates https://github.com/ARMmbed/mbed-os/pull/3918
3920: Heap size adjusted to work for both tls-client and mbed-client https://github.com/ARMmbed/mbed-os/pull/3920
3969: NUCLEO_F302R8: Add missing PB_8/PB_9 CAN pins https://github.com/ARMmbed/mbed-os/pull/3969

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 122:f9eeca106725 1 /**
Kojto 122:f9eeca106725 2 ******************************************************************************
Kojto 122:f9eeca106725 3 * @file stm32f7xx_hal_adc.h
Kojto 122:f9eeca106725 4 * @author MCD Application Team
<> 139:856d2700e60b 5 * @version V1.2.0
<> 139:856d2700e60b 6 * @date 30-December-2016
Kojto 122:f9eeca106725 7 * @brief Header file of ADC HAL extension 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 __STM32F7xx_ADC_H
Kojto 122:f9eeca106725 40 #define __STM32F7xx_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 "stm32f7xx_hal_def.h"
Kojto 122:f9eeca106725 48
Kojto 122:f9eeca106725 49 /** @addtogroup STM32F7xx_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 * @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 fullfills the ADC state condition) on the fly).
Kojto 122:f9eeca106725 74 */
Kojto 122:f9eeca106725 75 typedef struct
Kojto 122:f9eeca106725 76 {
Kojto 122:f9eeca106725 77 uint32_t ClockPrescaler; /*!< Select ADC clock prescaler. The clock is common for
Kojto 122:f9eeca106725 78 all the ADCs.
Kojto 122:f9eeca106725 79 This parameter can be a value of @ref ADC_ClockPrescaler */
Kojto 122:f9eeca106725 80 uint32_t Resolution; /*!< Configures the ADC resolution.
Kojto 122:f9eeca106725 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'.
<> 139:856d2700e60b 91 This parameter can be a value of @ref ADC_Scan_mode.
Kojto 122:f9eeca106725 92 This parameter can be set to ENABLE or DISABLE */
Kojto 122:f9eeca106725 93 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 94 This parameter can be a value of @ref ADC_EOCSelection.
Kojto 122:f9eeca106725 95 Note: For injected group, end of conversion (flag&IT) is raised only at the end of the sequence.
Kojto 122:f9eeca106725 96 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 97 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 98 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 99 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 100 uint32_t ContinuousConvMode; /*!< Specifies whether the conversion is performed in single mode (one conversion) or continuous mode for regular group,
Kojto 122:f9eeca106725 101 after the selected trigger occurred (software start or external trigger).
Kojto 122:f9eeca106725 102 This parameter can be set to ENABLE or DISABLE. */
Kojto 122:f9eeca106725 103 uint32_t NbrOfConversion; /*!< Specifies the number of ranks that will be converted within the regular group sequencer.
Kojto 122:f9eeca106725 104 To use regular group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
Kojto 122:f9eeca106725 105 This parameter must be a number between Min_Data = 1 and Max_Data = 16. */
Kojto 122:f9eeca106725 106 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 107 Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
Kojto 122:f9eeca106725 108 Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
Kojto 122:f9eeca106725 109 This parameter can be set to ENABLE or DISABLE. */
Kojto 122:f9eeca106725 110 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 111 If parameter 'DiscontinuousConvMode' is disabled, this parameter is discarded.
Kojto 122:f9eeca106725 112 This parameter must be a number between Min_Data = 1 and Max_Data = 8. */
Kojto 122:f9eeca106725 113 uint32_t ExternalTrigConv; /*!< Selects the external event used to trigger the conversion start of regular group.
Kojto 122:f9eeca106725 114 If set to ADC_SOFTWARE_START, external triggers are disabled.
Kojto 122:f9eeca106725 115 If set to external trigger source, triggering is on event rising edge by default.
Kojto 122:f9eeca106725 116 This parameter can be a value of @ref ADC_External_trigger_Source_Regular */
Kojto 122:f9eeca106725 117 uint32_t ExternalTrigConvEdge; /*!< Selects the external trigger edge of regular group.
Kojto 122:f9eeca106725 118 If trigger is set to ADC_SOFTWARE_START, this parameter is discarded.
Kojto 122:f9eeca106725 119 This parameter can be a value of @ref ADC_External_trigger_edge_Regular */
Kojto 122:f9eeca106725 120 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 121 or in Continuous mode (DMA transfer unlimited, whatever number of conversions).
Kojto 122:f9eeca106725 122 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 123 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 124 This parameter can be set to ENABLE or DISABLE. */
Kojto 122:f9eeca106725 125 }ADC_InitTypeDef;
Kojto 122:f9eeca106725 126
Kojto 122:f9eeca106725 127
Kojto 122:f9eeca106725 128
Kojto 122:f9eeca106725 129 /**
Kojto 122:f9eeca106725 130 * @brief Structure definition of ADC channel for regular group
Kojto 122:f9eeca106725 131 * @note The setting of these parameters with function HAL_ADC_ConfigChannel() is conditioned to ADC state.
Kojto 122:f9eeca106725 132 * ADC can be either disabled or enabled without conversion on going on regular group.
Kojto 122:f9eeca106725 133 */
Kojto 122:f9eeca106725 134 typedef struct
Kojto 122:f9eeca106725 135 {
Kojto 122:f9eeca106725 136 uint32_t Channel; /*!< Specifies the channel to configure into ADC regular group.
Kojto 122:f9eeca106725 137 This parameter can be a value of @ref ADC_channels */
Kojto 122:f9eeca106725 138 uint32_t Rank; /*!< Specifies the rank in the regular group sequencer.
<> 139:856d2700e60b 139 This parameter must be a number between Min_Data = 1 and Max_Data = 16
<> 139:856d2700e60b 140 This parameter can be a value of @ref ADC_regular_rank */
Kojto 122:f9eeca106725 141 uint32_t SamplingTime; /*!< Sampling time value to be set for the selected channel.
Kojto 122:f9eeca106725 142 Unit: ADC clock cycles
Kojto 122:f9eeca106725 143 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 144 This parameter can be a value of @ref ADC_sampling_times
Kojto 122:f9eeca106725 145 Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups.
Kojto 122:f9eeca106725 146 If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting.
Kojto 122:f9eeca106725 147 Note: In case of usage of internal measurement channels (VrefInt/Vbat/TempSensor),
Kojto 122:f9eeca106725 148 sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
Kojto 122:f9eeca106725 149 Refer to device datasheet for timings values, parameters TS_vrefint, TS_temp (values rough order: 4us min). */
Kojto 122:f9eeca106725 150 uint32_t Offset; /*!< Reserved for future use, can be set to 0 */
Kojto 122:f9eeca106725 151 }ADC_ChannelConfTypeDef;
Kojto 122:f9eeca106725 152
Kojto 122:f9eeca106725 153 /**
Kojto 122:f9eeca106725 154 * @brief ADC Configuration multi-mode structure definition
Kojto 122:f9eeca106725 155 */
Kojto 122:f9eeca106725 156 typedef struct
Kojto 122:f9eeca106725 157 {
Kojto 122:f9eeca106725 158 uint32_t WatchdogMode; /*!< Configures the ADC analog watchdog mode.
Kojto 122:f9eeca106725 159 This parameter can be a value of @ref ADC_analog_watchdog_selection */
Kojto 122:f9eeca106725 160 uint32_t HighThreshold; /*!< Configures the ADC analog watchdog High threshold value.
Kojto 122:f9eeca106725 161 This parameter must be a 12-bit value. */
Kojto 122:f9eeca106725 162 uint32_t LowThreshold; /*!< Configures the ADC analog watchdog High threshold value.
Kojto 122:f9eeca106725 163 This parameter must be a 12-bit value. */
Kojto 122:f9eeca106725 164 uint32_t Channel; /*!< Configures ADC channel for the analog watchdog.
Kojto 122:f9eeca106725 165 This parameter has an effect only if watchdog mode is configured on single channel
Kojto 122:f9eeca106725 166 This parameter can be a value of @ref ADC_channels */
Kojto 122:f9eeca106725 167 uint32_t ITMode; /*!< Specifies whether the analog watchdog is configured
Kojto 122:f9eeca106725 168 is interrupt mode or in polling mode.
Kojto 122:f9eeca106725 169 This parameter can be set to ENABLE or DISABLE */
Kojto 122:f9eeca106725 170 uint32_t WatchdogNumber; /*!< Reserved for future use, can be set to 0 */
Kojto 122:f9eeca106725 171 }ADC_AnalogWDGConfTypeDef;
Kojto 122:f9eeca106725 172
Kojto 122:f9eeca106725 173 /**
Kojto 122:f9eeca106725 174 * @brief HAL ADC state machine: ADC states definition (bitfields)
Kojto 122:f9eeca106725 175 */
Kojto 122:f9eeca106725 176 /* States of ADC global scope */
Kojto 122:f9eeca106725 177 #define HAL_ADC_STATE_RESET ((uint32_t)0x00000000U) /*!< ADC not yet initialized or disabled */
Kojto 122:f9eeca106725 178 #define HAL_ADC_STATE_READY ((uint32_t)0x00000001U) /*!< ADC peripheral ready for use */
Kojto 122:f9eeca106725 179 #define HAL_ADC_STATE_BUSY_INTERNAL ((uint32_t)0x00000002U) /*!< ADC is busy to internal process (initialization, calibration) */
Kojto 122:f9eeca106725 180 #define HAL_ADC_STATE_TIMEOUT ((uint32_t)0x00000004U) /*!< TimeOut occurrence */
Kojto 122:f9eeca106725 181
Kojto 122:f9eeca106725 182 /* States of ADC errors */
Kojto 122:f9eeca106725 183 #define HAL_ADC_STATE_ERROR_INTERNAL ((uint32_t)0x00000010U) /*!< Internal error occurrence */
Kojto 122:f9eeca106725 184 #define HAL_ADC_STATE_ERROR_CONFIG ((uint32_t)0x00000020U) /*!< Configuration error occurrence */
Kojto 122:f9eeca106725 185 #define HAL_ADC_STATE_ERROR_DMA ((uint32_t)0x00000040U) /*!< DMA error occurrence */
Kojto 122:f9eeca106725 186
Kojto 122:f9eeca106725 187 /* States of ADC group regular */
Kojto 122:f9eeca106725 188 #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 189 external trigger, low power auto power-on (if feature available), multimode ADC master control (if feature available)) */
Kojto 122:f9eeca106725 190 #define HAL_ADC_STATE_REG_EOC ((uint32_t)0x00000200U) /*!< Conversion data available on group regular */
Kojto 122:f9eeca106725 191 #define HAL_ADC_STATE_REG_OVR ((uint32_t)0x00000400U) /*!< Overrun occurrence */
Kojto 122:f9eeca106725 192
Kojto 122:f9eeca106725 193 /* States of ADC group injected */
Kojto 122:f9eeca106725 194 #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 195 external trigger, low power auto power-on (if feature available), multimode ADC master control (if feature available)) */
Kojto 122:f9eeca106725 196 #define HAL_ADC_STATE_INJ_EOC ((uint32_t)0x00002000U) /*!< Conversion data available on group injected */
Kojto 122:f9eeca106725 197
Kojto 122:f9eeca106725 198 /* States of ADC analog watchdogs */
Kojto 122:f9eeca106725 199 #define HAL_ADC_STATE_AWD1 ((uint32_t)0x00010000U) /*!< Out-of-window occurrence of analog watchdog 1 */
Kojto 122:f9eeca106725 200 #define HAL_ADC_STATE_AWD2 ((uint32_t)0x00020000U) /*!< Not available on STM32F7 device: Out-of-window occurrence of analog watchdog 2 */
Kojto 122:f9eeca106725 201 #define HAL_ADC_STATE_AWD3 ((uint32_t)0x00040000U) /*!< Not available on STM32F7 device: Out-of-window occurrence of analog watchdog 3 */
Kojto 122:f9eeca106725 202
Kojto 122:f9eeca106725 203 /* States of ADC multi-mode */
Kojto 122:f9eeca106725 204 #define HAL_ADC_STATE_MULTIMODE_SLAVE ((uint32_t)0x00100000U) /*!< Not available on STM32F7 device: ADC in multimode slave state, controlled by another ADC master ( */
Kojto 122:f9eeca106725 205
Kojto 122:f9eeca106725 206
Kojto 122:f9eeca106725 207 /**
Kojto 122:f9eeca106725 208 * @brief ADC handle Structure definition
Kojto 122:f9eeca106725 209 */
Kojto 122:f9eeca106725 210 typedef struct
Kojto 122:f9eeca106725 211 {
Kojto 122:f9eeca106725 212 ADC_TypeDef *Instance; /*!< Register base address */
Kojto 122:f9eeca106725 213
Kojto 122:f9eeca106725 214 ADC_InitTypeDef Init; /*!< ADC required parameters */
Kojto 122:f9eeca106725 215
Kojto 122:f9eeca106725 216 __IO uint32_t NbrOfCurrentConversionRank; /*!< ADC number of current conversion rank */
Kojto 122:f9eeca106725 217
Kojto 122:f9eeca106725 218 DMA_HandleTypeDef *DMA_Handle; /*!< Pointer DMA Handler */
Kojto 122:f9eeca106725 219
Kojto 122:f9eeca106725 220 HAL_LockTypeDef Lock; /*!< ADC locking object */
Kojto 122:f9eeca106725 221
Kojto 122:f9eeca106725 222 __IO uint32_t State; /*!< ADC communication state */
Kojto 122:f9eeca106725 223
Kojto 122:f9eeca106725 224 __IO uint32_t ErrorCode; /*!< ADC Error code */
Kojto 122:f9eeca106725 225 }ADC_HandleTypeDef;
Kojto 122:f9eeca106725 226 /**
Kojto 122:f9eeca106725 227 * @}
Kojto 122:f9eeca106725 228 */
Kojto 122:f9eeca106725 229
Kojto 122:f9eeca106725 230 /* Exported constants --------------------------------------------------------*/
Kojto 122:f9eeca106725 231 /** @defgroup ADC_Exported_Constants ADC Exported Constants
Kojto 122:f9eeca106725 232 * @{
Kojto 122:f9eeca106725 233 */
Kojto 122:f9eeca106725 234
Kojto 122:f9eeca106725 235 /** @defgroup ADC_Error_Code ADC Error Code
Kojto 122:f9eeca106725 236 * @{
Kojto 122:f9eeca106725 237 */
Kojto 122:f9eeca106725 238 #define HAL_ADC_ERROR_NONE ((uint32_t)0x00U) /*!< No error */
Kojto 122:f9eeca106725 239 #define HAL_ADC_ERROR_INTERNAL ((uint32_t)0x01U) /*!< ADC IP internal error: if problem of clocking,
Kojto 122:f9eeca106725 240 enable/disable, erroneous state */
Kojto 122:f9eeca106725 241 #define HAL_ADC_ERROR_OVR ((uint32_t)0x02U) /*!< Overrun error */
Kojto 122:f9eeca106725 242 #define HAL_ADC_ERROR_DMA ((uint32_t)0x04U) /*!< DMA transfer error */
Kojto 122:f9eeca106725 243 /**
Kojto 122:f9eeca106725 244 * @}
Kojto 122:f9eeca106725 245 */
Kojto 122:f9eeca106725 246
Kojto 122:f9eeca106725 247
Kojto 122:f9eeca106725 248 /** @defgroup ADC_ClockPrescaler ADC Clock Prescaler
Kojto 122:f9eeca106725 249 * @{
Kojto 122:f9eeca106725 250 */
Kojto 122:f9eeca106725 251 #define ADC_CLOCK_SYNC_PCLK_DIV2 ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 252 #define ADC_CLOCK_SYNC_PCLK_DIV4 ((uint32_t)ADC_CCR_ADCPRE_0)
Kojto 122:f9eeca106725 253 #define ADC_CLOCK_SYNC_PCLK_DIV6 ((uint32_t)ADC_CCR_ADCPRE_1)
Kojto 122:f9eeca106725 254 #define ADC_CLOCK_SYNC_PCLK_DIV8 ((uint32_t)ADC_CCR_ADCPRE)
Kojto 122:f9eeca106725 255 /**
Kojto 122:f9eeca106725 256 * @}
Kojto 122:f9eeca106725 257 */
Kojto 122:f9eeca106725 258
Kojto 122:f9eeca106725 259 /** @defgroup ADC_delay_between_2_sampling_phases ADC Delay Between 2 Sampling Phases
Kojto 122:f9eeca106725 260 * @{
Kojto 122:f9eeca106725 261 */
Kojto 122:f9eeca106725 262 #define ADC_TWOSAMPLINGDELAY_5CYCLES ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 263 #define ADC_TWOSAMPLINGDELAY_6CYCLES ((uint32_t)ADC_CCR_DELAY_0)
Kojto 122:f9eeca106725 264 #define ADC_TWOSAMPLINGDELAY_7CYCLES ((uint32_t)ADC_CCR_DELAY_1)
Kojto 122:f9eeca106725 265 #define ADC_TWOSAMPLINGDELAY_8CYCLES ((uint32_t)(ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
Kojto 122:f9eeca106725 266 #define ADC_TWOSAMPLINGDELAY_9CYCLES ((uint32_t)ADC_CCR_DELAY_2)
Kojto 122:f9eeca106725 267 #define ADC_TWOSAMPLINGDELAY_10CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0))
Kojto 122:f9eeca106725 268 #define ADC_TWOSAMPLINGDELAY_11CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1))
Kojto 122:f9eeca106725 269 #define ADC_TWOSAMPLINGDELAY_12CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
Kojto 122:f9eeca106725 270 #define ADC_TWOSAMPLINGDELAY_13CYCLES ((uint32_t)ADC_CCR_DELAY_3)
Kojto 122:f9eeca106725 271 #define ADC_TWOSAMPLINGDELAY_14CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_0))
Kojto 122:f9eeca106725 272 #define ADC_TWOSAMPLINGDELAY_15CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1))
Kojto 122:f9eeca106725 273 #define ADC_TWOSAMPLINGDELAY_16CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
Kojto 122:f9eeca106725 274 #define ADC_TWOSAMPLINGDELAY_17CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2))
Kojto 122:f9eeca106725 275 #define ADC_TWOSAMPLINGDELAY_18CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0))
Kojto 122:f9eeca106725 276 #define ADC_TWOSAMPLINGDELAY_19CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1))
Kojto 122:f9eeca106725 277 #define ADC_TWOSAMPLINGDELAY_20CYCLES ((uint32_t)ADC_CCR_DELAY)
Kojto 122:f9eeca106725 278 /**
Kojto 122:f9eeca106725 279 * @}
Kojto 122:f9eeca106725 280 */
Kojto 122:f9eeca106725 281
Kojto 122:f9eeca106725 282 /** @defgroup ADC_Resolution ADC Resolution
Kojto 122:f9eeca106725 283 * @{
Kojto 122:f9eeca106725 284 */
Kojto 122:f9eeca106725 285 #define ADC_RESOLUTION_12B ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 286 #define ADC_RESOLUTION_10B ((uint32_t)ADC_CR1_RES_0)
Kojto 122:f9eeca106725 287 #define ADC_RESOLUTION_8B ((uint32_t)ADC_CR1_RES_1)
Kojto 122:f9eeca106725 288 #define ADC_RESOLUTION_6B ((uint32_t)ADC_CR1_RES)
Kojto 122:f9eeca106725 289 /**
Kojto 122:f9eeca106725 290 * @}
Kojto 122:f9eeca106725 291 */
Kojto 122:f9eeca106725 292
Kojto 122:f9eeca106725 293 /** @defgroup ADC_External_trigger_edge_Regular ADC External Trigger Edge Regular
Kojto 122:f9eeca106725 294 * @{
Kojto 122:f9eeca106725 295 */
Kojto 122:f9eeca106725 296 #define ADC_EXTERNALTRIGCONVEDGE_NONE ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 297 #define ADC_EXTERNALTRIGCONVEDGE_RISING ((uint32_t)ADC_CR2_EXTEN_0)
Kojto 122:f9eeca106725 298 #define ADC_EXTERNALTRIGCONVEDGE_FALLING ((uint32_t)ADC_CR2_EXTEN_1)
Kojto 122:f9eeca106725 299 #define ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING ((uint32_t)ADC_CR2_EXTEN)
Kojto 122:f9eeca106725 300 /**
Kojto 122:f9eeca106725 301 * @}
Kojto 122:f9eeca106725 302 */
Kojto 122:f9eeca106725 303
Kojto 122:f9eeca106725 304 /** @defgroup ADC_External_trigger_Source_Regular ADC External Trigger Source Regular
Kojto 122:f9eeca106725 305 * @{
Kojto 122:f9eeca106725 306 */
Kojto 122:f9eeca106725 307 /* Note: Parameter ADC_SOFTWARE_START is a software parameter used for */
Kojto 122:f9eeca106725 308 /* compatibility with other STM32 devices. */
Kojto 122:f9eeca106725 309
Kojto 122:f9eeca106725 310
Kojto 122:f9eeca106725 311 #define ADC_EXTERNALTRIGCONV_T1_CC1 ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 312 #define ADC_EXTERNALTRIGCONV_T1_CC2 ((uint32_t)ADC_CR2_EXTSEL_0)
Kojto 122:f9eeca106725 313 #define ADC_EXTERNALTRIGCONV_T1_CC3 ((uint32_t)ADC_CR2_EXTSEL_1)
Kojto 122:f9eeca106725 314 #define ADC_EXTERNALTRIGCONV_T2_CC2 ((uint32_t)(ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
Kojto 122:f9eeca106725 315 #define ADC_EXTERNALTRIGCONV_T5_TRGO ((uint32_t)ADC_CR2_EXTSEL_2)
Kojto 122:f9eeca106725 316 #define ADC_EXTERNALTRIGCONV_T4_CC4 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
Kojto 122:f9eeca106725 317 #define ADC_EXTERNALTRIGCONV_T3_CC4 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1))
Kojto 122:f9eeca106725 318 #define ADC_EXTERNALTRIGCONV_T8_TRGO ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
Kojto 122:f9eeca106725 319 #define ADC_EXTERNALTRIGCONV_T8_TRGO2 ((uint32_t)ADC_CR2_EXTSEL_3)
Kojto 122:f9eeca106725 320 #define ADC_EXTERNALTRIGCONV_T1_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_0))
Kojto 122:f9eeca106725 321 #define ADC_EXTERNALTRIGCONV_T1_TRGO2 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1))
Kojto 122:f9eeca106725 322 #define ADC_EXTERNALTRIGCONV_T2_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
Kojto 122:f9eeca106725 323 #define ADC_EXTERNALTRIGCONV_T4_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2))
Kojto 122:f9eeca106725 324 #define ADC_EXTERNALTRIGCONV_T6_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
Kojto 122:f9eeca106725 325
Kojto 122:f9eeca106725 326 #define ADC_EXTERNALTRIGCONV_EXT_IT11 ((uint32_t)ADC_CR2_EXTSEL)
Kojto 122:f9eeca106725 327 #define ADC_SOFTWARE_START ((uint32_t)ADC_CR2_EXTSEL + 1)
Kojto 122:f9eeca106725 328
Kojto 122:f9eeca106725 329 /**
Kojto 122:f9eeca106725 330 * @}
Kojto 122:f9eeca106725 331 */
Kojto 122:f9eeca106725 332
Kojto 122:f9eeca106725 333 /** @defgroup ADC_Data_Align ADC Data Align
Kojto 122:f9eeca106725 334 * @{
Kojto 122:f9eeca106725 335 */
Kojto 122:f9eeca106725 336 #define ADC_DATAALIGN_RIGHT ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 337 #define ADC_DATAALIGN_LEFT ((uint32_t)ADC_CR2_ALIGN)
Kojto 122:f9eeca106725 338 /**
Kojto 122:f9eeca106725 339 * @}
Kojto 122:f9eeca106725 340 */
Kojto 122:f9eeca106725 341
<> 139:856d2700e60b 342 /** @defgroup ADC_Scan_mode ADC sequencer scan mode
<> 139:856d2700e60b 343 * @{
<> 139:856d2700e60b 344 */
<> 139:856d2700e60b 345 #define ADC_SCAN_DISABLE ((uint32_t)0x00000000) /*!< Scan mode disabled */
<> 139:856d2700e60b 346 #define ADC_SCAN_ENABLE ((uint32_t)0x00000001) /*!< Scan mode enabled */
<> 139:856d2700e60b 347 /**
<> 139:856d2700e60b 348 * @}
<> 139:856d2700e60b 349 */
<> 139:856d2700e60b 350
<> 139:856d2700e60b 351 /** @defgroup ADC_regular_rank ADC group regular sequencer rank
<> 139:856d2700e60b 352 * @{
<> 139:856d2700e60b 353 */
<> 139:856d2700e60b 354 #define ADC_REGULAR_RANK_1 ((uint32_t)0x00000001) /*!< ADC regular conversion rank 1 */
<> 139:856d2700e60b 355 #define ADC_REGULAR_RANK_2 ((uint32_t)0x00000002) /*!< ADC regular conversion rank 2 */
<> 139:856d2700e60b 356 #define ADC_REGULAR_RANK_3 ((uint32_t)0x00000003) /*!< ADC regular conversion rank 3 */
<> 139:856d2700e60b 357 #define ADC_REGULAR_RANK_4 ((uint32_t)0x00000004) /*!< ADC regular conversion rank 4 */
<> 139:856d2700e60b 358 #define ADC_REGULAR_RANK_5 ((uint32_t)0x00000005) /*!< ADC regular conversion rank 5 */
<> 139:856d2700e60b 359 #define ADC_REGULAR_RANK_6 ((uint32_t)0x00000006) /*!< ADC regular conversion rank 6 */
<> 139:856d2700e60b 360 #define ADC_REGULAR_RANK_7 ((uint32_t)0x00000007) /*!< ADC regular conversion rank 7 */
<> 139:856d2700e60b 361 #define ADC_REGULAR_RANK_8 ((uint32_t)0x00000008) /*!< ADC regular conversion rank 8 */
<> 139:856d2700e60b 362 #define ADC_REGULAR_RANK_9 ((uint32_t)0x00000009) /*!< ADC regular conversion rank 9 */
<> 139:856d2700e60b 363 #define ADC_REGULAR_RANK_10 ((uint32_t)0x0000000A) /*!< ADC regular conversion rank 10 */
<> 139:856d2700e60b 364 #define ADC_REGULAR_RANK_11 ((uint32_t)0x0000000B) /*!< ADC regular conversion rank 11 */
<> 139:856d2700e60b 365 #define ADC_REGULAR_RANK_12 ((uint32_t)0x0000000C) /*!< ADC regular conversion rank 12 */
<> 139:856d2700e60b 366 #define ADC_REGULAR_RANK_13 ((uint32_t)0x0000000D) /*!< ADC regular conversion rank 13 */
<> 139:856d2700e60b 367 #define ADC_REGULAR_RANK_14 ((uint32_t)0x0000000E) /*!< ADC regular conversion rank 14 */
<> 139:856d2700e60b 368 #define ADC_REGULAR_RANK_15 ((uint32_t)0x0000000F) /*!< ADC regular conversion rank 15 */
<> 139:856d2700e60b 369 #define ADC_REGULAR_RANK_16 ((uint32_t)0x00000010) /*!< ADC regular conversion rank 16 */
<> 139:856d2700e60b 370 /**
<> 139:856d2700e60b 371 * @}
<> 139:856d2700e60b 372 */
<> 139:856d2700e60b 373
Kojto 122:f9eeca106725 374 /** @defgroup ADC_channels ADC Common Channels
Kojto 122:f9eeca106725 375 * @{
Kojto 122:f9eeca106725 376 */
Kojto 122:f9eeca106725 377 #define ADC_CHANNEL_0 ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 378 #define ADC_CHANNEL_1 ((uint32_t)ADC_CR1_AWDCH_0)
Kojto 122:f9eeca106725 379 #define ADC_CHANNEL_2 ((uint32_t)ADC_CR1_AWDCH_1)
Kojto 122:f9eeca106725 380 #define ADC_CHANNEL_3 ((uint32_t)(ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 122:f9eeca106725 381 #define ADC_CHANNEL_4 ((uint32_t)ADC_CR1_AWDCH_2)
Kojto 122:f9eeca106725 382 #define ADC_CHANNEL_5 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0))
Kojto 122:f9eeca106725 383 #define ADC_CHANNEL_6 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1))
Kojto 122:f9eeca106725 384 #define ADC_CHANNEL_7 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 122:f9eeca106725 385 #define ADC_CHANNEL_8 ((uint32_t)ADC_CR1_AWDCH_3)
Kojto 122:f9eeca106725 386 #define ADC_CHANNEL_9 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0))
Kojto 122:f9eeca106725 387 #define ADC_CHANNEL_10 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1))
Kojto 122:f9eeca106725 388 #define ADC_CHANNEL_11 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 122:f9eeca106725 389 #define ADC_CHANNEL_12 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2))
Kojto 122:f9eeca106725 390 #define ADC_CHANNEL_13 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0))
Kojto 122:f9eeca106725 391 #define ADC_CHANNEL_14 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1))
Kojto 122:f9eeca106725 392 #define ADC_CHANNEL_15 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 122:f9eeca106725 393 #define ADC_CHANNEL_16 ((uint32_t)ADC_CR1_AWDCH_4)
Kojto 122:f9eeca106725 394 #define ADC_CHANNEL_17 ((uint32_t)(ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_0))
Kojto 122:f9eeca106725 395 #define ADC_CHANNEL_18 ((uint32_t)(ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_1))
Kojto 122:f9eeca106725 396
Kojto 122:f9eeca106725 397 #define ADC_CHANNEL_VREFINT ((uint32_t)ADC_CHANNEL_17)
Kojto 122:f9eeca106725 398 #define ADC_CHANNEL_VBAT ((uint32_t)ADC_CHANNEL_18)
Kojto 122:f9eeca106725 399 /**
Kojto 122:f9eeca106725 400 * @}
Kojto 122:f9eeca106725 401 */
Kojto 122:f9eeca106725 402
Kojto 122:f9eeca106725 403 /** @defgroup ADC_sampling_times ADC Sampling Times
Kojto 122:f9eeca106725 404 * @{
Kojto 122:f9eeca106725 405 */
Kojto 122:f9eeca106725 406 #define ADC_SAMPLETIME_3CYCLES ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 407 #define ADC_SAMPLETIME_15CYCLES ((uint32_t)ADC_SMPR1_SMP10_0)
Kojto 122:f9eeca106725 408 #define ADC_SAMPLETIME_28CYCLES ((uint32_t)ADC_SMPR1_SMP10_1)
Kojto 122:f9eeca106725 409 #define ADC_SAMPLETIME_56CYCLES ((uint32_t)(ADC_SMPR1_SMP10_1 | ADC_SMPR1_SMP10_0))
Kojto 122:f9eeca106725 410 #define ADC_SAMPLETIME_84CYCLES ((uint32_t)ADC_SMPR1_SMP10_2)
Kojto 122:f9eeca106725 411 #define ADC_SAMPLETIME_112CYCLES ((uint32_t)(ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_0))
Kojto 122:f9eeca106725 412 #define ADC_SAMPLETIME_144CYCLES ((uint32_t)(ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_1))
Kojto 122:f9eeca106725 413 #define ADC_SAMPLETIME_480CYCLES ((uint32_t)ADC_SMPR1_SMP10)
Kojto 122:f9eeca106725 414 /**
Kojto 122:f9eeca106725 415 * @}
Kojto 122:f9eeca106725 416 */
Kojto 122:f9eeca106725 417
Kojto 122:f9eeca106725 418 /** @defgroup ADC_EOCSelection ADC EOC Selection
Kojto 122:f9eeca106725 419 * @{
Kojto 122:f9eeca106725 420 */
Kojto 122:f9eeca106725 421 #define ADC_EOC_SEQ_CONV ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 422 #define ADC_EOC_SINGLE_CONV ((uint32_t)0x00000001U)
Kojto 122:f9eeca106725 423 #define ADC_EOC_SINGLE_SEQ_CONV ((uint32_t)0x00000002U) /*!< reserved for future use */
Kojto 122:f9eeca106725 424 /**
Kojto 122:f9eeca106725 425 * @}
Kojto 122:f9eeca106725 426 */
Kojto 122:f9eeca106725 427
Kojto 122:f9eeca106725 428 /** @defgroup ADC_Event_type ADC Event Type
Kojto 122:f9eeca106725 429 * @{
Kojto 122:f9eeca106725 430 */
Kojto 122:f9eeca106725 431 #define ADC_AWD_EVENT ((uint32_t)ADC_FLAG_AWD)
Kojto 122:f9eeca106725 432 #define ADC_OVR_EVENT ((uint32_t)ADC_FLAG_OVR)
Kojto 122:f9eeca106725 433 /**
Kojto 122:f9eeca106725 434 * @}
Kojto 122:f9eeca106725 435 */
Kojto 122:f9eeca106725 436
Kojto 122:f9eeca106725 437 /** @defgroup ADC_analog_watchdog_selection ADC Analog Watchdog Selection
Kojto 122:f9eeca106725 438 * @{
Kojto 122:f9eeca106725 439 */
Kojto 122:f9eeca106725 440 #define ADC_ANALOGWATCHDOG_SINGLE_REG ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN))
Kojto 122:f9eeca106725 441 #define ADC_ANALOGWATCHDOG_SINGLE_INJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_JAWDEN))
Kojto 122:f9eeca106725 442 #define ADC_ANALOGWATCHDOG_SINGLE_REGINJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
Kojto 122:f9eeca106725 443 #define ADC_ANALOGWATCHDOG_ALL_REG ((uint32_t)ADC_CR1_AWDEN)
Kojto 122:f9eeca106725 444 #define ADC_ANALOGWATCHDOG_ALL_INJEC ((uint32_t)ADC_CR1_JAWDEN)
Kojto 122:f9eeca106725 445 #define ADC_ANALOGWATCHDOG_ALL_REGINJEC ((uint32_t)(ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
Kojto 122:f9eeca106725 446 #define ADC_ANALOGWATCHDOG_NONE ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 447 /**
Kojto 122:f9eeca106725 448 * @}
Kojto 122:f9eeca106725 449 */
Kojto 122:f9eeca106725 450
Kojto 122:f9eeca106725 451 /** @defgroup ADC_interrupts_definition ADC Interrupts Definition
Kojto 122:f9eeca106725 452 * @{
Kojto 122:f9eeca106725 453 */
Kojto 122:f9eeca106725 454 #define ADC_IT_EOC ((uint32_t)ADC_CR1_EOCIE)
Kojto 122:f9eeca106725 455 #define ADC_IT_AWD ((uint32_t)ADC_CR1_AWDIE)
Kojto 122:f9eeca106725 456 #define ADC_IT_JEOC ((uint32_t)ADC_CR1_JEOCIE)
Kojto 122:f9eeca106725 457 #define ADC_IT_OVR ((uint32_t)ADC_CR1_OVRIE)
Kojto 122:f9eeca106725 458 /**
Kojto 122:f9eeca106725 459 * @}
Kojto 122:f9eeca106725 460 */
Kojto 122:f9eeca106725 461
Kojto 122:f9eeca106725 462 /** @defgroup ADC_flags_definition ADC Flags Definition
Kojto 122:f9eeca106725 463 * @{
Kojto 122:f9eeca106725 464 */
Kojto 122:f9eeca106725 465 #define ADC_FLAG_AWD ((uint32_t)ADC_SR_AWD)
Kojto 122:f9eeca106725 466 #define ADC_FLAG_EOC ((uint32_t)ADC_SR_EOC)
Kojto 122:f9eeca106725 467 #define ADC_FLAG_JEOC ((uint32_t)ADC_SR_JEOC)
Kojto 122:f9eeca106725 468 #define ADC_FLAG_JSTRT ((uint32_t)ADC_SR_JSTRT)
Kojto 122:f9eeca106725 469 #define ADC_FLAG_STRT ((uint32_t)ADC_SR_STRT)
Kojto 122:f9eeca106725 470 #define ADC_FLAG_OVR ((uint32_t)ADC_SR_OVR)
Kojto 122:f9eeca106725 471 /**
Kojto 122:f9eeca106725 472 * @}
Kojto 122:f9eeca106725 473 */
Kojto 122:f9eeca106725 474
Kojto 122:f9eeca106725 475 /** @defgroup ADC_channels_type ADC Channels Type
Kojto 122:f9eeca106725 476 * @{
Kojto 122:f9eeca106725 477 */
Kojto 122:f9eeca106725 478 #define ADC_ALL_CHANNELS ((uint32_t)0x00000001U)
Kojto 122:f9eeca106725 479 #define ADC_REGULAR_CHANNELS ((uint32_t)0x00000002U) /*!< reserved for future use */
Kojto 122:f9eeca106725 480 #define ADC_INJECTED_CHANNELS ((uint32_t)0x00000003U) /*!< reserved for future use */
Kojto 122:f9eeca106725 481 /**
Kojto 122:f9eeca106725 482 * @}
Kojto 122:f9eeca106725 483 */
Kojto 122:f9eeca106725 484
Kojto 122:f9eeca106725 485 /**
Kojto 122:f9eeca106725 486 * @}
Kojto 122:f9eeca106725 487 */
Kojto 122:f9eeca106725 488
Kojto 122:f9eeca106725 489 /* Exported macro ------------------------------------------------------------*/
Kojto 122:f9eeca106725 490 /** @defgroup ADC_Exported_Macros ADC Exported Macros
Kojto 122:f9eeca106725 491 * @{
Kojto 122:f9eeca106725 492 */
Kojto 122:f9eeca106725 493
Kojto 122:f9eeca106725 494 /** @brief Reset ADC handle state
Kojto 122:f9eeca106725 495 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 496 * @retval None
Kojto 122:f9eeca106725 497 */
Kojto 122:f9eeca106725 498 #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
Kojto 122:f9eeca106725 499
Kojto 122:f9eeca106725 500 /**
Kojto 122:f9eeca106725 501 * @brief Enable the ADC peripheral.
Kojto 122:f9eeca106725 502 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 503 * @retval None
Kojto 122:f9eeca106725 504 */
Kojto 122:f9eeca106725 505 #define __HAL_ADC_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR2 |= ADC_CR2_ADON)
Kojto 122:f9eeca106725 506
Kojto 122:f9eeca106725 507 /**
Kojto 122:f9eeca106725 508 * @brief Disable the ADC peripheral.
Kojto 122:f9eeca106725 509 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 510 * @retval None
Kojto 122:f9eeca106725 511 */
Kojto 122:f9eeca106725 512 #define __HAL_ADC_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR2 &= ~ADC_CR2_ADON)
Kojto 122:f9eeca106725 513
Kojto 122:f9eeca106725 514 /**
Kojto 122:f9eeca106725 515 * @brief Enable the ADC end of conversion interrupt.
Kojto 122:f9eeca106725 516 * @param __HANDLE__: specifies the ADC Handle.
Kojto 122:f9eeca106725 517 * @param __INTERRUPT__: ADC Interrupt.
Kojto 122:f9eeca106725 518 * @retval None
Kojto 122:f9eeca106725 519 */
Kojto 122:f9eeca106725 520 #define __HAL_ADC_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1) |= (__INTERRUPT__))
Kojto 122:f9eeca106725 521
Kojto 122:f9eeca106725 522 /**
Kojto 122:f9eeca106725 523 * @brief Disable the ADC end of conversion interrupt.
Kojto 122:f9eeca106725 524 * @param __HANDLE__: specifies the ADC Handle.
Kojto 122:f9eeca106725 525 * @param __INTERRUPT__: ADC interrupt.
Kojto 122:f9eeca106725 526 * @retval None
Kojto 122:f9eeca106725 527 */
Kojto 122:f9eeca106725 528 #define __HAL_ADC_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1) &= ~(__INTERRUPT__))
Kojto 122:f9eeca106725 529
Kojto 122:f9eeca106725 530 /** @brief Check if the specified ADC interrupt source is enabled or disabled.
Kojto 122:f9eeca106725 531 * @param __HANDLE__: specifies the ADC Handle.
Kojto 122:f9eeca106725 532 * @param __INTERRUPT__: specifies the ADC interrupt source to check.
Kojto 122:f9eeca106725 533 * @retval The new state of __IT__ (TRUE or FALSE).
Kojto 122:f9eeca106725 534 */
Kojto 122:f9eeca106725 535 #define __HAL_ADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__))
Kojto 122:f9eeca106725 536
Kojto 122:f9eeca106725 537 /**
Kojto 122:f9eeca106725 538 * @brief Clear the ADC's pending flags.
Kojto 122:f9eeca106725 539 * @param __HANDLE__: specifies the ADC Handle.
Kojto 122:f9eeca106725 540 * @param __FLAG__: ADC flag.
Kojto 122:f9eeca106725 541 * @retval None
Kojto 122:f9eeca106725 542 */
Kojto 122:f9eeca106725 543 #define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) = ~(__FLAG__))
Kojto 122:f9eeca106725 544
Kojto 122:f9eeca106725 545 /**
Kojto 122:f9eeca106725 546 * @brief Get the selected ADC's flag status.
Kojto 122:f9eeca106725 547 * @param __HANDLE__: specifies the ADC Handle.
Kojto 122:f9eeca106725 548 * @param __FLAG__: ADC flag.
Kojto 122:f9eeca106725 549 * @retval None
Kojto 122:f9eeca106725 550 */
Kojto 122:f9eeca106725 551 #define __HAL_ADC_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
Kojto 122:f9eeca106725 552
Kojto 122:f9eeca106725 553 /**
Kojto 122:f9eeca106725 554 * @}
Kojto 122:f9eeca106725 555 */
Kojto 122:f9eeca106725 556
Kojto 122:f9eeca106725 557 /* Include ADC HAL Extension module */
Kojto 122:f9eeca106725 558 #include "stm32f7xx_hal_adc_ex.h"
Kojto 122:f9eeca106725 559
Kojto 122:f9eeca106725 560 /* Exported functions --------------------------------------------------------*/
Kojto 122:f9eeca106725 561 /** @addtogroup ADC_Exported_Functions
Kojto 122:f9eeca106725 562 * @{
Kojto 122:f9eeca106725 563 */
Kojto 122:f9eeca106725 564
Kojto 122:f9eeca106725 565 /** @addtogroup ADC_Exported_Functions_Group1
Kojto 122:f9eeca106725 566 * @{
Kojto 122:f9eeca106725 567 */
Kojto 122:f9eeca106725 568 /* Initialization/de-initialization functions ***********************************/
Kojto 122:f9eeca106725 569 HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 570 HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
Kojto 122:f9eeca106725 571 void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 572 void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 573 /**
Kojto 122:f9eeca106725 574 * @}
Kojto 122:f9eeca106725 575 */
Kojto 122:f9eeca106725 576
Kojto 122:f9eeca106725 577 /** @addtogroup ADC_Exported_Functions_Group2
Kojto 122:f9eeca106725 578 * @{
Kojto 122:f9eeca106725 579 */
Kojto 122:f9eeca106725 580 /* I/O operation functions ******************************************************/
Kojto 122:f9eeca106725 581 HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 582 HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 583 HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
Kojto 122:f9eeca106725 584
Kojto 122:f9eeca106725 585 HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout);
Kojto 122:f9eeca106725 586
Kojto 122:f9eeca106725 587 HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 588 HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 589
Kojto 122:f9eeca106725 590 void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 591
Kojto 122:f9eeca106725 592 HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length);
Kojto 122:f9eeca106725 593 HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 594
Kojto 122:f9eeca106725 595 uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 596
Kojto 122:f9eeca106725 597 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 598 void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 599 void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 600 void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
Kojto 122:f9eeca106725 601 /**
Kojto 122:f9eeca106725 602 * @}
Kojto 122:f9eeca106725 603 */
Kojto 122:f9eeca106725 604
Kojto 122:f9eeca106725 605 /** @addtogroup ADC_Exported_Functions_Group3
Kojto 122:f9eeca106725 606 * @{
Kojto 122:f9eeca106725 607 */
Kojto 122:f9eeca106725 608 /* Peripheral Control functions *************************************************/
Kojto 122:f9eeca106725 609 HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig);
Kojto 122:f9eeca106725 610 HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig);
Kojto 122:f9eeca106725 611 /**
Kojto 122:f9eeca106725 612 * @}
Kojto 122:f9eeca106725 613 */
Kojto 122:f9eeca106725 614
Kojto 122:f9eeca106725 615 /** @addtogroup ADC_Exported_Functions_Group4
Kojto 122:f9eeca106725 616 * @{
Kojto 122:f9eeca106725 617 */
Kojto 122:f9eeca106725 618 /* Peripheral State functions ***************************************************/
Kojto 122:f9eeca106725 619 uint32_t HAL_ADC_GetState(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 620 uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc);
Kojto 122:f9eeca106725 621 /**
Kojto 122:f9eeca106725 622 * @}
Kojto 122:f9eeca106725 623 */
Kojto 122:f9eeca106725 624
Kojto 122:f9eeca106725 625 /**
Kojto 122:f9eeca106725 626 * @}
Kojto 122:f9eeca106725 627 */
Kojto 122:f9eeca106725 628
Kojto 122:f9eeca106725 629 /* Private types -------------------------------------------------------------*/
Kojto 122:f9eeca106725 630 /* Private variables ---------------------------------------------------------*/
Kojto 122:f9eeca106725 631 /* Private constants ---------------------------------------------------------*/
Kojto 122:f9eeca106725 632 /** @defgroup ADC_Private_Constants ADC Private Constants
Kojto 122:f9eeca106725 633 * @{
Kojto 122:f9eeca106725 634 */
Kojto 122:f9eeca106725 635 /* Delay for ADC stabilization time. */
Kojto 122:f9eeca106725 636 /* Maximum delay is 1us (refer to device datasheet, parameter tSTAB). */
Kojto 122:f9eeca106725 637 /* Unit: us */
Kojto 122:f9eeca106725 638 #define ADC_STAB_DELAY_US ((uint32_t) 3U)
Kojto 122:f9eeca106725 639 /* Delay for temperature sensor stabilization time. */
Kojto 122:f9eeca106725 640 /* Maximum delay is 10us (refer to device datasheet, parameter tSTART). */
Kojto 122:f9eeca106725 641 /* Unit: us */
Kojto 122:f9eeca106725 642 #define ADC_TEMPSENSOR_DELAY_US ((uint32_t) 10U)
Kojto 122:f9eeca106725 643 /**
Kojto 122:f9eeca106725 644 * @}
Kojto 122:f9eeca106725 645 */
Kojto 122:f9eeca106725 646
Kojto 122:f9eeca106725 647 /* Private macros ------------------------------------------------------------*/
Kojto 122:f9eeca106725 648 /** @defgroup ADC_Private_Macros ADC Private Macros
Kojto 122:f9eeca106725 649 * @{
Kojto 122:f9eeca106725 650 */
Kojto 122:f9eeca106725 651 /* Macro reserved for internal HAL driver usage, not intended to be used in
Kojto 122:f9eeca106725 652 code of final user */
Kojto 122:f9eeca106725 653
Kojto 122:f9eeca106725 654 /**
Kojto 122:f9eeca106725 655 * @brief Verification of ADC state: enabled or disabled
Kojto 122:f9eeca106725 656 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 657 * @retval SET (ADC enabled) or RESET (ADC disabled)
Kojto 122:f9eeca106725 658 */
Kojto 122:f9eeca106725 659 #define ADC_IS_ENABLE(__HANDLE__) \
Kojto 122:f9eeca106725 660 ((( ((__HANDLE__)->Instance->SR & ADC_SR_ADONS) == ADC_SR_ADONS ) \
Kojto 122:f9eeca106725 661 ) ? SET : RESET)
Kojto 122:f9eeca106725 662
Kojto 122:f9eeca106725 663 /**
Kojto 122:f9eeca106725 664 * @brief Test if conversion trigger of regular group is software start
Kojto 122:f9eeca106725 665 * or external trigger.
Kojto 122:f9eeca106725 666 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 667 * @retval SET (software start) or RESET (external trigger)
Kojto 122:f9eeca106725 668 */
Kojto 122:f9eeca106725 669 #define ADC_IS_SOFTWARE_START_REGULAR(__HANDLE__) \
Kojto 122:f9eeca106725 670 (((__HANDLE__)->Instance->CR2 & ADC_CR2_EXTEN) == RESET)
Kojto 122:f9eeca106725 671
Kojto 122:f9eeca106725 672 /**
Kojto 122:f9eeca106725 673 * @brief Test if conversion trigger of injected group is software start
Kojto 122:f9eeca106725 674 * or external trigger.
Kojto 122:f9eeca106725 675 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 676 * @retval SET (software start) or RESET (external trigger)
Kojto 122:f9eeca106725 677 */
Kojto 122:f9eeca106725 678 #define ADC_IS_SOFTWARE_START_INJECTED(__HANDLE__) \
Kojto 122:f9eeca106725 679 (((__HANDLE__)->Instance->CR2 & ADC_CR2_JEXTEN) == RESET)
Kojto 122:f9eeca106725 680
Kojto 122:f9eeca106725 681 /**
Kojto 122:f9eeca106725 682 * @brief Simultaneously clears and sets specific bits of the handle State
Kojto 122:f9eeca106725 683 * @note: ADC_STATE_CLR_SET() macro is merely aliased to generic macro MODIFY_REG(),
Kojto 122:f9eeca106725 684 * the first parameter is the ADC handle State, the second parameter is the
Kojto 122:f9eeca106725 685 * bit field to clear, the third and last parameter is the bit field to set.
Kojto 122:f9eeca106725 686 * @retval None
Kojto 122:f9eeca106725 687 */
Kojto 122:f9eeca106725 688 #define ADC_STATE_CLR_SET MODIFY_REG
Kojto 122:f9eeca106725 689
Kojto 122:f9eeca106725 690 /**
Kojto 122:f9eeca106725 691 * @brief Clear ADC error code (set it to error code: "no error")
Kojto 122:f9eeca106725 692 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 693 * @retval None
Kojto 122:f9eeca106725 694 */
Kojto 122:f9eeca106725 695 #define ADC_CLEAR_ERRORCODE(__HANDLE__) \
Kojto 122:f9eeca106725 696 ((__HANDLE__)->ErrorCode = HAL_ADC_ERROR_NONE)
Kojto 122:f9eeca106725 697 #define IS_ADC_CLOCKPRESCALER(__ADC_CLOCK__) (((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV2) || \
Kojto 122:f9eeca106725 698 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV4) || \
Kojto 122:f9eeca106725 699 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV6) || \
Kojto 122:f9eeca106725 700 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV8))
Kojto 122:f9eeca106725 701 #define IS_ADC_SAMPLING_DELAY(__DELAY__) (((__DELAY__) == ADC_TWOSAMPLINGDELAY_5CYCLES) || \
Kojto 122:f9eeca106725 702 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_6CYCLES) || \
Kojto 122:f9eeca106725 703 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_7CYCLES) || \
Kojto 122:f9eeca106725 704 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_8CYCLES) || \
Kojto 122:f9eeca106725 705 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_9CYCLES) || \
Kojto 122:f9eeca106725 706 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_10CYCLES) || \
Kojto 122:f9eeca106725 707 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_11CYCLES) || \
Kojto 122:f9eeca106725 708 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_12CYCLES) || \
Kojto 122:f9eeca106725 709 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_13CYCLES) || \
Kojto 122:f9eeca106725 710 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_14CYCLES) || \
Kojto 122:f9eeca106725 711 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_15CYCLES) || \
Kojto 122:f9eeca106725 712 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_16CYCLES) || \
Kojto 122:f9eeca106725 713 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_17CYCLES) || \
Kojto 122:f9eeca106725 714 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_18CYCLES) || \
Kojto 122:f9eeca106725 715 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_19CYCLES) || \
Kojto 122:f9eeca106725 716 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_20CYCLES))
Kojto 122:f9eeca106725 717 #define IS_ADC_RESOLUTION(__RESOLUTION__) (((__RESOLUTION__) == ADC_RESOLUTION_12B) || \
Kojto 122:f9eeca106725 718 ((__RESOLUTION__) == ADC_RESOLUTION_10B) || \
Kojto 122:f9eeca106725 719 ((__RESOLUTION__) == ADC_RESOLUTION_8B) || \
Kojto 122:f9eeca106725 720 ((__RESOLUTION__) == ADC_RESOLUTION_6B))
Kojto 122:f9eeca106725 721 #define IS_ADC_EXT_TRIG_EDGE(__EDGE__) (((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_NONE) || \
Kojto 122:f9eeca106725 722 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_RISING) || \
Kojto 122:f9eeca106725 723 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_FALLING) || \
Kojto 122:f9eeca106725 724 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING))
Kojto 122:f9eeca106725 725 #define IS_ADC_EXT_TRIG(__REGTRIG__) (((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
Kojto 122:f9eeca106725 726 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
Kojto 122:f9eeca106725 727 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_CC3) || \
Kojto 122:f9eeca106725 728 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
Kojto 122:f9eeca106725 729 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T5_TRGO) || \
Kojto 122:f9eeca106725 730 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
Kojto 122:f9eeca106725 731 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T3_CC4) || \
Kojto 122:f9eeca106725 732 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T8_TRGO) || \
Kojto 122:f9eeca106725 733 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T8_TRGO2) || \
Kojto 122:f9eeca106725 734 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_TRGO) || \
Kojto 122:f9eeca106725 735 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_TRGO2) || \
Kojto 122:f9eeca106725 736 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T2_TRGO) || \
Kojto 122:f9eeca106725 737 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T4_TRGO) || \
Kojto 122:f9eeca106725 738 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T6_TRGO) || \
Kojto 122:f9eeca106725 739 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
Kojto 122:f9eeca106725 740 ((__REGTRIG__) == ADC_SOFTWARE_START))
Kojto 122:f9eeca106725 741 #define IS_ADC_DATA_ALIGN(__ALIGN__) (((__ALIGN__) == ADC_DATAALIGN_RIGHT) || \
<> 139:856d2700e60b 742 ((__ALIGN__) == ADC_DATAALIGN_LEFT))
<> 139:856d2700e60b 743
Kojto 122:f9eeca106725 744
Kojto 122:f9eeca106725 745 #define IS_ADC_SAMPLE_TIME(__TIME__) (((__TIME__) == ADC_SAMPLETIME_3CYCLES) || \
Kojto 122:f9eeca106725 746 ((__TIME__) == ADC_SAMPLETIME_15CYCLES) || \
Kojto 122:f9eeca106725 747 ((__TIME__) == ADC_SAMPLETIME_28CYCLES) || \
Kojto 122:f9eeca106725 748 ((__TIME__) == ADC_SAMPLETIME_56CYCLES) || \
Kojto 122:f9eeca106725 749 ((__TIME__) == ADC_SAMPLETIME_84CYCLES) || \
Kojto 122:f9eeca106725 750 ((__TIME__) == ADC_SAMPLETIME_112CYCLES) || \
Kojto 122:f9eeca106725 751 ((__TIME__) == ADC_SAMPLETIME_144CYCLES) || \
Kojto 122:f9eeca106725 752 ((__TIME__) == ADC_SAMPLETIME_480CYCLES))
Kojto 122:f9eeca106725 753 #define IS_ADC_EOCSelection(__EOCSelection__) (((__EOCSelection__) == ADC_EOC_SINGLE_CONV) || \
Kojto 122:f9eeca106725 754 ((__EOCSelection__) == ADC_EOC_SEQ_CONV) || \
Kojto 122:f9eeca106725 755 ((__EOCSelection__) == ADC_EOC_SINGLE_SEQ_CONV))
Kojto 122:f9eeca106725 756 #define IS_ADC_EVENT_TYPE(__EVENT__) (((__EVENT__) == ADC_AWD_EVENT) || \
Kojto 122:f9eeca106725 757 ((__EVENT__) == ADC_OVR_EVENT))
Kojto 122:f9eeca106725 758 #define IS_ADC_ANALOG_WATCHDOG(__WATCHDOG__) (((__WATCHDOG__) == ADC_ANALOGWATCHDOG_SINGLE_REG) || \
Kojto 122:f9eeca106725 759 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_SINGLE_INJEC) || \
Kojto 122:f9eeca106725 760 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC) || \
Kojto 122:f9eeca106725 761 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_ALL_REG) || \
Kojto 122:f9eeca106725 762 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_ALL_INJEC) || \
Kojto 122:f9eeca106725 763 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_ALL_REGINJEC) || \
Kojto 122:f9eeca106725 764 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_NONE))
Kojto 122:f9eeca106725 765 #define IS_ADC_CHANNELS_TYPE(CHANNEL_TYPE) (((CHANNEL_TYPE) == ADC_ALL_CHANNELS) || \
Kojto 122:f9eeca106725 766 ((CHANNEL_TYPE) == ADC_REGULAR_CHANNELS) || \
Kojto 122:f9eeca106725 767 ((CHANNEL_TYPE) == ADC_INJECTED_CHANNELS))
<> 139:856d2700e60b 768
<> 139:856d2700e60b 769 #define IS_ADC_REGULAR_RANK(__RANK__) (((__RANK__) == ADC_REGULAR_RANK_1 ) || \
<> 139:856d2700e60b 770 ((__RANK__) == ADC_REGULAR_RANK_2 ) || \
<> 139:856d2700e60b 771 ((__RANK__) == ADC_REGULAR_RANK_3 ) || \
<> 139:856d2700e60b 772 ((__RANK__) == ADC_REGULAR_RANK_4 ) || \
<> 139:856d2700e60b 773 ((__RANK__) == ADC_REGULAR_RANK_5 ) || \
<> 139:856d2700e60b 774 ((__RANK__) == ADC_REGULAR_RANK_6 ) || \
<> 139:856d2700e60b 775 ((__RANK__) == ADC_REGULAR_RANK_7 ) || \
<> 139:856d2700e60b 776 ((__RANK__) == ADC_REGULAR_RANK_8 ) || \
<> 139:856d2700e60b 777 ((__RANK__) == ADC_REGULAR_RANK_9 ) || \
<> 139:856d2700e60b 778 ((__RANK__) == ADC_REGULAR_RANK_10) || \
<> 139:856d2700e60b 779 ((__RANK__) == ADC_REGULAR_RANK_11) || \
<> 139:856d2700e60b 780 ((__RANK__) == ADC_REGULAR_RANK_12) || \
<> 139:856d2700e60b 781 ((__RANK__) == ADC_REGULAR_RANK_13) || \
<> 139:856d2700e60b 782 ((__RANK__) == ADC_REGULAR_RANK_14) || \
<> 139:856d2700e60b 783 ((__RANK__) == ADC_REGULAR_RANK_15) || \
<> 139:856d2700e60b 784 ((__RANK__) == ADC_REGULAR_RANK_16))
<> 139:856d2700e60b 785
<> 139:856d2700e60b 786 #define IS_ADC_SCAN_MODE(__SCAN_MODE__) (((__SCAN_MODE__) == ADC_SCAN_DISABLE) || \
<> 139:856d2700e60b 787 ((__SCAN_MODE__) == ADC_SCAN_ENABLE))
<> 139:856d2700e60b 788
Kojto 122:f9eeca106725 789 #define IS_ADC_THRESHOLD(__THRESHOLD__) ((__THRESHOLD__) <= ((uint32_t)0xFFF))
Kojto 122:f9eeca106725 790 #define IS_ADC_REGULAR_LENGTH(__LENGTH__) (((__LENGTH__) >= ((uint32_t)1)) && ((__LENGTH__) <= ((uint32_t)16)))
Kojto 122:f9eeca106725 791 #define IS_ADC_REGULAR_DISC_NUMBER(__NUMBER__) (((__NUMBER__) >= ((uint32_t)1)) && ((__NUMBER__) <= ((uint32_t)8)))
Kojto 122:f9eeca106725 792 #define IS_ADC_RANGE(__RESOLUTION__, __ADC_VALUE__) \
Kojto 122:f9eeca106725 793 ((((__RESOLUTION__) == ADC_RESOLUTION_12B) && ((__ADC_VALUE__) <= ((uint32_t)0x0FFF))) || \
Kojto 122:f9eeca106725 794 (((__RESOLUTION__) == ADC_RESOLUTION_10B) && ((__ADC_VALUE__) <= ((uint32_t)0x03FF))) || \
Kojto 122:f9eeca106725 795 (((__RESOLUTION__) == ADC_RESOLUTION_8B) && ((__ADC_VALUE__) <= ((uint32_t)0x00FF))) || \
Kojto 122:f9eeca106725 796 (((__RESOLUTION__) == ADC_RESOLUTION_6B) && ((__ADC_VALUE__) <= ((uint32_t)0x003F))))
Kojto 122:f9eeca106725 797
Kojto 122:f9eeca106725 798 /**
Kojto 122:f9eeca106725 799 * @brief Set ADC Regular channel sequence length.
Kojto 122:f9eeca106725 800 * @param _NbrOfConversion_: Regular channel sequence length.
Kojto 122:f9eeca106725 801 * @retval None
Kojto 122:f9eeca106725 802 */
Kojto 122:f9eeca106725 803 #define ADC_SQR1(_NbrOfConversion_) (((_NbrOfConversion_) - (uint8_t)1) << 20)
Kojto 122:f9eeca106725 804
Kojto 122:f9eeca106725 805 /**
Kojto 122:f9eeca106725 806 * @brief Set the ADC's sample time for channel numbers between 10 and 18.
Kojto 122:f9eeca106725 807 * @param _SAMPLETIME_: Sample time parameter.
Kojto 122:f9eeca106725 808 * @param _CHANNELNB_: Channel number.
Kojto 122:f9eeca106725 809 * @retval None
Kojto 122:f9eeca106725 810 */
Kojto 122:f9eeca106725 811 #define ADC_SMPR1(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3 * (((uint32_t)((uint16_t)(_CHANNELNB_))) - 10)))
Kojto 122:f9eeca106725 812
Kojto 122:f9eeca106725 813 /**
Kojto 122:f9eeca106725 814 * @brief Set the ADC's sample time for channel numbers between 0 and 9.
Kojto 122:f9eeca106725 815 * @param _SAMPLETIME_: Sample time parameter.
Kojto 122:f9eeca106725 816 * @param _CHANNELNB_: Channel number.
Kojto 122:f9eeca106725 817 * @retval None
Kojto 122:f9eeca106725 818 */
Kojto 122:f9eeca106725 819 #define ADC_SMPR2(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3 * ((uint32_t)((uint16_t)(_CHANNELNB_)))))
Kojto 122:f9eeca106725 820
Kojto 122:f9eeca106725 821 /**
Kojto 122:f9eeca106725 822 * @brief Set the selected regular channel rank for rank between 1 and 6.
Kojto 122:f9eeca106725 823 * @param _CHANNELNB_: Channel number.
Kojto 122:f9eeca106725 824 * @param _RANKNB_: Rank number.
Kojto 122:f9eeca106725 825 * @retval None
Kojto 122:f9eeca106725 826 */
Kojto 122:f9eeca106725 827 #define ADC_SQR3_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5 * ((_RANKNB_) - 1)))
Kojto 122:f9eeca106725 828
Kojto 122:f9eeca106725 829 /**
Kojto 122:f9eeca106725 830 * @brief Set the selected regular channel rank for rank between 7 and 12.
Kojto 122:f9eeca106725 831 * @param _CHANNELNB_: Channel number.
Kojto 122:f9eeca106725 832 * @param _RANKNB_: Rank number.
Kojto 122:f9eeca106725 833 * @retval None
Kojto 122:f9eeca106725 834 */
Kojto 122:f9eeca106725 835 #define ADC_SQR2_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5 * ((_RANKNB_) - 7)))
Kojto 122:f9eeca106725 836
Kojto 122:f9eeca106725 837 /**
Kojto 122:f9eeca106725 838 * @brief Set the selected regular channel rank for rank between 13 and 16.
Kojto 122:f9eeca106725 839 * @param _CHANNELNB_: Channel number.
Kojto 122:f9eeca106725 840 * @param _RANKNB_: Rank number.
Kojto 122:f9eeca106725 841 * @retval None
Kojto 122:f9eeca106725 842 */
Kojto 122:f9eeca106725 843 #define ADC_SQR1_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5 * ((_RANKNB_) - 13)))
Kojto 122:f9eeca106725 844
Kojto 122:f9eeca106725 845 /**
Kojto 122:f9eeca106725 846 * @brief Enable ADC continuous conversion mode.
Kojto 122:f9eeca106725 847 * @param _CONTINUOUS_MODE_: Continuous mode.
Kojto 122:f9eeca106725 848 * @retval None
Kojto 122:f9eeca106725 849 */
Kojto 122:f9eeca106725 850 #define ADC_CR2_CONTINUOUS(_CONTINUOUS_MODE_) ((_CONTINUOUS_MODE_) << 1)
Kojto 122:f9eeca106725 851
Kojto 122:f9eeca106725 852 /**
Kojto 122:f9eeca106725 853 * @brief Configures the number of discontinuous conversions for the regular group channels.
Kojto 122:f9eeca106725 854 * @param _NBR_DISCONTINUOUSCONV_: Number of discontinuous conversions.
Kojto 122:f9eeca106725 855 * @retval None
Kojto 122:f9eeca106725 856 */
Kojto 122:f9eeca106725 857 #define ADC_CR1_DISCONTINUOUS(_NBR_DISCONTINUOUSCONV_) (((_NBR_DISCONTINUOUSCONV_) - 1) << POSITION_VAL(ADC_CR1_DISCNUM))
Kojto 122:f9eeca106725 858
Kojto 122:f9eeca106725 859 /**
Kojto 122:f9eeca106725 860 * @brief Enable ADC scan mode.
Kojto 122:f9eeca106725 861 * @param _SCANCONV_MODE_: Scan conversion mode.
Kojto 122:f9eeca106725 862 * @retval None
Kojto 122:f9eeca106725 863 */
Kojto 122:f9eeca106725 864 #define ADC_CR1_SCANCONV(_SCANCONV_MODE_) ((_SCANCONV_MODE_) << 8)
Kojto 122:f9eeca106725 865
Kojto 122:f9eeca106725 866 /**
Kojto 122:f9eeca106725 867 * @brief Enable the ADC end of conversion selection.
Kojto 122:f9eeca106725 868 * @param _EOCSelection_MODE_: End of conversion selection mode.
Kojto 122:f9eeca106725 869 * @retval None
Kojto 122:f9eeca106725 870 */
Kojto 122:f9eeca106725 871 #define ADC_CR2_EOCSelection(_EOCSelection_MODE_) ((_EOCSelection_MODE_) << 10)
Kojto 122:f9eeca106725 872
Kojto 122:f9eeca106725 873 /**
Kojto 122:f9eeca106725 874 * @brief Enable the ADC DMA continuous request.
Kojto 122:f9eeca106725 875 * @param _DMAContReq_MODE_: DMA continuous request mode.
Kojto 122:f9eeca106725 876 * @retval None
Kojto 122:f9eeca106725 877 */
Kojto 122:f9eeca106725 878 #define ADC_CR2_DMAContReq(_DMAContReq_MODE_) ((_DMAContReq_MODE_) << 9)
Kojto 122:f9eeca106725 879
Kojto 122:f9eeca106725 880 /**
Kojto 122:f9eeca106725 881 * @brief Return resolution bits in CR1 register.
Kojto 122:f9eeca106725 882 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 883 * @retval None
Kojto 122:f9eeca106725 884 */
Kojto 122:f9eeca106725 885 #define ADC_GET_RESOLUTION(__HANDLE__) (((__HANDLE__)->Instance->CR1) & ADC_CR1_RES)
Kojto 122:f9eeca106725 886
Kojto 122:f9eeca106725 887 /**
Kojto 122:f9eeca106725 888 * @}
Kojto 122:f9eeca106725 889 */
Kojto 122:f9eeca106725 890
Kojto 122:f9eeca106725 891 /* Private functions ---------------------------------------------------------*/
Kojto 122:f9eeca106725 892 /** @defgroup ADC_Private_Functions ADC Private Functions
Kojto 122:f9eeca106725 893 * @{
Kojto 122:f9eeca106725 894 */
Kojto 122:f9eeca106725 895
Kojto 122:f9eeca106725 896 /**
Kojto 122:f9eeca106725 897 * @}
Kojto 122:f9eeca106725 898 */
Kojto 122:f9eeca106725 899
Kojto 122:f9eeca106725 900 /**
Kojto 122:f9eeca106725 901 * @}
Kojto 122:f9eeca106725 902 */
Kojto 122:f9eeca106725 903
Kojto 122:f9eeca106725 904 /**
Kojto 122:f9eeca106725 905 * @}
Kojto 122:f9eeca106725 906 */
Kojto 122:f9eeca106725 907
Kojto 122:f9eeca106725 908 #ifdef __cplusplus
Kojto 122:f9eeca106725 909 }
Kojto 122:f9eeca106725 910 #endif
Kojto 122:f9eeca106725 911
Kojto 122:f9eeca106725 912 #endif /*__STM32F7xx_ADC_H */
Kojto 122:f9eeca106725 913
Kojto 122:f9eeca106725 914
Kojto 122:f9eeca106725 915 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/