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