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:
Kojto
Date:
Tue Feb 14 11:24:20 2017 +0000
Revision:
136:ef9c61f8c49f
Parent:
135:176b8275d35d
Child:
139:856d2700e60b
Release 136 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

3432: Target STM USBHOST support https://github.com/ARMmbed/mbed-os/pull/3432
3181: NUCLEO_F207ZG extending PeripheralPins.c: all available alternate functions can be used now https://github.com/ARMmbed/mbed-os/pull/3181
3626: NUCLEO_F412ZG : Add USB Device +Host https://github.com/ARMmbed/mbed-os/pull/3626
3628: Fix warnings https://github.com/ARMmbed/mbed-os/pull/3628
3629: STM32: L0 LL layer https://github.com/ARMmbed/mbed-os/pull/3629
3632: IDE Export support for platform VK_RZ_A1H https://github.com/ARMmbed/mbed-os/pull/3632
3642: Missing IRQ pin fix for platform VK_RZ_A1H https://github.com/ARMmbed/mbed-os/pull/3642
3664: Fix ncs36510 sleep definitions https://github.com/ARMmbed/mbed-os/pull/3664
3655: [STM32F4] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3655
3657: [STM32L4] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3657
3658: [STM32F3] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3658
3685: STM32: I2C: reset state machine https://github.com/ARMmbed/mbed-os/pull/3685
3692: uVisor: Standardize available legacy heap and stack https://github.com/ARMmbed/mbed-os/pull/3692
3621: Fix for #2884, LPC824: export to LPCXpresso, target running with wron https://github.com/ARMmbed/mbed-os/pull/3621
3649: [STM32F7] Modify folder structure https://github.com/ARMmbed/mbed-os/pull/3649
3695: Enforce device_name is valid in targets.json https://github.com/ARMmbed/mbed-os/pull/3695
3723: NCS36510: spi_format function bug fix https://github.com/ARMmbed/mbed-os/pull/3723

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
<> 135:176b8275d35d 5 * @version V1.1.2
<> 135:176b8275d35d 6 * @date 23-September-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'.
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 122:f9eeca106725 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 122:f9eeca106725 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 122:f9eeca106725 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 122:f9eeca106725 111 This parameter must be a number between Min_Data = 1 and Max_Data = 8. */
Kojto 122:f9eeca106725 112 uint32_t ExternalTrigConv; /*!< Selects the external event used to trigger the conversion start of regular group.
Kojto 122:f9eeca106725 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 122:f9eeca106725 116 uint32_t ExternalTrigConvEdge; /*!< Selects the external trigger edge of regular group.
Kojto 122:f9eeca106725 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 122:f9eeca106725 124 }ADC_InitTypeDef;
Kojto 122:f9eeca106725 125
Kojto 122:f9eeca106725 126
Kojto 122:f9eeca106725 127
Kojto 122:f9eeca106725 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 122:f9eeca106725 132 */
Kojto 122:f9eeca106725 133 typedef struct
Kojto 122:f9eeca106725 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 122:f9eeca106725 149 }ADC_ChannelConfTypeDef;
Kojto 122:f9eeca106725 150
Kojto 122:f9eeca106725 151 /**
Kojto 122:f9eeca106725 152 * @brief ADC Configuration multi-mode structure definition
Kojto 122:f9eeca106725 153 */
Kojto 122:f9eeca106725 154 typedef struct
Kojto 122:f9eeca106725 155 {
Kojto 122:f9eeca106725 156 uint32_t WatchdogMode; /*!< Configures the ADC analog watchdog mode.
Kojto 122:f9eeca106725 157 This parameter can be a value of @ref ADC_analog_watchdog_selection */
Kojto 122:f9eeca106725 158 uint32_t HighThreshold; /*!< Configures the ADC analog watchdog High threshold value.
Kojto 122:f9eeca106725 159 This parameter must be a 12-bit value. */
Kojto 122:f9eeca106725 160 uint32_t LowThreshold; /*!< 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 Channel; /*!< Configures ADC channel for the analog watchdog.
Kojto 122:f9eeca106725 163 This parameter has an effect only if watchdog mode is configured on single channel
Kojto 122:f9eeca106725 164 This parameter can be a value of @ref ADC_channels */
Kojto 122:f9eeca106725 165 uint32_t ITMode; /*!< Specifies whether the analog watchdog is configured
Kojto 122:f9eeca106725 166 is interrupt mode or in polling mode.
Kojto 122:f9eeca106725 167 This parameter can be set to ENABLE or DISABLE */
Kojto 122:f9eeca106725 168 uint32_t WatchdogNumber; /*!< Reserved for future use, can be set to 0 */
Kojto 122:f9eeca106725 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 STM32F7 device: Out-of-window occurrence of analog watchdog 2 */
Kojto 122:f9eeca106725 199 #define HAL_ADC_STATE_AWD3 ((uint32_t)0x00040000U) /*!< Not available on STM32F7 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 STM32F7 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 122:f9eeca106725 224 /**
Kojto 122:f9eeca106725 225 * @}
Kojto 122:f9eeca106725 226 */
Kojto 122:f9eeca106725 227
Kojto 122:f9eeca106725 228 /* Exported constants --------------------------------------------------------*/
Kojto 122:f9eeca106725 229 /** @defgroup ADC_Exported_Constants ADC Exported Constants
Kojto 122:f9eeca106725 230 * @{
Kojto 122:f9eeca106725 231 */
Kojto 122:f9eeca106725 232
Kojto 122:f9eeca106725 233 /** @defgroup ADC_Error_Code ADC Error Code
Kojto 122:f9eeca106725 234 * @{
Kojto 122:f9eeca106725 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 122:f9eeca106725 241 /**
Kojto 122:f9eeca106725 242 * @}
Kojto 122:f9eeca106725 243 */
Kojto 122:f9eeca106725 244
Kojto 122:f9eeca106725 245
Kojto 122:f9eeca106725 246 /** @defgroup ADC_ClockPrescaler ADC Clock Prescaler
Kojto 122:f9eeca106725 247 * @{
Kojto 122:f9eeca106725 248 */
Kojto 122:f9eeca106725 249 #define ADC_CLOCK_SYNC_PCLK_DIV2 ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 250 #define ADC_CLOCK_SYNC_PCLK_DIV4 ((uint32_t)ADC_CCR_ADCPRE_0)
Kojto 122:f9eeca106725 251 #define ADC_CLOCK_SYNC_PCLK_DIV6 ((uint32_t)ADC_CCR_ADCPRE_1)
Kojto 122:f9eeca106725 252 #define ADC_CLOCK_SYNC_PCLK_DIV8 ((uint32_t)ADC_CCR_ADCPRE)
Kojto 122:f9eeca106725 253 /**
Kojto 122:f9eeca106725 254 * @}
Kojto 122:f9eeca106725 255 */
Kojto 122:f9eeca106725 256
Kojto 122:f9eeca106725 257 /** @defgroup ADC_delay_between_2_sampling_phases ADC Delay Between 2 Sampling Phases
Kojto 122:f9eeca106725 258 * @{
Kojto 122:f9eeca106725 259 */
Kojto 122:f9eeca106725 260 #define ADC_TWOSAMPLINGDELAY_5CYCLES ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 261 #define ADC_TWOSAMPLINGDELAY_6CYCLES ((uint32_t)ADC_CCR_DELAY_0)
Kojto 122:f9eeca106725 262 #define ADC_TWOSAMPLINGDELAY_7CYCLES ((uint32_t)ADC_CCR_DELAY_1)
Kojto 122:f9eeca106725 263 #define ADC_TWOSAMPLINGDELAY_8CYCLES ((uint32_t)(ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
Kojto 122:f9eeca106725 264 #define ADC_TWOSAMPLINGDELAY_9CYCLES ((uint32_t)ADC_CCR_DELAY_2)
Kojto 122:f9eeca106725 265 #define ADC_TWOSAMPLINGDELAY_10CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0))
Kojto 122:f9eeca106725 266 #define ADC_TWOSAMPLINGDELAY_11CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1))
Kojto 122:f9eeca106725 267 #define ADC_TWOSAMPLINGDELAY_12CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
Kojto 122:f9eeca106725 268 #define ADC_TWOSAMPLINGDELAY_13CYCLES ((uint32_t)ADC_CCR_DELAY_3)
Kojto 122:f9eeca106725 269 #define ADC_TWOSAMPLINGDELAY_14CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_0))
Kojto 122:f9eeca106725 270 #define ADC_TWOSAMPLINGDELAY_15CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1))
Kojto 122:f9eeca106725 271 #define ADC_TWOSAMPLINGDELAY_16CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
Kojto 122:f9eeca106725 272 #define ADC_TWOSAMPLINGDELAY_17CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2))
Kojto 122:f9eeca106725 273 #define ADC_TWOSAMPLINGDELAY_18CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0))
Kojto 122:f9eeca106725 274 #define ADC_TWOSAMPLINGDELAY_19CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1))
Kojto 122:f9eeca106725 275 #define ADC_TWOSAMPLINGDELAY_20CYCLES ((uint32_t)ADC_CCR_DELAY)
Kojto 122:f9eeca106725 276 /**
Kojto 122:f9eeca106725 277 * @}
Kojto 122:f9eeca106725 278 */
Kojto 122:f9eeca106725 279
Kojto 122:f9eeca106725 280 /** @defgroup ADC_Resolution ADC Resolution
Kojto 122:f9eeca106725 281 * @{
Kojto 122:f9eeca106725 282 */
Kojto 122:f9eeca106725 283 #define ADC_RESOLUTION_12B ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 284 #define ADC_RESOLUTION_10B ((uint32_t)ADC_CR1_RES_0)
Kojto 122:f9eeca106725 285 #define ADC_RESOLUTION_8B ((uint32_t)ADC_CR1_RES_1)
Kojto 122:f9eeca106725 286 #define ADC_RESOLUTION_6B ((uint32_t)ADC_CR1_RES)
Kojto 122:f9eeca106725 287 /**
Kojto 122:f9eeca106725 288 * @}
Kojto 122:f9eeca106725 289 */
Kojto 122:f9eeca106725 290
Kojto 122:f9eeca106725 291 /** @defgroup ADC_External_trigger_edge_Regular ADC External Trigger Edge Regular
Kojto 122:f9eeca106725 292 * @{
Kojto 122:f9eeca106725 293 */
Kojto 122:f9eeca106725 294 #define ADC_EXTERNALTRIGCONVEDGE_NONE ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 295 #define ADC_EXTERNALTRIGCONVEDGE_RISING ((uint32_t)ADC_CR2_EXTEN_0)
Kojto 122:f9eeca106725 296 #define ADC_EXTERNALTRIGCONVEDGE_FALLING ((uint32_t)ADC_CR2_EXTEN_1)
Kojto 122:f9eeca106725 297 #define ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING ((uint32_t)ADC_CR2_EXTEN)
Kojto 122:f9eeca106725 298 /**
Kojto 122:f9eeca106725 299 * @}
Kojto 122:f9eeca106725 300 */
Kojto 122:f9eeca106725 301
Kojto 122:f9eeca106725 302 /** @defgroup ADC_External_trigger_Source_Regular ADC External Trigger Source Regular
Kojto 122:f9eeca106725 303 * @{
Kojto 122:f9eeca106725 304 */
Kojto 122:f9eeca106725 305 /* Note: Parameter ADC_SOFTWARE_START is a software parameter used for */
Kojto 122:f9eeca106725 306 /* compatibility with other STM32 devices. */
Kojto 122:f9eeca106725 307
Kojto 122:f9eeca106725 308
Kojto 122:f9eeca106725 309 #define ADC_EXTERNALTRIGCONV_T1_CC1 ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 310 #define ADC_EXTERNALTRIGCONV_T1_CC2 ((uint32_t)ADC_CR2_EXTSEL_0)
Kojto 122:f9eeca106725 311 #define ADC_EXTERNALTRIGCONV_T1_CC3 ((uint32_t)ADC_CR2_EXTSEL_1)
Kojto 122:f9eeca106725 312 #define ADC_EXTERNALTRIGCONV_T2_CC2 ((uint32_t)(ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
Kojto 122:f9eeca106725 313 #define ADC_EXTERNALTRIGCONV_T5_TRGO ((uint32_t)ADC_CR2_EXTSEL_2)
Kojto 122:f9eeca106725 314 #define ADC_EXTERNALTRIGCONV_T4_CC4 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
Kojto 122:f9eeca106725 315 #define ADC_EXTERNALTRIGCONV_T3_CC4 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1))
Kojto 122:f9eeca106725 316 #define ADC_EXTERNALTRIGCONV_T8_TRGO ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
Kojto 122:f9eeca106725 317 #define ADC_EXTERNALTRIGCONV_T8_TRGO2 ((uint32_t)ADC_CR2_EXTSEL_3)
Kojto 122:f9eeca106725 318 #define ADC_EXTERNALTRIGCONV_T1_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_0))
Kojto 122:f9eeca106725 319 #define ADC_EXTERNALTRIGCONV_T1_TRGO2 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1))
Kojto 122:f9eeca106725 320 #define ADC_EXTERNALTRIGCONV_T2_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
Kojto 122:f9eeca106725 321 #define ADC_EXTERNALTRIGCONV_T4_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2))
Kojto 122:f9eeca106725 322 #define ADC_EXTERNALTRIGCONV_T6_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
Kojto 122:f9eeca106725 323
Kojto 122:f9eeca106725 324 #define ADC_EXTERNALTRIGCONV_EXT_IT11 ((uint32_t)ADC_CR2_EXTSEL)
Kojto 122:f9eeca106725 325 #define ADC_SOFTWARE_START ((uint32_t)ADC_CR2_EXTSEL + 1)
Kojto 122:f9eeca106725 326
Kojto 122:f9eeca106725 327 /**
Kojto 122:f9eeca106725 328 * @}
Kojto 122:f9eeca106725 329 */
Kojto 122:f9eeca106725 330
Kojto 122:f9eeca106725 331 /** @defgroup ADC_Data_Align ADC Data Align
Kojto 122:f9eeca106725 332 * @{
Kojto 122:f9eeca106725 333 */
Kojto 122:f9eeca106725 334 #define ADC_DATAALIGN_RIGHT ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 335 #define ADC_DATAALIGN_LEFT ((uint32_t)ADC_CR2_ALIGN)
Kojto 122:f9eeca106725 336 /**
Kojto 122:f9eeca106725 337 * @}
Kojto 122:f9eeca106725 338 */
Kojto 122:f9eeca106725 339
Kojto 122:f9eeca106725 340 /** @defgroup ADC_channels ADC Common Channels
Kojto 122:f9eeca106725 341 * @{
Kojto 122:f9eeca106725 342 */
Kojto 122:f9eeca106725 343 #define ADC_CHANNEL_0 ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 344 #define ADC_CHANNEL_1 ((uint32_t)ADC_CR1_AWDCH_0)
Kojto 122:f9eeca106725 345 #define ADC_CHANNEL_2 ((uint32_t)ADC_CR1_AWDCH_1)
Kojto 122:f9eeca106725 346 #define ADC_CHANNEL_3 ((uint32_t)(ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 122:f9eeca106725 347 #define ADC_CHANNEL_4 ((uint32_t)ADC_CR1_AWDCH_2)
Kojto 122:f9eeca106725 348 #define ADC_CHANNEL_5 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0))
Kojto 122:f9eeca106725 349 #define ADC_CHANNEL_6 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1))
Kojto 122:f9eeca106725 350 #define ADC_CHANNEL_7 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 122:f9eeca106725 351 #define ADC_CHANNEL_8 ((uint32_t)ADC_CR1_AWDCH_3)
Kojto 122:f9eeca106725 352 #define ADC_CHANNEL_9 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0))
Kojto 122:f9eeca106725 353 #define ADC_CHANNEL_10 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1))
Kojto 122:f9eeca106725 354 #define ADC_CHANNEL_11 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 122:f9eeca106725 355 #define ADC_CHANNEL_12 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2))
Kojto 122:f9eeca106725 356 #define ADC_CHANNEL_13 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0))
Kojto 122:f9eeca106725 357 #define ADC_CHANNEL_14 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1))
Kojto 122:f9eeca106725 358 #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 359 #define ADC_CHANNEL_16 ((uint32_t)ADC_CR1_AWDCH_4)
Kojto 122:f9eeca106725 360 #define ADC_CHANNEL_17 ((uint32_t)(ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_0))
Kojto 122:f9eeca106725 361 #define ADC_CHANNEL_18 ((uint32_t)(ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_1))
Kojto 122:f9eeca106725 362
Kojto 122:f9eeca106725 363 #define ADC_CHANNEL_VREFINT ((uint32_t)ADC_CHANNEL_17)
Kojto 122:f9eeca106725 364 #define ADC_CHANNEL_VBAT ((uint32_t)ADC_CHANNEL_18)
Kojto 122:f9eeca106725 365 /**
Kojto 122:f9eeca106725 366 * @}
Kojto 122:f9eeca106725 367 */
Kojto 122:f9eeca106725 368
Kojto 122:f9eeca106725 369 /** @defgroup ADC_sampling_times ADC Sampling Times
Kojto 122:f9eeca106725 370 * @{
Kojto 122:f9eeca106725 371 */
Kojto 122:f9eeca106725 372 #define ADC_SAMPLETIME_3CYCLES ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 373 #define ADC_SAMPLETIME_15CYCLES ((uint32_t)ADC_SMPR1_SMP10_0)
Kojto 122:f9eeca106725 374 #define ADC_SAMPLETIME_28CYCLES ((uint32_t)ADC_SMPR1_SMP10_1)
Kojto 122:f9eeca106725 375 #define ADC_SAMPLETIME_56CYCLES ((uint32_t)(ADC_SMPR1_SMP10_1 | ADC_SMPR1_SMP10_0))
Kojto 122:f9eeca106725 376 #define ADC_SAMPLETIME_84CYCLES ((uint32_t)ADC_SMPR1_SMP10_2)
Kojto 122:f9eeca106725 377 #define ADC_SAMPLETIME_112CYCLES ((uint32_t)(ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_0))
Kojto 122:f9eeca106725 378 #define ADC_SAMPLETIME_144CYCLES ((uint32_t)(ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_1))
Kojto 122:f9eeca106725 379 #define ADC_SAMPLETIME_480CYCLES ((uint32_t)ADC_SMPR1_SMP10)
Kojto 122:f9eeca106725 380 /**
Kojto 122:f9eeca106725 381 * @}
Kojto 122:f9eeca106725 382 */
Kojto 122:f9eeca106725 383
Kojto 122:f9eeca106725 384 /** @defgroup ADC_EOCSelection ADC EOC Selection
Kojto 122:f9eeca106725 385 * @{
Kojto 122:f9eeca106725 386 */
Kojto 122:f9eeca106725 387 #define ADC_EOC_SEQ_CONV ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 388 #define ADC_EOC_SINGLE_CONV ((uint32_t)0x00000001U)
Kojto 122:f9eeca106725 389 #define ADC_EOC_SINGLE_SEQ_CONV ((uint32_t)0x00000002U) /*!< reserved for future use */
Kojto 122:f9eeca106725 390 /**
Kojto 122:f9eeca106725 391 * @}
Kojto 122:f9eeca106725 392 */
Kojto 122:f9eeca106725 393
Kojto 122:f9eeca106725 394 /** @defgroup ADC_Event_type ADC Event Type
Kojto 122:f9eeca106725 395 * @{
Kojto 122:f9eeca106725 396 */
Kojto 122:f9eeca106725 397 #define ADC_AWD_EVENT ((uint32_t)ADC_FLAG_AWD)
Kojto 122:f9eeca106725 398 #define ADC_OVR_EVENT ((uint32_t)ADC_FLAG_OVR)
Kojto 122:f9eeca106725 399 /**
Kojto 122:f9eeca106725 400 * @}
Kojto 122:f9eeca106725 401 */
Kojto 122:f9eeca106725 402
Kojto 122:f9eeca106725 403 /** @defgroup ADC_analog_watchdog_selection ADC Analog Watchdog Selection
Kojto 122:f9eeca106725 404 * @{
Kojto 122:f9eeca106725 405 */
Kojto 122:f9eeca106725 406 #define ADC_ANALOGWATCHDOG_SINGLE_REG ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN))
Kojto 122:f9eeca106725 407 #define ADC_ANALOGWATCHDOG_SINGLE_INJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_JAWDEN))
Kojto 122:f9eeca106725 408 #define ADC_ANALOGWATCHDOG_SINGLE_REGINJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
Kojto 122:f9eeca106725 409 #define ADC_ANALOGWATCHDOG_ALL_REG ((uint32_t)ADC_CR1_AWDEN)
Kojto 122:f9eeca106725 410 #define ADC_ANALOGWATCHDOG_ALL_INJEC ((uint32_t)ADC_CR1_JAWDEN)
Kojto 122:f9eeca106725 411 #define ADC_ANALOGWATCHDOG_ALL_REGINJEC ((uint32_t)(ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
Kojto 122:f9eeca106725 412 #define ADC_ANALOGWATCHDOG_NONE ((uint32_t)0x00000000U)
Kojto 122:f9eeca106725 413 /**
Kojto 122:f9eeca106725 414 * @}
Kojto 122:f9eeca106725 415 */
Kojto 122:f9eeca106725 416
Kojto 122:f9eeca106725 417 /** @defgroup ADC_interrupts_definition ADC Interrupts Definition
Kojto 122:f9eeca106725 418 * @{
Kojto 122:f9eeca106725 419 */
Kojto 122:f9eeca106725 420 #define ADC_IT_EOC ((uint32_t)ADC_CR1_EOCIE)
Kojto 122:f9eeca106725 421 #define ADC_IT_AWD ((uint32_t)ADC_CR1_AWDIE)
Kojto 122:f9eeca106725 422 #define ADC_IT_JEOC ((uint32_t)ADC_CR1_JEOCIE)
Kojto 122:f9eeca106725 423 #define ADC_IT_OVR ((uint32_t)ADC_CR1_OVRIE)
Kojto 122:f9eeca106725 424 /**
Kojto 122:f9eeca106725 425 * @}
Kojto 122:f9eeca106725 426 */
Kojto 122:f9eeca106725 427
Kojto 122:f9eeca106725 428 /** @defgroup ADC_flags_definition ADC Flags Definition
Kojto 122:f9eeca106725 429 * @{
Kojto 122:f9eeca106725 430 */
Kojto 122:f9eeca106725 431 #define ADC_FLAG_AWD ((uint32_t)ADC_SR_AWD)
Kojto 122:f9eeca106725 432 #define ADC_FLAG_EOC ((uint32_t)ADC_SR_EOC)
Kojto 122:f9eeca106725 433 #define ADC_FLAG_JEOC ((uint32_t)ADC_SR_JEOC)
Kojto 122:f9eeca106725 434 #define ADC_FLAG_JSTRT ((uint32_t)ADC_SR_JSTRT)
Kojto 122:f9eeca106725 435 #define ADC_FLAG_STRT ((uint32_t)ADC_SR_STRT)
Kojto 122:f9eeca106725 436 #define ADC_FLAG_OVR ((uint32_t)ADC_SR_OVR)
Kojto 122:f9eeca106725 437 /**
Kojto 122:f9eeca106725 438 * @}
Kojto 122:f9eeca106725 439 */
Kojto 122:f9eeca106725 440
Kojto 122:f9eeca106725 441 /** @defgroup ADC_channels_type ADC Channels Type
Kojto 122:f9eeca106725 442 * @{
Kojto 122:f9eeca106725 443 */
Kojto 122:f9eeca106725 444 #define ADC_ALL_CHANNELS ((uint32_t)0x00000001U)
Kojto 122:f9eeca106725 445 #define ADC_REGULAR_CHANNELS ((uint32_t)0x00000002U) /*!< reserved for future use */
Kojto 122:f9eeca106725 446 #define ADC_INJECTED_CHANNELS ((uint32_t)0x00000003U) /*!< reserved for future use */
Kojto 122:f9eeca106725 447 /**
Kojto 122:f9eeca106725 448 * @}
Kojto 122:f9eeca106725 449 */
Kojto 122:f9eeca106725 450
Kojto 122:f9eeca106725 451 /**
Kojto 122:f9eeca106725 452 * @}
Kojto 122:f9eeca106725 453 */
Kojto 122:f9eeca106725 454
Kojto 122:f9eeca106725 455 /* Exported macro ------------------------------------------------------------*/
Kojto 122:f9eeca106725 456 /** @defgroup ADC_Exported_Macros ADC Exported Macros
Kojto 122:f9eeca106725 457 * @{
Kojto 122:f9eeca106725 458 */
Kojto 122:f9eeca106725 459
Kojto 122:f9eeca106725 460 /** @brief Reset ADC handle state
Kojto 122:f9eeca106725 461 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 462 * @retval None
Kojto 122:f9eeca106725 463 */
Kojto 122:f9eeca106725 464 #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
Kojto 122:f9eeca106725 465
Kojto 122:f9eeca106725 466 /**
Kojto 122:f9eeca106725 467 * @brief Enable the ADC peripheral.
Kojto 122:f9eeca106725 468 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 469 * @retval None
Kojto 122:f9eeca106725 470 */
Kojto 122:f9eeca106725 471 #define __HAL_ADC_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR2 |= ADC_CR2_ADON)
Kojto 122:f9eeca106725 472
Kojto 122:f9eeca106725 473 /**
Kojto 122:f9eeca106725 474 * @brief Disable the ADC peripheral.
Kojto 122:f9eeca106725 475 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 476 * @retval None
Kojto 122:f9eeca106725 477 */
Kojto 122:f9eeca106725 478 #define __HAL_ADC_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR2 &= ~ADC_CR2_ADON)
Kojto 122:f9eeca106725 479
Kojto 122:f9eeca106725 480 /**
Kojto 122:f9eeca106725 481 * @brief Enable the ADC end of conversion interrupt.
Kojto 122:f9eeca106725 482 * @param __HANDLE__: specifies the ADC Handle.
Kojto 122:f9eeca106725 483 * @param __INTERRUPT__: ADC Interrupt.
Kojto 122:f9eeca106725 484 * @retval None
Kojto 122:f9eeca106725 485 */
Kojto 122:f9eeca106725 486 #define __HAL_ADC_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1) |= (__INTERRUPT__))
Kojto 122:f9eeca106725 487
Kojto 122:f9eeca106725 488 /**
Kojto 122:f9eeca106725 489 * @brief Disable the ADC end of conversion interrupt.
Kojto 122:f9eeca106725 490 * @param __HANDLE__: specifies the ADC Handle.
Kojto 122:f9eeca106725 491 * @param __INTERRUPT__: ADC interrupt.
Kojto 122:f9eeca106725 492 * @retval None
Kojto 122:f9eeca106725 493 */
Kojto 122:f9eeca106725 494 #define __HAL_ADC_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1) &= ~(__INTERRUPT__))
Kojto 122:f9eeca106725 495
Kojto 122:f9eeca106725 496 /** @brief Check if the specified ADC interrupt source is enabled or disabled.
Kojto 122:f9eeca106725 497 * @param __HANDLE__: specifies the ADC Handle.
Kojto 122:f9eeca106725 498 * @param __INTERRUPT__: specifies the ADC interrupt source to check.
Kojto 122:f9eeca106725 499 * @retval The new state of __IT__ (TRUE or FALSE).
Kojto 122:f9eeca106725 500 */
Kojto 122:f9eeca106725 501 #define __HAL_ADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__))
Kojto 122:f9eeca106725 502
Kojto 122:f9eeca106725 503 /**
Kojto 122:f9eeca106725 504 * @brief Clear the ADC's pending flags.
Kojto 122:f9eeca106725 505 * @param __HANDLE__: specifies the ADC Handle.
Kojto 122:f9eeca106725 506 * @param __FLAG__: ADC flag.
Kojto 122:f9eeca106725 507 * @retval None
Kojto 122:f9eeca106725 508 */
Kojto 122:f9eeca106725 509 #define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) = ~(__FLAG__))
Kojto 122:f9eeca106725 510
Kojto 122:f9eeca106725 511 /**
Kojto 122:f9eeca106725 512 * @brief Get the selected ADC's flag status.
Kojto 122:f9eeca106725 513 * @param __HANDLE__: specifies the ADC Handle.
Kojto 122:f9eeca106725 514 * @param __FLAG__: ADC flag.
Kojto 122:f9eeca106725 515 * @retval None
Kojto 122:f9eeca106725 516 */
Kojto 122:f9eeca106725 517 #define __HAL_ADC_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
Kojto 122:f9eeca106725 518
Kojto 122:f9eeca106725 519 /**
Kojto 122:f9eeca106725 520 * @}
Kojto 122:f9eeca106725 521 */
Kojto 122:f9eeca106725 522
Kojto 122:f9eeca106725 523 /* Include ADC HAL Extension module */
Kojto 122:f9eeca106725 524 #include "stm32f7xx_hal_adc_ex.h"
Kojto 122:f9eeca106725 525
Kojto 122:f9eeca106725 526 /* Exported functions --------------------------------------------------------*/
Kojto 122:f9eeca106725 527 /** @addtogroup ADC_Exported_Functions
Kojto 122:f9eeca106725 528 * @{
Kojto 122:f9eeca106725 529 */
Kojto 122:f9eeca106725 530
Kojto 122:f9eeca106725 531 /** @addtogroup ADC_Exported_Functions_Group1
Kojto 122:f9eeca106725 532 * @{
Kojto 122:f9eeca106725 533 */
Kojto 122:f9eeca106725 534 /* Initialization/de-initialization functions ***********************************/
Kojto 122:f9eeca106725 535 HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 536 HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
Kojto 122:f9eeca106725 537 void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 538 void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 539 /**
Kojto 122:f9eeca106725 540 * @}
Kojto 122:f9eeca106725 541 */
Kojto 122:f9eeca106725 542
Kojto 122:f9eeca106725 543 /** @addtogroup ADC_Exported_Functions_Group2
Kojto 122:f9eeca106725 544 * @{
Kojto 122:f9eeca106725 545 */
Kojto 122:f9eeca106725 546 /* I/O operation functions ******************************************************/
Kojto 122:f9eeca106725 547 HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 548 HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 549 HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
Kojto 122:f9eeca106725 550
Kojto 122:f9eeca106725 551 HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout);
Kojto 122:f9eeca106725 552
Kojto 122:f9eeca106725 553 HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 554 HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 555
Kojto 122:f9eeca106725 556 void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 557
Kojto 122:f9eeca106725 558 HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length);
Kojto 122:f9eeca106725 559 HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 560
Kojto 122:f9eeca106725 561 uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 562
Kojto 122:f9eeca106725 563 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 564 void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 565 void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 566 void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
Kojto 122:f9eeca106725 567 /**
Kojto 122:f9eeca106725 568 * @}
Kojto 122:f9eeca106725 569 */
Kojto 122:f9eeca106725 570
Kojto 122:f9eeca106725 571 /** @addtogroup ADC_Exported_Functions_Group3
Kojto 122:f9eeca106725 572 * @{
Kojto 122:f9eeca106725 573 */
Kojto 122:f9eeca106725 574 /* Peripheral Control functions *************************************************/
Kojto 122:f9eeca106725 575 HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig);
Kojto 122:f9eeca106725 576 HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig);
Kojto 122:f9eeca106725 577 /**
Kojto 122:f9eeca106725 578 * @}
Kojto 122:f9eeca106725 579 */
Kojto 122:f9eeca106725 580
Kojto 122:f9eeca106725 581 /** @addtogroup ADC_Exported_Functions_Group4
Kojto 122:f9eeca106725 582 * @{
Kojto 122:f9eeca106725 583 */
Kojto 122:f9eeca106725 584 /* Peripheral State functions ***************************************************/
Kojto 122:f9eeca106725 585 uint32_t HAL_ADC_GetState(ADC_HandleTypeDef* hadc);
Kojto 122:f9eeca106725 586 uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc);
Kojto 122:f9eeca106725 587 /**
Kojto 122:f9eeca106725 588 * @}
Kojto 122:f9eeca106725 589 */
Kojto 122:f9eeca106725 590
Kojto 122:f9eeca106725 591 /**
Kojto 122:f9eeca106725 592 * @}
Kojto 122:f9eeca106725 593 */
Kojto 122:f9eeca106725 594
Kojto 122:f9eeca106725 595 /* Private types -------------------------------------------------------------*/
Kojto 122:f9eeca106725 596 /* Private variables ---------------------------------------------------------*/
Kojto 122:f9eeca106725 597 /* Private constants ---------------------------------------------------------*/
Kojto 122:f9eeca106725 598 /** @defgroup ADC_Private_Constants ADC Private Constants
Kojto 122:f9eeca106725 599 * @{
Kojto 122:f9eeca106725 600 */
Kojto 122:f9eeca106725 601 /* Delay for ADC stabilization time. */
Kojto 122:f9eeca106725 602 /* Maximum delay is 1us (refer to device datasheet, parameter tSTAB). */
Kojto 122:f9eeca106725 603 /* Unit: us */
Kojto 122:f9eeca106725 604 #define ADC_STAB_DELAY_US ((uint32_t) 3U)
Kojto 122:f9eeca106725 605 /* Delay for temperature sensor stabilization time. */
Kojto 122:f9eeca106725 606 /* Maximum delay is 10us (refer to device datasheet, parameter tSTART). */
Kojto 122:f9eeca106725 607 /* Unit: us */
Kojto 122:f9eeca106725 608 #define ADC_TEMPSENSOR_DELAY_US ((uint32_t) 10U)
Kojto 122:f9eeca106725 609 /**
Kojto 122:f9eeca106725 610 * @}
Kojto 122:f9eeca106725 611 */
Kojto 122:f9eeca106725 612
Kojto 122:f9eeca106725 613 /* Private macros ------------------------------------------------------------*/
Kojto 122:f9eeca106725 614 /** @defgroup ADC_Private_Macros ADC Private Macros
Kojto 122:f9eeca106725 615 * @{
Kojto 122:f9eeca106725 616 */
Kojto 122:f9eeca106725 617 /* Macro reserved for internal HAL driver usage, not intended to be used in
Kojto 122:f9eeca106725 618 code of final user */
Kojto 122:f9eeca106725 619
Kojto 122:f9eeca106725 620 /**
Kojto 122:f9eeca106725 621 * @brief Verification of ADC state: enabled or disabled
Kojto 122:f9eeca106725 622 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 623 * @retval SET (ADC enabled) or RESET (ADC disabled)
Kojto 122:f9eeca106725 624 */
Kojto 122:f9eeca106725 625 #define ADC_IS_ENABLE(__HANDLE__) \
Kojto 122:f9eeca106725 626 ((( ((__HANDLE__)->Instance->SR & ADC_SR_ADONS) == ADC_SR_ADONS ) \
Kojto 122:f9eeca106725 627 ) ? SET : RESET)
Kojto 122:f9eeca106725 628
Kojto 122:f9eeca106725 629 /**
Kojto 122:f9eeca106725 630 * @brief Test if conversion trigger of regular group is software start
Kojto 122:f9eeca106725 631 * or external trigger.
Kojto 122:f9eeca106725 632 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 633 * @retval SET (software start) or RESET (external trigger)
Kojto 122:f9eeca106725 634 */
Kojto 122:f9eeca106725 635 #define ADC_IS_SOFTWARE_START_REGULAR(__HANDLE__) \
Kojto 122:f9eeca106725 636 (((__HANDLE__)->Instance->CR2 & ADC_CR2_EXTEN) == RESET)
Kojto 122:f9eeca106725 637
Kojto 122:f9eeca106725 638 /**
Kojto 122:f9eeca106725 639 * @brief Test if conversion trigger of injected group is software start
Kojto 122:f9eeca106725 640 * or external trigger.
Kojto 122:f9eeca106725 641 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 642 * @retval SET (software start) or RESET (external trigger)
Kojto 122:f9eeca106725 643 */
Kojto 122:f9eeca106725 644 #define ADC_IS_SOFTWARE_START_INJECTED(__HANDLE__) \
Kojto 122:f9eeca106725 645 (((__HANDLE__)->Instance->CR2 & ADC_CR2_JEXTEN) == RESET)
Kojto 122:f9eeca106725 646
Kojto 122:f9eeca106725 647 /**
Kojto 122:f9eeca106725 648 * @brief Simultaneously clears and sets specific bits of the handle State
Kojto 122:f9eeca106725 649 * @note: ADC_STATE_CLR_SET() macro is merely aliased to generic macro MODIFY_REG(),
Kojto 122:f9eeca106725 650 * the first parameter is the ADC handle State, the second parameter is the
Kojto 122:f9eeca106725 651 * bit field to clear, the third and last parameter is the bit field to set.
Kojto 122:f9eeca106725 652 * @retval None
Kojto 122:f9eeca106725 653 */
Kojto 122:f9eeca106725 654 #define ADC_STATE_CLR_SET MODIFY_REG
Kojto 122:f9eeca106725 655
Kojto 122:f9eeca106725 656 /**
Kojto 122:f9eeca106725 657 * @brief Clear ADC error code (set it to error code: "no error")
Kojto 122:f9eeca106725 658 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 659 * @retval None
Kojto 122:f9eeca106725 660 */
Kojto 122:f9eeca106725 661 #define ADC_CLEAR_ERRORCODE(__HANDLE__) \
Kojto 122:f9eeca106725 662 ((__HANDLE__)->ErrorCode = HAL_ADC_ERROR_NONE)
Kojto 122:f9eeca106725 663 #define IS_ADC_CLOCKPRESCALER(__ADC_CLOCK__) (((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV2) || \
Kojto 122:f9eeca106725 664 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV4) || \
Kojto 122:f9eeca106725 665 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV6) || \
Kojto 122:f9eeca106725 666 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV8))
Kojto 122:f9eeca106725 667 #define IS_ADC_SAMPLING_DELAY(__DELAY__) (((__DELAY__) == ADC_TWOSAMPLINGDELAY_5CYCLES) || \
Kojto 122:f9eeca106725 668 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_6CYCLES) || \
Kojto 122:f9eeca106725 669 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_7CYCLES) || \
Kojto 122:f9eeca106725 670 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_8CYCLES) || \
Kojto 122:f9eeca106725 671 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_9CYCLES) || \
Kojto 122:f9eeca106725 672 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_10CYCLES) || \
Kojto 122:f9eeca106725 673 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_11CYCLES) || \
Kojto 122:f9eeca106725 674 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_12CYCLES) || \
Kojto 122:f9eeca106725 675 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_13CYCLES) || \
Kojto 122:f9eeca106725 676 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_14CYCLES) || \
Kojto 122:f9eeca106725 677 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_15CYCLES) || \
Kojto 122:f9eeca106725 678 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_16CYCLES) || \
Kojto 122:f9eeca106725 679 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_17CYCLES) || \
Kojto 122:f9eeca106725 680 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_18CYCLES) || \
Kojto 122:f9eeca106725 681 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_19CYCLES) || \
Kojto 122:f9eeca106725 682 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_20CYCLES))
Kojto 122:f9eeca106725 683 #define IS_ADC_RESOLUTION(__RESOLUTION__) (((__RESOLUTION__) == ADC_RESOLUTION_12B) || \
Kojto 122:f9eeca106725 684 ((__RESOLUTION__) == ADC_RESOLUTION_10B) || \
Kojto 122:f9eeca106725 685 ((__RESOLUTION__) == ADC_RESOLUTION_8B) || \
Kojto 122:f9eeca106725 686 ((__RESOLUTION__) == ADC_RESOLUTION_6B))
Kojto 122:f9eeca106725 687 #define IS_ADC_EXT_TRIG_EDGE(__EDGE__) (((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_NONE) || \
Kojto 122:f9eeca106725 688 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_RISING) || \
Kojto 122:f9eeca106725 689 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_FALLING) || \
Kojto 122:f9eeca106725 690 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING))
Kojto 122:f9eeca106725 691 #define IS_ADC_EXT_TRIG(__REGTRIG__) (((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
Kojto 122:f9eeca106725 692 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
Kojto 122:f9eeca106725 693 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_CC3) || \
Kojto 122:f9eeca106725 694 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
Kojto 122:f9eeca106725 695 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T5_TRGO) || \
Kojto 122:f9eeca106725 696 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
Kojto 122:f9eeca106725 697 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T3_CC4) || \
Kojto 122:f9eeca106725 698 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T8_TRGO) || \
Kojto 122:f9eeca106725 699 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T8_TRGO2) || \
Kojto 122:f9eeca106725 700 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_TRGO) || \
Kojto 122:f9eeca106725 701 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_TRGO2) || \
Kojto 122:f9eeca106725 702 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T2_TRGO) || \
Kojto 122:f9eeca106725 703 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T4_TRGO) || \
Kojto 122:f9eeca106725 704 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T6_TRGO) || \
Kojto 122:f9eeca106725 705 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
Kojto 122:f9eeca106725 706 ((__REGTRIG__) == ADC_SOFTWARE_START))
Kojto 122:f9eeca106725 707 #define IS_ADC_DATA_ALIGN(__ALIGN__) (((__ALIGN__) == ADC_DATAALIGN_RIGHT) || \
Kojto 122:f9eeca106725 708 ((__ALIGN__) == ADC_DATAALIGN_LEFT))
Kojto 122:f9eeca106725 709
Kojto 122:f9eeca106725 710 #define IS_ADC_SAMPLE_TIME(__TIME__) (((__TIME__) == ADC_SAMPLETIME_3CYCLES) || \
Kojto 122:f9eeca106725 711 ((__TIME__) == ADC_SAMPLETIME_15CYCLES) || \
Kojto 122:f9eeca106725 712 ((__TIME__) == ADC_SAMPLETIME_28CYCLES) || \
Kojto 122:f9eeca106725 713 ((__TIME__) == ADC_SAMPLETIME_56CYCLES) || \
Kojto 122:f9eeca106725 714 ((__TIME__) == ADC_SAMPLETIME_84CYCLES) || \
Kojto 122:f9eeca106725 715 ((__TIME__) == ADC_SAMPLETIME_112CYCLES) || \
Kojto 122:f9eeca106725 716 ((__TIME__) == ADC_SAMPLETIME_144CYCLES) || \
Kojto 122:f9eeca106725 717 ((__TIME__) == ADC_SAMPLETIME_480CYCLES))
Kojto 122:f9eeca106725 718 #define IS_ADC_EOCSelection(__EOCSelection__) (((__EOCSelection__) == ADC_EOC_SINGLE_CONV) || \
Kojto 122:f9eeca106725 719 ((__EOCSelection__) == ADC_EOC_SEQ_CONV) || \
Kojto 122:f9eeca106725 720 ((__EOCSelection__) == ADC_EOC_SINGLE_SEQ_CONV))
Kojto 122:f9eeca106725 721 #define IS_ADC_EVENT_TYPE(__EVENT__) (((__EVENT__) == ADC_AWD_EVENT) || \
Kojto 122:f9eeca106725 722 ((__EVENT__) == ADC_OVR_EVENT))
Kojto 122:f9eeca106725 723 #define IS_ADC_ANALOG_WATCHDOG(__WATCHDOG__) (((__WATCHDOG__) == ADC_ANALOGWATCHDOG_SINGLE_REG) || \
Kojto 122:f9eeca106725 724 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_SINGLE_INJEC) || \
Kojto 122:f9eeca106725 725 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC) || \
Kojto 122:f9eeca106725 726 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_ALL_REG) || \
Kojto 122:f9eeca106725 727 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_ALL_INJEC) || \
Kojto 122:f9eeca106725 728 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_ALL_REGINJEC) || \
Kojto 122:f9eeca106725 729 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_NONE))
Kojto 122:f9eeca106725 730 #define IS_ADC_CHANNELS_TYPE(CHANNEL_TYPE) (((CHANNEL_TYPE) == ADC_ALL_CHANNELS) || \
Kojto 122:f9eeca106725 731 ((CHANNEL_TYPE) == ADC_REGULAR_CHANNELS) || \
Kojto 122:f9eeca106725 732 ((CHANNEL_TYPE) == ADC_INJECTED_CHANNELS))
Kojto 122:f9eeca106725 733 #define IS_ADC_THRESHOLD(__THRESHOLD__) ((__THRESHOLD__) <= ((uint32_t)0xFFF))
Kojto 122:f9eeca106725 734 #define IS_ADC_REGULAR_LENGTH(__LENGTH__) (((__LENGTH__) >= ((uint32_t)1)) && ((__LENGTH__) <= ((uint32_t)16)))
Kojto 122:f9eeca106725 735 #define IS_ADC_REGULAR_RANK(__RANK__) (((__RANK__) >= ((uint32_t)1)) && ((__RANK__) <= ((uint32_t)16)))
Kojto 122:f9eeca106725 736 #define IS_ADC_REGULAR_DISC_NUMBER(__NUMBER__) (((__NUMBER__) >= ((uint32_t)1)) && ((__NUMBER__) <= ((uint32_t)8)))
Kojto 122:f9eeca106725 737 #define IS_ADC_RANGE(__RESOLUTION__, __ADC_VALUE__) \
Kojto 122:f9eeca106725 738 ((((__RESOLUTION__) == ADC_RESOLUTION_12B) && ((__ADC_VALUE__) <= ((uint32_t)0x0FFF))) || \
Kojto 122:f9eeca106725 739 (((__RESOLUTION__) == ADC_RESOLUTION_10B) && ((__ADC_VALUE__) <= ((uint32_t)0x03FF))) || \
Kojto 122:f9eeca106725 740 (((__RESOLUTION__) == ADC_RESOLUTION_8B) && ((__ADC_VALUE__) <= ((uint32_t)0x00FF))) || \
Kojto 122:f9eeca106725 741 (((__RESOLUTION__) == ADC_RESOLUTION_6B) && ((__ADC_VALUE__) <= ((uint32_t)0x003F))))
Kojto 122:f9eeca106725 742
Kojto 122:f9eeca106725 743 /**
Kojto 122:f9eeca106725 744 * @brief Set ADC Regular channel sequence length.
Kojto 122:f9eeca106725 745 * @param _NbrOfConversion_: Regular channel sequence length.
Kojto 122:f9eeca106725 746 * @retval None
Kojto 122:f9eeca106725 747 */
Kojto 122:f9eeca106725 748 #define ADC_SQR1(_NbrOfConversion_) (((_NbrOfConversion_) - (uint8_t)1) << 20)
Kojto 122:f9eeca106725 749
Kojto 122:f9eeca106725 750 /**
Kojto 122:f9eeca106725 751 * @brief Set the ADC's sample time for channel numbers between 10 and 18.
Kojto 122:f9eeca106725 752 * @param _SAMPLETIME_: Sample time parameter.
Kojto 122:f9eeca106725 753 * @param _CHANNELNB_: Channel number.
Kojto 122:f9eeca106725 754 * @retval None
Kojto 122:f9eeca106725 755 */
Kojto 122:f9eeca106725 756 #define ADC_SMPR1(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3 * (((uint32_t)((uint16_t)(_CHANNELNB_))) - 10)))
Kojto 122:f9eeca106725 757
Kojto 122:f9eeca106725 758 /**
Kojto 122:f9eeca106725 759 * @brief Set the ADC's sample time for channel numbers between 0 and 9.
Kojto 122:f9eeca106725 760 * @param _SAMPLETIME_: Sample time parameter.
Kojto 122:f9eeca106725 761 * @param _CHANNELNB_: Channel number.
Kojto 122:f9eeca106725 762 * @retval None
Kojto 122:f9eeca106725 763 */
Kojto 122:f9eeca106725 764 #define ADC_SMPR2(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3 * ((uint32_t)((uint16_t)(_CHANNELNB_)))))
Kojto 122:f9eeca106725 765
Kojto 122:f9eeca106725 766 /**
Kojto 122:f9eeca106725 767 * @brief Set the selected regular channel rank for rank between 1 and 6.
Kojto 122:f9eeca106725 768 * @param _CHANNELNB_: Channel number.
Kojto 122:f9eeca106725 769 * @param _RANKNB_: Rank number.
Kojto 122:f9eeca106725 770 * @retval None
Kojto 122:f9eeca106725 771 */
Kojto 122:f9eeca106725 772 #define ADC_SQR3_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5 * ((_RANKNB_) - 1)))
Kojto 122:f9eeca106725 773
Kojto 122:f9eeca106725 774 /**
Kojto 122:f9eeca106725 775 * @brief Set the selected regular channel rank for rank between 7 and 12.
Kojto 122:f9eeca106725 776 * @param _CHANNELNB_: Channel number.
Kojto 122:f9eeca106725 777 * @param _RANKNB_: Rank number.
Kojto 122:f9eeca106725 778 * @retval None
Kojto 122:f9eeca106725 779 */
Kojto 122:f9eeca106725 780 #define ADC_SQR2_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5 * ((_RANKNB_) - 7)))
Kojto 122:f9eeca106725 781
Kojto 122:f9eeca106725 782 /**
Kojto 122:f9eeca106725 783 * @brief Set the selected regular channel rank for rank between 13 and 16.
Kojto 122:f9eeca106725 784 * @param _CHANNELNB_: Channel number.
Kojto 122:f9eeca106725 785 * @param _RANKNB_: Rank number.
Kojto 122:f9eeca106725 786 * @retval None
Kojto 122:f9eeca106725 787 */
Kojto 122:f9eeca106725 788 #define ADC_SQR1_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5 * ((_RANKNB_) - 13)))
Kojto 122:f9eeca106725 789
Kojto 122:f9eeca106725 790 /**
Kojto 122:f9eeca106725 791 * @brief Enable ADC continuous conversion mode.
Kojto 122:f9eeca106725 792 * @param _CONTINUOUS_MODE_: Continuous mode.
Kojto 122:f9eeca106725 793 * @retval None
Kojto 122:f9eeca106725 794 */
Kojto 122:f9eeca106725 795 #define ADC_CR2_CONTINUOUS(_CONTINUOUS_MODE_) ((_CONTINUOUS_MODE_) << 1)
Kojto 122:f9eeca106725 796
Kojto 122:f9eeca106725 797 /**
Kojto 122:f9eeca106725 798 * @brief Configures the number of discontinuous conversions for the regular group channels.
Kojto 122:f9eeca106725 799 * @param _NBR_DISCONTINUOUSCONV_: Number of discontinuous conversions.
Kojto 122:f9eeca106725 800 * @retval None
Kojto 122:f9eeca106725 801 */
Kojto 122:f9eeca106725 802 #define ADC_CR1_DISCONTINUOUS(_NBR_DISCONTINUOUSCONV_) (((_NBR_DISCONTINUOUSCONV_) - 1) << POSITION_VAL(ADC_CR1_DISCNUM))
Kojto 122:f9eeca106725 803
Kojto 122:f9eeca106725 804 /**
Kojto 122:f9eeca106725 805 * @brief Enable ADC scan mode.
Kojto 122:f9eeca106725 806 * @param _SCANCONV_MODE_: Scan conversion mode.
Kojto 122:f9eeca106725 807 * @retval None
Kojto 122:f9eeca106725 808 */
Kojto 122:f9eeca106725 809 #define ADC_CR1_SCANCONV(_SCANCONV_MODE_) ((_SCANCONV_MODE_) << 8)
Kojto 122:f9eeca106725 810
Kojto 122:f9eeca106725 811 /**
Kojto 122:f9eeca106725 812 * @brief Enable the ADC end of conversion selection.
Kojto 122:f9eeca106725 813 * @param _EOCSelection_MODE_: End of conversion selection mode.
Kojto 122:f9eeca106725 814 * @retval None
Kojto 122:f9eeca106725 815 */
Kojto 122:f9eeca106725 816 #define ADC_CR2_EOCSelection(_EOCSelection_MODE_) ((_EOCSelection_MODE_) << 10)
Kojto 122:f9eeca106725 817
Kojto 122:f9eeca106725 818 /**
Kojto 122:f9eeca106725 819 * @brief Enable the ADC DMA continuous request.
Kojto 122:f9eeca106725 820 * @param _DMAContReq_MODE_: DMA continuous request mode.
Kojto 122:f9eeca106725 821 * @retval None
Kojto 122:f9eeca106725 822 */
Kojto 122:f9eeca106725 823 #define ADC_CR2_DMAContReq(_DMAContReq_MODE_) ((_DMAContReq_MODE_) << 9)
Kojto 122:f9eeca106725 824
Kojto 122:f9eeca106725 825 /**
Kojto 122:f9eeca106725 826 * @brief Return resolution bits in CR1 register.
Kojto 122:f9eeca106725 827 * @param __HANDLE__: ADC handle
Kojto 122:f9eeca106725 828 * @retval None
Kojto 122:f9eeca106725 829 */
Kojto 122:f9eeca106725 830 #define ADC_GET_RESOLUTION(__HANDLE__) (((__HANDLE__)->Instance->CR1) & ADC_CR1_RES)
Kojto 122:f9eeca106725 831
Kojto 122:f9eeca106725 832 /**
Kojto 122:f9eeca106725 833 * @}
Kojto 122:f9eeca106725 834 */
Kojto 122:f9eeca106725 835
Kojto 122:f9eeca106725 836 /* Private functions ---------------------------------------------------------*/
Kojto 122:f9eeca106725 837 /** @defgroup ADC_Private_Functions ADC Private Functions
Kojto 122:f9eeca106725 838 * @{
Kojto 122:f9eeca106725 839 */
Kojto 122:f9eeca106725 840
Kojto 122:f9eeca106725 841 /**
Kojto 122:f9eeca106725 842 * @}
Kojto 122:f9eeca106725 843 */
Kojto 122:f9eeca106725 844
Kojto 122:f9eeca106725 845 /**
Kojto 122:f9eeca106725 846 * @}
Kojto 122:f9eeca106725 847 */
Kojto 122:f9eeca106725 848
Kojto 122:f9eeca106725 849 /**
Kojto 122:f9eeca106725 850 * @}
Kojto 122:f9eeca106725 851 */
Kojto 122:f9eeca106725 852
Kojto 122:f9eeca106725 853 #ifdef __cplusplus
Kojto 122:f9eeca106725 854 }
Kojto 122:f9eeca106725 855 #endif
Kojto 122:f9eeca106725 856
Kojto 122:f9eeca106725 857 #endif /*__STM32F7xx_ADC_H */
Kojto 122:f9eeca106725 858
Kojto 122:f9eeca106725 859
Kojto 122:f9eeca106725 860 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/