mbed(SerialHalfDuplex入り)

Fork of mbed by mbed official

Committer:
Kojto
Date:
Tue Mar 17 14:27:45 2015 +0000
Revision:
96:487b796308b0
Release 96 of the mbed library

Changes:
- IAR support for ble boards, lpc, ethernet stack
- RTC - attach function to redirect time functions
- Nucleo F103RB - cube driver
- k20xx - fixes for teensy and k20 platforms in sleep/deepsleep and usb
- STM32L0, Nucleo/Disco L053 - refactoring

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Kojto 96:487b796308b0 1 /**
Kojto 96:487b796308b0 2 ******************************************************************************
Kojto 96:487b796308b0 3 * @file stm32f1xx_hal_adc.h
Kojto 96:487b796308b0 4 * @author MCD Application Team
Kojto 96:487b796308b0 5 * @version V1.0.0
Kojto 96:487b796308b0 6 * @date 15-December-2014
Kojto 96:487b796308b0 7 * @brief Header file containing functions prototypes of ADC HAL library.
Kojto 96:487b796308b0 8 ******************************************************************************
Kojto 96:487b796308b0 9 * @attention
Kojto 96:487b796308b0 10 *
Kojto 96:487b796308b0 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
Kojto 96:487b796308b0 12 *
Kojto 96:487b796308b0 13 * Redistribution and use in source and binary forms, with or without modification,
Kojto 96:487b796308b0 14 * are permitted provided that the following conditions are met:
Kojto 96:487b796308b0 15 * 1. Redistributions of source code must retain the above copyright notice,
Kojto 96:487b796308b0 16 * this list of conditions and the following disclaimer.
Kojto 96:487b796308b0 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
Kojto 96:487b796308b0 18 * this list of conditions and the following disclaimer in the documentation
Kojto 96:487b796308b0 19 * and/or other materials provided with the distribution.
Kojto 96:487b796308b0 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
Kojto 96:487b796308b0 21 * may be used to endorse or promote products derived from this software
Kojto 96:487b796308b0 22 * without specific prior written permission.
Kojto 96:487b796308b0 23 *
Kojto 96:487b796308b0 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Kojto 96:487b796308b0 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Kojto 96:487b796308b0 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Kojto 96:487b796308b0 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
Kojto 96:487b796308b0 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Kojto 96:487b796308b0 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Kojto 96:487b796308b0 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Kojto 96:487b796308b0 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Kojto 96:487b796308b0 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Kojto 96:487b796308b0 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Kojto 96:487b796308b0 34 *
Kojto 96:487b796308b0 35 ******************************************************************************
Kojto 96:487b796308b0 36 */
Kojto 96:487b796308b0 37
Kojto 96:487b796308b0 38 /* Define to prevent recursive inclusion -------------------------------------*/
Kojto 96:487b796308b0 39 #ifndef __STM32F1xx_HAL_ADC_H
Kojto 96:487b796308b0 40 #define __STM32F1xx_HAL_ADC_H
Kojto 96:487b796308b0 41
Kojto 96:487b796308b0 42 #ifdef __cplusplus
Kojto 96:487b796308b0 43 extern "C" {
Kojto 96:487b796308b0 44 #endif
Kojto 96:487b796308b0 45
Kojto 96:487b796308b0 46 /* Includes ------------------------------------------------------------------*/
Kojto 96:487b796308b0 47 #include "stm32f1xx_hal_def.h"
Kojto 96:487b796308b0 48 /** @addtogroup STM32F1xx_HAL_Driver
Kojto 96:487b796308b0 49 * @{
Kojto 96:487b796308b0 50 */
Kojto 96:487b796308b0 51
Kojto 96:487b796308b0 52 /** @addtogroup ADC
Kojto 96:487b796308b0 53 * @{
Kojto 96:487b796308b0 54 */
Kojto 96:487b796308b0 55
Kojto 96:487b796308b0 56 /* Exported types ------------------------------------------------------------*/
Kojto 96:487b796308b0 57 /** @defgroup ADC_Exported_Types ADC Exported Types
Kojto 96:487b796308b0 58 * @{
Kojto 96:487b796308b0 59 */
Kojto 96:487b796308b0 60
Kojto 96:487b796308b0 61 /**
Kojto 96:487b796308b0 62 * @brief Structure definition of ADC and regular group initialization
Kojto 96:487b796308b0 63 * @note Parameters of this structure are shared within 2 scopes:
Kojto 96:487b796308b0 64 * - Scope entire ADC (affects regular and injected groups): DataAlign, ScanConvMode.
Kojto 96:487b796308b0 65 * - Scope regular group: ContinuousConvMode, NbrOfConversion, DiscontinuousConvMode, NbrOfDiscConversion, ExternalTrigConvEdge, ExternalTrigConv.
Kojto 96:487b796308b0 66 * @note The setting of these parameters with function HAL_ADC_Init() is conditioned to ADC state.
Kojto 96:487b796308b0 67 * ADC can be either disabled or enabled without conversion on going on regular group.
Kojto 96:487b796308b0 68 */
Kojto 96:487b796308b0 69 typedef struct
Kojto 96:487b796308b0 70 {
Kojto 96:487b796308b0 71 uint32_t DataAlign; /*!< Specifies ADC data alignment to right (MSB on register bit 11 and LSB on register bit 0) (default setting)
Kojto 96:487b796308b0 72 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 96:487b796308b0 73 This parameter can be a value of @ref ADC_Data_align */
Kojto 96:487b796308b0 74 uint32_t ScanConvMode; /*!< Configures the sequencer of regular and injected groups.
Kojto 96:487b796308b0 75 This parameter can be associated to parameter 'DiscontinuousConvMode' to have main sequence subdivided in successive parts.
Kojto 96:487b796308b0 76 If disabled: Conversion is performed in single mode (one channel converted, the one defined in rank 1).
Kojto 96:487b796308b0 77 Parameters 'NbrOfConversion' and 'InjectedNbrOfConversion' are discarded (equivalent to set to 1).
Kojto 96:487b796308b0 78 If enabled: Conversions are performed in sequence mode (multiple ranks defined by 'NbrOfConversion'/'InjectedNbrOfConversion' and each channel rank).
Kojto 96:487b796308b0 79 Scan direction is upward: from rank1 to rank 'n'.
Kojto 96:487b796308b0 80 This parameter can be a value of @ref ADC_Scan_mode
Kojto 96:487b796308b0 81 Note: For regular group, this parameter should be enabled in conversion either by polling (HAL_ADC_Start with Discontinuous mode and NbrOfDiscConversion=1)
Kojto 96:487b796308b0 82 or by DMA (HAL_ADC_Start_DMA), but not by interruption (HAL_ADC_Start_IT): in scan mode, interruption is triggered only on the
Kojto 96:487b796308b0 83 the last conversion of the sequence. All previous conversions would be overwritten by the last one.
Kojto 96:487b796308b0 84 Injected group used with scan mode has not this constraint: each rank has its own result register, no data is overwritten. */
Kojto 96:487b796308b0 85 uint32_t ContinuousConvMode; /*!< Specifies whether the conversion is performed in single mode (one conversion) or continuous mode for regular group,
Kojto 96:487b796308b0 86 after the selected trigger occurred (software start or external trigger).
Kojto 96:487b796308b0 87 This parameter can be set to ENABLE or DISABLE. */
Kojto 96:487b796308b0 88 uint32_t NbrOfConversion; /*!< Specifies the number of ranks that will be converted within the regular group sequencer.
Kojto 96:487b796308b0 89 To use regular group sequencer and convert several ranks, parameter 'ScanConvMode' must be enabled.
Kojto 96:487b796308b0 90 This parameter must be a number between Min_Data = 1 and Max_Data = 16. */
Kojto 96:487b796308b0 91 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 96:487b796308b0 92 Discontinuous mode is used only if sequencer is enabled (parameter 'ScanConvMode'). If sequencer is disabled, this parameter is discarded.
Kojto 96:487b796308b0 93 Discontinuous mode can be enabled only if continuous mode is disabled. If continuous mode is enabled, this parameter setting is discarded.
Kojto 96:487b796308b0 94 This parameter can be set to ENABLE or DISABLE. */
Kojto 96:487b796308b0 95 uint32_t NbrOfDiscConversion; /*!< Specifies the number of discontinuous conversions in which the main sequence of regular group (parameter NbrOfConversion) will be subdivided.
Kojto 96:487b796308b0 96 If parameter 'DiscontinuousConvMode' is disabled, this parameter is discarded.
Kojto 96:487b796308b0 97 This parameter must be a number between Min_Data = 1 and Max_Data = 8. */
Kojto 96:487b796308b0 98 uint32_t ExternalTrigConv; /*!< Selects the external event used to trigger the conversion start of regular group.
Kojto 96:487b796308b0 99 If set to ADC_SOFTWARE_START, external triggers are disabled.
Kojto 96:487b796308b0 100 If set to external trigger source, triggering is on event rising edge.
Kojto 96:487b796308b0 101 This parameter can be a value of @ref ADC_External_trigger_source_Regular */
Kojto 96:487b796308b0 102 }ADC_InitTypeDef;
Kojto 96:487b796308b0 103
Kojto 96:487b796308b0 104 /**
Kojto 96:487b796308b0 105 * @brief Structure definition of ADC channel for regular group
Kojto 96:487b796308b0 106 * @note The setting of these parameters with function HAL_ADC_ConfigChannel() is conditioned to ADC state.
Kojto 96:487b796308b0 107 * ADC can be either disabled or enabled without conversion on going on regular group.
Kojto 96:487b796308b0 108 */
Kojto 96:487b796308b0 109 typedef struct
Kojto 96:487b796308b0 110 {
Kojto 96:487b796308b0 111 uint32_t Channel; /*!< Specifies the channel to configure into ADC regular group.
Kojto 96:487b796308b0 112 This parameter can be a value of @ref ADC_channels
Kojto 96:487b796308b0 113 Note: Depending on devices, some channels may not be available on package pins. Refer to device datasheet for channels availability.
Kojto 96:487b796308b0 114 Note: On STM32F1 devices with several ADC: Only ADC1 can access internal measurement channels (VrefInt/TempSensor)
Kojto 96:487b796308b0 115 Note: On STM32F10xx8 and STM32F10xxB devices: A low-amplitude voltage glitch may be generated (on ADC input 0) on the PA0 pin, when the ADC is converting with injection trigger.
Kojto 96:487b796308b0 116 It is advised to distribute the analog channels so that Channel 0 is configured as an injected channel.
Kojto 96:487b796308b0 117 Refer to errata sheet of these devices for more details. */
Kojto 96:487b796308b0 118 uint32_t Rank; /*!< Specifies the rank in the regular group sequencer
Kojto 96:487b796308b0 119 This parameter can be a value of @ref ADC_regular_rank
Kojto 96:487b796308b0 120 Note: In case of need to disable a channel or change order of conversion sequencer, rank containing a previous channel setting can be overwritten by the new channel setting (or parameter number of conversions can be adjusted) */
Kojto 96:487b796308b0 121 uint32_t SamplingTime; /*!< Sampling time value to be set for the selected channel.
Kojto 96:487b796308b0 122 Unit: ADC clock cycles
Kojto 96:487b796308b0 123 Conversion time is the addition of sampling time and processing time (12.5 ADC clock cycles at ADC resolution 12 bits).
Kojto 96:487b796308b0 124 This parameter can be a value of @ref ADC_sampling_times
Kojto 96:487b796308b0 125 Caution: This parameter updates the parameter property of the channel, that can be used into regular and/or injected groups.
Kojto 96:487b796308b0 126 If this same channel has been previously configured in the other group (regular/injected), it will be updated to last setting.
Kojto 96:487b796308b0 127 Note: In case of usage of internal measurement channels (VrefInt/TempSensor),
Kojto 96:487b796308b0 128 sampling time constraints must be respected (sampling time can be adjusted in function of ADC clock frequency and sampling time setting)
Kojto 96:487b796308b0 129 Refer to device datasheet for timings values, parameters TS_vrefint, TS_temp (values rough order: 5us to 17.1us min). */
Kojto 96:487b796308b0 130 }ADC_ChannelConfTypeDef;
Kojto 96:487b796308b0 131
Kojto 96:487b796308b0 132 /**
Kojto 96:487b796308b0 133 * @brief ADC Configuration analog watchdog definition
Kojto 96:487b796308b0 134 * @note The setting of these parameters with function is conditioned to ADC state.
Kojto 96:487b796308b0 135 * ADC state can be either disabled or enabled without conversion on going on regular and injected groups.
Kojto 96:487b796308b0 136 */
Kojto 96:487b796308b0 137 typedef struct
Kojto 96:487b796308b0 138 {
Kojto 96:487b796308b0 139 uint32_t WatchdogMode; /*!< Configures the ADC analog watchdog mode: single/all channels, regular/injected group.
Kojto 96:487b796308b0 140 This parameter can be a value of @ref ADC_analog_watchdog_mode. */
Kojto 96:487b796308b0 141 uint32_t Channel; /*!< Selects which ADC channel to monitor by analog watchdog.
Kojto 96:487b796308b0 142 This parameter has an effect only if watchdog mode is configured on single channel (parameter WatchdogMode)
Kojto 96:487b796308b0 143 This parameter can be a value of @ref ADC_channels. */
Kojto 96:487b796308b0 144 uint32_t ITMode; /*!< Specifies whether the analog watchdog is configured in interrupt or polling mode.
Kojto 96:487b796308b0 145 This parameter can be set to ENABLE or DISABLE */
Kojto 96:487b796308b0 146 uint32_t HighThreshold; /*!< Configures the ADC analog watchdog High threshold value.
Kojto 96:487b796308b0 147 This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */
Kojto 96:487b796308b0 148 uint32_t LowThreshold; /*!< Configures the ADC analog watchdog High threshold value.
Kojto 96:487b796308b0 149 This parameter must be a number between Min_Data = 0x000 and Max_Data = 0xFFF. */
Kojto 96:487b796308b0 150 uint32_t WatchdogNumber; /*!< Reserved for future use, can be set to 0 */
Kojto 96:487b796308b0 151 }ADC_AnalogWDGConfTypeDef;
Kojto 96:487b796308b0 152
Kojto 96:487b796308b0 153 /**
Kojto 96:487b796308b0 154 * @brief HAL ADC state machine: ADC States structure definition
Kojto 96:487b796308b0 155 */
Kojto 96:487b796308b0 156 typedef enum
Kojto 96:487b796308b0 157 {
Kojto 96:487b796308b0 158 HAL_ADC_STATE_RESET = 0x00, /*!< ADC not yet initialized or disabled */
Kojto 96:487b796308b0 159 HAL_ADC_STATE_READY = 0x01, /*!< ADC peripheral ready for use */
Kojto 96:487b796308b0 160 HAL_ADC_STATE_BUSY = 0x02, /*!< An internal process is ongoing */
Kojto 96:487b796308b0 161 HAL_ADC_STATE_BUSY_REG = 0x12, /*!< Regular conversion is ongoing */
Kojto 96:487b796308b0 162 HAL_ADC_STATE_BUSY_INJ = 0x22, /*!< Injected conversion is ongoing */
Kojto 96:487b796308b0 163 HAL_ADC_STATE_BUSY_INJ_REG = 0x32, /*!< Injected and regular conversion are ongoing */
Kojto 96:487b796308b0 164 HAL_ADC_STATE_TIMEOUT = 0x03, /*!< Timeout state */
Kojto 96:487b796308b0 165 HAL_ADC_STATE_ERROR = 0x04, /*!< ADC state error */
Kojto 96:487b796308b0 166 HAL_ADC_STATE_EOC = 0x05, /*!< Conversion is completed */
Kojto 96:487b796308b0 167 HAL_ADC_STATE_EOC_REG = 0x15, /*!< Regular conversion is completed */
Kojto 96:487b796308b0 168 HAL_ADC_STATE_EOC_INJ = 0x25, /*!< Injected conversion is completed */
Kojto 96:487b796308b0 169 HAL_ADC_STATE_EOC_INJ_REG = 0x35, /*!< Injected and regular conversion are completed */
Kojto 96:487b796308b0 170 HAL_ADC_STATE_AWD = 0x06, /*!< ADC state analog watchdog */
Kojto 96:487b796308b0 171 HAL_ADC_STATE_AWD2 = 0x07, /*!< Not used on STM32F1xx devices (kept for compatibility with other devices featuring several AWD) */
Kojto 96:487b796308b0 172 HAL_ADC_STATE_AWD3 = 0x08, /*!< Not used on STM32F1xx devices (kept for compatibility with other devices featuring several AWD) */
Kojto 96:487b796308b0 173 }HAL_ADC_StateTypeDef;
Kojto 96:487b796308b0 174
Kojto 96:487b796308b0 175 /**
Kojto 96:487b796308b0 176 * @brief ADC handle Structure definition
Kojto 96:487b796308b0 177 */
Kojto 96:487b796308b0 178 typedef struct
Kojto 96:487b796308b0 179 {
Kojto 96:487b796308b0 180 ADC_TypeDef *Instance; /*!< Register base address */
Kojto 96:487b796308b0 181
Kojto 96:487b796308b0 182 ADC_InitTypeDef Init; /*!< ADC required parameters */
Kojto 96:487b796308b0 183
Kojto 96:487b796308b0 184 __IO uint32_t NbrOfConversionRank ; /*!< ADC conversion rank counter */
Kojto 96:487b796308b0 185
Kojto 96:487b796308b0 186 DMA_HandleTypeDef *DMA_Handle; /*!< Pointer DMA Handler */
Kojto 96:487b796308b0 187
Kojto 96:487b796308b0 188 HAL_LockTypeDef Lock; /*!< ADC locking object */
Kojto 96:487b796308b0 189
Kojto 96:487b796308b0 190 __IO HAL_ADC_StateTypeDef State; /*!< ADC communication state */
Kojto 96:487b796308b0 191
Kojto 96:487b796308b0 192 __IO uint32_t ErrorCode; /*!< ADC Error code */
Kojto 96:487b796308b0 193 }ADC_HandleTypeDef;
Kojto 96:487b796308b0 194 /**
Kojto 96:487b796308b0 195 * @}
Kojto 96:487b796308b0 196 */
Kojto 96:487b796308b0 197
Kojto 96:487b796308b0 198
Kojto 96:487b796308b0 199
Kojto 96:487b796308b0 200 /* Exported constants --------------------------------------------------------*/
Kojto 96:487b796308b0 201
Kojto 96:487b796308b0 202 /** @defgroup ADC_Exported_Constants ADC Exported Constants
Kojto 96:487b796308b0 203 * @{
Kojto 96:487b796308b0 204 */
Kojto 96:487b796308b0 205
Kojto 96:487b796308b0 206 /** @defgroup ADC_Error_Code ADC Error Code
Kojto 96:487b796308b0 207 * @{
Kojto 96:487b796308b0 208 */
Kojto 96:487b796308b0 209 #define HAL_ADC_ERROR_NONE ((uint32_t)0x00) /*!< No error */
Kojto 96:487b796308b0 210 #define HAL_ADC_ERROR_INTERNAL ((uint32_t)0x01) /*!< ADC IP internal error: if problem of clocking,
Kojto 96:487b796308b0 211 enable/disable, erroneous state */
Kojto 96:487b796308b0 212 #define HAL_ADC_ERROR_OVR ((uint32_t)0x02) /*!< Overrun error */
Kojto 96:487b796308b0 213 #define HAL_ADC_ERROR_DMA ((uint32_t)0x04) /*!< DMA transfer error */
Kojto 96:487b796308b0 214
Kojto 96:487b796308b0 215 /**
Kojto 96:487b796308b0 216 * @}
Kojto 96:487b796308b0 217 */
Kojto 96:487b796308b0 218
Kojto 96:487b796308b0 219
Kojto 96:487b796308b0 220 /** @defgroup ADC_Data_align ADC data alignment
Kojto 96:487b796308b0 221 * @{
Kojto 96:487b796308b0 222 */
Kojto 96:487b796308b0 223 #define ADC_DATAALIGN_RIGHT ((uint32_t)0x00000000)
Kojto 96:487b796308b0 224 #define ADC_DATAALIGN_LEFT ((uint32_t)ADC_CR2_ALIGN)
Kojto 96:487b796308b0 225 /**
Kojto 96:487b796308b0 226 * @}
Kojto 96:487b796308b0 227 */
Kojto 96:487b796308b0 228
Kojto 96:487b796308b0 229 /** @defgroup ADC_Scan_mode ADC scan mode
Kojto 96:487b796308b0 230 * @{
Kojto 96:487b796308b0 231 */
Kojto 96:487b796308b0 232 /* Note: Scan mode values are not among binary choices ENABLE/DISABLE for */
Kojto 96:487b796308b0 233 /* compatibility with other STM32 devices having a sequencer with */
Kojto 96:487b796308b0 234 /* additional options. */
Kojto 96:487b796308b0 235 #define ADC_SCAN_DISABLE ((uint32_t)0x00000000)
Kojto 96:487b796308b0 236 #define ADC_SCAN_ENABLE ((uint32_t)ADC_CR1_SCAN)
Kojto 96:487b796308b0 237 /**
Kojto 96:487b796308b0 238 * @}
Kojto 96:487b796308b0 239 */
Kojto 96:487b796308b0 240
Kojto 96:487b796308b0 241 /** @defgroup ADC_External_trigger_edge_Regular ADC external trigger enable for regular group
Kojto 96:487b796308b0 242 * @{
Kojto 96:487b796308b0 243 */
Kojto 96:487b796308b0 244 #define ADC_EXTERNALTRIGCONVEDGE_NONE ((uint32_t)0x00000000)
Kojto 96:487b796308b0 245 #define ADC_EXTERNALTRIGCONVEDGE_RISING ((uint32_t)ADC_CR2_EXTTRIG)
Kojto 96:487b796308b0 246 /**
Kojto 96:487b796308b0 247 * @}
Kojto 96:487b796308b0 248 */
Kojto 96:487b796308b0 249
Kojto 96:487b796308b0 250 /** @defgroup ADC_channels ADC channels
Kojto 96:487b796308b0 251 * @{
Kojto 96:487b796308b0 252 */
Kojto 96:487b796308b0 253 /* Note: Depending on devices, some channels may not be available on package */
Kojto 96:487b796308b0 254 /* pins. Refer to device datasheet for channels availability. */
Kojto 96:487b796308b0 255 #define ADC_CHANNEL_0 ((uint32_t)0x00000000)
Kojto 96:487b796308b0 256 #define ADC_CHANNEL_1 ((uint32_t)( ADC_SQR3_SQ1_0))
Kojto 96:487b796308b0 257 #define ADC_CHANNEL_2 ((uint32_t)( ADC_SQR3_SQ1_1 ))
Kojto 96:487b796308b0 258 #define ADC_CHANNEL_3 ((uint32_t)( ADC_SQR3_SQ1_1 | ADC_SQR3_SQ1_0))
Kojto 96:487b796308b0 259 #define ADC_CHANNEL_4 ((uint32_t)( ADC_SQR3_SQ1_2 ))
Kojto 96:487b796308b0 260 #define ADC_CHANNEL_5 ((uint32_t)( ADC_SQR3_SQ1_2 | ADC_SQR3_SQ1_0))
Kojto 96:487b796308b0 261 #define ADC_CHANNEL_6 ((uint32_t)( ADC_SQR3_SQ1_2 | ADC_SQR3_SQ1_1 ))
Kojto 96:487b796308b0 262 #define ADC_CHANNEL_7 ((uint32_t)( ADC_SQR3_SQ1_2 | ADC_SQR3_SQ1_1 | ADC_SQR3_SQ1_0))
Kojto 96:487b796308b0 263 #define ADC_CHANNEL_8 ((uint32_t)( ADC_SQR3_SQ1_3 ))
Kojto 96:487b796308b0 264 #define ADC_CHANNEL_9 ((uint32_t)( ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_0))
Kojto 96:487b796308b0 265 #define ADC_CHANNEL_10 ((uint32_t)( ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_1 ))
Kojto 96:487b796308b0 266 #define ADC_CHANNEL_11 ((uint32_t)( ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_1 | ADC_SQR3_SQ1_0))
Kojto 96:487b796308b0 267 #define ADC_CHANNEL_12 ((uint32_t)( ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_2 ))
Kojto 96:487b796308b0 268 #define ADC_CHANNEL_13 ((uint32_t)( ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_2 | ADC_SQR3_SQ1_0))
Kojto 96:487b796308b0 269 #define ADC_CHANNEL_14 ((uint32_t)( ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_2 | ADC_SQR3_SQ1_1 ))
Kojto 96:487b796308b0 270 #define ADC_CHANNEL_15 ((uint32_t)( ADC_SQR3_SQ1_3 | ADC_SQR3_SQ1_2 | ADC_SQR3_SQ1_1 | ADC_SQR3_SQ1_0))
Kojto 96:487b796308b0 271 #define ADC_CHANNEL_16 ((uint32_t)(ADC_SQR3_SQ1_4 ))
Kojto 96:487b796308b0 272 #define ADC_CHANNEL_17 ((uint32_t)(ADC_SQR3_SQ1_4 | ADC_SQR3_SQ1_0))
Kojto 96:487b796308b0 273
Kojto 96:487b796308b0 274 #define ADC_CHANNEL_TEMPSENSOR ADC_CHANNEL_16 /* ADC internal channel (no connection on device pin) */
Kojto 96:487b796308b0 275 #define ADC_CHANNEL_VREFINT ADC_CHANNEL_17 /* ADC internal channel (no connection on device pin) */
Kojto 96:487b796308b0 276 /**
Kojto 96:487b796308b0 277 * @}
Kojto 96:487b796308b0 278 */
Kojto 96:487b796308b0 279
Kojto 96:487b796308b0 280 /** @defgroup ADC_sampling_times ADC sampling times
Kojto 96:487b796308b0 281 * @{
Kojto 96:487b796308b0 282 */
Kojto 96:487b796308b0 283 #define ADC_SAMPLETIME_1CYCLE_5 ((uint32_t)0x00000000) /*!< Sampling time 1.5 ADC clock cycle */
Kojto 96:487b796308b0 284 #define ADC_SAMPLETIME_7CYCLES_5 ((uint32_t)( ADC_SMPR2_SMP0_0)) /*!< Sampling time 7.5 ADC clock cycles */
Kojto 96:487b796308b0 285 #define ADC_SAMPLETIME_13CYCLES_5 ((uint32_t)( ADC_SMPR2_SMP0_1 )) /*!< Sampling time 13.5 ADC clock cycles */
Kojto 96:487b796308b0 286 #define ADC_SAMPLETIME_28CYCLES_5 ((uint32_t)( ADC_SMPR2_SMP0_1 | ADC_SMPR2_SMP0_0)) /*!< Sampling time 28.5 ADC clock cycles */
Kojto 96:487b796308b0 287 #define ADC_SAMPLETIME_41CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP0_2 )) /*!< Sampling time 41.5 ADC clock cycles */
Kojto 96:487b796308b0 288 #define ADC_SAMPLETIME_55CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP0_2 | ADC_SMPR2_SMP0_0)) /*!< Sampling time 55.5 ADC clock cycles */
Kojto 96:487b796308b0 289 #define ADC_SAMPLETIME_71CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP0_2 | ADC_SMPR2_SMP0_1 )) /*!< Sampling time 71.5 ADC clock cycles */
Kojto 96:487b796308b0 290 #define ADC_SAMPLETIME_239CYCLES_5 ((uint32_t)(ADC_SMPR2_SMP0_2 | ADC_SMPR2_SMP0_1 | ADC_SMPR2_SMP0_0)) /*!< Sampling time 239.5 ADC clock cycles */
Kojto 96:487b796308b0 291 /**
Kojto 96:487b796308b0 292 * @}
Kojto 96:487b796308b0 293 */
Kojto 96:487b796308b0 294
Kojto 96:487b796308b0 295 /** @defgroup ADC_regular_rank ADC rank into regular group
Kojto 96:487b796308b0 296 * @{
Kojto 96:487b796308b0 297 */
Kojto 96:487b796308b0 298 #define ADC_REGULAR_RANK_1 ((uint32_t)0x00000001)
Kojto 96:487b796308b0 299 #define ADC_REGULAR_RANK_2 ((uint32_t)0x00000002)
Kojto 96:487b796308b0 300 #define ADC_REGULAR_RANK_3 ((uint32_t)0x00000003)
Kojto 96:487b796308b0 301 #define ADC_REGULAR_RANK_4 ((uint32_t)0x00000004)
Kojto 96:487b796308b0 302 #define ADC_REGULAR_RANK_5 ((uint32_t)0x00000005)
Kojto 96:487b796308b0 303 #define ADC_REGULAR_RANK_6 ((uint32_t)0x00000006)
Kojto 96:487b796308b0 304 #define ADC_REGULAR_RANK_7 ((uint32_t)0x00000007)
Kojto 96:487b796308b0 305 #define ADC_REGULAR_RANK_8 ((uint32_t)0x00000008)
Kojto 96:487b796308b0 306 #define ADC_REGULAR_RANK_9 ((uint32_t)0x00000009)
Kojto 96:487b796308b0 307 #define ADC_REGULAR_RANK_10 ((uint32_t)0x0000000A)
Kojto 96:487b796308b0 308 #define ADC_REGULAR_RANK_11 ((uint32_t)0x0000000B)
Kojto 96:487b796308b0 309 #define ADC_REGULAR_RANK_12 ((uint32_t)0x0000000C)
Kojto 96:487b796308b0 310 #define ADC_REGULAR_RANK_13 ((uint32_t)0x0000000D)
Kojto 96:487b796308b0 311 #define ADC_REGULAR_RANK_14 ((uint32_t)0x0000000E)
Kojto 96:487b796308b0 312 #define ADC_REGULAR_RANK_15 ((uint32_t)0x0000000F)
Kojto 96:487b796308b0 313 #define ADC_REGULAR_RANK_16 ((uint32_t)0x00000010)
Kojto 96:487b796308b0 314 /**
Kojto 96:487b796308b0 315 * @}
Kojto 96:487b796308b0 316 */
Kojto 96:487b796308b0 317
Kojto 96:487b796308b0 318 /** @defgroup ADC_analog_watchdog_mode ADC analog watchdog mode
Kojto 96:487b796308b0 319 * @{
Kojto 96:487b796308b0 320 */
Kojto 96:487b796308b0 321 #define ADC_ANALOGWATCHDOG_NONE ((uint32_t)0x00000000)
Kojto 96:487b796308b0 322 #define ADC_ANALOGWATCHDOG_SINGLE_REG ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN))
Kojto 96:487b796308b0 323 #define ADC_ANALOGWATCHDOG_SINGLE_INJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_JAWDEN))
Kojto 96:487b796308b0 324 #define ADC_ANALOGWATCHDOG_SINGLE_REGINJEC ((uint32_t)(ADC_CR1_AWDSGL | ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
Kojto 96:487b796308b0 325 #define ADC_ANALOGWATCHDOG_ALL_REG ((uint32_t) ADC_CR1_AWDEN)
Kojto 96:487b796308b0 326 #define ADC_ANALOGWATCHDOG_ALL_INJEC ((uint32_t) ADC_CR1_JAWDEN)
Kojto 96:487b796308b0 327 #define ADC_ANALOGWATCHDOG_ALL_REGINJEC ((uint32_t)(ADC_CR1_AWDEN | ADC_CR1_JAWDEN))
Kojto 96:487b796308b0 328 /**
Kojto 96:487b796308b0 329 * @}
Kojto 96:487b796308b0 330 */
Kojto 96:487b796308b0 331
Kojto 96:487b796308b0 332 /** @defgroup ADC_conversion_group ADC conversion group
Kojto 96:487b796308b0 333 * @{
Kojto 96:487b796308b0 334 */
Kojto 96:487b796308b0 335 #define ADC_REGULAR_GROUP ((uint32_t)(ADC_FLAG_EOC))
Kojto 96:487b796308b0 336 #define ADC_INJECTED_GROUP ((uint32_t)(ADC_FLAG_JEOC))
Kojto 96:487b796308b0 337 #define ADC_REGULAR_INJECTED_GROUP ((uint32_t)(ADC_FLAG_EOC | ADC_FLAG_JEOC))
Kojto 96:487b796308b0 338 /**
Kojto 96:487b796308b0 339 * @}
Kojto 96:487b796308b0 340 */
Kojto 96:487b796308b0 341
Kojto 96:487b796308b0 342 /** @defgroup ADC_Event_type ADC Event type
Kojto 96:487b796308b0 343 * @{
Kojto 96:487b796308b0 344 */
Kojto 96:487b796308b0 345 #define ADC_AWD_EVENT ((uint32_t)ADC_FLAG_AWD) /*!< ADC Analog watchdog event */
Kojto 96:487b796308b0 346
Kojto 96:487b796308b0 347 #define ADC_AWD1_EVENT ADC_AWD_EVENT /*!< ADC Analog watchdog 1 event: Alternate naming for compatibility with other STM32 devices having several analog watchdogs */
Kojto 96:487b796308b0 348 /**
Kojto 96:487b796308b0 349 * @}
Kojto 96:487b796308b0 350 */
Kojto 96:487b796308b0 351
Kojto 96:487b796308b0 352 /** @defgroup ADC_interrupts_definition ADC interrupts definition
Kojto 96:487b796308b0 353 * @{
Kojto 96:487b796308b0 354 */
Kojto 96:487b796308b0 355 #define ADC_IT_EOC ADC_CR1_EOCIE /*!< ADC End of Regular Conversion interrupt source */
Kojto 96:487b796308b0 356 #define ADC_IT_JEOC ADC_CR1_JEOCIE /*!< ADC End of Injected Conversion interrupt source */
Kojto 96:487b796308b0 357 #define ADC_IT_AWD ADC_CR1_AWDIE /*!< ADC Analog watchdog interrupt source */
Kojto 96:487b796308b0 358 /**
Kojto 96:487b796308b0 359 * @}
Kojto 96:487b796308b0 360 */
Kojto 96:487b796308b0 361
Kojto 96:487b796308b0 362 /** @defgroup ADC_flags_definition ADC flags definition
Kojto 96:487b796308b0 363 * @{
Kojto 96:487b796308b0 364 */
Kojto 96:487b796308b0 365 #define ADC_FLAG_STRT ADC_SR_STRT /*!< ADC Regular group start flag */
Kojto 96:487b796308b0 366 #define ADC_FLAG_JSTRT ADC_SR_JSTRT /*!< ADC Injected group start flag */
Kojto 96:487b796308b0 367 #define ADC_FLAG_EOC ADC_SR_EOC /*!< ADC End of Regular conversion flag */
Kojto 96:487b796308b0 368 #define ADC_FLAG_JEOC ADC_SR_JEOC /*!< ADC End of Injected conversion flag */
Kojto 96:487b796308b0 369 #define ADC_FLAG_AWD ADC_SR_AWD /*!< ADC Analog watchdog flag */
Kojto 96:487b796308b0 370 /**
Kojto 96:487b796308b0 371 * @}
Kojto 96:487b796308b0 372 */
Kojto 96:487b796308b0 373
Kojto 96:487b796308b0 374
Kojto 96:487b796308b0 375 /**
Kojto 96:487b796308b0 376 * @}
Kojto 96:487b796308b0 377 */
Kojto 96:487b796308b0 378
Kojto 96:487b796308b0 379 /* Private constants ---------------------------------------------------------*/
Kojto 96:487b796308b0 380
Kojto 96:487b796308b0 381 /** @addtogroup ADC_Private_Constants ADC Private Constants
Kojto 96:487b796308b0 382 * @{
Kojto 96:487b796308b0 383 */
Kojto 96:487b796308b0 384
Kojto 96:487b796308b0 385 /** @defgroup ADC_conversion_cycles ADC conversion cycles
Kojto 96:487b796308b0 386 * @{
Kojto 96:487b796308b0 387 */
Kojto 96:487b796308b0 388 /* ADC conversion cycles (unit: ADC clock cycles) */
Kojto 96:487b796308b0 389 /* (selected sampling time + conversion time of 12.5 ADC clock cycles, with */
Kojto 96:487b796308b0 390 /* resolution 12 bits) */
Kojto 96:487b796308b0 391 #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_1CYCLE5 ((uint32_t) 14)
Kojto 96:487b796308b0 392 #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_7CYCLES5 ((uint32_t) 20)
Kojto 96:487b796308b0 393 #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_13CYCLES5 ((uint32_t) 26)
Kojto 96:487b796308b0 394 #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_28CYCLES5 ((uint32_t) 41)
Kojto 96:487b796308b0 395 #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_41CYCLES5 ((uint32_t) 54)
Kojto 96:487b796308b0 396 #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_55CYCLES5 ((uint32_t) 68)
Kojto 96:487b796308b0 397 #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_71CYCLES5 ((uint32_t) 84)
Kojto 96:487b796308b0 398 #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_239CYCLES5 ((uint32_t)252)
Kojto 96:487b796308b0 399 /**
Kojto 96:487b796308b0 400 * @}
Kojto 96:487b796308b0 401 */
Kojto 96:487b796308b0 402
Kojto 96:487b796308b0 403 /** @defgroup ADC_sampling_times_all_channels ADC sampling times all channels
Kojto 96:487b796308b0 404 * @{
Kojto 96:487b796308b0 405 */
Kojto 96:487b796308b0 406 #define ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT2 \
Kojto 96:487b796308b0 407 (ADC_SMPR2_SMP9_2 | ADC_SMPR2_SMP8_2 | ADC_SMPR2_SMP7_2 | ADC_SMPR2_SMP6_2 | \
Kojto 96:487b796308b0 408 ADC_SMPR2_SMP5_2 | ADC_SMPR2_SMP4_2 | ADC_SMPR2_SMP3_2 | ADC_SMPR2_SMP2_2 | \
Kojto 96:487b796308b0 409 ADC_SMPR2_SMP1_2 | ADC_SMPR2_SMP0_2)
Kojto 96:487b796308b0 410 #define ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT2 \
Kojto 96:487b796308b0 411 (ADC_SMPR1_SMP17_2 | ADC_SMPR1_SMP16_2 | ADC_SMPR1_SMP15_2 | ADC_SMPR1_SMP14_2 | \
Kojto 96:487b796308b0 412 ADC_SMPR1_SMP13_2 | ADC_SMPR1_SMP12_2 | ADC_SMPR1_SMP11_2 | ADC_SMPR1_SMP10_2 )
Kojto 96:487b796308b0 413
Kojto 96:487b796308b0 414 #define ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1 \
Kojto 96:487b796308b0 415 (ADC_SMPR2_SMP9_1 | ADC_SMPR2_SMP8_1 | ADC_SMPR2_SMP7_1 | ADC_SMPR2_SMP6_1 | \
Kojto 96:487b796308b0 416 ADC_SMPR2_SMP5_1 | ADC_SMPR2_SMP4_1 | ADC_SMPR2_SMP3_1 | ADC_SMPR2_SMP2_1 | \
Kojto 96:487b796308b0 417 ADC_SMPR2_SMP1_1 | ADC_SMPR2_SMP0_1)
Kojto 96:487b796308b0 418 #define ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1 \
Kojto 96:487b796308b0 419 (ADC_SMPR1_SMP17_1 | ADC_SMPR1_SMP16_1 | ADC_SMPR1_SMP15_1 | ADC_SMPR1_SMP14_1 | \
Kojto 96:487b796308b0 420 ADC_SMPR1_SMP13_1 | ADC_SMPR1_SMP12_1 | ADC_SMPR1_SMP11_1 | ADC_SMPR1_SMP10_1 )
Kojto 96:487b796308b0 421
Kojto 96:487b796308b0 422 #define ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT0 \
Kojto 96:487b796308b0 423 (ADC_SMPR2_SMP9_0 | ADC_SMPR2_SMP8_0 | ADC_SMPR2_SMP7_0 | ADC_SMPR2_SMP6_0 | \
Kojto 96:487b796308b0 424 ADC_SMPR2_SMP5_0 | ADC_SMPR2_SMP4_0 | ADC_SMPR2_SMP3_0 | ADC_SMPR2_SMP2_0 | \
Kojto 96:487b796308b0 425 ADC_SMPR2_SMP1_0 | ADC_SMPR2_SMP0_0)
Kojto 96:487b796308b0 426 #define ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0 \
Kojto 96:487b796308b0 427 (ADC_SMPR1_SMP17_0 | ADC_SMPR1_SMP16_0 | ADC_SMPR1_SMP15_0 | ADC_SMPR1_SMP14_0 | \
Kojto 96:487b796308b0 428 ADC_SMPR1_SMP13_0 | ADC_SMPR1_SMP12_0 | ADC_SMPR1_SMP11_0 | ADC_SMPR1_SMP10_0 )
Kojto 96:487b796308b0 429
Kojto 96:487b796308b0 430 #define ADC_SAMPLETIME_1CYCLE5_SMPR2ALLCHANNELS ((uint32_t)0x00000000)
Kojto 96:487b796308b0 431 #define ADC_SAMPLETIME_7CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT0)
Kojto 96:487b796308b0 432 #define ADC_SAMPLETIME_13CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1)
Kojto 96:487b796308b0 433 #define ADC_SAMPLETIME_28CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1 | ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT0)
Kojto 96:487b796308b0 434 #define ADC_SAMPLETIME_41CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT2)
Kojto 96:487b796308b0 435 #define ADC_SAMPLETIME_55CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT2 | ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT0)
Kojto 96:487b796308b0 436 #define ADC_SAMPLETIME_71CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT2 | ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1)
Kojto 96:487b796308b0 437 #define ADC_SAMPLETIME_239CYCLES5_SMPR2ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT2 | ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1 | ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT0)
Kojto 96:487b796308b0 438
Kojto 96:487b796308b0 439 #define ADC_SAMPLETIME_1CYCLE5_SMPR1ALLCHANNELS ((uint32_t)0x00000000)
Kojto 96:487b796308b0 440 #define ADC_SAMPLETIME_7CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0)
Kojto 96:487b796308b0 441 #define ADC_SAMPLETIME_13CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1)
Kojto 96:487b796308b0 442 #define ADC_SAMPLETIME_28CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1 | ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0)
Kojto 96:487b796308b0 443 #define ADC_SAMPLETIME_41CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT2)
Kojto 96:487b796308b0 444 #define ADC_SAMPLETIME_55CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT2 | ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0)
Kojto 96:487b796308b0 445 #define ADC_SAMPLETIME_71CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT2 | ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1)
Kojto 96:487b796308b0 446 #define ADC_SAMPLETIME_239CYCLES5_SMPR1ALLCHANNELS (ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT2 | ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1 | ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0)
Kojto 96:487b796308b0 447 /**
Kojto 96:487b796308b0 448 * @}
Kojto 96:487b796308b0 449 */
Kojto 96:487b796308b0 450
Kojto 96:487b796308b0 451 /* Combination of all post-conversion flags bits: EOC/EOS, JEOC/JEOS, OVR, AWDx */
Kojto 96:487b796308b0 452 #define ADC_FLAG_POSTCONV_ALL (ADC_FLAG_EOC | ADC_FLAG_JEOC | ADC_FLAG_AWD )
Kojto 96:487b796308b0 453
Kojto 96:487b796308b0 454 /**
Kojto 96:487b796308b0 455 * @}
Kojto 96:487b796308b0 456 */
Kojto 96:487b796308b0 457
Kojto 96:487b796308b0 458
Kojto 96:487b796308b0 459 /* Exported macro ------------------------------------------------------------*/
Kojto 96:487b796308b0 460
Kojto 96:487b796308b0 461 /** @defgroup ADC_Exported_Macros ADC Exported Macros
Kojto 96:487b796308b0 462 * @{
Kojto 96:487b796308b0 463 */
Kojto 96:487b796308b0 464 /* Macro for internal HAL driver usage, and possibly can be used into code of */
Kojto 96:487b796308b0 465 /* final user. */
Kojto 96:487b796308b0 466
Kojto 96:487b796308b0 467 /**
Kojto 96:487b796308b0 468 * @brief Enable the ADC peripheral
Kojto 96:487b796308b0 469 * @note ADC enable requires a delay for ADC stabilization time
Kojto 96:487b796308b0 470 * (refer to device datasheet, parameter tSTAB)
Kojto 96:487b796308b0 471 * @note On STM32F1, if ADC is already enabled this macro trigs a conversion
Kojto 96:487b796308b0 472 * SW start on regular group.
Kojto 96:487b796308b0 473 * @param __HANDLE__: ADC handle
Kojto 96:487b796308b0 474 * @retval None
Kojto 96:487b796308b0 475 */
Kojto 96:487b796308b0 476 #define __HAL_ADC_ENABLE(__HANDLE__) \
Kojto 96:487b796308b0 477 (SET_BIT((__HANDLE__)->Instance->CR2, (ADC_CR2_ADON)))
Kojto 96:487b796308b0 478
Kojto 96:487b796308b0 479 /**
Kojto 96:487b796308b0 480 * @brief Disable the ADC peripheral
Kojto 96:487b796308b0 481 * @param __HANDLE__: ADC handle
Kojto 96:487b796308b0 482 * @retval None
Kojto 96:487b796308b0 483 */
Kojto 96:487b796308b0 484 #define __HAL_ADC_DISABLE(__HANDLE__) \
Kojto 96:487b796308b0 485 (CLEAR_BIT((__HANDLE__)->Instance->CR2, (ADC_CR2_ADON)))
Kojto 96:487b796308b0 486
Kojto 96:487b796308b0 487 /** @brief Enable the ADC end of conversion interrupt.
Kojto 96:487b796308b0 488 * @param __HANDLE__: ADC handle
Kojto 96:487b796308b0 489 * @param __INTERRUPT__: ADC Interrupt
Kojto 96:487b796308b0 490 * This parameter can be any combination of the following values:
Kojto 96:487b796308b0 491 * @arg ADC_IT_EOC: ADC End of Regular Conversion interrupt source
Kojto 96:487b796308b0 492 * @arg ADC_IT_JEOC: ADC End of Injected Conversion interrupt source
Kojto 96:487b796308b0 493 * @arg ADC_IT_AWD: ADC Analog watchdog interrupt source
Kojto 96:487b796308b0 494 * @retval None
Kojto 96:487b796308b0 495 */
Kojto 96:487b796308b0 496 #define __HAL_ADC_ENABLE_IT(__HANDLE__, __INTERRUPT__) \
Kojto 96:487b796308b0 497 (SET_BIT((__HANDLE__)->Instance->CR1, (__INTERRUPT__)))
Kojto 96:487b796308b0 498
Kojto 96:487b796308b0 499 /** @brief Disable the ADC end of conversion interrupt.
Kojto 96:487b796308b0 500 * @param __HANDLE__: ADC handle
Kojto 96:487b796308b0 501 * @param __INTERRUPT__: ADC Interrupt
Kojto 96:487b796308b0 502 * This parameter can be any combination of the following values:
Kojto 96:487b796308b0 503 * @arg ADC_IT_EOC: ADC End of Regular Conversion interrupt source
Kojto 96:487b796308b0 504 * @arg ADC_IT_JEOC: ADC End of Injected Conversion interrupt source
Kojto 96:487b796308b0 505 * @arg ADC_IT_AWD: ADC Analog watchdog interrupt source
Kojto 96:487b796308b0 506 * @retval None
Kojto 96:487b796308b0 507 */
Kojto 96:487b796308b0 508 #define __HAL_ADC_DISABLE_IT(__HANDLE__, __INTERRUPT__) \
Kojto 96:487b796308b0 509 (CLEAR_BIT((__HANDLE__)->Instance->CR1, (__INTERRUPT__)))
Kojto 96:487b796308b0 510
Kojto 96:487b796308b0 511 /** @brief Checks if the specified ADC interrupt source is enabled or disabled.
Kojto 96:487b796308b0 512 * @param __HANDLE__: ADC handle
Kojto 96:487b796308b0 513 * @param __INTERRUPT__: ADC interrupt source to check
Kojto 96:487b796308b0 514 * This parameter can be any combination of the following values:
Kojto 96:487b796308b0 515 * @arg ADC_IT_EOC: ADC End of Regular Conversion interrupt source
Kojto 96:487b796308b0 516 * @arg ADC_IT_JEOC: ADC End of Injected Conversion interrupt source
Kojto 96:487b796308b0 517 * @arg ADC_IT_AWD: ADC Analog watchdog interrupt source
Kojto 96:487b796308b0 518 * @retval None
Kojto 96:487b796308b0 519 */
Kojto 96:487b796308b0 520 #define __HAL_ADC_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) \
Kojto 96:487b796308b0 521 (((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__))
Kojto 96:487b796308b0 522
Kojto 96:487b796308b0 523 /** @brief Get the selected ADC's flag status.
Kojto 96:487b796308b0 524 * @param __HANDLE__: ADC handle
Kojto 96:487b796308b0 525 * @param __FLAG__: ADC flag
Kojto 96:487b796308b0 526 * This parameter can be any combination of the following values:
Kojto 96:487b796308b0 527 * @arg ADC_FLAG_STRT: ADC Regular group start flag
Kojto 96:487b796308b0 528 * @arg ADC_FLAG_JSTRT: ADC Injected group start flag
Kojto 96:487b796308b0 529 * @arg ADC_FLAG_EOC: ADC End of Regular conversion flag
Kojto 96:487b796308b0 530 * @arg ADC_FLAG_JEOC: ADC End of Injected conversion flag
Kojto 96:487b796308b0 531 * @arg ADC_FLAG_AWD: ADC Analog watchdog flag
Kojto 96:487b796308b0 532 * @retval None
Kojto 96:487b796308b0 533 */
Kojto 96:487b796308b0 534 #define __HAL_ADC_GET_FLAG(__HANDLE__, __FLAG__) \
Kojto 96:487b796308b0 535 ((((__HANDLE__)->Instance->SR) & (__FLAG__)) == (__FLAG__))
Kojto 96:487b796308b0 536
Kojto 96:487b796308b0 537 /** @brief Clear the ADC's pending flags
Kojto 96:487b796308b0 538 * @param __HANDLE__: ADC handle
Kojto 96:487b796308b0 539 * @param __FLAG__: ADC flag
Kojto 96:487b796308b0 540 * This parameter can be any combination of the following values:
Kojto 96:487b796308b0 541 * @arg ADC_FLAG_STRT: ADC Regular group start flag
Kojto 96:487b796308b0 542 * @arg ADC_FLAG_JSTRT: ADC Injected group start flag
Kojto 96:487b796308b0 543 * @arg ADC_FLAG_EOC: ADC End of Regular conversion flag
Kojto 96:487b796308b0 544 * @arg ADC_FLAG_JEOC: ADC End of Injected conversion flag
Kojto 96:487b796308b0 545 * @arg ADC_FLAG_AWD: ADC Analog watchdog flag
Kojto 96:487b796308b0 546 * @retval None
Kojto 96:487b796308b0 547 */
Kojto 96:487b796308b0 548 #define __HAL_ADC_CLEAR_FLAG(__HANDLE__, __FLAG__) \
Kojto 96:487b796308b0 549 (CLEAR_BIT((__HANDLE__)->Instance->SR, (__FLAG__)))
Kojto 96:487b796308b0 550
Kojto 96:487b796308b0 551 /** @brief Reset ADC handle state
Kojto 96:487b796308b0 552 * @param __HANDLE__: ADC handle
Kojto 96:487b796308b0 553 * @retval None
Kojto 96:487b796308b0 554 */
Kojto 96:487b796308b0 555 #define __HAL_ADC_RESET_HANDLE_STATE(__HANDLE__) \
Kojto 96:487b796308b0 556 ((__HANDLE__)->State = HAL_ADC_STATE_RESET)
Kojto 96:487b796308b0 557
Kojto 96:487b796308b0 558 /**
Kojto 96:487b796308b0 559 * @}
Kojto 96:487b796308b0 560 */
Kojto 96:487b796308b0 561
Kojto 96:487b796308b0 562 /* Private macro ------------------------------------------------------------*/
Kojto 96:487b796308b0 563
Kojto 96:487b796308b0 564 /** @defgroup ADC_Private_Macros ADC Private Macros
Kojto 96:487b796308b0 565 * @{
Kojto 96:487b796308b0 566 */
Kojto 96:487b796308b0 567 /* Macro reserved for internal HAL driver usage, not intended to be used in */
Kojto 96:487b796308b0 568 /* code of final user. */
Kojto 96:487b796308b0 569
Kojto 96:487b796308b0 570 /**
Kojto 96:487b796308b0 571 * @brief Verification of ADC state: enabled or disabled
Kojto 96:487b796308b0 572 * @param __HANDLE__: ADC handle
Kojto 96:487b796308b0 573 * @retval SET (ADC enabled) or RESET (ADC disabled)
Kojto 96:487b796308b0 574 */
Kojto 96:487b796308b0 575 #define ADC_IS_ENABLE(__HANDLE__) \
Kojto 96:487b796308b0 576 ((( ((__HANDLE__)->Instance->CR2 & ADC_CR2_ADON) == ADC_CR2_ADON ) \
Kojto 96:487b796308b0 577 ) ? SET : RESET)
Kojto 96:487b796308b0 578
Kojto 96:487b796308b0 579 /**
Kojto 96:487b796308b0 580 * @brief Test if conversion trigger of regular group is software start
Kojto 96:487b796308b0 581 * or external trigger.
Kojto 96:487b796308b0 582 * @param __HANDLE__: ADC handle
Kojto 96:487b796308b0 583 * @retval SET (software start) or RESET (external trigger)
Kojto 96:487b796308b0 584 */
Kojto 96:487b796308b0 585 #define ADC_IS_SOFTWARE_START_REGULAR(__HANDLE__) \
Kojto 96:487b796308b0 586 (READ_BIT((__HANDLE__)->Instance->CR2, ADC_CR2_EXTSEL) == ADC_SOFTWARE_START)
Kojto 96:487b796308b0 587
Kojto 96:487b796308b0 588 /**
Kojto 96:487b796308b0 589 * @brief Test if conversion trigger of injected group is software start
Kojto 96:487b796308b0 590 * or external trigger.
Kojto 96:487b796308b0 591 * @param __HANDLE__: ADC handle
Kojto 96:487b796308b0 592 * @retval SET (software start) or RESET (external trigger)
Kojto 96:487b796308b0 593 */
Kojto 96:487b796308b0 594 #define ADC_IS_SOFTWARE_START_INJECTED(__HANDLE__) \
Kojto 96:487b796308b0 595 (READ_BIT((__HANDLE__)->Instance->CR2, ADC_CR2_JEXTSEL) == ADC_INJECTED_SOFTWARE_START)
Kojto 96:487b796308b0 596
Kojto 96:487b796308b0 597 /**
Kojto 96:487b796308b0 598 * @brief Clear ADC error code (set it to error code: "no error")
Kojto 96:487b796308b0 599 * @param __HANDLE__: ADC handle
Kojto 96:487b796308b0 600 * @retval None
Kojto 96:487b796308b0 601 */
Kojto 96:487b796308b0 602 #define ADC_CLEAR_ERRORCODE(__HANDLE__) \
Kojto 96:487b796308b0 603 ((__HANDLE__)->ErrorCode = HAL_ADC_ERROR_NONE)
Kojto 96:487b796308b0 604
Kojto 96:487b796308b0 605 /**
Kojto 96:487b796308b0 606 * @brief Set ADC number of conversions into regular channel sequence length.
Kojto 96:487b796308b0 607 * @param _NbrOfConversion_: Regular channel sequence length
Kojto 96:487b796308b0 608 * @retval None
Kojto 96:487b796308b0 609 */
Kojto 96:487b796308b0 610 #define ADC_SQR1_L_SHIFT(_NbrOfConversion_) \
Kojto 96:487b796308b0 611 (((_NbrOfConversion_) - (uint8_t)1) << POSITION_VAL(ADC_SQR1_L))
Kojto 96:487b796308b0 612
Kojto 96:487b796308b0 613 /**
Kojto 96:487b796308b0 614 * @brief Set the ADC's sample time for channel numbers between 10 and 18.
Kojto 96:487b796308b0 615 * @param _SAMPLETIME_: Sample time parameter.
Kojto 96:487b796308b0 616 * @param _CHANNELNB_: Channel number.
Kojto 96:487b796308b0 617 * @retval None
Kojto 96:487b796308b0 618 */
Kojto 96:487b796308b0 619 #define ADC_SMPR1(_SAMPLETIME_, _CHANNELNB_) \
Kojto 96:487b796308b0 620 ((_SAMPLETIME_) << (POSITION_VAL(ADC_SMPR1_SMP11) * ((_CHANNELNB_) - 10)))
Kojto 96:487b796308b0 621
Kojto 96:487b796308b0 622 /**
Kojto 96:487b796308b0 623 * @brief Set the ADC's sample time for channel numbers between 0 and 9.
Kojto 96:487b796308b0 624 * @param _SAMPLETIME_: Sample time parameter.
Kojto 96:487b796308b0 625 * @param _CHANNELNB_: Channel number.
Kojto 96:487b796308b0 626 * @retval None
Kojto 96:487b796308b0 627 */
Kojto 96:487b796308b0 628 #define ADC_SMPR2(_SAMPLETIME_, _CHANNELNB_) \
Kojto 96:487b796308b0 629 ((_SAMPLETIME_) << (POSITION_VAL(ADC_SMPR2_SMP1) * (_CHANNELNB_)))
Kojto 96:487b796308b0 630
Kojto 96:487b796308b0 631 /**
Kojto 96:487b796308b0 632 * @brief Set the selected regular channel rank for rank between 1 and 6.
Kojto 96:487b796308b0 633 * @param _CHANNELNB_: Channel number.
Kojto 96:487b796308b0 634 * @param _RANKNB_: Rank number.
Kojto 96:487b796308b0 635 * @retval None
Kojto 96:487b796308b0 636 */
Kojto 96:487b796308b0 637 #define ADC_SQR3_RK(_CHANNELNB_, _RANKNB_) \
Kojto 96:487b796308b0 638 ((_CHANNELNB_) << (POSITION_VAL(ADC_SQR3_SQ2) * ((_RANKNB_) - 1)))
Kojto 96:487b796308b0 639
Kojto 96:487b796308b0 640 /**
Kojto 96:487b796308b0 641 * @brief Set the selected regular channel rank for rank between 7 and 12.
Kojto 96:487b796308b0 642 * @param _CHANNELNB_: Channel number.
Kojto 96:487b796308b0 643 * @param _RANKNB_: Rank number.
Kojto 96:487b796308b0 644 * @retval None
Kojto 96:487b796308b0 645 */
Kojto 96:487b796308b0 646 #define ADC_SQR2_RK(_CHANNELNB_, _RANKNB_) \
Kojto 96:487b796308b0 647 ((_CHANNELNB_) << (POSITION_VAL(ADC_SQR2_SQ8) * ((_RANKNB_) - 7)))
Kojto 96:487b796308b0 648
Kojto 96:487b796308b0 649 /**
Kojto 96:487b796308b0 650 * @brief Set the selected regular channel rank for rank between 13 and 16.
Kojto 96:487b796308b0 651 * @param _CHANNELNB_: Channel number.
Kojto 96:487b796308b0 652 * @param _RANKNB_: Rank number.
Kojto 96:487b796308b0 653 * @retval None
Kojto 96:487b796308b0 654 */
Kojto 96:487b796308b0 655 #define ADC_SQR1_RK(_CHANNELNB_, _RANKNB_) \
Kojto 96:487b796308b0 656 ((_CHANNELNB_) << (POSITION_VAL(ADC_SQR1_SQ14) * ((_RANKNB_) - 13)))
Kojto 96:487b796308b0 657
Kojto 96:487b796308b0 658 /**
Kojto 96:487b796308b0 659 * @brief Set the injected sequence length.
Kojto 96:487b796308b0 660 * @param _JSQR_JL_: Sequence length.
Kojto 96:487b796308b0 661 * @retval None
Kojto 96:487b796308b0 662 */
Kojto 96:487b796308b0 663 #define ADC_JSQR_JL_SHIFT(_JSQR_JL_) \
Kojto 96:487b796308b0 664 (((_JSQR_JL_) -1) << POSITION_VAL(ADC_JSQR_JL))
Kojto 96:487b796308b0 665
Kojto 96:487b796308b0 666 /**
Kojto 96:487b796308b0 667 * @brief Set the selected injected channel rank
Kojto 96:487b796308b0 668 * Note: on STM32F1 devices, channel rank position in JSQR register
Kojto 96:487b796308b0 669 * is depending on total number of ranks selected into
Kojto 96:487b796308b0 670 * injected sequencer (ranks sequence starting from 4-JL)
Kojto 96:487b796308b0 671 * @param _CHANNELNB_: Channel number.
Kojto 96:487b796308b0 672 * @param _RANKNB_: Rank number.
Kojto 96:487b796308b0 673 * @param _JSQR_JL_: Sequence length.
Kojto 96:487b796308b0 674 * @retval None
Kojto 96:487b796308b0 675 */
Kojto 96:487b796308b0 676 #define ADC_JSQR_RK_JL(_CHANNELNB_, _RANKNB_, _JSQR_JL_) \
Kojto 96:487b796308b0 677 ((_CHANNELNB_) << (POSITION_VAL(ADC_JSQR_JSQ2) * ((4 - ((_JSQR_JL_) - (_RANKNB_))) - 1)))
Kojto 96:487b796308b0 678
Kojto 96:487b796308b0 679 /**
Kojto 96:487b796308b0 680 * @brief Enable ADC continuous conversion mode.
Kojto 96:487b796308b0 681 * @param _CONTINUOUS_MODE_: Continuous mode.
Kojto 96:487b796308b0 682 * @retval None
Kojto 96:487b796308b0 683 */
Kojto 96:487b796308b0 684 #define ADC_CR2_CONTINUOUS(_CONTINUOUS_MODE_) \
Kojto 96:487b796308b0 685 ((_CONTINUOUS_MODE_) << POSITION_VAL(ADC_CR2_CONT))
Kojto 96:487b796308b0 686
Kojto 96:487b796308b0 687 /**
Kojto 96:487b796308b0 688 * @brief Configures the number of discontinuous conversions for the regular group channels.
Kojto 96:487b796308b0 689 * @param _NBR_DISCONTINUOUS_CONV_: Number of discontinuous conversions.
Kojto 96:487b796308b0 690 * @retval None
Kojto 96:487b796308b0 691 */
Kojto 96:487b796308b0 692 #define ADC_CR1_DISCONTINUOUS_NUM(_NBR_DISCONTINUOUS_CONV_) \
Kojto 96:487b796308b0 693 (((_NBR_DISCONTINUOUS_CONV_) - 1) << POSITION_VAL(ADC_CR1_DISCNUM))
Kojto 96:487b796308b0 694
Kojto 96:487b796308b0 695 /**
Kojto 96:487b796308b0 696 * @brief Enable ADC scan mode to convert multiple ranks with sequencer.
Kojto 96:487b796308b0 697 * @param _SCAN_MODE_: Scan conversion mode.
Kojto 96:487b796308b0 698 * @retval None
Kojto 96:487b796308b0 699 */
Kojto 96:487b796308b0 700 /* Note: Scan mode is compared to ENABLE for legacy purpose, this parameter */
Kojto 96:487b796308b0 701 /* is equivalent to ADC_SCAN_ENABLE. */
Kojto 96:487b796308b0 702 #define ADC_CR1_SCAN_SET(_SCAN_MODE_) \
Kojto 96:487b796308b0 703 (( ((_SCAN_MODE_) == ADC_SCAN_ENABLE) || ((_SCAN_MODE_) == ENABLE) \
Kojto 96:487b796308b0 704 )? (ADC_SCAN_ENABLE) : (ADC_SCAN_DISABLE) \
Kojto 96:487b796308b0 705 )
Kojto 96:487b796308b0 706
Kojto 96:487b796308b0 707 /**
Kojto 96:487b796308b0 708 * @brief Get the maximum ADC conversion cycles on all channels.
Kojto 96:487b796308b0 709 * Returns the selected sampling time + conversion time (12.5 ADC clock cycles)
Kojto 96:487b796308b0 710 * Approximation of sampling time within 4 ranges, returns the highest value:
Kojto 96:487b796308b0 711 * below 7.5 cycles {1.5 cycle; 7.5 cycles},
Kojto 96:487b796308b0 712 * between 13.5 cycles and 28.5 cycles {13.5 cycles; 28.5 cycles}
Kojto 96:487b796308b0 713 * between 41.5 cycles and 71.5 cycles {41.5 cycles; 55.5 cycles; 71.5cycles}
Kojto 96:487b796308b0 714 * equal to 239.5 cycles
Kojto 96:487b796308b0 715 * Unit: ADC clock cycles
Kojto 96:487b796308b0 716 * @param __HANDLE__: ADC handle
Kojto 96:487b796308b0 717 * @retval ADC conversion cycles on all channels
Kojto 96:487b796308b0 718 */
Kojto 96:487b796308b0 719 #define ADC_CONVCYCLES_MAX_RANGE(__HANDLE__) \
Kojto 96:487b796308b0 720 (( (((__HANDLE__)->Instance->SMPR2 & ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT2) == RESET) && \
Kojto 96:487b796308b0 721 (((__HANDLE__)->Instance->SMPR1 & ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT2) == RESET) ) ? \
Kojto 96:487b796308b0 722 \
Kojto 96:487b796308b0 723 (( (((__HANDLE__)->Instance->SMPR2 & ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1) == RESET) && \
Kojto 96:487b796308b0 724 (((__HANDLE__)->Instance->SMPR1 & ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1) == RESET) ) ? \
Kojto 96:487b796308b0 725 ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_7CYCLES5 : ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_28CYCLES5) \
Kojto 96:487b796308b0 726 : \
Kojto 96:487b796308b0 727 ((((((__HANDLE__)->Instance->SMPR2 & ADC_SAMPLETIME_ALLCHANNELS_SMPR2BIT1) == RESET) && \
Kojto 96:487b796308b0 728 (((__HANDLE__)->Instance->SMPR1 & ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT1) == RESET)) || \
Kojto 96:487b796308b0 729 ((((__HANDLE__)->Instance->SMPR2 & ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0) == RESET) && \
Kojto 96:487b796308b0 730 (((__HANDLE__)->Instance->SMPR1 & ADC_SAMPLETIME_ALLCHANNELS_SMPR1BIT0) == RESET))) ? \
Kojto 96:487b796308b0 731 ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_71CYCLES5 : ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_239CYCLES5) \
Kojto 96:487b796308b0 732 )
Kojto 96:487b796308b0 733
Kojto 96:487b796308b0 734 #define IS_ADC_DATA_ALIGN(ALIGN) (((ALIGN) == ADC_DATAALIGN_RIGHT) || \
Kojto 96:487b796308b0 735 ((ALIGN) == ADC_DATAALIGN_LEFT) )
Kojto 96:487b796308b0 736
Kojto 96:487b796308b0 737 #define IS_ADC_SCAN_MODE(SCAN_MODE) (((SCAN_MODE) == ADC_SCAN_DISABLE) || \
Kojto 96:487b796308b0 738 ((SCAN_MODE) == ADC_SCAN_ENABLE) )
Kojto 96:487b796308b0 739
Kojto 96:487b796308b0 740 #define IS_ADC_EXTTRIG_EDGE(EDGE) (((EDGE) == ADC_EXTERNALTRIGCONVEDGE_NONE) || \
Kojto 96:487b796308b0 741 ((EDGE) == ADC_EXTERNALTRIGCONVEDGE_RISING) )
Kojto 96:487b796308b0 742
Kojto 96:487b796308b0 743 #define IS_ADC_CHANNEL(CHANNEL) (((CHANNEL) == ADC_CHANNEL_0) || \
Kojto 96:487b796308b0 744 ((CHANNEL) == ADC_CHANNEL_1) || \
Kojto 96:487b796308b0 745 ((CHANNEL) == ADC_CHANNEL_2) || \
Kojto 96:487b796308b0 746 ((CHANNEL) == ADC_CHANNEL_3) || \
Kojto 96:487b796308b0 747 ((CHANNEL) == ADC_CHANNEL_4) || \
Kojto 96:487b796308b0 748 ((CHANNEL) == ADC_CHANNEL_5) || \
Kojto 96:487b796308b0 749 ((CHANNEL) == ADC_CHANNEL_6) || \
Kojto 96:487b796308b0 750 ((CHANNEL) == ADC_CHANNEL_7) || \
Kojto 96:487b796308b0 751 ((CHANNEL) == ADC_CHANNEL_8) || \
Kojto 96:487b796308b0 752 ((CHANNEL) == ADC_CHANNEL_9) || \
Kojto 96:487b796308b0 753 ((CHANNEL) == ADC_CHANNEL_10) || \
Kojto 96:487b796308b0 754 ((CHANNEL) == ADC_CHANNEL_11) || \
Kojto 96:487b796308b0 755 ((CHANNEL) == ADC_CHANNEL_12) || \
Kojto 96:487b796308b0 756 ((CHANNEL) == ADC_CHANNEL_13) || \
Kojto 96:487b796308b0 757 ((CHANNEL) == ADC_CHANNEL_14) || \
Kojto 96:487b796308b0 758 ((CHANNEL) == ADC_CHANNEL_15) || \
Kojto 96:487b796308b0 759 ((CHANNEL) == ADC_CHANNEL_16) || \
Kojto 96:487b796308b0 760 ((CHANNEL) == ADC_CHANNEL_17) )
Kojto 96:487b796308b0 761
Kojto 96:487b796308b0 762 #define IS_ADC_SAMPLE_TIME(TIME) (((TIME) == ADC_SAMPLETIME_1CYCLE_5) || \
Kojto 96:487b796308b0 763 ((TIME) == ADC_SAMPLETIME_7CYCLES_5) || \
Kojto 96:487b796308b0 764 ((TIME) == ADC_SAMPLETIME_13CYCLES_5) || \
Kojto 96:487b796308b0 765 ((TIME) == ADC_SAMPLETIME_28CYCLES_5) || \
Kojto 96:487b796308b0 766 ((TIME) == ADC_SAMPLETIME_41CYCLES_5) || \
Kojto 96:487b796308b0 767 ((TIME) == ADC_SAMPLETIME_55CYCLES_5) || \
Kojto 96:487b796308b0 768 ((TIME) == ADC_SAMPLETIME_71CYCLES_5) || \
Kojto 96:487b796308b0 769 ((TIME) == ADC_SAMPLETIME_239CYCLES_5) )
Kojto 96:487b796308b0 770
Kojto 96:487b796308b0 771 #define IS_ADC_REGULAR_RANK(CHANNEL) (((CHANNEL) == ADC_REGULAR_RANK_1 ) || \
Kojto 96:487b796308b0 772 ((CHANNEL) == ADC_REGULAR_RANK_2 ) || \
Kojto 96:487b796308b0 773 ((CHANNEL) == ADC_REGULAR_RANK_3 ) || \
Kojto 96:487b796308b0 774 ((CHANNEL) == ADC_REGULAR_RANK_4 ) || \
Kojto 96:487b796308b0 775 ((CHANNEL) == ADC_REGULAR_RANK_5 ) || \
Kojto 96:487b796308b0 776 ((CHANNEL) == ADC_REGULAR_RANK_6 ) || \
Kojto 96:487b796308b0 777 ((CHANNEL) == ADC_REGULAR_RANK_7 ) || \
Kojto 96:487b796308b0 778 ((CHANNEL) == ADC_REGULAR_RANK_8 ) || \
Kojto 96:487b796308b0 779 ((CHANNEL) == ADC_REGULAR_RANK_9 ) || \
Kojto 96:487b796308b0 780 ((CHANNEL) == ADC_REGULAR_RANK_10) || \
Kojto 96:487b796308b0 781 ((CHANNEL) == ADC_REGULAR_RANK_11) || \
Kojto 96:487b796308b0 782 ((CHANNEL) == ADC_REGULAR_RANK_12) || \
Kojto 96:487b796308b0 783 ((CHANNEL) == ADC_REGULAR_RANK_13) || \
Kojto 96:487b796308b0 784 ((CHANNEL) == ADC_REGULAR_RANK_14) || \
Kojto 96:487b796308b0 785 ((CHANNEL) == ADC_REGULAR_RANK_15) || \
Kojto 96:487b796308b0 786 ((CHANNEL) == ADC_REGULAR_RANK_16) )
Kojto 96:487b796308b0 787
Kojto 96:487b796308b0 788 #define IS_ADC_ANALOG_WATCHDOG_MODE(WATCHDOG) (((WATCHDOG) == ADC_ANALOGWATCHDOG_NONE) || \
Kojto 96:487b796308b0 789 ((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_REG) || \
Kojto 96:487b796308b0 790 ((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_INJEC) || \
Kojto 96:487b796308b0 791 ((WATCHDOG) == ADC_ANALOGWATCHDOG_SINGLE_REGINJEC) || \
Kojto 96:487b796308b0 792 ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_REG) || \
Kojto 96:487b796308b0 793 ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_INJEC) || \
Kojto 96:487b796308b0 794 ((WATCHDOG) == ADC_ANALOGWATCHDOG_ALL_REGINJEC) )
Kojto 96:487b796308b0 795
Kojto 96:487b796308b0 796 #define IS_ADC_CONVERSION_GROUP(CONVERSION) (((CONVERSION) == ADC_REGULAR_GROUP) || \
Kojto 96:487b796308b0 797 ((CONVERSION) == ADC_INJECTED_GROUP) || \
Kojto 96:487b796308b0 798 ((CONVERSION) == ADC_REGULAR_INJECTED_GROUP) )
Kojto 96:487b796308b0 799
Kojto 96:487b796308b0 800 #define IS_ADC_EVENT_TYPE(EVENT) ((EVENT) == ADC_AWD_EVENT)
Kojto 96:487b796308b0 801
Kojto 96:487b796308b0 802
Kojto 96:487b796308b0 803 /** @defgroup ADC_range_verification ADC range verification
Kojto 96:487b796308b0 804 * For a unique ADC resolution: 12 bits
Kojto 96:487b796308b0 805 * @{
Kojto 96:487b796308b0 806 */
Kojto 96:487b796308b0 807 #define IS_ADC_RANGE(ADC_VALUE) ((ADC_VALUE) <= ((uint32_t)0x0FFF))
Kojto 96:487b796308b0 808 /**
Kojto 96:487b796308b0 809 * @}
Kojto 96:487b796308b0 810 */
Kojto 96:487b796308b0 811
Kojto 96:487b796308b0 812 /** @defgroup ADC_regular_nb_conv_verification ADC regular nb conv verification
Kojto 96:487b796308b0 813 * @{
Kojto 96:487b796308b0 814 */
Kojto 96:487b796308b0 815 #define IS_ADC_REGULAR_NB_CONV(LENGTH) (((LENGTH) >= ((uint32_t)1)) && ((LENGTH) <= ((uint32_t)16)))
Kojto 96:487b796308b0 816 /**
Kojto 96:487b796308b0 817 * @}
Kojto 96:487b796308b0 818 */
Kojto 96:487b796308b0 819
Kojto 96:487b796308b0 820 /** @defgroup ADC_regular_discontinuous_mode_number_verification ADC regular discontinuous mode number verification
Kojto 96:487b796308b0 821 * @{
Kojto 96:487b796308b0 822 */
Kojto 96:487b796308b0 823 #define IS_ADC_REGULAR_DISCONT_NUMBER(NUMBER) (((NUMBER) >= ((uint32_t)1)) && ((NUMBER) <= ((uint32_t)8)))
Kojto 96:487b796308b0 824 /**
Kojto 96:487b796308b0 825 * @}
Kojto 96:487b796308b0 826 */
Kojto 96:487b796308b0 827
Kojto 96:487b796308b0 828 /**
Kojto 96:487b796308b0 829 * @}
Kojto 96:487b796308b0 830 */
Kojto 96:487b796308b0 831
Kojto 96:487b796308b0 832 /* Include ADC HAL Extension module */
Kojto 96:487b796308b0 833 #include "stm32f1xx_hal_adc_ex.h"
Kojto 96:487b796308b0 834
Kojto 96:487b796308b0 835 /* Exported functions --------------------------------------------------------*/
Kojto 96:487b796308b0 836 /** @addtogroup ADC_Exported_Functions
Kojto 96:487b796308b0 837 * @{
Kojto 96:487b796308b0 838 */
Kojto 96:487b796308b0 839
Kojto 96:487b796308b0 840 /** @addtogroup ADC_Exported_Functions_Group1
Kojto 96:487b796308b0 841 * @{
Kojto 96:487b796308b0 842 */
Kojto 96:487b796308b0 843
Kojto 96:487b796308b0 844
Kojto 96:487b796308b0 845 /* Initialization and de-initialization functions **********************************/
Kojto 96:487b796308b0 846 HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc);
Kojto 96:487b796308b0 847 HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef *hadc);
Kojto 96:487b796308b0 848 void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc);
Kojto 96:487b796308b0 849 void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc);
Kojto 96:487b796308b0 850 /**
Kojto 96:487b796308b0 851 * @}
Kojto 96:487b796308b0 852 */
Kojto 96:487b796308b0 853
Kojto 96:487b796308b0 854 /* IO operation functions *****************************************************/
Kojto 96:487b796308b0 855
Kojto 96:487b796308b0 856 /** @addtogroup ADC_Exported_Functions_Group2
Kojto 96:487b796308b0 857 * @{
Kojto 96:487b796308b0 858 */
Kojto 96:487b796308b0 859
Kojto 96:487b796308b0 860
Kojto 96:487b796308b0 861 /* Blocking mode: Polling */
Kojto 96:487b796308b0 862 HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc);
Kojto 96:487b796308b0 863 HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc);
Kojto 96:487b796308b0 864 HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout);
Kojto 96:487b796308b0 865 HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout);
Kojto 96:487b796308b0 866
Kojto 96:487b796308b0 867 /* Non-blocking mode: Interruption */
Kojto 96:487b796308b0 868 HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc);
Kojto 96:487b796308b0 869 HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc);
Kojto 96:487b796308b0 870
Kojto 96:487b796308b0 871 /* Non-blocking mode: DMA */
Kojto 96:487b796308b0 872 HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length);
Kojto 96:487b796308b0 873 HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc);
Kojto 96:487b796308b0 874
Kojto 96:487b796308b0 875 /* ADC retrieve conversion value intended to be used with polling or interruption */
Kojto 96:487b796308b0 876 uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc);
Kojto 96:487b796308b0 877
Kojto 96:487b796308b0 878 /* ADC IRQHandler and Callbacks used in non-blocking modes (Interruption and DMA) */
Kojto 96:487b796308b0 879 void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc);
Kojto 96:487b796308b0 880 void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc);
Kojto 96:487b796308b0 881 void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc);
Kojto 96:487b796308b0 882 void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc);
Kojto 96:487b796308b0 883 void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc);
Kojto 96:487b796308b0 884 /**
Kojto 96:487b796308b0 885 * @}
Kojto 96:487b796308b0 886 */
Kojto 96:487b796308b0 887
Kojto 96:487b796308b0 888
Kojto 96:487b796308b0 889 /* Peripheral Control functions ***********************************************/
Kojto 96:487b796308b0 890 /** @addtogroup ADC_Exported_Functions_Group3
Kojto 96:487b796308b0 891 * @{
Kojto 96:487b796308b0 892 */
Kojto 96:487b796308b0 893 HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig);
Kojto 96:487b796308b0 894 HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig);
Kojto 96:487b796308b0 895 /**
Kojto 96:487b796308b0 896 * @}
Kojto 96:487b796308b0 897 */
Kojto 96:487b796308b0 898
Kojto 96:487b796308b0 899
Kojto 96:487b796308b0 900 /* Peripheral State functions *************************************************/
Kojto 96:487b796308b0 901 /** @addtogroup ADC_Exported_Functions_Group4
Kojto 96:487b796308b0 902 * @{
Kojto 96:487b796308b0 903 */
Kojto 96:487b796308b0 904 HAL_ADC_StateTypeDef HAL_ADC_GetState(ADC_HandleTypeDef* hadc);
Kojto 96:487b796308b0 905 uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc);
Kojto 96:487b796308b0 906 /**
Kojto 96:487b796308b0 907 * @}
Kojto 96:487b796308b0 908 */
Kojto 96:487b796308b0 909
Kojto 96:487b796308b0 910
Kojto 96:487b796308b0 911 /**
Kojto 96:487b796308b0 912 * @}
Kojto 96:487b796308b0 913 */
Kojto 96:487b796308b0 914
Kojto 96:487b796308b0 915
Kojto 96:487b796308b0 916 /* Internal HAL driver functions **********************************************/
Kojto 96:487b796308b0 917 /** @addtogroup ADC_Private_Functions
Kojto 96:487b796308b0 918 * @{
Kojto 96:487b796308b0 919 */
Kojto 96:487b796308b0 920 HAL_StatusTypeDef ADC_Enable(ADC_HandleTypeDef* hadc);
Kojto 96:487b796308b0 921 HAL_StatusTypeDef ADC_ConversionStop_Disable(ADC_HandleTypeDef* hadc);
Kojto 96:487b796308b0 922 void ADC_StabilizationTime(uint32_t DelayUs);
Kojto 96:487b796308b0 923 void ADC_DMAConvCplt(DMA_HandleTypeDef *hdma);
Kojto 96:487b796308b0 924 void ADC_DMAHalfConvCplt(DMA_HandleTypeDef *hdma);
Kojto 96:487b796308b0 925 void ADC_DMAError(DMA_HandleTypeDef *hdma);
Kojto 96:487b796308b0 926 /**
Kojto 96:487b796308b0 927 * @}
Kojto 96:487b796308b0 928 */
Kojto 96:487b796308b0 929
Kojto 96:487b796308b0 930
Kojto 96:487b796308b0 931 /**
Kojto 96:487b796308b0 932 * @}
Kojto 96:487b796308b0 933 */
Kojto 96:487b796308b0 934
Kojto 96:487b796308b0 935 /**
Kojto 96:487b796308b0 936 * @}
Kojto 96:487b796308b0 937 */
Kojto 96:487b796308b0 938
Kojto 96:487b796308b0 939 #ifdef __cplusplus
Kojto 96:487b796308b0 940 }
Kojto 96:487b796308b0 941 #endif
Kojto 96:487b796308b0 942
Kojto 96:487b796308b0 943
Kojto 96:487b796308b0 944 #endif /* __STM32F1xx_HAL_ADC_H */
Kojto 96:487b796308b0 945
Kojto 96:487b796308b0 946 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/