mbed official / mbed

Dependents:   hello SerialTestv11 SerialTestv12 Sierpinski ... more

Committer:
Kojto
Date:
Wed Sep 16 15:32:31 2015 +0100
Revision:
107:4f6c30876dfa
Child:
116:c0f6e94411f5
Release 107  of the mbed library

Changes:
- new platforms - DISCO_F746NG, DISCO_L476VG, NUCLEO_L476RG
- KL43Z - bugfix RTC init function
- K20 - SPI mode fix

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 107:4f6c30876dfa 1 /**
Kojto 107:4f6c30876dfa 2 ******************************************************************************
Kojto 107:4f6c30876dfa 3 * @file stm32f7xx_hal_adc.h
Kojto 107:4f6c30876dfa 4 * @author MCD Application Team
Kojto 107:4f6c30876dfa 5 * @version V1.0.1
Kojto 107:4f6c30876dfa 6 * @date 25-June-2015
Kojto 107:4f6c30876dfa 7 * @brief Header file of ADC HAL extension module.
Kojto 107:4f6c30876dfa 8 ******************************************************************************
Kojto 107:4f6c30876dfa 9 * @attention
Kojto 107:4f6c30876dfa 10 *
Kojto 107:4f6c30876dfa 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
Kojto 107:4f6c30876dfa 12 *
Kojto 107:4f6c30876dfa 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 107:4f6c30876dfa 14 * are permitted provided that the following conditions are met:
Kojto 107:4f6c30876dfa 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 107:4f6c30876dfa 16 * this list of conditions and the following disclaimer.
Kojto 107:4f6c30876dfa 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 107:4f6c30876dfa 18 * this list of conditions and the following disclaimer in the documentation
Kojto 107:4f6c30876dfa 19 * and/or other materials provided with the distribution.
Kojto 107:4f6c30876dfa 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 107:4f6c30876dfa 21 * may be used to endorse or promote products derived from this software
Kojto 107:4f6c30876dfa 22 * without specific prior written permission.
Kojto 107:4f6c30876dfa 23 *
Kojto 107:4f6c30876dfa 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 107:4f6c30876dfa 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 107:4f6c30876dfa 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 107:4f6c30876dfa 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 107:4f6c30876dfa 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 107:4f6c30876dfa 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 107:4f6c30876dfa 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 107:4f6c30876dfa 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 107:4f6c30876dfa 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 107:4f6c30876dfa 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 107:4f6c30876dfa 34 *
Kojto 107:4f6c30876dfa 35 ******************************************************************************
Kojto 107:4f6c30876dfa 36 */
Kojto 107:4f6c30876dfa 37
Kojto 107:4f6c30876dfa 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 107:4f6c30876dfa 39 #ifndef __STM32F7xx_ADC_H
Kojto 107:4f6c30876dfa 40 #define __STM32F7xx_ADC_H
Kojto 107:4f6c30876dfa 41
Kojto 107:4f6c30876dfa 42 #ifdef __cplusplus
Kojto 107:4f6c30876dfa 43 extern "C" {
Kojto 107:4f6c30876dfa 44 #endif
Kojto 107:4f6c30876dfa 45
Kojto 107:4f6c30876dfa 46 /* Includes ------------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 47 #include "stm32f7xx_hal_def.h"
Kojto 107:4f6c30876dfa 48
Kojto 107:4f6c30876dfa 49 /** @addtogroup STM32F7xx_HAL_Driver
Kojto 107:4f6c30876dfa 50 * @{
Kojto 107:4f6c30876dfa 51 */
Kojto 107:4f6c30876dfa 52
Kojto 107:4f6c30876dfa 53 /** @addtogroup ADC
Kojto 107:4f6c30876dfa 54 * @{
Kojto 107:4f6c30876dfa 55 */
Kojto 107:4f6c30876dfa 56
Kojto 107:4f6c30876dfa 57 /* Exported types ------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 58 /** @defgroup ADC_Exported_Types ADC Exported Types
Kojto 107:4f6c30876dfa 59 * @{
Kojto 107:4f6c30876dfa 60 */
Kojto 107:4f6c30876dfa 61
Kojto 107:4f6c30876dfa 62 /**
Kojto 107:4f6c30876dfa 63 * @brief HAL State structures definition
Kojto 107:4f6c30876dfa 64 */
Kojto 107:4f6c30876dfa 65 typedef enum
Kojto 107:4f6c30876dfa 66 {
Kojto 107:4f6c30876dfa 67 HAL_ADC_STATE_RESET = 0x00, /*!< ADC not yet initialized or disabled */
Kojto 107:4f6c30876dfa 68 HAL_ADC_STATE_READY = 0x01, /*!< ADC peripheral ready for use */
Kojto 107:4f6c30876dfa 69 HAL_ADC_STATE_BUSY = 0x02, /*!< An internal process is ongoing */
Kojto 107:4f6c30876dfa 70 HAL_ADC_STATE_BUSY_REG = 0x12, /*!< Regular conversion is ongoing */
Kojto 107:4f6c30876dfa 71 HAL_ADC_STATE_BUSY_INJ = 0x22, /*!< Injected conversion is ongoing */
Kojto 107:4f6c30876dfa 72 HAL_ADC_STATE_BUSY_INJ_REG = 0x32, /*!< Injected and regular conversion are ongoing */
Kojto 107:4f6c30876dfa 73 HAL_ADC_STATE_TIMEOUT = 0x03, /*!< Timeout state */
Kojto 107:4f6c30876dfa 74 HAL_ADC_STATE_ERROR = 0x04, /*!< ADC state error */
Kojto 107:4f6c30876dfa 75 HAL_ADC_STATE_EOC = 0x05, /*!< Conversion is completed */
Kojto 107:4f6c30876dfa 76 HAL_ADC_STATE_EOC_REG = 0x15, /*!< Regular conversion is completed */
Kojto 107:4f6c30876dfa 77 HAL_ADC_STATE_EOC_INJ = 0x25, /*!< Injected conversion is completed */
Kojto 107:4f6c30876dfa 78 HAL_ADC_STATE_EOC_INJ_REG = 0x35, /*!< Injected and regular conversion are completed */
Kojto 107:4f6c30876dfa 79 HAL_ADC_STATE_AWD = 0x06 /*!< ADC state analog watchdog */
Kojto 107:4f6c30876dfa 80
Kojto 107:4f6c30876dfa 81 }HAL_ADC_StateTypeDef;
Kojto 107:4f6c30876dfa 82
Kojto 107:4f6c30876dfa 83 /**
Kojto 107:4f6c30876dfa 84 * @brief ADC Init structure definition
Kojto 107:4f6c30876dfa 85 */
Kojto 107:4f6c30876dfa 86 typedef struct
Kojto 107:4f6c30876dfa 87 {
Kojto 107:4f6c30876dfa 88 uint32_t ClockPrescaler; /*!< Select the frequency of the clock to the ADC. The clock is common for
Kojto 107:4f6c30876dfa 89 all the ADCs.
Kojto 107:4f6c30876dfa 90 This parameter can be a value of @ref ADC_ClockPrescaler */
Kojto 107:4f6c30876dfa 91 uint32_t Resolution; /*!< Configures the ADC resolution dual mode.
Kojto 107:4f6c30876dfa 92 This parameter can be a value of @ref ADC_Resolution */
Kojto 107:4f6c30876dfa 93 uint32_t DataAlign; /*!< Specifies whether the ADC data alignment is left or right.
Kojto 107:4f6c30876dfa 94 This parameter can be a value of @ref ADC_data_align */
Kojto 107:4f6c30876dfa 95 uint32_t ScanConvMode; /*!< Specifies whether the conversion is performed in Scan (multi channels) or
Kojto 107:4f6c30876dfa 96 Single (one channel) mode.
Kojto 107:4f6c30876dfa 97 This parameter can be set to ENABLE or DISABLE */
Kojto 107:4f6c30876dfa 98 uint32_t EOCSelection; /*!< Specifies whether the EOC flag is set
Kojto 107:4f6c30876dfa 99 at the end of single channel conversion or at the end of all conversions.
Kojto 107:4f6c30876dfa 100 This parameter can be a value of @ref ADC_EOCSelection */
Kojto 107:4f6c30876dfa 101 uint32_t ContinuousConvMode; /*!< Specifies whether the conversion is performed in Continuous or Single mode.
Kojto 107:4f6c30876dfa 102 This parameter can be set to ENABLE or DISABLE. */
Kojto 107:4f6c30876dfa 103 uint32_t DMAContinuousRequests; /*!< Specifies whether the DMA requests is performed in Continuous or in Single mode.
Kojto 107:4f6c30876dfa 104 This parameter can be set to ENABLE or DISABLE. */
Kojto 107:4f6c30876dfa 105 uint32_t NbrOfConversion; /*!< Specifies the number of ADC conversions that will be done using the sequencer for
Kojto 107:4f6c30876dfa 106 regular channel group.
Kojto 107:4f6c30876dfa 107 This parameter must be a number between Min_Data = 1 and Max_Data = 16. */
Kojto 107:4f6c30876dfa 108 uint32_t DiscontinuousConvMode; /*!< Specifies whether the conversion is performed in Discontinuous or not
Kojto 107:4f6c30876dfa 109 for regular channels.
Kojto 107:4f6c30876dfa 110 This parameter can be set to ENABLE or DISABLE. */
Kojto 107:4f6c30876dfa 111 uint32_t NbrOfDiscConversion; /*!< Specifies the number of ADC discontinuous conversions that will be done
Kojto 107:4f6c30876dfa 112 using the sequencer for regular channel group.
Kojto 107:4f6c30876dfa 113 This parameter must be a number between Min_Data = 1 and Max_Data = 8. */
Kojto 107:4f6c30876dfa 114 uint32_t ExternalTrigConv; /*!< Selects the external event used to trigger the conversion start of regular group.
Kojto 107:4f6c30876dfa 115 If set to ADC_SOFTWARE_START, external triggers are disabled.
Kojto 107:4f6c30876dfa 116 This parameter can be a value of @ref ADC_External_trigger_Source_Regular
Kojto 107:4f6c30876dfa 117 Note: This parameter can be modified only if there is no conversion is ongoing. */
Kojto 107:4f6c30876dfa 118 uint32_t ExternalTrigConvEdge; /*!< Selects the external trigger edge of regular group.
Kojto 107:4f6c30876dfa 119 If trigger is set to ADC_SOFTWARE_START, this parameter is discarded.
Kojto 107:4f6c30876dfa 120 This parameter can be a value of @ref ADC_External_trigger_edge_Regular
Kojto 107:4f6c30876dfa 121 Note: This parameter can be modified only if there is no conversion is ongoing. */
Kojto 107:4f6c30876dfa 122 }ADC_InitTypeDef;
Kojto 107:4f6c30876dfa 123
Kojto 107:4f6c30876dfa 124 /**
Kojto 107:4f6c30876dfa 125 * @brief ADC handle Structure definition
Kojto 107:4f6c30876dfa 126 */
Kojto 107:4f6c30876dfa 127 typedef struct
Kojto 107:4f6c30876dfa 128 {
Kojto 107:4f6c30876dfa 129 ADC_TypeDef *Instance; /*!< Register base address */
Kojto 107:4f6c30876dfa 130
Kojto 107:4f6c30876dfa 131 ADC_InitTypeDef Init; /*!< ADC required parameters */
Kojto 107:4f6c30876dfa 132
Kojto 107:4f6c30876dfa 133 __IO uint32_t NbrOfCurrentConversionRank; /*!< ADC number of current conversion rank */
Kojto 107:4f6c30876dfa 134
Kojto 107:4f6c30876dfa 135 DMA_HandleTypeDef *DMA_Handle; /*!< Pointer DMA Handler */
Kojto 107:4f6c30876dfa 136
Kojto 107:4f6c30876dfa 137 HAL_LockTypeDef Lock; /*!< ADC locking object */
Kojto 107:4f6c30876dfa 138
Kojto 107:4f6c30876dfa 139 __IO HAL_ADC_StateTypeDef State; /*!< ADC communication state */
Kojto 107:4f6c30876dfa 140
Kojto 107:4f6c30876dfa 141 __IO uint32_t ErrorCode; /*!< ADC Error code */
Kojto 107:4f6c30876dfa 142 }ADC_HandleTypeDef;
Kojto 107:4f6c30876dfa 143
Kojto 107:4f6c30876dfa 144 /**
Kojto 107:4f6c30876dfa 145 * @brief ADC Configuration regular Channel structure definition
Kojto 107:4f6c30876dfa 146 */
Kojto 107:4f6c30876dfa 147 typedef struct
Kojto 107:4f6c30876dfa 148 {
Kojto 107:4f6c30876dfa 149 uint32_t Channel; /*!< The ADC channel to configure.
Kojto 107:4f6c30876dfa 150 This parameter can be a value of @ref ADC_channels */
Kojto 107:4f6c30876dfa 151 uint32_t Rank; /*!< The rank in the regular group sequencer.
Kojto 107:4f6c30876dfa 152 This parameter must be a number between Min_Data = 1 and Max_Data = 16 */
Kojto 107:4f6c30876dfa 153 uint32_t SamplingTime; /*!< The sample time value to be set for the selected channel.
Kojto 107:4f6c30876dfa 154 This parameter can be a value of @ref ADC_sampling_times */
Kojto 107:4f6c30876dfa 155 uint32_t Offset; /*!< Reserved for future use, can be set to 0 */
Kojto 107:4f6c30876dfa 156 }ADC_ChannelConfTypeDef;
Kojto 107:4f6c30876dfa 157
Kojto 107:4f6c30876dfa 158 /**
Kojto 107:4f6c30876dfa 159 * @brief ADC Configuration multi-mode structure definition
Kojto 107:4f6c30876dfa 160 */
Kojto 107:4f6c30876dfa 161 typedef struct
Kojto 107:4f6c30876dfa 162 {
Kojto 107:4f6c30876dfa 163 uint32_t WatchdogMode; /*!< Configures the ADC analog watchdog mode.
Kojto 107:4f6c30876dfa 164 This parameter can be a value of @ref ADC_analog_watchdog_selection */
Kojto 107:4f6c30876dfa 165 uint32_t HighThreshold; /*!< Configures the ADC analog watchdog High threshold value.
Kojto 107:4f6c30876dfa 166 This parameter must be a 12-bit value. */
Kojto 107:4f6c30876dfa 167 uint32_t LowThreshold; /*!< Configures the ADC analog watchdog High threshold value.
Kojto 107:4f6c30876dfa 168 This parameter must be a 12-bit value. */
Kojto 107:4f6c30876dfa 169 uint32_t Channel; /*!< Configures ADC channel for the analog watchdog.
Kojto 107:4f6c30876dfa 170 This parameter has an effect only if watchdog mode is configured on single channel
Kojto 107:4f6c30876dfa 171 This parameter can be a value of @ref ADC_channels */
Kojto 107:4f6c30876dfa 172 uint32_t ITMode; /*!< Specifies whether the analog watchdog is configured
Kojto 107:4f6c30876dfa 173 is interrupt mode or in polling mode.
Kojto 107:4f6c30876dfa 174 This parameter can be set to ENABLE or DISABLE */
Kojto 107:4f6c30876dfa 175 uint32_t WatchdogNumber; /*!< Reserved for future use, can be set to 0 */
Kojto 107:4f6c30876dfa 176 }ADC_AnalogWDGConfTypeDef;
Kojto 107:4f6c30876dfa 177 /**
Kojto 107:4f6c30876dfa 178 * @}
Kojto 107:4f6c30876dfa 179 */
Kojto 107:4f6c30876dfa 180
Kojto 107:4f6c30876dfa 181 /* Exported constants --------------------------------------------------------*/
Kojto 107:4f6c30876dfa 182
Kojto 107:4f6c30876dfa 183 /** @defgroup ADC_Exported_Constants ADC Exported Constants
Kojto 107:4f6c30876dfa 184 * @{
Kojto 107:4f6c30876dfa 185 */
Kojto 107:4f6c30876dfa 186
Kojto 107:4f6c30876dfa 187
Kojto 107:4f6c30876dfa 188 /** @defgroup ADC_Error_Code ADC Error Code
Kojto 107:4f6c30876dfa 189 * @{
Kojto 107:4f6c30876dfa 190 */
Kojto 107:4f6c30876dfa 191
Kojto 107:4f6c30876dfa 192 #define HAL_ADC_ERROR_NONE ((uint32_t)0x00) /*!< No error */
Kojto 107:4f6c30876dfa 193 #define HAL_ADC_ERROR_OVR ((uint32_t)0x01) /*!< OVR error */
Kojto 107:4f6c30876dfa 194 #define HAL_ADC_ERROR_DMA ((uint32_t)0x02) /*!< DMA transfer error */
Kojto 107:4f6c30876dfa 195 /**
Kojto 107:4f6c30876dfa 196 * @}
Kojto 107:4f6c30876dfa 197 */
Kojto 107:4f6c30876dfa 198
Kojto 107:4f6c30876dfa 199
Kojto 107:4f6c30876dfa 200 /** @defgroup ADC_ClockPrescaler ADC Clock Prescaler
Kojto 107:4f6c30876dfa 201 * @{
Kojto 107:4f6c30876dfa 202 */
Kojto 107:4f6c30876dfa 203 #define ADC_CLOCK_SYNC_PCLK_DIV2 ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 204 #define ADC_CLOCK_SYNC_PCLK_DIV4 ((uint32_t)ADC_CCR_ADCPRE_0)
Kojto 107:4f6c30876dfa 205 #define ADC_CLOCK_SYNC_PCLK_DIV6 ((uint32_t)ADC_CCR_ADCPRE_1)
Kojto 107:4f6c30876dfa 206 #define ADC_CLOCK_SYNC_PCLK_DIV8 ((uint32_t)ADC_CCR_ADCPRE)
Kojto 107:4f6c30876dfa 207 /**
Kojto 107:4f6c30876dfa 208 * @}
Kojto 107:4f6c30876dfa 209 */
Kojto 107:4f6c30876dfa 210
Kojto 107:4f6c30876dfa 211 /** @defgroup ADC_delay_between_2_sampling_phases ADC Delay Between 2 Sampling Phases
Kojto 107:4f6c30876dfa 212 * @{
Kojto 107:4f6c30876dfa 213 */
Kojto 107:4f6c30876dfa 214 #define ADC_TWOSAMPLINGDELAY_5CYCLES ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 215 #define ADC_TWOSAMPLINGDELAY_6CYCLES ((uint32_t)ADC_CCR_DELAY_0)
Kojto 107:4f6c30876dfa 216 #define ADC_TWOSAMPLINGDELAY_7CYCLES ((uint32_t)ADC_CCR_DELAY_1)
Kojto 107:4f6c30876dfa 217 #define ADC_TWOSAMPLINGDELAY_8CYCLES ((uint32_t)(ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
Kojto 107:4f6c30876dfa 218 #define ADC_TWOSAMPLINGDELAY_9CYCLES ((uint32_t)ADC_CCR_DELAY_2)
Kojto 107:4f6c30876dfa 219 #define ADC_TWOSAMPLINGDELAY_10CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0))
Kojto 107:4f6c30876dfa 220 #define ADC_TWOSAMPLINGDELAY_11CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1))
Kojto 107:4f6c30876dfa 221 #define ADC_TWOSAMPLINGDELAY_12CYCLES ((uint32_t)(ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
Kojto 107:4f6c30876dfa 222 #define ADC_TWOSAMPLINGDELAY_13CYCLES ((uint32_t)ADC_CCR_DELAY_3)
Kojto 107:4f6c30876dfa 223 #define ADC_TWOSAMPLINGDELAY_14CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_0))
Kojto 107:4f6c30876dfa 224 #define ADC_TWOSAMPLINGDELAY_15CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1))
Kojto 107:4f6c30876dfa 225 #define ADC_TWOSAMPLINGDELAY_16CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_1 | ADC_CCR_DELAY_0))
Kojto 107:4f6c30876dfa 226 #define ADC_TWOSAMPLINGDELAY_17CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2))
Kojto 107:4f6c30876dfa 227 #define ADC_TWOSAMPLINGDELAY_18CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_0))
Kojto 107:4f6c30876dfa 228 #define ADC_TWOSAMPLINGDELAY_19CYCLES ((uint32_t)(ADC_CCR_DELAY_3 | ADC_CCR_DELAY_2 | ADC_CCR_DELAY_1))
Kojto 107:4f6c30876dfa 229 #define ADC_TWOSAMPLINGDELAY_20CYCLES ((uint32_t)ADC_CCR_DELAY)
Kojto 107:4f6c30876dfa 230 /**
Kojto 107:4f6c30876dfa 231 * @}
Kojto 107:4f6c30876dfa 232 */
Kojto 107:4f6c30876dfa 233
Kojto 107:4f6c30876dfa 234 /** @defgroup ADC_Resolution ADC Resolution
Kojto 107:4f6c30876dfa 235 * @{
Kojto 107:4f6c30876dfa 236 */
Kojto 107:4f6c30876dfa 237 #define ADC_RESOLUTION_12B ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 238 #define ADC_RESOLUTION_10B ((uint32_t)ADC_CR1_RES_0)
Kojto 107:4f6c30876dfa 239 #define ADC_RESOLUTION_8B ((uint32_t)ADC_CR1_RES_1)
Kojto 107:4f6c30876dfa 240 #define ADC_RESOLUTION_6B ((uint32_t)ADC_CR1_RES)
Kojto 107:4f6c30876dfa 241 /**
Kojto 107:4f6c30876dfa 242 * @}
Kojto 107:4f6c30876dfa 243 */
Kojto 107:4f6c30876dfa 244
Kojto 107:4f6c30876dfa 245 /** @defgroup ADC_External_trigger_edge_Regular ADC External Trigger Edge Regular
Kojto 107:4f6c30876dfa 246 * @{
Kojto 107:4f6c30876dfa 247 */
Kojto 107:4f6c30876dfa 248 #define ADC_EXTERNALTRIGCONVEDGE_NONE ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 249 #define ADC_EXTERNALTRIGCONVEDGE_RISING ((uint32_t)ADC_CR2_EXTEN_0)
Kojto 107:4f6c30876dfa 250 #define ADC_EXTERNALTRIGCONVEDGE_FALLING ((uint32_t)ADC_CR2_EXTEN_1)
Kojto 107:4f6c30876dfa 251 #define ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING ((uint32_t)ADC_CR2_EXTEN)
Kojto 107:4f6c30876dfa 252 /**
Kojto 107:4f6c30876dfa 253 * @}
Kojto 107:4f6c30876dfa 254 */
Kojto 107:4f6c30876dfa 255
Kojto 107:4f6c30876dfa 256 /** @defgroup ADC_External_trigger_Source_Regular ADC External Trigger Source Regular
Kojto 107:4f6c30876dfa 257 * @{
Kojto 107:4f6c30876dfa 258 */
Kojto 107:4f6c30876dfa 259 /* Note: Parameter ADC_SOFTWARE_START is a software parameter used for */
Kojto 107:4f6c30876dfa 260 /* compatibility with other STM32 devices. */
Kojto 107:4f6c30876dfa 261 #define ADC_EXTERNALTRIGCONV_T1_CC1 ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 262 #define ADC_EXTERNALTRIGCONV_T1_CC2 ((uint32_t)ADC_CR2_EXTSEL_0)
Kojto 107:4f6c30876dfa 263 #define ADC_EXTERNALTRIGCONV_T1_CC3 ((uint32_t)ADC_CR2_EXTSEL_1)
Kojto 107:4f6c30876dfa 264 #define ADC_EXTERNALTRIGCONV_T2_CC2 ((uint32_t)(ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
Kojto 107:4f6c30876dfa 265 #define ADC_EXTERNALTRIGCONV_T5_TRGO ((uint32_t)ADC_CR2_EXTSEL_2)
Kojto 107:4f6c30876dfa 266 #define ADC_EXTERNALTRIGCONV_T4_CC4 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
Kojto 107:4f6c30876dfa 267 #define ADC_EXTERNALTRIGCONV_T3_CC4 ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1))
Kojto 107:4f6c30876dfa 268 #define ADC_EXTERNALTRIGCONV_T8_TRGO ((uint32_t)(ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
Kojto 107:4f6c30876dfa 269 #define ADC_EXTERNALTRIGCONV_T8_TRGO2 ((uint32_t)ADC_CR2_EXTSEL_3)
Kojto 107:4f6c30876dfa 270 #define ADC_EXTERNALTRIGCONV_T1_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_0))
Kojto 107:4f6c30876dfa 271 #define ADC_EXTERNALTRIGCONV_T1_TRGO2 ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1))
Kojto 107:4f6c30876dfa 272 #define ADC_EXTERNALTRIGCONV_T2_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0))
Kojto 107:4f6c30876dfa 273 #define ADC_EXTERNALTRIGCONV_T4_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2))
Kojto 107:4f6c30876dfa 274 #define ADC_EXTERNALTRIGCONV_T6_TRGO ((uint32_t)(ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0))
Kojto 107:4f6c30876dfa 275
Kojto 107:4f6c30876dfa 276 #define ADC_EXTERNALTRIGCONV_EXT_IT11 ((uint32_t)ADC_CR2_EXTSEL)
Kojto 107:4f6c30876dfa 277 #define ADC_SOFTWARE_START ((uint32_t)ADC_CR2_EXTSEL + 1)
Kojto 107:4f6c30876dfa 278 /**
Kojto 107:4f6c30876dfa 279 * @}
Kojto 107:4f6c30876dfa 280 */
Kojto 107:4f6c30876dfa 281
Kojto 107:4f6c30876dfa 282 /** @defgroup ADC_data_align ADC Data Align
Kojto 107:4f6c30876dfa 283 * @{
Kojto 107:4f6c30876dfa 284 */
Kojto 107:4f6c30876dfa 285 #define ADC_DATAALIGN_RIGHT ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 286 #define ADC_DATAALIGN_LEFT ((uint32_t)ADC_CR2_ALIGN)
Kojto 107:4f6c30876dfa 287 /**
Kojto 107:4f6c30876dfa 288 * @}
Kojto 107:4f6c30876dfa 289 */
Kojto 107:4f6c30876dfa 290
Kojto 107:4f6c30876dfa 291 /** @defgroup ADC_channels ADC Common Channels
Kojto 107:4f6c30876dfa 292 * @{
Kojto 107:4f6c30876dfa 293 */
Kojto 107:4f6c30876dfa 294 #define ADC_CHANNEL_0 ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 295 #define ADC_CHANNEL_1 ((uint32_t)ADC_CR1_AWDCH_0)
Kojto 107:4f6c30876dfa 296 #define ADC_CHANNEL_2 ((uint32_t)ADC_CR1_AWDCH_1)
Kojto 107:4f6c30876dfa 297 #define ADC_CHANNEL_3 ((uint32_t)(ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 107:4f6c30876dfa 298 #define ADC_CHANNEL_4 ((uint32_t)ADC_CR1_AWDCH_2)
Kojto 107:4f6c30876dfa 299 #define ADC_CHANNEL_5 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0))
Kojto 107:4f6c30876dfa 300 #define ADC_CHANNEL_6 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1))
Kojto 107:4f6c30876dfa 301 #define ADC_CHANNEL_7 ((uint32_t)(ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 107:4f6c30876dfa 302 #define ADC_CHANNEL_8 ((uint32_t)ADC_CR1_AWDCH_3)
Kojto 107:4f6c30876dfa 303 #define ADC_CHANNEL_9 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0))
Kojto 107:4f6c30876dfa 304 #define ADC_CHANNEL_10 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1))
Kojto 107:4f6c30876dfa 305 #define ADC_CHANNEL_11 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 107:4f6c30876dfa 306 #define ADC_CHANNEL_12 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2))
Kojto 107:4f6c30876dfa 307 #define ADC_CHANNEL_13 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0))
Kojto 107:4f6c30876dfa 308 #define ADC_CHANNEL_14 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1))
Kojto 107:4f6c30876dfa 309 #define ADC_CHANNEL_15 ((uint32_t)(ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0))
Kojto 107:4f6c30876dfa 310 #define ADC_CHANNEL_16 ((uint32_t)ADC_CR1_AWDCH_4)
Kojto 107:4f6c30876dfa 311 #define ADC_CHANNEL_17 ((uint32_t)(ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_0))
Kojto 107:4f6c30876dfa 312 #define ADC_CHANNEL_18 ((uint32_t)(ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_1))
Kojto 107:4f6c30876dfa 313
Kojto 107:4f6c30876dfa 314 #define ADC_CHANNEL_VREFINT ((uint32_t)ADC_CHANNEL_17)
Kojto 107:4f6c30876dfa 315 #define ADC_CHANNEL_VBAT ((uint32_t)ADC_CHANNEL_18)
Kojto 107:4f6c30876dfa 316 /**
Kojto 107:4f6c30876dfa 317 * @}
Kojto 107:4f6c30876dfa 318 */
Kojto 107:4f6c30876dfa 319
Kojto 107:4f6c30876dfa 320 /** @defgroup ADC_sampling_times ADC Sampling Times
Kojto 107:4f6c30876dfa 321 * @{
Kojto 107:4f6c30876dfa 322 */
Kojto 107:4f6c30876dfa 323 #define ADC_SAMPLETIME_3CYCLES ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 324 #define ADC_SAMPLETIME_15CYCLES ((uint32_t)ADC_SMPR1_SMP10_0)
Kojto 107:4f6c30876dfa 325 #define ADC_SAMPLETIME_28CYCLES ((uint32_t)ADC_SMPR1_SMP10_1)
Kojto 107:4f6c30876dfa 326 #define ADC_SAMPLETIME_56CYCLES ((uint32_t)(ADC_SMPR1_SMP10_1 | ADC_SMPR1_SMP10_0))
Kojto 107:4f6c30876dfa 327 #define ADC_SAMPLETIME_84CYCLES ((uint32_t)ADC_SMPR1_SMP10_2)
Kojto 107:4f6c30876dfa 328 #define ADC_SAMPLETIME_112CYCLES ((uint32_t)(ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_0))
Kojto 107:4f6c30876dfa 329 #define ADC_SAMPLETIME_144CYCLES ((uint32_t)(ADC_SMPR1_SMP10_2 | ADC_SMPR1_SMP10_1))
Kojto 107:4f6c30876dfa 330 #define ADC_SAMPLETIME_480CYCLES ((uint32_t)ADC_SMPR1_SMP10)
Kojto 107:4f6c30876dfa 331 /**
Kojto 107:4f6c30876dfa 332 * @}
Kojto 107:4f6c30876dfa 333 */
Kojto 107:4f6c30876dfa 334
Kojto 107:4f6c30876dfa 335 /** @defgroup ADC_EOCSelection ADC EOC Selection
Kojto 107:4f6c30876dfa 336 * @{
Kojto 107:4f6c30876dfa 337 */
Kojto 107:4f6c30876dfa 338 #define ADC_EOC_SEQ_CONV ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 339 #define ADC_EOC_SINGLE_CONV ((uint32_t)0x00000001)
Kojto 107:4f6c30876dfa 340 #define ADC_EOC_SINGLE_SEQ_CONV ((uint32_t)0x00000002) /*!< reserved for future use */
Kojto 107:4f6c30876dfa 341 /**
Kojto 107:4f6c30876dfa 342 * @}
Kojto 107:4f6c30876dfa 343 */
Kojto 107:4f6c30876dfa 344
Kojto 107:4f6c30876dfa 345 /** @defgroup ADC_Event_type ADC Event Type
Kojto 107:4f6c30876dfa 346 * @{
Kojto 107:4f6c30876dfa 347 */
Kojto 107:4f6c30876dfa 348 #define ADC_AWD_EVENT ((uint32_t)ADC_FLAG_AWD)
Kojto 107:4f6c30876dfa 349 #define ADC_OVR_EVENT ((uint32_t)ADC_FLAG_OVR)
Kojto 107:4f6c30876dfa 350 /**
Kojto 107:4f6c30876dfa 351 * @}
Kojto 107:4f6c30876dfa 352 */
Kojto 107:4f6c30876dfa 353
Kojto 107:4f6c30876dfa 354 /** @defgroup ADC_analog_watchdog_selection ADC Analog Watchdog Selection
Kojto 107:4f6c30876dfa 355 * @{
Kojto 107:4f6c30876dfa 356 */
Kojto 107:4f6c30876dfa 357 #define ADC_ANALOGWATCHDOG_SINGLE_REG ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN))
Kojto 107:4f6c30876dfa 358 #define ADC_ANALOGWATCHDOG_SINGLE_INJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_JAWDEN))
Kojto 107:4f6c30876dfa 359 #define ADC_ANALOGWATCHDOG_SINGLE_REGINJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
Kojto 107:4f6c30876dfa 360 #define ADC_ANALOGWATCHDOG_ALL_REG ((uint32_t)ADC_CR1_AWDEN)
Kojto 107:4f6c30876dfa 361 #define ADC_ANALOGWATCHDOG_ALL_INJEC ((uint32_t)ADC_CR1_JAWDEN)
Kojto 107:4f6c30876dfa 362 #define ADC_ANALOGWATCHDOG_ALL_REGINJEC ((uint32_t)(ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
Kojto 107:4f6c30876dfa 363 #define ADC_ANALOGWATCHDOG_NONE ((uint32_t)0x00000000)
Kojto 107:4f6c30876dfa 364 /**
Kojto 107:4f6c30876dfa 365 * @}
Kojto 107:4f6c30876dfa 366 */
Kojto 107:4f6c30876dfa 367
Kojto 107:4f6c30876dfa 368 /** @defgroup ADC_interrupts_definition ADC Interrupts Definition
Kojto 107:4f6c30876dfa 369 * @{
Kojto 107:4f6c30876dfa 370 */
Kojto 107:4f6c30876dfa 371 #define ADC_IT_EOC ((uint32_t)ADC_CR1_EOCIE)
Kojto 107:4f6c30876dfa 372 #define ADC_IT_AWD ((uint32_t)ADC_CR1_AWDIE)
Kojto 107:4f6c30876dfa 373 #define ADC_IT_JEOC ((uint32_t)ADC_CR1_JEOCIE)
Kojto 107:4f6c30876dfa 374 #define ADC_IT_OVR ((uint32_t)ADC_CR1_OVRIE)
Kojto 107:4f6c30876dfa 375 /**
Kojto 107:4f6c30876dfa 376 * @}
Kojto 107:4f6c30876dfa 377 */
Kojto 107:4f6c30876dfa 378
Kojto 107:4f6c30876dfa 379 /** @defgroup ADC_flags_definition ADC Flags Definition
Kojto 107:4f6c30876dfa 380 * @{
Kojto 107:4f6c30876dfa 381 */
Kojto 107:4f6c30876dfa 382 #define ADC_FLAG_AWD ((uint32_t)ADC_SR_AWD)
Kojto 107:4f6c30876dfa 383 #define ADC_FLAG_EOC ((uint32_t)ADC_SR_EOC)
Kojto 107:4f6c30876dfa 384 #define ADC_FLAG_JEOC ((uint32_t)ADC_SR_JEOC)
Kojto 107:4f6c30876dfa 385 #define ADC_FLAG_JSTRT ((uint32_t)ADC_SR_JSTRT)
Kojto 107:4f6c30876dfa 386 #define ADC_FLAG_STRT ((uint32_t)ADC_SR_STRT)
Kojto 107:4f6c30876dfa 387 #define ADC_FLAG_OVR ((uint32_t)ADC_SR_OVR)
Kojto 107:4f6c30876dfa 388 /**
Kojto 107:4f6c30876dfa 389 * @}
Kojto 107:4f6c30876dfa 390 */
Kojto 107:4f6c30876dfa 391
Kojto 107:4f6c30876dfa 392 /** @defgroup ADC_channels_type ADC Channels Type
Kojto 107:4f6c30876dfa 393 * @{
Kojto 107:4f6c30876dfa 394 */
Kojto 107:4f6c30876dfa 395 #define ADC_ALL_CHANNELS ((uint32_t)0x00000001)
Kojto 107:4f6c30876dfa 396 #define ADC_REGULAR_CHANNELS ((uint32_t)0x00000002) /*!< reserved for future use */
Kojto 107:4f6c30876dfa 397 #define ADC_INJECTED_CHANNELS ((uint32_t)0x00000003) /*!< reserved for future use */
Kojto 107:4f6c30876dfa 398 /**
Kojto 107:4f6c30876dfa 399 * @}
Kojto 107:4f6c30876dfa 400 */
Kojto 107:4f6c30876dfa 401
Kojto 107:4f6c30876dfa 402 /**
Kojto 107:4f6c30876dfa 403 * @}
Kojto 107:4f6c30876dfa 404 */
Kojto 107:4f6c30876dfa 405
Kojto 107:4f6c30876dfa 406 /* Exported macro ------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 407 /** @defgroup ADC_Exported_Macros ADC Exported Macros
Kojto 107:4f6c30876dfa 408 * @{
Kojto 107:4f6c30876dfa 409 */
Kojto 107:4f6c30876dfa 410
Kojto 107:4f6c30876dfa 411 /** @brief Reset ADC handle state
Kojto 107:4f6c30876dfa 412 * @param __HANDLE__: ADC handle
Kojto 107:4f6c30876dfa 413 * @retval None
Kojto 107:4f6c30876dfa 414 */
Kojto 107:4f6c30876dfa 415 #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
Kojto 107:4f6c30876dfa 416
Kojto 107:4f6c30876dfa 417 /**
Kojto 107:4f6c30876dfa 418 * @brief Enable the ADC peripheral.
Kojto 107:4f6c30876dfa 419 * @param __HANDLE__: ADC handle
Kojto 107:4f6c30876dfa 420 * @retval None
Kojto 107:4f6c30876dfa 421 */
Kojto 107:4f6c30876dfa 422 #define __HAL_ADC_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR2 |= ADC_CR2_ADON)
Kojto 107:4f6c30876dfa 423
Kojto 107:4f6c30876dfa 424 /**
Kojto 107:4f6c30876dfa 425 * @brief Disable the ADC peripheral.
Kojto 107:4f6c30876dfa 426 * @param __HANDLE__: ADC handle
Kojto 107:4f6c30876dfa 427 * @retval None
Kojto 107:4f6c30876dfa 428 */
Kojto 107:4f6c30876dfa 429 #define __HAL_ADC_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR2 &= ~ADC_CR2_ADON)
Kojto 107:4f6c30876dfa 430
Kojto 107:4f6c30876dfa 431 /**
Kojto 107:4f6c30876dfa 432 * @brief Enable the ADC end of conversion interrupt.
Kojto 107:4f6c30876dfa 433 * @param __HANDLE__: specifies the ADC Handle.
Kojto 107:4f6c30876dfa 434 * @param __INTERRUPT__: ADC Interrupt.
Kojto 107:4f6c30876dfa 435 * @retval None
Kojto 107:4f6c30876dfa 436 */
Kojto 107:4f6c30876dfa 437 #define __HAL_ADC_ENABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1) |= (__INTERRUPT__))
Kojto 107:4f6c30876dfa 438
Kojto 107:4f6c30876dfa 439 /**
Kojto 107:4f6c30876dfa 440 * @brief Disable the ADC end of conversion interrupt.
Kojto 107:4f6c30876dfa 441 * @param __HANDLE__: specifies the ADC Handle.
Kojto 107:4f6c30876dfa 442 * @param __INTERRUPT__: ADC interrupt.
Kojto 107:4f6c30876dfa 443 * @retval None
Kojto 107:4f6c30876dfa 444 */
Kojto 107:4f6c30876dfa 445 #define __HAL_ADC_DISABLE_IT(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1) &= ~(__INTERRUPT__))
Kojto 107:4f6c30876dfa 446
Kojto 107:4f6c30876dfa 447 /** @brief Check if the specified ADC interrupt source is enabled or disabled.
Kojto 107:4f6c30876dfa 448 * @param __HANDLE__: specifies the ADC Handle.
Kojto 107:4f6c30876dfa 449 * @param __INTERRUPT__: specifies the ADC interrupt source to check.
Kojto 107:4f6c30876dfa 450 * @retval The new state of __IT__ (TRUE or FALSE).
Kojto 107:4f6c30876dfa 451 */
Kojto 107:4f6c30876dfa 452 #define __HAL_ADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__))
Kojto 107:4f6c30876dfa 453
Kojto 107:4f6c30876dfa 454 /**
Kojto 107:4f6c30876dfa 455 * @brief Clear the ADC's pending flags.
Kojto 107:4f6c30876dfa 456 * @param __HANDLE__: specifies the ADC Handle.
Kojto 107:4f6c30876dfa 457 * @param __FLAG__: ADC flag.
Kojto 107:4f6c30876dfa 458 * @retval None
Kojto 107:4f6c30876dfa 459 */
Kojto 107:4f6c30876dfa 460 #define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__) (((__HANDLE__)->Instance->SR) = ~(__FLAG__))
Kojto 107:4f6c30876dfa 461
Kojto 107:4f6c30876dfa 462 /**
Kojto 107:4f6c30876dfa 463 * @brief Get the selected ADC's flag status.
Kojto 107:4f6c30876dfa 464 * @param __HANDLE__: specifies the ADC Handle.
Kojto 107:4f6c30876dfa 465 * @param __FLAG__: ADC flag.
Kojto 107:4f6c30876dfa 466 * @retval None
Kojto 107:4f6c30876dfa 467 */
Kojto 107:4f6c30876dfa 468 #define __HAL_ADC_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
Kojto 107:4f6c30876dfa 469
Kojto 107:4f6c30876dfa 470 /**
Kojto 107:4f6c30876dfa 471 * @}
Kojto 107:4f6c30876dfa 472 */
Kojto 107:4f6c30876dfa 473
Kojto 107:4f6c30876dfa 474 /* Include ADC HAL Extension module */
Kojto 107:4f6c30876dfa 475 #include "stm32f7xx_hal_adc_ex.h"
Kojto 107:4f6c30876dfa 476
Kojto 107:4f6c30876dfa 477 /* Exported functions --------------------------------------------------------*/
Kojto 107:4f6c30876dfa 478 /** @addtogroup ADC_Exported_Functions
Kojto 107:4f6c30876dfa 479 * @{
Kojto 107:4f6c30876dfa 480 */
Kojto 107:4f6c30876dfa 481
Kojto 107:4f6c30876dfa 482 /** @addtogroup ADC_Exported_Functions_Group1
Kojto 107:4f6c30876dfa 483 * @{
Kojto 107:4f6c30876dfa 484 */
Kojto 107:4f6c30876dfa 485 /* Initialization/de-initialization functions ***********************************/
Kojto 107:4f6c30876dfa 486 HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 487 HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
Kojto 107:4f6c30876dfa 488 void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 489 void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 490 /**
Kojto 107:4f6c30876dfa 491 * @}
Kojto 107:4f6c30876dfa 492 */
Kojto 107:4f6c30876dfa 493
Kojto 107:4f6c30876dfa 494 /** @addtogroup ADC_Exported_Functions_Group2
Kojto 107:4f6c30876dfa 495 * @{
Kojto 107:4f6c30876dfa 496 */
Kojto 107:4f6c30876dfa 497 /* I/O operation functions ******************************************************/
Kojto 107:4f6c30876dfa 498 HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 499 HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 500 HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
Kojto 107:4f6c30876dfa 501
Kojto 107:4f6c30876dfa 502 HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout);
Kojto 107:4f6c30876dfa 503
Kojto 107:4f6c30876dfa 504 HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 505 HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 506
Kojto 107:4f6c30876dfa 507 void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 508
Kojto 107:4f6c30876dfa 509 HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length);
Kojto 107:4f6c30876dfa 510 HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 511
Kojto 107:4f6c30876dfa 512 uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 513
Kojto 107:4f6c30876dfa 514 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 515 void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 516 void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 517 void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
Kojto 107:4f6c30876dfa 518 /**
Kojto 107:4f6c30876dfa 519 * @}
Kojto 107:4f6c30876dfa 520 */
Kojto 107:4f6c30876dfa 521
Kojto 107:4f6c30876dfa 522 /** @addtogroup ADC_Exported_Functions_Group3
Kojto 107:4f6c30876dfa 523 * @{
Kojto 107:4f6c30876dfa 524 */
Kojto 107:4f6c30876dfa 525 /* Peripheral Control functions *************************************************/
Kojto 107:4f6c30876dfa 526 HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig);
Kojto 107:4f6c30876dfa 527 HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig);
Kojto 107:4f6c30876dfa 528 /**
Kojto 107:4f6c30876dfa 529 * @}
Kojto 107:4f6c30876dfa 530 */
Kojto 107:4f6c30876dfa 531
Kojto 107:4f6c30876dfa 532 /** @addtogroup ADC_Exported_Functions_Group4
Kojto 107:4f6c30876dfa 533 * @{
Kojto 107:4f6c30876dfa 534 */
Kojto 107:4f6c30876dfa 535 /* Peripheral State functions ***************************************************/
Kojto 107:4f6c30876dfa 536 HAL_ADC_StateTypeDef HAL_ADC_GetState(ADC_HandleTypeDef* hadc);
Kojto 107:4f6c30876dfa 537 uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc);
Kojto 107:4f6c30876dfa 538 /**
Kojto 107:4f6c30876dfa 539 * @}
Kojto 107:4f6c30876dfa 540 */
Kojto 107:4f6c30876dfa 541
Kojto 107:4f6c30876dfa 542 /**
Kojto 107:4f6c30876dfa 543 * @}
Kojto 107:4f6c30876dfa 544 */
Kojto 107:4f6c30876dfa 545
Kojto 107:4f6c30876dfa 546 /* Private types -------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 547 /* Private variables ---------------------------------------------------------*/
Kojto 107:4f6c30876dfa 548 /* Private constants ---------------------------------------------------------*/
Kojto 107:4f6c30876dfa 549 /** @defgroup ADC_Private_Constants ADC Private Constants
Kojto 107:4f6c30876dfa 550 * @{
Kojto 107:4f6c30876dfa 551 */
Kojto 107:4f6c30876dfa 552 /* Delay for ADC stabilization time. */
Kojto 107:4f6c30876dfa 553 /* Maximum delay is 1us (refer to device datasheet, parameter tSTAB). */
Kojto 107:4f6c30876dfa 554 /* Unit: us */
Kojto 107:4f6c30876dfa 555 #define ADC_STAB_DELAY_US ((uint32_t) 3)
Kojto 107:4f6c30876dfa 556 /* Delay for temperature sensor stabilization time. */
Kojto 107:4f6c30876dfa 557 /* Maximum delay is 10us (refer to device datasheet, parameter tSTART). */
Kojto 107:4f6c30876dfa 558 /* Unit: us */
Kojto 107:4f6c30876dfa 559 #define ADC_TEMPSENSOR_DELAY_US ((uint32_t) 10)
Kojto 107:4f6c30876dfa 560 /**
Kojto 107:4f6c30876dfa 561 * @}
Kojto 107:4f6c30876dfa 562 */
Kojto 107:4f6c30876dfa 563
Kojto 107:4f6c30876dfa 564 /* Private macros ------------------------------------------------------------*/
Kojto 107:4f6c30876dfa 565 /** @defgroup ADC_Private_Macros ADC Private Macros
Kojto 107:4f6c30876dfa 566 * @{
Kojto 107:4f6c30876dfa 567 */
Kojto 107:4f6c30876dfa 568 #define IS_ADC_CLOCKPRESCALER(__ADC_CLOCK__) (((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV2) || \
Kojto 107:4f6c30876dfa 569 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV4) || \
Kojto 107:4f6c30876dfa 570 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV6) || \
Kojto 107:4f6c30876dfa 571 ((__ADC_CLOCK__) == ADC_CLOCK_SYNC_PCLK_DIV8))
Kojto 107:4f6c30876dfa 572 #define IS_ADC_SAMPLING_DELAY(__DELAY__) (((__DELAY__) == ADC_TWOSAMPLINGDELAY_5CYCLES) || \
Kojto 107:4f6c30876dfa 573 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_6CYCLES) || \
Kojto 107:4f6c30876dfa 574 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_7CYCLES) || \
Kojto 107:4f6c30876dfa 575 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_8CYCLES) || \
Kojto 107:4f6c30876dfa 576 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_9CYCLES) || \
Kojto 107:4f6c30876dfa 577 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_10CYCLES) || \
Kojto 107:4f6c30876dfa 578 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_11CYCLES) || \
Kojto 107:4f6c30876dfa 579 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_12CYCLES) || \
Kojto 107:4f6c30876dfa 580 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_13CYCLES) || \
Kojto 107:4f6c30876dfa 581 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_14CYCLES) || \
Kojto 107:4f6c30876dfa 582 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_15CYCLES) || \
Kojto 107:4f6c30876dfa 583 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_16CYCLES) || \
Kojto 107:4f6c30876dfa 584 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_17CYCLES) || \
Kojto 107:4f6c30876dfa 585 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_18CYCLES) || \
Kojto 107:4f6c30876dfa 586 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_19CYCLES) || \
Kojto 107:4f6c30876dfa 587 ((__DELAY__) == ADC_TWOSAMPLINGDELAY_20CYCLES))
Kojto 107:4f6c30876dfa 588 #define IS_ADC_RESOLUTION(__RESOLUTION__) (((__RESOLUTION__) == ADC_RESOLUTION_12B) || \
Kojto 107:4f6c30876dfa 589 ((__RESOLUTION__) == ADC_RESOLUTION_10B) || \
Kojto 107:4f6c30876dfa 590 ((__RESOLUTION__) == ADC_RESOLUTION_8B) || \
Kojto 107:4f6c30876dfa 591 ((__RESOLUTION__) == ADC_RESOLUTION_6B))
Kojto 107:4f6c30876dfa 592 #define IS_ADC_EXT_TRIG_EDGE(__EDGE__) (((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_NONE) || \
Kojto 107:4f6c30876dfa 593 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_RISING) || \
Kojto 107:4f6c30876dfa 594 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_FALLING) || \
Kojto 107:4f6c30876dfa 595 ((__EDGE__) == ADC_EXTERNALTRIGCONVEDGE_RISINGFALLING))
Kojto 107:4f6c30876dfa 596 #define IS_ADC_EXT_TRIG(__REGTRIG__) (((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_CC1) || \
Kojto 107:4f6c30876dfa 597 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_CC2) || \
Kojto 107:4f6c30876dfa 598 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_CC3) || \
Kojto 107:4f6c30876dfa 599 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T2_CC2) || \
Kojto 107:4f6c30876dfa 600 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T5_TRGO) || \
Kojto 107:4f6c30876dfa 601 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T4_CC4) || \
Kojto 107:4f6c30876dfa 602 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T3_CC4) || \
Kojto 107:4f6c30876dfa 603 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T8_TRGO) || \
Kojto 107:4f6c30876dfa 604 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T8_TRGO2) || \
Kojto 107:4f6c30876dfa 605 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_TRGO) || \
Kojto 107:4f6c30876dfa 606 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T1_TRGO2) || \
Kojto 107:4f6c30876dfa 607 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T2_TRGO) || \
Kojto 107:4f6c30876dfa 608 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T4_TRGO) || \
Kojto 107:4f6c30876dfa 609 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_T6_TRGO) || \
Kojto 107:4f6c30876dfa 610 ((__REGTRIG__) == ADC_EXTERNALTRIGCONV_EXT_IT11) || \
Kojto 107:4f6c30876dfa 611 ((__REGTRIG__) == ADC_SOFTWARE_START))
Kojto 107:4f6c30876dfa 612 #define IS_ADC_DATA_ALIGN(__ALIGN__) (((__ALIGN__) == ADC_DATAALIGN_RIGHT) || \
Kojto 107:4f6c30876dfa 613 ((__ALIGN__) == ADC_DATAALIGN_LEFT))
Kojto 107:4f6c30876dfa 614
Kojto 107:4f6c30876dfa 615 #define IS_ADC_SAMPLE_TIME(__TIME__) (((__TIME__) == ADC_SAMPLETIME_3CYCLES) || \
Kojto 107:4f6c30876dfa 616 ((__TIME__) == ADC_SAMPLETIME_15CYCLES) || \
Kojto 107:4f6c30876dfa 617 ((__TIME__) == ADC_SAMPLETIME_28CYCLES) || \
Kojto 107:4f6c30876dfa 618 ((__TIME__) == ADC_SAMPLETIME_56CYCLES) || \
Kojto 107:4f6c30876dfa 619 ((__TIME__) == ADC_SAMPLETIME_84CYCLES) || \
Kojto 107:4f6c30876dfa 620 ((__TIME__) == ADC_SAMPLETIME_112CYCLES) || \
Kojto 107:4f6c30876dfa 621 ((__TIME__) == ADC_SAMPLETIME_144CYCLES) || \
Kojto 107:4f6c30876dfa 622 ((__TIME__) == ADC_SAMPLETIME_480CYCLES))
Kojto 107:4f6c30876dfa 623 #define IS_ADC_EOCSelection(__EOCSelection__) (((__EOCSelection__) == ADC_EOC_SINGLE_CONV) || \
Kojto 107:4f6c30876dfa 624 ((__EOCSelection__) == ADC_EOC_SEQ_CONV) || \
Kojto 107:4f6c30876dfa 625 ((__EOCSelection__) == ADC_EOC_SINGLE_SEQ_CONV))
Kojto 107:4f6c30876dfa 626 #define IS_ADC_EVENT_TYPE(__EVENT__) (((__EVENT__) == ADC_AWD_EVENT) || \
Kojto 107:4f6c30876dfa 627 ((__EVENT__) == ADC_OVR_EVENT))
Kojto 107:4f6c30876dfa 628 #define IS_ADC_ANALOG_WATCHDOG(__WATCHDOG__) (((__WATCHDOG__) == ADC_ANALOGWATCHDOG_SINGLE_REG) || \
Kojto 107:4f6c30876dfa 629 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_SINGLE_INJEC) || \
Kojto 107:4f6c30876dfa 630 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC) || \
Kojto 107:4f6c30876dfa 631 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_ALL_REG) || \
Kojto 107:4f6c30876dfa 632 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_ALL_INJEC) || \
Kojto 107:4f6c30876dfa 633 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_ALL_REGINJEC) || \
Kojto 107:4f6c30876dfa 634 ((__WATCHDOG__) == ADC_ANALOGWATCHDOG_NONE))
Kojto 107:4f6c30876dfa 635 #define IS_ADC_CHANNELS_TYPE(CHANNEL_TYPE) (((CHANNEL_TYPE) == ADC_ALL_CHANNELS) || \
Kojto 107:4f6c30876dfa 636 ((CHANNEL_TYPE) == ADC_REGULAR_CHANNELS) || \
Kojto 107:4f6c30876dfa 637 ((CHANNEL_TYPE) == ADC_INJECTED_CHANNELS))
Kojto 107:4f6c30876dfa 638 #define IS_ADC_THRESHOLD(__THRESHOLD__) ((__THRESHOLD__) <= ((uint32_t)0xFFF))
Kojto 107:4f6c30876dfa 639 #define IS_ADC_REGULAR_LENGTH(__LENGTH__) (((__LENGTH__) >= ((uint32_t)1)) && ((__LENGTH__) <= ((uint32_t)16)))
Kojto 107:4f6c30876dfa 640 #define IS_ADC_REGULAR_RANK(__RANK__) (((__RANK__) >= ((uint32_t)1)) && ((__RANK__) <= ((uint32_t)16)))
Kojto 107:4f6c30876dfa 641 #define IS_ADC_REGULAR_DISC_NUMBER(__NUMBER__) (((__NUMBER__) >= ((uint32_t)1)) && ((__NUMBER__) <= ((uint32_t)8)))
Kojto 107:4f6c30876dfa 642 #define IS_ADC_RANGE(__RESOLUTION__, __ADC_VALUE__) \
Kojto 107:4f6c30876dfa 643 ((((__RESOLUTION__) == ADC_RESOLUTION_12B) && ((__ADC_VALUE__) <= ((uint32_t)0x0FFF))) || \
Kojto 107:4f6c30876dfa 644 (((__RESOLUTION__) == ADC_RESOLUTION_10B) && ((__ADC_VALUE__) <= ((uint32_t)0x03FF))) || \
Kojto 107:4f6c30876dfa 645 (((__RESOLUTION__) == ADC_RESOLUTION_8B) && ((__ADC_VALUE__) <= ((uint32_t)0x00FF))) || \
Kojto 107:4f6c30876dfa 646 (((__RESOLUTION__) == ADC_RESOLUTION_6B) && ((__ADC_VALUE__) <= ((uint32_t)0x003F))))
Kojto 107:4f6c30876dfa 647
Kojto 107:4f6c30876dfa 648 /**
Kojto 107:4f6c30876dfa 649 * @brief Set ADC Regular channel sequence length.
Kojto 107:4f6c30876dfa 650 * @param _NbrOfConversion_: Regular channel sequence length.
Kojto 107:4f6c30876dfa 651 * @retval None
Kojto 107:4f6c30876dfa 652 */
Kojto 107:4f6c30876dfa 653 #define ADC_SQR1(_NbrOfConversion_) (((_NbrOfConversion_) - (uint8_t)1) << 20)
Kojto 107:4f6c30876dfa 654
Kojto 107:4f6c30876dfa 655 /**
Kojto 107:4f6c30876dfa 656 * @brief Set the ADC's sample time for channel numbers between 10 and 18.
Kojto 107:4f6c30876dfa 657 * @param _SAMPLETIME_: Sample time parameter.
Kojto 107:4f6c30876dfa 658 * @param _CHANNELNB_: Channel number.
Kojto 107:4f6c30876dfa 659 * @retval None
Kojto 107:4f6c30876dfa 660 */
Kojto 107:4f6c30876dfa 661 #define ADC_SMPR1(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3 * (((uint32_t)((uint16_t)(_CHANNELNB_))) - 10)))
Kojto 107:4f6c30876dfa 662
Kojto 107:4f6c30876dfa 663 /**
Kojto 107:4f6c30876dfa 664 * @brief Set the ADC's sample time for channel numbers between 0 and 9.
Kojto 107:4f6c30876dfa 665 * @param _SAMPLETIME_: Sample time parameter.
Kojto 107:4f6c30876dfa 666 * @param _CHANNELNB_: Channel number.
Kojto 107:4f6c30876dfa 667 * @retval None
Kojto 107:4f6c30876dfa 668 */
Kojto 107:4f6c30876dfa 669 #define ADC_SMPR2(_SAMPLETIME_, _CHANNELNB_) ((_SAMPLETIME_) << (3 * ((uint32_t)((uint16_t)(_CHANNELNB_)))))
Kojto 107:4f6c30876dfa 670
Kojto 107:4f6c30876dfa 671 /**
Kojto 107:4f6c30876dfa 672 * @brief Set the selected regular channel rank for rank between 1 and 6.
Kojto 107:4f6c30876dfa 673 * @param _CHANNELNB_: Channel number.
Kojto 107:4f6c30876dfa 674 * @param _RANKNB_: Rank number.
Kojto 107:4f6c30876dfa 675 * @retval None
Kojto 107:4f6c30876dfa 676 */
Kojto 107:4f6c30876dfa 677 #define ADC_SQR3_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5 * ((_RANKNB_) - 1)))
Kojto 107:4f6c30876dfa 678
Kojto 107:4f6c30876dfa 679 /**
Kojto 107:4f6c30876dfa 680 * @brief Set the selected regular channel rank for rank between 7 and 12.
Kojto 107:4f6c30876dfa 681 * @param _CHANNELNB_: Channel number.
Kojto 107:4f6c30876dfa 682 * @param _RANKNB_: Rank number.
Kojto 107:4f6c30876dfa 683 * @retval None
Kojto 107:4f6c30876dfa 684 */
Kojto 107:4f6c30876dfa 685 #define ADC_SQR2_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5 * ((_RANKNB_) - 7)))
Kojto 107:4f6c30876dfa 686
Kojto 107:4f6c30876dfa 687 /**
Kojto 107:4f6c30876dfa 688 * @brief Set the selected regular channel rank for rank between 13 and 16.
Kojto 107:4f6c30876dfa 689 * @param _CHANNELNB_: Channel number.
Kojto 107:4f6c30876dfa 690 * @param _RANKNB_: Rank number.
Kojto 107:4f6c30876dfa 691 * @retval None
Kojto 107:4f6c30876dfa 692 */
Kojto 107:4f6c30876dfa 693 #define ADC_SQR1_RK(_CHANNELNB_, _RANKNB_) (((uint32_t)((uint16_t)(_CHANNELNB_))) << (5 * ((_RANKNB_) - 13)))
Kojto 107:4f6c30876dfa 694
Kojto 107:4f6c30876dfa 695 /**
Kojto 107:4f6c30876dfa 696 * @brief Enable ADC continuous conversion mode.
Kojto 107:4f6c30876dfa 697 * @param _CONTINUOUS_MODE_: Continuous mode.
Kojto 107:4f6c30876dfa 698 * @retval None
Kojto 107:4f6c30876dfa 699 */
Kojto 107:4f6c30876dfa 700 #define ADC_CR2_CONTINUOUS(_CONTINUOUS_MODE_) ((_CONTINUOUS_MODE_) << 1)
Kojto 107:4f6c30876dfa 701
Kojto 107:4f6c30876dfa 702 /**
Kojto 107:4f6c30876dfa 703 * @brief Configures the number of discontinuous conversions for the regular group channels.
Kojto 107:4f6c30876dfa 704 * @param _NBR_DISCONTINUOUSCONV_: Number of discontinuous conversions.
Kojto 107:4f6c30876dfa 705 * @retval None
Kojto 107:4f6c30876dfa 706 */
Kojto 107:4f6c30876dfa 707 #define ADC_CR1_DISCONTINUOUS(_NBR_DISCONTINUOUSCONV_) (((_NBR_DISCONTINUOUSCONV_) - 1) << POSITION_VAL(ADC_CR1_DISCNUM))
Kojto 107:4f6c30876dfa 708
Kojto 107:4f6c30876dfa 709 /**
Kojto 107:4f6c30876dfa 710 * @brief Enable ADC scan mode.
Kojto 107:4f6c30876dfa 711 * @param _SCANCONV_MODE_: Scan conversion mode.
Kojto 107:4f6c30876dfa 712 * @retval None
Kojto 107:4f6c30876dfa 713 */
Kojto 107:4f6c30876dfa 714 #define ADC_CR1_SCANCONV(_SCANCONV_MODE_) ((_SCANCONV_MODE_) << 8)
Kojto 107:4f6c30876dfa 715
Kojto 107:4f6c30876dfa 716 /**
Kojto 107:4f6c30876dfa 717 * @brief Enable the ADC end of conversion selection.
Kojto 107:4f6c30876dfa 718 * @param _EOCSelection_MODE_: End of conversion selection mode.
Kojto 107:4f6c30876dfa 719 * @retval None
Kojto 107:4f6c30876dfa 720 */
Kojto 107:4f6c30876dfa 721 #define ADC_CR2_EOCSelection(_EOCSelection_MODE_) ((_EOCSelection_MODE_) << 10)
Kojto 107:4f6c30876dfa 722
Kojto 107:4f6c30876dfa 723 /**
Kojto 107:4f6c30876dfa 724 * @brief Enable the ADC DMA continuous request.
Kojto 107:4f6c30876dfa 725 * @param _DMAContReq_MODE_: DMA continuous request mode.
Kojto 107:4f6c30876dfa 726 * @retval None
Kojto 107:4f6c30876dfa 727 */
Kojto 107:4f6c30876dfa 728 #define ADC_CR2_DMAContReq(_DMAContReq_MODE_) ((_DMAContReq_MODE_) << 9)
Kojto 107:4f6c30876dfa 729
Kojto 107:4f6c30876dfa 730 /**
Kojto 107:4f6c30876dfa 731 * @brief Return resolution bits in CR1 register.
Kojto 107:4f6c30876dfa 732 * @param __HANDLE__: ADC handle
Kojto 107:4f6c30876dfa 733 * @retval None
Kojto 107:4f6c30876dfa 734 */
Kojto 107:4f6c30876dfa 735 #define ADC_GET_RESOLUTION(__HANDLE__) (((__HANDLE__)->Instance->CR1) & ADC_CR1_RES)
Kojto 107:4f6c30876dfa 736
Kojto 107:4f6c30876dfa 737 /**
Kojto 107:4f6c30876dfa 738 * @}
Kojto 107:4f6c30876dfa 739 */
Kojto 107:4f6c30876dfa 740
Kojto 107:4f6c30876dfa 741 /* Private functions ---------------------------------------------------------*/
Kojto 107:4f6c30876dfa 742 /** @defgroup ADC_Private_Functions ADC Private Functions
Kojto 107:4f6c30876dfa 743 * @{
Kojto 107:4f6c30876dfa 744 */
Kojto 107:4f6c30876dfa 745
Kojto 107:4f6c30876dfa 746 /**
Kojto 107:4f6c30876dfa 747 * @}
Kojto 107:4f6c30876dfa 748 */
Kojto 107:4f6c30876dfa 749
Kojto 107:4f6c30876dfa 750 /**
Kojto 107:4f6c30876dfa 751 * @}
Kojto 107:4f6c30876dfa 752 */
Kojto 107:4f6c30876dfa 753
Kojto 107:4f6c30876dfa 754 /**
Kojto 107:4f6c30876dfa 755 * @}
Kojto 107:4f6c30876dfa 756 */
Kojto 107:4f6c30876dfa 757
Kojto 107:4f6c30876dfa 758 #ifdef __cplusplus
Kojto 107:4f6c30876dfa 759 }
Kojto 107:4f6c30876dfa 760 #endif
Kojto 107:4f6c30876dfa 761
Kojto 107:4f6c30876dfa 762 #endif /*__STM32F7xx_ADC_H */
Kojto 107:4f6c30876dfa 763
Kojto 107:4f6c30876dfa 764
Kojto 107:4f6c30876dfa 765 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/