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