Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: SPIne CH_Communicatuin_Test CH_Communicatuin_Test2 MCP_SPIne ... more
Fork of mbed-dev-f303 by
targets/TARGET_STM/TARGET_STM32F3/device/stm32f3xx_hal_adc.c@179:97f825502e2a, 2018-05-02 (annotated)
- Committer:
- benkatz
- Date:
- Wed May 02 18:08:16 2018 +0000
- Revision:
- 179:97f825502e2a
- Parent:
- 157:ff67d9f36b67
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 144:ef7eb2e8f9f7 | 1 | /** |
<> | 144:ef7eb2e8f9f7 | 2 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 3 | * @file stm32f3xx_hal_adc.c |
<> | 144:ef7eb2e8f9f7 | 4 | * @author MCD Application Team |
<> | 157:ff67d9f36b67 | 5 | * @version V1.4.0 |
<> | 157:ff67d9f36b67 | 6 | * @date 16-December-2016 |
<> | 144:ef7eb2e8f9f7 | 7 | * @brief This file provides firmware functions to manage the following |
<> | 144:ef7eb2e8f9f7 | 8 | * functionalities of the Analog to Digital Convertor (ADC) |
<> | 144:ef7eb2e8f9f7 | 9 | * peripheral: |
<> | 144:ef7eb2e8f9f7 | 10 | * + Initialization and de-initialization functions |
<> | 144:ef7eb2e8f9f7 | 11 | * ++ Initialization and Configuration of ADC |
<> | 144:ef7eb2e8f9f7 | 12 | * + Operation functions |
<> | 144:ef7eb2e8f9f7 | 13 | * ++ Start, stop, get result of conversions of regular |
<> | 144:ef7eb2e8f9f7 | 14 | * group, using 3 possible modes: polling, interruption or DMA. |
<> | 144:ef7eb2e8f9f7 | 15 | * + Control functions |
<> | 144:ef7eb2e8f9f7 | 16 | * ++ Channels configuration on regular group |
<> | 144:ef7eb2e8f9f7 | 17 | * ++ Channels configuration on injected group |
<> | 144:ef7eb2e8f9f7 | 18 | * ++ Analog Watchdog configuration |
<> | 144:ef7eb2e8f9f7 | 19 | * + State functions |
<> | 144:ef7eb2e8f9f7 | 20 | * ++ ADC state machine management |
<> | 144:ef7eb2e8f9f7 | 21 | * ++ Interrupts and flags management |
<> | 144:ef7eb2e8f9f7 | 22 | * Other functions (extended functions) are available in file |
<> | 144:ef7eb2e8f9f7 | 23 | * "stm32f3xx_hal_adc_ex.c". |
<> | 144:ef7eb2e8f9f7 | 24 | * |
<> | 144:ef7eb2e8f9f7 | 25 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 26 | ============================================================================== |
<> | 144:ef7eb2e8f9f7 | 27 | ##### ADC peripheral features ##### |
<> | 144:ef7eb2e8f9f7 | 28 | ============================================================================== |
<> | 144:ef7eb2e8f9f7 | 29 | [..] |
<> | 144:ef7eb2e8f9f7 | 30 | (+) 12-bit, 10-bit, 8-bit or 6-bit configurable resolution (available only on |
<> | 144:ef7eb2e8f9f7 | 31 | STM32F30xxC devices). |
<> | 144:ef7eb2e8f9f7 | 32 | |
<> | 144:ef7eb2e8f9f7 | 33 | (+) Interrupt generation at the end of regular conversion, end of injected |
<> | 144:ef7eb2e8f9f7 | 34 | conversion, and in case of analog watchdog or overrun events. |
<> | 144:ef7eb2e8f9f7 | 35 | |
<> | 144:ef7eb2e8f9f7 | 36 | (+) Single and continuous conversion modes. |
<> | 144:ef7eb2e8f9f7 | 37 | |
<> | 144:ef7eb2e8f9f7 | 38 | (+) Scan mode for conversion of several channels sequentially. |
<> | 144:ef7eb2e8f9f7 | 39 | |
<> | 144:ef7eb2e8f9f7 | 40 | (+) Data alignment with in-built data coherency. |
<> | 144:ef7eb2e8f9f7 | 41 | |
<> | 144:ef7eb2e8f9f7 | 42 | (+) Programmable sampling time (channel wise) |
<> | 144:ef7eb2e8f9f7 | 43 | |
<> | 144:ef7eb2e8f9f7 | 44 | (+) ADC conversion of regular group and injected group. |
<> | 144:ef7eb2e8f9f7 | 45 | |
<> | 144:ef7eb2e8f9f7 | 46 | (+) External trigger (timer or EXTI) with configurable polarity |
<> | 144:ef7eb2e8f9f7 | 47 | for both regular and injected groups. |
<> | 144:ef7eb2e8f9f7 | 48 | |
<> | 144:ef7eb2e8f9f7 | 49 | (+) DMA request generation for transfer of conversions data of regular group. |
<> | 144:ef7eb2e8f9f7 | 50 | |
<> | 144:ef7eb2e8f9f7 | 51 | (+) Multimode dual mode (available on devices with 2 ADCs or more). |
<> | 144:ef7eb2e8f9f7 | 52 | |
<> | 144:ef7eb2e8f9f7 | 53 | (+) Configurable DMA data storage in Multimode Dual mode (available on devices |
<> | 144:ef7eb2e8f9f7 | 54 | with 2 DCs or more). |
<> | 144:ef7eb2e8f9f7 | 55 | |
<> | 144:ef7eb2e8f9f7 | 56 | (+) Configurable delay between conversions in Dual interleaved mode (available |
<> | 144:ef7eb2e8f9f7 | 57 | on devices with 2 DCs or more). |
<> | 144:ef7eb2e8f9f7 | 58 | |
<> | 144:ef7eb2e8f9f7 | 59 | (+) ADC calibration |
<> | 144:ef7eb2e8f9f7 | 60 | |
<> | 144:ef7eb2e8f9f7 | 61 | (+) ADC channels selectable single/differential input (available only on |
<> | 144:ef7eb2e8f9f7 | 62 | STM32F30xxC devices) |
<> | 144:ef7eb2e8f9f7 | 63 | |
<> | 144:ef7eb2e8f9f7 | 64 | (+) ADC Injected sequencer&channels configuration context queue (available |
<> | 144:ef7eb2e8f9f7 | 65 | only on STM32F30xxC devices) |
<> | 144:ef7eb2e8f9f7 | 66 | |
<> | 144:ef7eb2e8f9f7 | 67 | (+) ADC offset on injected and regular groups (offset on regular group |
<> | 144:ef7eb2e8f9f7 | 68 | available only on STM32F30xxC devices) |
<> | 144:ef7eb2e8f9f7 | 69 | |
<> | 144:ef7eb2e8f9f7 | 70 | (+) ADC supply requirements: 2.4 V to 3.6 V at full speed and down to 1.8 V at |
<> | 144:ef7eb2e8f9f7 | 71 | slower speed. |
<> | 144:ef7eb2e8f9f7 | 72 | |
<> | 144:ef7eb2e8f9f7 | 73 | (+) ADC input range: from Vref- (connected to Vssa) to Vref+ (connected to |
<> | 144:ef7eb2e8f9f7 | 74 | Vdda or to an external voltage reference). |
<> | 144:ef7eb2e8f9f7 | 75 | |
<> | 144:ef7eb2e8f9f7 | 76 | |
<> | 144:ef7eb2e8f9f7 | 77 | ##### How to use this driver ##### |
<> | 144:ef7eb2e8f9f7 | 78 | ============================================================================== |
<> | 144:ef7eb2e8f9f7 | 79 | [..] |
<> | 144:ef7eb2e8f9f7 | 80 | |
<> | 144:ef7eb2e8f9f7 | 81 | *** Configuration of top level parameters related to ADC *** |
<> | 144:ef7eb2e8f9f7 | 82 | ============================================================ |
<> | 144:ef7eb2e8f9f7 | 83 | [..] |
<> | 144:ef7eb2e8f9f7 | 84 | |
<> | 144:ef7eb2e8f9f7 | 85 | (#) Enable the ADC interface |
<> | 144:ef7eb2e8f9f7 | 86 | (++) As prerequisite, ADC clock must be configured at RCC top level. |
<> | 144:ef7eb2e8f9f7 | 87 | |
<> | 144:ef7eb2e8f9f7 | 88 | (++) For STM32F30x/STM32F33x devices: |
<> | 144:ef7eb2e8f9f7 | 89 | Two possible clock sources: synchronous clock derived from AHB clock |
<> | 144:ef7eb2e8f9f7 | 90 | or asynchronous clock derived from ADC dedicated PLL 72MHz. |
<> | 144:ef7eb2e8f9f7 | 91 | - Synchronous clock is mandatory since used as ADC core clock. |
<> | 144:ef7eb2e8f9f7 | 92 | Synchronous clock can be used optionally as ADC conversion clock, depending on ADC init structure clock setting. |
<> | 144:ef7eb2e8f9f7 | 93 | Synchronous clock is configured using macro __ADCx_CLK_ENABLE(). |
<> | 144:ef7eb2e8f9f7 | 94 | - Asynchronous can be used optionally as ADC conversion clock, depending on ADC init structure clock setting. |
<> | 144:ef7eb2e8f9f7 | 95 | Asynchronous clock is configured using function HAL_RCCEx_PeriphCLKConfig(). |
<> | 144:ef7eb2e8f9f7 | 96 | (+++) For example, in case of device with a single ADC: |
<> | 144:ef7eb2e8f9f7 | 97 | Into HAL_ADC_MspInit() (recommended code location) or with |
<> | 144:ef7eb2e8f9f7 | 98 | other device clock parameters configuration: |
<> | 144:ef7eb2e8f9f7 | 99 | (+++) __HAL_RCC_ADC1_CLK_ENABLE() (mandatory) |
<> | 144:ef7eb2e8f9f7 | 100 | (+++) PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC (optional, if ADC conversion from asynchronous clock) |
<> | 144:ef7eb2e8f9f7 | 101 | (+++) PeriphClkInit.Adc1ClockSelection = RCC_ADC1PLLCLK_DIV1 (optional, if ADC conversion from asynchronous clock) |
<> | 144:ef7eb2e8f9f7 | 102 | (+++) HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInitStructure) (optional, if ADC conversion from asynchronous clock) |
<> | 144:ef7eb2e8f9f7 | 103 | |
<> | 144:ef7eb2e8f9f7 | 104 | (+++) For example, in case of device with 4 ADCs: |
<> | 144:ef7eb2e8f9f7 | 105 | |
<> | 144:ef7eb2e8f9f7 | 106 | (+++) if((hadc->Instance == ADC1) || (hadc->Instance == ADC2)) |
<> | 144:ef7eb2e8f9f7 | 107 | (+++) { |
<> | 144:ef7eb2e8f9f7 | 108 | (+++) __HAL_RCC_ADC12_CLK_ENABLE() (mandatory) |
<> | 144:ef7eb2e8f9f7 | 109 | (+++) PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC (optional, if ADC conversion from asynchronous clock) |
<> | 144:ef7eb2e8f9f7 | 110 | (+++) PeriphClkInit.Adc12ClockSelection = RCC_ADC12PLLCLK_DIV1 (optional, if ADC conversion from asynchronous clock) |
<> | 144:ef7eb2e8f9f7 | 111 | (+++) HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInitStructure) (optional, if ADC conversion from asynchronous clock) |
<> | 144:ef7eb2e8f9f7 | 112 | (+++) } |
<> | 144:ef7eb2e8f9f7 | 113 | (+++) else |
<> | 144:ef7eb2e8f9f7 | 114 | (+++) { |
<> | 144:ef7eb2e8f9f7 | 115 | (+++) __HAL_RCC_ADC34_CLK_ENABLE() (mandatory) |
<> | 144:ef7eb2e8f9f7 | 116 | (+++) PeriphClkInit.Adc34ClockSelection = RCC_ADC34PLLCLK_DIV1; (optional, if ADC conversion from asynchronous clock) |
<> | 144:ef7eb2e8f9f7 | 117 | (+++) HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInitStructure); (optional, if ADC conversion from asynchronous clock) |
<> | 144:ef7eb2e8f9f7 | 118 | (+++) } |
<> | 144:ef7eb2e8f9f7 | 119 | |
<> | 144:ef7eb2e8f9f7 | 120 | (++) For STM32F37x devices: |
<> | 144:ef7eb2e8f9f7 | 121 | One clock setting is mandatory: |
<> | 144:ef7eb2e8f9f7 | 122 | ADC clock (core and conversion clock) from APB2 clock. |
<> | 144:ef7eb2e8f9f7 | 123 | (+++) Example: |
<> | 144:ef7eb2e8f9f7 | 124 | Into HAL_ADC_MspInit() (recommended code location) or with |
<> | 144:ef7eb2e8f9f7 | 125 | other device clock parameters configuration: |
<> | 144:ef7eb2e8f9f7 | 126 | (+++) PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC |
<> | 144:ef7eb2e8f9f7 | 127 | (+++) PeriphClkInit.AdcClockSelection = RCC_ADCPLLCLK_DIV2 |
<> | 144:ef7eb2e8f9f7 | 128 | (+++) HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) |
<> | 144:ef7eb2e8f9f7 | 129 | |
<> | 144:ef7eb2e8f9f7 | 130 | (#) ADC pins configuration |
<> | 144:ef7eb2e8f9f7 | 131 | (++) Enable the clock for the ADC GPIOs |
<> | 144:ef7eb2e8f9f7 | 132 | using macro __HAL_RCC_GPIOx_CLK_ENABLE() |
<> | 144:ef7eb2e8f9f7 | 133 | (++) Configure these ADC pins in analog mode |
<> | 144:ef7eb2e8f9f7 | 134 | using function HAL_GPIO_Init() |
<> | 144:ef7eb2e8f9f7 | 135 | |
<> | 144:ef7eb2e8f9f7 | 136 | (#) Optionally, in case of usage of ADC with interruptions: |
<> | 144:ef7eb2e8f9f7 | 137 | (++) Configure the NVIC for ADC |
<> | 144:ef7eb2e8f9f7 | 138 | using function HAL_NVIC_EnableIRQ(ADCx_IRQn) |
<> | 144:ef7eb2e8f9f7 | 139 | (++) Insert the ADC interruption handler function HAL_ADC_IRQHandler() |
<> | 144:ef7eb2e8f9f7 | 140 | into the function of corresponding ADC interruption vector |
<> | 144:ef7eb2e8f9f7 | 141 | ADCx_IRQHandler(). |
<> | 144:ef7eb2e8f9f7 | 142 | |
<> | 144:ef7eb2e8f9f7 | 143 | (#) Optionally, in case of usage of DMA: |
<> | 144:ef7eb2e8f9f7 | 144 | (++) Configure the DMA (DMA channel, mode normal or circular, ...) |
<> | 144:ef7eb2e8f9f7 | 145 | using function HAL_DMA_Init(). |
<> | 144:ef7eb2e8f9f7 | 146 | (++) Configure the NVIC for DMA |
<> | 144:ef7eb2e8f9f7 | 147 | using function HAL_NVIC_EnableIRQ(DMAx_Channelx_IRQn) |
<> | 144:ef7eb2e8f9f7 | 148 | (++) Insert the ADC interruption handler function HAL_ADC_IRQHandler() |
<> | 144:ef7eb2e8f9f7 | 149 | into the function of corresponding DMA interruption vector |
<> | 144:ef7eb2e8f9f7 | 150 | DMAx_Channelx_IRQHandler(). |
<> | 144:ef7eb2e8f9f7 | 151 | |
<> | 144:ef7eb2e8f9f7 | 152 | *** Configuration of ADC, groups regular/injected, channels parameters *** |
<> | 144:ef7eb2e8f9f7 | 153 | ========================================================================== |
<> | 144:ef7eb2e8f9f7 | 154 | [..] |
<> | 144:ef7eb2e8f9f7 | 155 | |
<> | 144:ef7eb2e8f9f7 | 156 | (#) Configure the ADC parameters (resolution, data alignment, ...) |
<> | 144:ef7eb2e8f9f7 | 157 | and regular group parameters (conversion trigger, sequencer, ...) |
<> | 144:ef7eb2e8f9f7 | 158 | using function HAL_ADC_Init(). |
<> | 144:ef7eb2e8f9f7 | 159 | |
<> | 144:ef7eb2e8f9f7 | 160 | (#) Configure the channels for regular group parameters (channel number, |
<> | 144:ef7eb2e8f9f7 | 161 | channel rank into sequencer, ..., into regular group) |
<> | 144:ef7eb2e8f9f7 | 162 | using function HAL_ADC_ConfigChannel(). |
<> | 144:ef7eb2e8f9f7 | 163 | |
<> | 144:ef7eb2e8f9f7 | 164 | (#) Optionally, configure the injected group parameters (conversion trigger, |
<> | 144:ef7eb2e8f9f7 | 165 | sequencer, ..., of injected group) |
<> | 144:ef7eb2e8f9f7 | 166 | and the channels for injected group parameters (channel number, |
<> | 144:ef7eb2e8f9f7 | 167 | channel rank into sequencer, ..., into injected group) |
<> | 144:ef7eb2e8f9f7 | 168 | using function HAL_ADCEx_InjectedConfigChannel(). |
<> | 144:ef7eb2e8f9f7 | 169 | |
<> | 144:ef7eb2e8f9f7 | 170 | (#) Optionally, configure the analog watchdog parameters (channels |
<> | 144:ef7eb2e8f9f7 | 171 | monitored, thresholds, ...) |
<> | 144:ef7eb2e8f9f7 | 172 | using function HAL_ADC_AnalogWDGConfig(). |
<> | 144:ef7eb2e8f9f7 | 173 | |
<> | 144:ef7eb2e8f9f7 | 174 | (#) Optionally, for devices with several ADC instances: configure the |
<> | 144:ef7eb2e8f9f7 | 175 | multimode parameters |
<> | 144:ef7eb2e8f9f7 | 176 | using function HAL_ADCEx_MultiModeConfigChannel(). |
<> | 144:ef7eb2e8f9f7 | 177 | |
<> | 144:ef7eb2e8f9f7 | 178 | *** Execution of ADC conversions *** |
<> | 144:ef7eb2e8f9f7 | 179 | ==================================== |
<> | 144:ef7eb2e8f9f7 | 180 | [..] |
<> | 144:ef7eb2e8f9f7 | 181 | |
<> | 144:ef7eb2e8f9f7 | 182 | (#) Optionally, perform an automatic ADC calibration to improve the |
<> | 144:ef7eb2e8f9f7 | 183 | conversion accuracy |
<> | 144:ef7eb2e8f9f7 | 184 | using function HAL_ADCEx_Calibration_Start(). |
<> | 144:ef7eb2e8f9f7 | 185 | |
<> | 144:ef7eb2e8f9f7 | 186 | (#) ADC driver can be used among three modes: polling, interruption, |
<> | 144:ef7eb2e8f9f7 | 187 | transfer by DMA. |
<> | 144:ef7eb2e8f9f7 | 188 | |
<> | 144:ef7eb2e8f9f7 | 189 | (++) ADC conversion by polling: |
<> | 144:ef7eb2e8f9f7 | 190 | (+++) Activate the ADC peripheral and start conversions |
<> | 144:ef7eb2e8f9f7 | 191 | using function HAL_ADC_Start() |
<> | 144:ef7eb2e8f9f7 | 192 | (+++) Wait for ADC conversion completion |
<> | 144:ef7eb2e8f9f7 | 193 | using function HAL_ADC_PollForConversion() |
<> | 144:ef7eb2e8f9f7 | 194 | (or for injected group: HAL_ADCEx_InjectedPollForConversion() ) |
<> | 144:ef7eb2e8f9f7 | 195 | (+++) Retrieve conversion results |
<> | 144:ef7eb2e8f9f7 | 196 | using function HAL_ADC_GetValue() |
<> | 144:ef7eb2e8f9f7 | 197 | (or for injected group: HAL_ADCEx_InjectedGetValue() ) |
<> | 144:ef7eb2e8f9f7 | 198 | (+++) Stop conversion and disable the ADC peripheral |
<> | 144:ef7eb2e8f9f7 | 199 | using function HAL_ADC_Stop() |
<> | 144:ef7eb2e8f9f7 | 200 | |
<> | 144:ef7eb2e8f9f7 | 201 | (++) ADC conversion by interruption: |
<> | 144:ef7eb2e8f9f7 | 202 | (+++) Activate the ADC peripheral and start conversions |
<> | 144:ef7eb2e8f9f7 | 203 | using function HAL_ADC_Start_IT() |
<> | 144:ef7eb2e8f9f7 | 204 | (+++) Wait for ADC conversion completion by call of function |
<> | 144:ef7eb2e8f9f7 | 205 | HAL_ADC_ConvCpltCallback() |
<> | 144:ef7eb2e8f9f7 | 206 | (this function must be implemented in user program) |
<> | 144:ef7eb2e8f9f7 | 207 | (or for injected group: HAL_ADCEx_InjectedConvCpltCallback() ) |
<> | 144:ef7eb2e8f9f7 | 208 | (+++) Retrieve conversion results |
<> | 144:ef7eb2e8f9f7 | 209 | using function HAL_ADC_GetValue() |
<> | 144:ef7eb2e8f9f7 | 210 | (or for injected group: HAL_ADCEx_InjectedGetValue() ) |
<> | 144:ef7eb2e8f9f7 | 211 | (+++) Stop conversion and disable the ADC peripheral |
<> | 144:ef7eb2e8f9f7 | 212 | using function HAL_ADC_Stop_IT() |
<> | 144:ef7eb2e8f9f7 | 213 | |
<> | 144:ef7eb2e8f9f7 | 214 | (++) ADC conversion with transfer by DMA: |
<> | 144:ef7eb2e8f9f7 | 215 | (+++) Activate the ADC peripheral and start conversions |
<> | 144:ef7eb2e8f9f7 | 216 | using function HAL_ADC_Start_DMA() |
<> | 144:ef7eb2e8f9f7 | 217 | (+++) Wait for ADC conversion completion by call of function |
<> | 144:ef7eb2e8f9f7 | 218 | HAL_ADC_ConvCpltCallback() or HAL_ADC_ConvHalfCpltCallback() |
<> | 144:ef7eb2e8f9f7 | 219 | (these functions must be implemented in user program) |
<> | 144:ef7eb2e8f9f7 | 220 | (+++) Conversion results are automatically transferred by DMA into |
<> | 144:ef7eb2e8f9f7 | 221 | destination variable address. |
<> | 144:ef7eb2e8f9f7 | 222 | (+++) Stop conversion and disable the ADC peripheral |
<> | 144:ef7eb2e8f9f7 | 223 | using function HAL_ADC_Stop_DMA() |
<> | 144:ef7eb2e8f9f7 | 224 | |
<> | 144:ef7eb2e8f9f7 | 225 | (++) For devices with several ADCs: ADC multimode conversion |
<> | 144:ef7eb2e8f9f7 | 226 | with transfer by DMA: |
<> | 144:ef7eb2e8f9f7 | 227 | (+++) Activate the ADC peripheral (slave) |
<> | 144:ef7eb2e8f9f7 | 228 | using function HAL_ADC_Start() |
<> | 144:ef7eb2e8f9f7 | 229 | (conversion start pending ADC master) |
<> | 144:ef7eb2e8f9f7 | 230 | (+++) Activate the ADC peripheral (master) and start conversions |
<> | 144:ef7eb2e8f9f7 | 231 | using function HAL_ADCEx_MultiModeStart_DMA() |
<> | 144:ef7eb2e8f9f7 | 232 | (+++) Wait for ADC conversion completion by call of function |
<> | 144:ef7eb2e8f9f7 | 233 | HAL_ADC_ConvCpltCallback() or HAL_ADC_ConvHalfCpltCallback() |
<> | 144:ef7eb2e8f9f7 | 234 | (these functions must be implemented in user program) |
<> | 144:ef7eb2e8f9f7 | 235 | (+++) Conversion results are automatically transferred by DMA into |
<> | 144:ef7eb2e8f9f7 | 236 | destination variable address. |
<> | 144:ef7eb2e8f9f7 | 237 | (+++) Stop conversion and disable the ADC peripheral (master) |
<> | 144:ef7eb2e8f9f7 | 238 | using function HAL_ADCEx_MultiModeStop_DMA() |
<> | 144:ef7eb2e8f9f7 | 239 | (+++) Stop conversion and disable the ADC peripheral (slave) |
<> | 144:ef7eb2e8f9f7 | 240 | using function HAL_ADC_Stop_IT() |
<> | 144:ef7eb2e8f9f7 | 241 | |
<> | 144:ef7eb2e8f9f7 | 242 | [..] |
<> | 144:ef7eb2e8f9f7 | 243 | |
<> | 144:ef7eb2e8f9f7 | 244 | (@) Callback functions must be implemented in user program: |
<> | 144:ef7eb2e8f9f7 | 245 | (+@) HAL_ADC_ErrorCallback() |
<> | 144:ef7eb2e8f9f7 | 246 | (+@) HAL_ADC_LevelOutOfWindowCallback() (callback of analog watchdog) |
<> | 144:ef7eb2e8f9f7 | 247 | (+@) HAL_ADC_ConvCpltCallback() |
<> | 144:ef7eb2e8f9f7 | 248 | (+@) HAL_ADC_ConvHalfCpltCallback |
<> | 144:ef7eb2e8f9f7 | 249 | (+@) HAL_ADCEx_InjectedConvCpltCallback() |
<> | 144:ef7eb2e8f9f7 | 250 | (+@) HAL_ADCEx_InjectedQueueOverflowCallback() (for STM32F30x/STM32F33x devices) |
<> | 144:ef7eb2e8f9f7 | 251 | |
<> | 144:ef7eb2e8f9f7 | 252 | *** Deinitialization of ADC *** |
<> | 144:ef7eb2e8f9f7 | 253 | ============================================================ |
<> | 144:ef7eb2e8f9f7 | 254 | [..] |
<> | 144:ef7eb2e8f9f7 | 255 | |
<> | 144:ef7eb2e8f9f7 | 256 | (#) Disable the ADC interface |
<> | 144:ef7eb2e8f9f7 | 257 | (++) ADC clock can be hard reset and disabled at RCC top level. |
<> | 144:ef7eb2e8f9f7 | 258 | (++) Hard reset of ADC peripherals |
<> | 144:ef7eb2e8f9f7 | 259 | using macro __ADCx_FORCE_RESET(), __ADCx_RELEASE_RESET(). |
<> | 144:ef7eb2e8f9f7 | 260 | (++) ADC clock disable |
<> | 144:ef7eb2e8f9f7 | 261 | using the equivalent macro/functions as configuration step. |
<> | 144:ef7eb2e8f9f7 | 262 | |
<> | 144:ef7eb2e8f9f7 | 263 | (++) For STM32F30x/STM32F33x devices: |
<> | 144:ef7eb2e8f9f7 | 264 | Caution: For devices with several ADCs: |
<> | 144:ef7eb2e8f9f7 | 265 | These settings impact both ADC of common group: ADC1&ADC2, ADC3&ADC4 |
<> | 144:ef7eb2e8f9f7 | 266 | if available (ADC2, ADC3, ADC4 availability depends on STM32 product) |
<> | 144:ef7eb2e8f9f7 | 267 | |
<> | 144:ef7eb2e8f9f7 | 268 | (+++) For example, in case of device with a single ADC: |
<> | 144:ef7eb2e8f9f7 | 269 | Into HAL_ADC_MspDeInit() (recommended code location) or with |
<> | 144:ef7eb2e8f9f7 | 270 | other device clock parameters configuration: |
<> | 144:ef7eb2e8f9f7 | 271 | (+++) __HAL_RCC_ADC1_FORCE_RESET() (optional) |
<> | 144:ef7eb2e8f9f7 | 272 | (+++) __HAL_RCC_ADC1_RELEASE_RESET() (optional) |
<> | 144:ef7eb2e8f9f7 | 273 | (+++) __HAL_RCC_ADC1_CLK_DISABLE() (mandatory) |
<> | 144:ef7eb2e8f9f7 | 274 | (+++) PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC (optional, if configured before) |
<> | 144:ef7eb2e8f9f7 | 275 | (+++) PeriphClkInit.Adc1ClockSelection = RCC_ADC1PLLCLK_OFF (optional, if configured before) |
<> | 144:ef7eb2e8f9f7 | 276 | (+++) HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInitStructure) (optional, if configured before) |
<> | 144:ef7eb2e8f9f7 | 277 | |
<> | 144:ef7eb2e8f9f7 | 278 | (+++) For example, in case of device with 4 ADCs: |
<> | 144:ef7eb2e8f9f7 | 279 | (+++) if((hadc->Instance == ADC1) || (hadc->Instance == ADC2)) |
<> | 144:ef7eb2e8f9f7 | 280 | (+++) { |
<> | 144:ef7eb2e8f9f7 | 281 | (+++) __HAL_RCC_ADC12_FORCE_RESET() (optional) |
<> | 144:ef7eb2e8f9f7 | 282 | (+++) __HAL_RCC_ADC12_RELEASE_RESET() (optional) |
<> | 144:ef7eb2e8f9f7 | 283 | (+++) __HAL_RCC_ADC12_CLK_DISABLE() (mandatory) |
<> | 144:ef7eb2e8f9f7 | 284 | (+++) PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC (optional, if configured before) |
<> | 144:ef7eb2e8f9f7 | 285 | (+++) PeriphClkInit.Adc12ClockSelection = RCC_ADC12PLLCLK_OFF (optional, if configured before) |
<> | 144:ef7eb2e8f9f7 | 286 | (+++) HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInitStructure) (optional, if configured before) |
<> | 144:ef7eb2e8f9f7 | 287 | (+++) } |
<> | 144:ef7eb2e8f9f7 | 288 | (+++) else |
<> | 144:ef7eb2e8f9f7 | 289 | (+++) { |
<> | 144:ef7eb2e8f9f7 | 290 | (+++) __HAL_RCC_ADC32_FORCE_RESET() (optional) |
<> | 144:ef7eb2e8f9f7 | 291 | (+++) __HAL_RCC_ADC32_RELEASE_RESET() (optional) |
<> | 144:ef7eb2e8f9f7 | 292 | (+++) __HAL_RCC_ADC34_CLK_DISABLE() (mandatory) |
<> | 144:ef7eb2e8f9f7 | 293 | (+++) PeriphClkInit.Adc34ClockSelection = RCC_ADC34PLLCLK_OFF (optional, if configured before) |
<> | 144:ef7eb2e8f9f7 | 294 | (+++) HAL_RCCEx_PeriphCLKConfig(&RCC_PeriphClkInitStructure) (optional, if configured before) |
<> | 144:ef7eb2e8f9f7 | 295 | (+++) } |
<> | 144:ef7eb2e8f9f7 | 296 | |
<> | 144:ef7eb2e8f9f7 | 297 | (++) For STM32F37x devices: |
<> | 144:ef7eb2e8f9f7 | 298 | (+++) Example: |
<> | 144:ef7eb2e8f9f7 | 299 | Into HAL_ADC_MspDeInit() (recommended code location) or with |
<> | 144:ef7eb2e8f9f7 | 300 | other device clock parameters configuration: |
<> | 144:ef7eb2e8f9f7 | 301 | (+++) PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC |
<> | 144:ef7eb2e8f9f7 | 302 | (+++) PeriphClkInit.AdcClockSelection = RCC_ADCPLLCLK_OFF |
<> | 144:ef7eb2e8f9f7 | 303 | (+++) HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) |
<> | 144:ef7eb2e8f9f7 | 304 | |
<> | 144:ef7eb2e8f9f7 | 305 | (#) ADC pins configuration |
<> | 144:ef7eb2e8f9f7 | 306 | (++) Disable the clock for the ADC GPIOs |
<> | 144:ef7eb2e8f9f7 | 307 | using macro __HAL_RCC_GPIOx_CLK_DISABLE() |
<> | 144:ef7eb2e8f9f7 | 308 | |
<> | 144:ef7eb2e8f9f7 | 309 | (#) Optionally, in case of usage of ADC with interruptions: |
<> | 144:ef7eb2e8f9f7 | 310 | (++) Disable the NVIC for ADC |
<> | 144:ef7eb2e8f9f7 | 311 | using function HAL_NVIC_EnableIRQ(ADCx_IRQn) |
<> | 144:ef7eb2e8f9f7 | 312 | |
<> | 144:ef7eb2e8f9f7 | 313 | (#) Optionally, in case of usage of DMA: |
<> | 144:ef7eb2e8f9f7 | 314 | (++) Deinitialize the DMA |
<> | 144:ef7eb2e8f9f7 | 315 | using function HAL_DMA_Init(). |
<> | 144:ef7eb2e8f9f7 | 316 | (++) Disable the NVIC for DMA |
<> | 144:ef7eb2e8f9f7 | 317 | using function HAL_NVIC_EnableIRQ(DMAx_Channelx_IRQn) |
<> | 144:ef7eb2e8f9f7 | 318 | |
<> | 144:ef7eb2e8f9f7 | 319 | [..] |
<> | 144:ef7eb2e8f9f7 | 320 | |
<> | 144:ef7eb2e8f9f7 | 321 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 322 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 323 | * @attention |
<> | 144:ef7eb2e8f9f7 | 324 | * |
<> | 144:ef7eb2e8f9f7 | 325 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
<> | 144:ef7eb2e8f9f7 | 326 | * |
<> | 144:ef7eb2e8f9f7 | 327 | * Redistribution and use in source and binary forms, with or without modification, |
<> | 144:ef7eb2e8f9f7 | 328 | * are permitted provided that the following conditions are met: |
<> | 144:ef7eb2e8f9f7 | 329 | * 1. Redistributions of source code must retain the above copyright notice, |
<> | 144:ef7eb2e8f9f7 | 330 | * this list of conditions and the following disclaimer. |
<> | 144:ef7eb2e8f9f7 | 331 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
<> | 144:ef7eb2e8f9f7 | 332 | * this list of conditions and the following disclaimer in the documentation |
<> | 144:ef7eb2e8f9f7 | 333 | * and/or other materials provided with the distribution. |
<> | 144:ef7eb2e8f9f7 | 334 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
<> | 144:ef7eb2e8f9f7 | 335 | * may be used to endorse or promote products derived from this software |
<> | 144:ef7eb2e8f9f7 | 336 | * without specific prior written permission. |
<> | 144:ef7eb2e8f9f7 | 337 | * |
<> | 144:ef7eb2e8f9f7 | 338 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
<> | 144:ef7eb2e8f9f7 | 339 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
<> | 144:ef7eb2e8f9f7 | 340 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
<> | 144:ef7eb2e8f9f7 | 341 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
<> | 144:ef7eb2e8f9f7 | 342 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
<> | 144:ef7eb2e8f9f7 | 343 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
<> | 144:ef7eb2e8f9f7 | 344 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
<> | 144:ef7eb2e8f9f7 | 345 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
<> | 144:ef7eb2e8f9f7 | 346 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
<> | 144:ef7eb2e8f9f7 | 347 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
<> | 144:ef7eb2e8f9f7 | 348 | * |
<> | 144:ef7eb2e8f9f7 | 349 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 350 | */ |
<> | 144:ef7eb2e8f9f7 | 351 | |
<> | 144:ef7eb2e8f9f7 | 352 | /* Includes ------------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 353 | #include "stm32f3xx_hal.h" |
<> | 144:ef7eb2e8f9f7 | 354 | |
<> | 144:ef7eb2e8f9f7 | 355 | /** @addtogroup STM32F3xx_HAL_Driver |
<> | 144:ef7eb2e8f9f7 | 356 | * @{ |
<> | 144:ef7eb2e8f9f7 | 357 | */ |
<> | 144:ef7eb2e8f9f7 | 358 | |
<> | 144:ef7eb2e8f9f7 | 359 | /** @defgroup ADC ADC |
<> | 144:ef7eb2e8f9f7 | 360 | * @brief ADC HAL module driver |
<> | 144:ef7eb2e8f9f7 | 361 | * @{ |
<> | 144:ef7eb2e8f9f7 | 362 | */ |
<> | 144:ef7eb2e8f9f7 | 363 | |
<> | 144:ef7eb2e8f9f7 | 364 | #ifdef HAL_ADC_MODULE_ENABLED |
<> | 144:ef7eb2e8f9f7 | 365 | |
<> | 144:ef7eb2e8f9f7 | 366 | /* Private typedef -----------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 367 | /* Private define ------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 368 | /* Private macro -------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 369 | /* Private variables ---------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 370 | /* Private function prototypes -----------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 371 | /* Exported functions --------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 372 | |
<> | 144:ef7eb2e8f9f7 | 373 | /** @defgroup ADC_Exported_Functions ADC Exported Functions |
<> | 144:ef7eb2e8f9f7 | 374 | * @{ |
<> | 144:ef7eb2e8f9f7 | 375 | */ |
<> | 144:ef7eb2e8f9f7 | 376 | |
<> | 144:ef7eb2e8f9f7 | 377 | /** @defgroup ADC_Exported_Functions_Group1 Initialization and de-initialization functions |
<> | 144:ef7eb2e8f9f7 | 378 | * @brief Initialization and Configuration functions |
<> | 144:ef7eb2e8f9f7 | 379 | * |
<> | 144:ef7eb2e8f9f7 | 380 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 381 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 382 | ##### Initialization and de-initialization functions ##### |
<> | 144:ef7eb2e8f9f7 | 383 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 384 | [..] This section provides functions allowing to: |
<> | 144:ef7eb2e8f9f7 | 385 | (+) Initialize and configure the ADC. |
<> | 144:ef7eb2e8f9f7 | 386 | (+) De-initialize the ADC. |
<> | 144:ef7eb2e8f9f7 | 387 | |
<> | 144:ef7eb2e8f9f7 | 388 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 389 | * @{ |
<> | 144:ef7eb2e8f9f7 | 390 | */ |
<> | 144:ef7eb2e8f9f7 | 391 | |
<> | 144:ef7eb2e8f9f7 | 392 | /** |
<> | 144:ef7eb2e8f9f7 | 393 | * @brief Initializes the ADC peripheral and regular group according to |
<> | 144:ef7eb2e8f9f7 | 394 | * parameters specified in structure "ADC_InitTypeDef". |
<> | 144:ef7eb2e8f9f7 | 395 | * @note As prerequisite, ADC clock must be configured at RCC top level |
<> | 144:ef7eb2e8f9f7 | 396 | * depending on both possible clock sources: PLL clock or AHB clock. |
<> | 144:ef7eb2e8f9f7 | 397 | * See commented example code below that can be copied and uncommented |
<> | 144:ef7eb2e8f9f7 | 398 | * into HAL_ADC_MspInit(). |
<> | 144:ef7eb2e8f9f7 | 399 | * @note Possibility to update parameters on the fly: |
<> | 144:ef7eb2e8f9f7 | 400 | * This function initializes the ADC MSP (HAL_ADC_MspInit()) only when |
<> | 144:ef7eb2e8f9f7 | 401 | * coming from ADC state reset. Following calls to this function can |
<> | 144:ef7eb2e8f9f7 | 402 | * be used to reconfigure some parameters of ADC_InitTypeDef |
<> | 144:ef7eb2e8f9f7 | 403 | * structure on the fly, without modifying MSP configuration. If ADC |
<> | 144:ef7eb2e8f9f7 | 404 | * MSP has to be modified again, HAL_ADC_DeInit() must be called |
<> | 144:ef7eb2e8f9f7 | 405 | * before HAL_ADC_Init(). |
<> | 144:ef7eb2e8f9f7 | 406 | * The setting of these parameters is conditioned to ADC state. |
<> | 144:ef7eb2e8f9f7 | 407 | * For parameters constraints, see comments of structure |
<> | 144:ef7eb2e8f9f7 | 408 | * "ADC_InitTypeDef". |
<> | 144:ef7eb2e8f9f7 | 409 | * @note This function configures the ADC within 2 scopes: scope of entire |
<> | 144:ef7eb2e8f9f7 | 410 | * ADC and scope of regular group. For parameters details, see comments |
<> | 144:ef7eb2e8f9f7 | 411 | * of structure "ADC_InitTypeDef". |
<> | 144:ef7eb2e8f9f7 | 412 | * @note For devices with several ADCs: parameters related to common ADC |
<> | 144:ef7eb2e8f9f7 | 413 | * registers (ADC clock mode) are set only if all ADCs sharing the |
<> | 144:ef7eb2e8f9f7 | 414 | * same common group are disabled. |
<> | 144:ef7eb2e8f9f7 | 415 | * If this is not the case, these common parameters setting are |
<> | 144:ef7eb2e8f9f7 | 416 | * bypassed without error reporting: it can be the intended behaviour in |
<> | 144:ef7eb2e8f9f7 | 417 | * case of update of a parameter of ADC_InitTypeDef on the fly, |
<> | 144:ef7eb2e8f9f7 | 418 | * without disabling the other ADCs sharing the same common group. |
<> | 144:ef7eb2e8f9f7 | 419 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 420 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 421 | */ |
<> | 144:ef7eb2e8f9f7 | 422 | __weak HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc) |
<> | 144:ef7eb2e8f9f7 | 423 | { |
<> | 144:ef7eb2e8f9f7 | 424 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 425 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 426 | |
<> | 144:ef7eb2e8f9f7 | 427 | /* Note : This function is defined into this file for library reference. */ |
<> | 144:ef7eb2e8f9f7 | 428 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
<> | 144:ef7eb2e8f9f7 | 429 | |
<> | 144:ef7eb2e8f9f7 | 430 | /* Return function status */ |
<> | 144:ef7eb2e8f9f7 | 431 | return HAL_ERROR; |
<> | 144:ef7eb2e8f9f7 | 432 | } |
<> | 144:ef7eb2e8f9f7 | 433 | |
<> | 144:ef7eb2e8f9f7 | 434 | /** |
<> | 144:ef7eb2e8f9f7 | 435 | * @brief Deinitialize the ADC peripheral registers to their default reset |
<> | 144:ef7eb2e8f9f7 | 436 | * values, with deinitialization of the ADC MSP. |
<> | 144:ef7eb2e8f9f7 | 437 | * @note For devices with several ADCs: reset of ADC common registers is done |
<> | 144:ef7eb2e8f9f7 | 438 | * only if all ADCs sharing the same common group are disabled. |
<> | 144:ef7eb2e8f9f7 | 439 | * If this is not the case, reset of these common parameters reset is |
<> | 144:ef7eb2e8f9f7 | 440 | * bypassed without error reporting: it can be the intended behaviour in |
<> | 144:ef7eb2e8f9f7 | 441 | * case of reset of a single ADC while the other ADCs sharing the same |
<> | 144:ef7eb2e8f9f7 | 442 | * common group is still running. |
<> | 144:ef7eb2e8f9f7 | 443 | * @note For devices with several ADCs: Global reset of all ADCs sharing a |
<> | 144:ef7eb2e8f9f7 | 444 | * common group is possible. |
<> | 144:ef7eb2e8f9f7 | 445 | * As this function is intended to reset a single ADC, to not impact |
<> | 144:ef7eb2e8f9f7 | 446 | * other ADCs, instructions for global reset of multiple ADCs have been |
<> | 144:ef7eb2e8f9f7 | 447 | * let commented below. |
<> | 144:ef7eb2e8f9f7 | 448 | * If needed, the example code can be copied and uncommented into |
<> | 144:ef7eb2e8f9f7 | 449 | * function HAL_ADC_MspDeInit(). |
<> | 144:ef7eb2e8f9f7 | 450 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 451 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 452 | */ |
<> | 144:ef7eb2e8f9f7 | 453 | __weak HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef* hadc) |
<> | 144:ef7eb2e8f9f7 | 454 | { |
<> | 144:ef7eb2e8f9f7 | 455 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 456 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 457 | |
<> | 144:ef7eb2e8f9f7 | 458 | /* Note : This function is defined into this file for library reference. */ |
<> | 144:ef7eb2e8f9f7 | 459 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
<> | 144:ef7eb2e8f9f7 | 460 | |
<> | 144:ef7eb2e8f9f7 | 461 | /* Return function status */ |
<> | 144:ef7eb2e8f9f7 | 462 | return HAL_ERROR; |
<> | 144:ef7eb2e8f9f7 | 463 | } |
<> | 144:ef7eb2e8f9f7 | 464 | |
<> | 144:ef7eb2e8f9f7 | 465 | /** |
<> | 144:ef7eb2e8f9f7 | 466 | * @brief Initializes the ADC MSP. |
<> | 144:ef7eb2e8f9f7 | 467 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 468 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 469 | */ |
<> | 144:ef7eb2e8f9f7 | 470 | __weak void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) |
<> | 144:ef7eb2e8f9f7 | 471 | { |
<> | 144:ef7eb2e8f9f7 | 472 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 473 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 474 | |
<> | 144:ef7eb2e8f9f7 | 475 | /* NOTE : This function should not be modified. When the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 476 | function HAL_ADC_MspInit must be implemented in the user file. |
<> | 144:ef7eb2e8f9f7 | 477 | */ |
<> | 144:ef7eb2e8f9f7 | 478 | } |
<> | 144:ef7eb2e8f9f7 | 479 | |
<> | 144:ef7eb2e8f9f7 | 480 | /** |
<> | 144:ef7eb2e8f9f7 | 481 | * @brief DeInitializes the ADC MSP. |
<> | 144:ef7eb2e8f9f7 | 482 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 483 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 484 | */ |
<> | 144:ef7eb2e8f9f7 | 485 | __weak void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) |
<> | 144:ef7eb2e8f9f7 | 486 | { |
<> | 144:ef7eb2e8f9f7 | 487 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 488 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 489 | |
<> | 144:ef7eb2e8f9f7 | 490 | /* NOTE : This function should not be modified. When the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 491 | function HAL_ADC_MspDeInit must be implemented in the user file. |
<> | 144:ef7eb2e8f9f7 | 492 | */ |
<> | 144:ef7eb2e8f9f7 | 493 | } |
<> | 144:ef7eb2e8f9f7 | 494 | |
<> | 144:ef7eb2e8f9f7 | 495 | /** |
<> | 144:ef7eb2e8f9f7 | 496 | * @} |
<> | 144:ef7eb2e8f9f7 | 497 | */ |
<> | 144:ef7eb2e8f9f7 | 498 | |
<> | 144:ef7eb2e8f9f7 | 499 | /** @defgroup ADC_Exported_Functions_Group2 Input and Output operation functions |
<> | 144:ef7eb2e8f9f7 | 500 | * @brief IO operation functions |
<> | 144:ef7eb2e8f9f7 | 501 | * |
<> | 144:ef7eb2e8f9f7 | 502 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 503 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 504 | ##### IO operation functions ##### |
<> | 144:ef7eb2e8f9f7 | 505 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 506 | [..] This section provides functions allowing to: |
<> | 144:ef7eb2e8f9f7 | 507 | (+) Start conversion of regular group. |
<> | 144:ef7eb2e8f9f7 | 508 | (+) Stop conversion of regular group. |
<> | 144:ef7eb2e8f9f7 | 509 | (+) Poll for conversion complete on regular group. |
<> | 144:ef7eb2e8f9f7 | 510 | (+) Poll for conversion event. |
<> | 144:ef7eb2e8f9f7 | 511 | (+) Get result of regular channel conversion. |
<> | 144:ef7eb2e8f9f7 | 512 | (+) Start conversion of regular group and enable interruptions. |
<> | 144:ef7eb2e8f9f7 | 513 | (+) Stop conversion of regular group and disable interruptions. |
<> | 144:ef7eb2e8f9f7 | 514 | (+) Handle ADC interrupt request |
<> | 144:ef7eb2e8f9f7 | 515 | (+) Start conversion of regular group and enable DMA transfer. |
<> | 144:ef7eb2e8f9f7 | 516 | (+) Stop conversion of regular group and disable ADC DMA transfer. |
<> | 144:ef7eb2e8f9f7 | 517 | |
<> | 144:ef7eb2e8f9f7 | 518 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 519 | * @{ |
<> | 144:ef7eb2e8f9f7 | 520 | */ |
<> | 144:ef7eb2e8f9f7 | 521 | /** |
<> | 144:ef7eb2e8f9f7 | 522 | * @brief Enables ADC, starts conversion of regular group. |
<> | 144:ef7eb2e8f9f7 | 523 | * Interruptions enabled in this function: None. |
<> | 144:ef7eb2e8f9f7 | 524 | * @note: Case of multimode enabled (for devices with several ADCs): This |
<> | 144:ef7eb2e8f9f7 | 525 | * function must be called for ADC slave first, then ADC master. |
<> | 144:ef7eb2e8f9f7 | 526 | * For ADC slave, ADC is enabled only (conversion is not started). |
<> | 144:ef7eb2e8f9f7 | 527 | * For ADC master, ADC is enabled and multimode conversion is started. |
<> | 144:ef7eb2e8f9f7 | 528 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 529 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 530 | */ |
<> | 144:ef7eb2e8f9f7 | 531 | __weak HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc) |
<> | 144:ef7eb2e8f9f7 | 532 | { |
<> | 144:ef7eb2e8f9f7 | 533 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 534 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 535 | |
<> | 144:ef7eb2e8f9f7 | 536 | /* Return function status */ |
<> | 144:ef7eb2e8f9f7 | 537 | return HAL_ERROR; |
<> | 144:ef7eb2e8f9f7 | 538 | } |
<> | 144:ef7eb2e8f9f7 | 539 | |
<> | 144:ef7eb2e8f9f7 | 540 | /** |
<> | 144:ef7eb2e8f9f7 | 541 | * @brief Stop ADC conversion of regular group (and injected group in |
<> | 144:ef7eb2e8f9f7 | 542 | * case of auto_injection mode), disable ADC peripheral. |
<> | 144:ef7eb2e8f9f7 | 543 | * @note: ADC peripheral disable is forcing stop of potential |
<> | 144:ef7eb2e8f9f7 | 544 | * conversion on injected group. If injected group is under use, it |
<> | 144:ef7eb2e8f9f7 | 545 | * should be preliminarily stopped using HAL_ADCEx_InjectedStop function. |
<> | 144:ef7eb2e8f9f7 | 546 | * @note: Case of multimode enabled (for devices with several ADCs): This |
<> | 144:ef7eb2e8f9f7 | 547 | * function must be called for ADC master first, then ADC slave. |
<> | 144:ef7eb2e8f9f7 | 548 | * For ADC master, converson is stopped and ADC is disabled. |
<> | 144:ef7eb2e8f9f7 | 549 | * For ADC slave, ADC is disabled only (conversion stop of ADC master |
<> | 144:ef7eb2e8f9f7 | 550 | * has already stopped conversion of ADC slave). |
<> | 144:ef7eb2e8f9f7 | 551 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 552 | * @retval HAL status. |
<> | 144:ef7eb2e8f9f7 | 553 | */ |
<> | 144:ef7eb2e8f9f7 | 554 | __weak HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc) |
<> | 144:ef7eb2e8f9f7 | 555 | { |
<> | 144:ef7eb2e8f9f7 | 556 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 557 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 558 | |
<> | 144:ef7eb2e8f9f7 | 559 | /* Note : This function is defined into this file for library reference. */ |
<> | 144:ef7eb2e8f9f7 | 560 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
<> | 144:ef7eb2e8f9f7 | 561 | |
<> | 144:ef7eb2e8f9f7 | 562 | /* Return function status */ |
<> | 144:ef7eb2e8f9f7 | 563 | return HAL_ERROR; |
<> | 144:ef7eb2e8f9f7 | 564 | } |
<> | 144:ef7eb2e8f9f7 | 565 | |
<> | 144:ef7eb2e8f9f7 | 566 | /** |
<> | 144:ef7eb2e8f9f7 | 567 | * @brief Wait for regular group conversion to be completed. |
<> | 144:ef7eb2e8f9f7 | 568 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 569 | * @param Timeout: Timeout value in millisecond. |
<> | 144:ef7eb2e8f9f7 | 570 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 571 | */ |
<> | 144:ef7eb2e8f9f7 | 572 | __weak HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout) |
<> | 144:ef7eb2e8f9f7 | 573 | { |
<> | 144:ef7eb2e8f9f7 | 574 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 575 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 576 | UNUSED(Timeout); |
<> | 144:ef7eb2e8f9f7 | 577 | |
<> | 144:ef7eb2e8f9f7 | 578 | /* Note : This function is defined into this file for library reference. */ |
<> | 144:ef7eb2e8f9f7 | 579 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
<> | 144:ef7eb2e8f9f7 | 580 | |
<> | 144:ef7eb2e8f9f7 | 581 | /* Return function status */ |
<> | 144:ef7eb2e8f9f7 | 582 | return HAL_ERROR; |
<> | 144:ef7eb2e8f9f7 | 583 | } |
<> | 144:ef7eb2e8f9f7 | 584 | |
<> | 144:ef7eb2e8f9f7 | 585 | /** |
<> | 144:ef7eb2e8f9f7 | 586 | * @brief Poll for conversion event. |
<> | 144:ef7eb2e8f9f7 | 587 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 588 | * @param EventType: the ADC event type. |
<> | 144:ef7eb2e8f9f7 | 589 | * This parameter can be one of the following values: |
<> | 144:ef7eb2e8f9f7 | 590 | * @arg ADC_AWD_EVENT: ADC Analog watchdog 1 event (main analog watchdog, present on all STM32 devices) |
<> | 144:ef7eb2e8f9f7 | 591 | * @arg ADC_AWD2_EVENT: ADC Analog watchdog 2 event (additional analog watchdog, present only on STM32F3 devices) |
<> | 144:ef7eb2e8f9f7 | 592 | * @arg ADC_AWD3_EVENT: ADC Analog watchdog 3 event (additional analog watchdog, present only on STM32F3 devices) |
<> | 144:ef7eb2e8f9f7 | 593 | * @arg ADC_OVR_EVENT: ADC Overrun event |
<> | 144:ef7eb2e8f9f7 | 594 | * @arg ADC_JQOVF_EVENT: ADC Injected context queue overflow event |
<> | 144:ef7eb2e8f9f7 | 595 | * @param Timeout: Timeout value in millisecond. |
<> | 144:ef7eb2e8f9f7 | 596 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 597 | */ |
<> | 144:ef7eb2e8f9f7 | 598 | __weak HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout) |
<> | 144:ef7eb2e8f9f7 | 599 | { |
<> | 144:ef7eb2e8f9f7 | 600 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 601 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 602 | UNUSED(EventType); |
<> | 144:ef7eb2e8f9f7 | 603 | UNUSED(Timeout); |
<> | 144:ef7eb2e8f9f7 | 604 | |
<> | 144:ef7eb2e8f9f7 | 605 | /* Note : This function is defined into this file for library reference. */ |
<> | 144:ef7eb2e8f9f7 | 606 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
<> | 144:ef7eb2e8f9f7 | 607 | |
<> | 144:ef7eb2e8f9f7 | 608 | /* Return function status */ |
<> | 144:ef7eb2e8f9f7 | 609 | return HAL_ERROR; |
<> | 144:ef7eb2e8f9f7 | 610 | } |
<> | 144:ef7eb2e8f9f7 | 611 | |
<> | 144:ef7eb2e8f9f7 | 612 | /** |
<> | 144:ef7eb2e8f9f7 | 613 | * @brief Enables ADC, starts conversion of regular group with interruption. |
<> | 144:ef7eb2e8f9f7 | 614 | * Interruptions enabled in this function: |
<> | 144:ef7eb2e8f9f7 | 615 | * - EOC (end of conversion of regular group) or EOS (end of |
<> | 144:ef7eb2e8f9f7 | 616 | * sequence of regular group) depending on ADC initialization |
<> | 144:ef7eb2e8f9f7 | 617 | * parameter "EOCSelection" (if available) |
<> | 144:ef7eb2e8f9f7 | 618 | * - overrun (if available) |
<> | 144:ef7eb2e8f9f7 | 619 | * Each of these interruptions has its dedicated callback function. |
<> | 144:ef7eb2e8f9f7 | 620 | * @note: Case of multimode enabled (for devices with several ADCs): This |
<> | 144:ef7eb2e8f9f7 | 621 | * function must be called for ADC slave first, then ADC master. |
<> | 144:ef7eb2e8f9f7 | 622 | * For ADC slave, ADC is enabled only (conversion is not started). |
<> | 144:ef7eb2e8f9f7 | 623 | * For ADC master, ADC is enabled and multimode conversion is started. |
<> | 144:ef7eb2e8f9f7 | 624 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 625 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 626 | */ |
<> | 144:ef7eb2e8f9f7 | 627 | __weak HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc) |
<> | 144:ef7eb2e8f9f7 | 628 | { |
<> | 144:ef7eb2e8f9f7 | 629 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 630 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 631 | |
<> | 144:ef7eb2e8f9f7 | 632 | /* Note : This function is defined into this file for library reference. */ |
<> | 144:ef7eb2e8f9f7 | 633 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
<> | 144:ef7eb2e8f9f7 | 634 | |
<> | 144:ef7eb2e8f9f7 | 635 | /* Return function status */ |
<> | 144:ef7eb2e8f9f7 | 636 | return HAL_ERROR; |
<> | 144:ef7eb2e8f9f7 | 637 | } |
<> | 144:ef7eb2e8f9f7 | 638 | |
<> | 144:ef7eb2e8f9f7 | 639 | /** |
<> | 144:ef7eb2e8f9f7 | 640 | * @brief Stop ADC conversion of regular group (and injected group in |
<> | 144:ef7eb2e8f9f7 | 641 | * case of auto_injection mode), disable interruption of |
<> | 144:ef7eb2e8f9f7 | 642 | * end-of-conversion, disable ADC peripheral. |
<> | 144:ef7eb2e8f9f7 | 643 | * @note: ADC peripheral disable is forcing stop of potential |
<> | 144:ef7eb2e8f9f7 | 644 | * conversion on injected group. If injected group is under use, it |
<> | 144:ef7eb2e8f9f7 | 645 | * should be preliminarily stopped using HAL_ADCEx_InjectedStop function. |
<> | 144:ef7eb2e8f9f7 | 646 | * @note: Case of multimode enabled (for devices with several ADCs): This |
<> | 144:ef7eb2e8f9f7 | 647 | * function must be called for ADC master first, then ADC slave. |
<> | 144:ef7eb2e8f9f7 | 648 | * For ADC master, conversion is stopped and ADC is disabled. |
<> | 144:ef7eb2e8f9f7 | 649 | * For ADC slave, ADC is disabled only (conversion stop of ADC master |
<> | 144:ef7eb2e8f9f7 | 650 | * has already stopped conversion of ADC slave). |
<> | 144:ef7eb2e8f9f7 | 651 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 652 | * @retval HAL status. |
<> | 144:ef7eb2e8f9f7 | 653 | */ |
<> | 144:ef7eb2e8f9f7 | 654 | __weak HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc) |
<> | 144:ef7eb2e8f9f7 | 655 | { |
<> | 144:ef7eb2e8f9f7 | 656 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 657 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 658 | |
<> | 144:ef7eb2e8f9f7 | 659 | /* Note : This function is defined into this file for library reference. */ |
<> | 144:ef7eb2e8f9f7 | 660 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
<> | 144:ef7eb2e8f9f7 | 661 | |
<> | 144:ef7eb2e8f9f7 | 662 | /* Return function status */ |
<> | 144:ef7eb2e8f9f7 | 663 | return HAL_ERROR; |
<> | 144:ef7eb2e8f9f7 | 664 | } |
<> | 144:ef7eb2e8f9f7 | 665 | |
<> | 144:ef7eb2e8f9f7 | 666 | /** |
<> | 144:ef7eb2e8f9f7 | 667 | * @brief Enables ADC, starts conversion of regular group and transfers result |
<> | 144:ef7eb2e8f9f7 | 668 | * through DMA. |
<> | 144:ef7eb2e8f9f7 | 669 | * Interruptions enabled in this function: |
<> | 144:ef7eb2e8f9f7 | 670 | * - DMA transfer complete |
<> | 144:ef7eb2e8f9f7 | 671 | * - DMA half transfer |
<> | 144:ef7eb2e8f9f7 | 672 | * - overrun (if available) |
<> | 144:ef7eb2e8f9f7 | 673 | * Each of these interruptions has its dedicated callback function. |
<> | 144:ef7eb2e8f9f7 | 674 | * @note: Case of multimode enabled (for devices with several ADCs): This |
<> | 144:ef7eb2e8f9f7 | 675 | * function is for single-ADC mode only. For multimode, use the |
<> | 144:ef7eb2e8f9f7 | 676 | * dedicated MultimodeStart function. |
<> | 144:ef7eb2e8f9f7 | 677 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 678 | * @param pData: The destination Buffer address. |
<> | 144:ef7eb2e8f9f7 | 679 | * @param Length: The length of data to be transferred from ADC peripheral to memory. |
<> | 144:ef7eb2e8f9f7 | 680 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 681 | */ |
<> | 144:ef7eb2e8f9f7 | 682 | __weak HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length) |
<> | 144:ef7eb2e8f9f7 | 683 | { |
<> | 144:ef7eb2e8f9f7 | 684 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 685 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 686 | UNUSED(pData); |
<> | 144:ef7eb2e8f9f7 | 687 | UNUSED(Length); |
<> | 144:ef7eb2e8f9f7 | 688 | |
<> | 144:ef7eb2e8f9f7 | 689 | /* Note : This function is defined into this file for library reference. */ |
<> | 144:ef7eb2e8f9f7 | 690 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
<> | 144:ef7eb2e8f9f7 | 691 | |
<> | 144:ef7eb2e8f9f7 | 692 | /* Return function status */ |
<> | 144:ef7eb2e8f9f7 | 693 | return HAL_ERROR; |
<> | 144:ef7eb2e8f9f7 | 694 | } |
<> | 144:ef7eb2e8f9f7 | 695 | |
<> | 144:ef7eb2e8f9f7 | 696 | /** |
<> | 144:ef7eb2e8f9f7 | 697 | * @brief Stop ADC conversion of regular group (and injected group in |
<> | 144:ef7eb2e8f9f7 | 698 | * case of auto_injection mode), disable ADC DMA transfer, disable |
<> | 144:ef7eb2e8f9f7 | 699 | * ADC peripheral. |
<> | 144:ef7eb2e8f9f7 | 700 | * @note: ADC peripheral disable is forcing stop of potential |
<> | 144:ef7eb2e8f9f7 | 701 | * conversion on injected group. If injected group is under use, it |
<> | 144:ef7eb2e8f9f7 | 702 | * should be preliminarily stopped using HAL_ADCEx_InjectedStop function. |
<> | 144:ef7eb2e8f9f7 | 703 | * @note: Case of multimode enabled (for devices with several ADCs): This |
<> | 144:ef7eb2e8f9f7 | 704 | * function is for single-ADC mode only. For multimode, use the |
<> | 144:ef7eb2e8f9f7 | 705 | * dedicated MultimodeStop function. |
<> | 144:ef7eb2e8f9f7 | 706 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 707 | * @retval HAL status. |
<> | 144:ef7eb2e8f9f7 | 708 | */ |
<> | 144:ef7eb2e8f9f7 | 709 | __weak HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc) |
<> | 144:ef7eb2e8f9f7 | 710 | { |
<> | 144:ef7eb2e8f9f7 | 711 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 712 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 713 | |
<> | 144:ef7eb2e8f9f7 | 714 | /* Note : This function is defined into this file for library reference. */ |
<> | 144:ef7eb2e8f9f7 | 715 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
<> | 144:ef7eb2e8f9f7 | 716 | |
<> | 144:ef7eb2e8f9f7 | 717 | /* Return function status */ |
<> | 144:ef7eb2e8f9f7 | 718 | return HAL_ERROR; |
<> | 144:ef7eb2e8f9f7 | 719 | } |
<> | 144:ef7eb2e8f9f7 | 720 | |
<> | 144:ef7eb2e8f9f7 | 721 | /** |
<> | 144:ef7eb2e8f9f7 | 722 | * @brief Get ADC regular group conversion result. |
<> | 144:ef7eb2e8f9f7 | 723 | * @note Reading DR register automatically clears EOC (end of conversion of |
<> | 144:ef7eb2e8f9f7 | 724 | * regular group) flag. |
<> | 144:ef7eb2e8f9f7 | 725 | * Additionally, this functions clears EOS (end of sequence of |
<> | 144:ef7eb2e8f9f7 | 726 | * regular group) flag, in case of the end of the sequence is reached. |
<> | 144:ef7eb2e8f9f7 | 727 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 728 | * @retval Converted value |
<> | 144:ef7eb2e8f9f7 | 729 | */ |
<> | 144:ef7eb2e8f9f7 | 730 | __weak uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc) |
<> | 144:ef7eb2e8f9f7 | 731 | { |
<> | 144:ef7eb2e8f9f7 | 732 | /* Note : This function is defined into this file for library reference. */ |
<> | 144:ef7eb2e8f9f7 | 733 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
<> | 144:ef7eb2e8f9f7 | 734 | |
<> | 144:ef7eb2e8f9f7 | 735 | /* Return ADC converted value */ |
<> | 144:ef7eb2e8f9f7 | 736 | return hadc->Instance->DR; |
<> | 144:ef7eb2e8f9f7 | 737 | } |
<> | 144:ef7eb2e8f9f7 | 738 | |
<> | 144:ef7eb2e8f9f7 | 739 | /** |
<> | 144:ef7eb2e8f9f7 | 740 | * @brief Handles ADC interrupt request. |
<> | 144:ef7eb2e8f9f7 | 741 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 742 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 743 | */ |
<> | 144:ef7eb2e8f9f7 | 744 | __weak void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc) |
<> | 144:ef7eb2e8f9f7 | 745 | { |
<> | 144:ef7eb2e8f9f7 | 746 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 747 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 748 | |
<> | 144:ef7eb2e8f9f7 | 749 | /* Note : This function is defined into this file for library reference. */ |
<> | 144:ef7eb2e8f9f7 | 750 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
<> | 144:ef7eb2e8f9f7 | 751 | } |
<> | 144:ef7eb2e8f9f7 | 752 | |
<> | 144:ef7eb2e8f9f7 | 753 | /** |
<> | 144:ef7eb2e8f9f7 | 754 | * @brief Conversion complete callback in non blocking mode |
<> | 144:ef7eb2e8f9f7 | 755 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 756 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 757 | */ |
<> | 144:ef7eb2e8f9f7 | 758 | __weak void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc) |
<> | 144:ef7eb2e8f9f7 | 759 | { |
<> | 144:ef7eb2e8f9f7 | 760 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 761 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 762 | |
<> | 144:ef7eb2e8f9f7 | 763 | /* NOTE : This function should not be modified. When the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 764 | function HAL_ADC_ConvCpltCallback must be implemented in the user file. |
<> | 144:ef7eb2e8f9f7 | 765 | */ |
<> | 144:ef7eb2e8f9f7 | 766 | } |
<> | 144:ef7eb2e8f9f7 | 767 | |
<> | 144:ef7eb2e8f9f7 | 768 | /** |
<> | 144:ef7eb2e8f9f7 | 769 | * @brief Conversion DMA half-transfer callback in non blocking mode |
<> | 144:ef7eb2e8f9f7 | 770 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 771 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 772 | */ |
<> | 144:ef7eb2e8f9f7 | 773 | __weak void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc) |
<> | 144:ef7eb2e8f9f7 | 774 | { |
<> | 144:ef7eb2e8f9f7 | 775 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 776 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 777 | |
<> | 144:ef7eb2e8f9f7 | 778 | /* NOTE : This function should not be modified. When the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 779 | function HAL_ADC_ConvHalfCpltCallback must be implemented in the user file. |
<> | 144:ef7eb2e8f9f7 | 780 | */ |
<> | 144:ef7eb2e8f9f7 | 781 | } |
<> | 144:ef7eb2e8f9f7 | 782 | |
<> | 144:ef7eb2e8f9f7 | 783 | /** |
<> | 144:ef7eb2e8f9f7 | 784 | * @brief Analog watchdog callback in non blocking mode. |
<> | 144:ef7eb2e8f9f7 | 785 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 786 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 787 | */ |
<> | 144:ef7eb2e8f9f7 | 788 | __weak void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc) |
<> | 144:ef7eb2e8f9f7 | 789 | { |
<> | 144:ef7eb2e8f9f7 | 790 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 791 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 792 | |
<> | 144:ef7eb2e8f9f7 | 793 | /* NOTE : This function should not be modified. When the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 794 | function HAL_ADC_LevelOoutOfWindowCallback must be implemented in the user file. |
<> | 144:ef7eb2e8f9f7 | 795 | */ |
<> | 144:ef7eb2e8f9f7 | 796 | } |
<> | 144:ef7eb2e8f9f7 | 797 | |
<> | 144:ef7eb2e8f9f7 | 798 | /** |
<> | 144:ef7eb2e8f9f7 | 799 | * @brief ADC error callback in non blocking mode |
<> | 144:ef7eb2e8f9f7 | 800 | * (ADC conversion with interruption or transfer by DMA) |
<> | 144:ef7eb2e8f9f7 | 801 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 802 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 803 | */ |
<> | 144:ef7eb2e8f9f7 | 804 | __weak void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc) |
<> | 144:ef7eb2e8f9f7 | 805 | { |
<> | 144:ef7eb2e8f9f7 | 806 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 807 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 808 | |
<> | 144:ef7eb2e8f9f7 | 809 | /* NOTE : This function should not be modified. When the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 810 | function HAL_ADC_ErrorCallback must be implemented in the user file. |
<> | 144:ef7eb2e8f9f7 | 811 | */ |
<> | 144:ef7eb2e8f9f7 | 812 | } |
<> | 144:ef7eb2e8f9f7 | 813 | |
<> | 144:ef7eb2e8f9f7 | 814 | /** |
<> | 144:ef7eb2e8f9f7 | 815 | * @} |
<> | 144:ef7eb2e8f9f7 | 816 | */ |
<> | 144:ef7eb2e8f9f7 | 817 | |
<> | 144:ef7eb2e8f9f7 | 818 | /** @defgroup ADC_Exported_Functions_Group3 Peripheral Control functions |
<> | 144:ef7eb2e8f9f7 | 819 | * @brief Peripheral Control functions |
<> | 144:ef7eb2e8f9f7 | 820 | * |
<> | 144:ef7eb2e8f9f7 | 821 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 822 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 823 | ##### Peripheral Control functions ##### |
<> | 144:ef7eb2e8f9f7 | 824 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 825 | [..] This section provides functions allowing to: |
<> | 144:ef7eb2e8f9f7 | 826 | (+) Configure channels on regular group |
<> | 144:ef7eb2e8f9f7 | 827 | (+) Configure the analog watchdog |
<> | 144:ef7eb2e8f9f7 | 828 | |
<> | 144:ef7eb2e8f9f7 | 829 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 830 | * @{ |
<> | 144:ef7eb2e8f9f7 | 831 | */ |
<> | 144:ef7eb2e8f9f7 | 832 | |
<> | 144:ef7eb2e8f9f7 | 833 | /** |
<> | 144:ef7eb2e8f9f7 | 834 | * @brief Configures the the selected channel to be linked to the regular |
<> | 144:ef7eb2e8f9f7 | 835 | * group. |
<> | 144:ef7eb2e8f9f7 | 836 | * @note In case of usage of internal measurement channels: |
<> | 144:ef7eb2e8f9f7 | 837 | * Vbat/VrefInt/TempSensor. |
<> | 144:ef7eb2e8f9f7 | 838 | * The recommended sampling time is at least: |
<> | 144:ef7eb2e8f9f7 | 839 | * - For devices STM32F37x: 17.1us for temperature sensor |
<> | 144:ef7eb2e8f9f7 | 840 | * - For the other STM32F3 devices: 2.2us for each of channels |
<> | 144:ef7eb2e8f9f7 | 841 | * Vbat/VrefInt/TempSensor. |
<> | 144:ef7eb2e8f9f7 | 842 | * These internal paths can be be disabled using function |
<> | 144:ef7eb2e8f9f7 | 843 | * HAL_ADC_DeInit(). |
<> | 144:ef7eb2e8f9f7 | 844 | * @note Possibility to update parameters on the fly: |
<> | 144:ef7eb2e8f9f7 | 845 | * This function initializes channel into regular group, following |
<> | 144:ef7eb2e8f9f7 | 846 | * calls to this function can be used to reconfigure some parameters |
<> | 144:ef7eb2e8f9f7 | 847 | * of structure "ADC_ChannelConfTypeDef" on the fly, without reseting |
<> | 144:ef7eb2e8f9f7 | 848 | * the ADC. |
<> | 144:ef7eb2e8f9f7 | 849 | * The setting of these parameters is conditioned to ADC state. |
<> | 144:ef7eb2e8f9f7 | 850 | * For parameters constraints, see comments of structure |
<> | 144:ef7eb2e8f9f7 | 851 | * "ADC_ChannelConfTypeDef". |
<> | 144:ef7eb2e8f9f7 | 852 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 853 | * @param sConfig: Structure of ADC channel for regular group. |
<> | 144:ef7eb2e8f9f7 | 854 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 855 | */ |
<> | 144:ef7eb2e8f9f7 | 856 | __weak HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig) |
<> | 144:ef7eb2e8f9f7 | 857 | { |
<> | 144:ef7eb2e8f9f7 | 858 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 859 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 860 | UNUSED(sConfig); |
<> | 144:ef7eb2e8f9f7 | 861 | |
<> | 144:ef7eb2e8f9f7 | 862 | /* Note : This function is defined into this file for library reference. */ |
<> | 144:ef7eb2e8f9f7 | 863 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
<> | 144:ef7eb2e8f9f7 | 864 | |
<> | 144:ef7eb2e8f9f7 | 865 | /* Return function status */ |
<> | 144:ef7eb2e8f9f7 | 866 | return HAL_ERROR; |
<> | 144:ef7eb2e8f9f7 | 867 | } |
<> | 144:ef7eb2e8f9f7 | 868 | |
<> | 144:ef7eb2e8f9f7 | 869 | /** |
<> | 144:ef7eb2e8f9f7 | 870 | * @brief Configures the analog watchdog. |
<> | 144:ef7eb2e8f9f7 | 871 | * @note Possibility to update parameters on the fly: |
<> | 144:ef7eb2e8f9f7 | 872 | * This function initializes the selected analog watchdog, following |
<> | 144:ef7eb2e8f9f7 | 873 | * calls to this function can be used to reconfigure some parameters |
<> | 144:ef7eb2e8f9f7 | 874 | * of structure "ADC_AnalogWDGConfTypeDef" on the fly, without reseting |
<> | 144:ef7eb2e8f9f7 | 875 | * the ADC. |
<> | 144:ef7eb2e8f9f7 | 876 | * The setting of these parameters is conditioned to ADC state. |
<> | 144:ef7eb2e8f9f7 | 877 | * For parameters constraints, see comments of structure |
<> | 144:ef7eb2e8f9f7 | 878 | * "ADC_AnalogWDGConfTypeDef". |
<> | 144:ef7eb2e8f9f7 | 879 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 880 | * @param AnalogWDGConfig: Structure of ADC analog watchdog configuration |
<> | 144:ef7eb2e8f9f7 | 881 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 882 | */ |
<> | 144:ef7eb2e8f9f7 | 883 | __weak HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig) |
<> | 144:ef7eb2e8f9f7 | 884 | { |
<> | 144:ef7eb2e8f9f7 | 885 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 886 | UNUSED(hadc); |
<> | 144:ef7eb2e8f9f7 | 887 | UNUSED(AnalogWDGConfig); |
<> | 144:ef7eb2e8f9f7 | 888 | |
<> | 144:ef7eb2e8f9f7 | 889 | /* Note : This function is defined into this file for library reference. */ |
<> | 144:ef7eb2e8f9f7 | 890 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
<> | 144:ef7eb2e8f9f7 | 891 | |
<> | 144:ef7eb2e8f9f7 | 892 | /* Return function status */ |
<> | 144:ef7eb2e8f9f7 | 893 | return HAL_ERROR; |
<> | 144:ef7eb2e8f9f7 | 894 | } |
<> | 144:ef7eb2e8f9f7 | 895 | |
<> | 144:ef7eb2e8f9f7 | 896 | /** |
<> | 144:ef7eb2e8f9f7 | 897 | * @} |
<> | 144:ef7eb2e8f9f7 | 898 | */ |
<> | 144:ef7eb2e8f9f7 | 899 | |
<> | 144:ef7eb2e8f9f7 | 900 | /** @defgroup ADC_Exported_Functions_Group4 Peripheral State functions |
<> | 144:ef7eb2e8f9f7 | 901 | * @brief ADC Peripheral State functions |
<> | 144:ef7eb2e8f9f7 | 902 | * |
<> | 144:ef7eb2e8f9f7 | 903 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 904 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 905 | ##### Peripheral state and errors functions ##### |
<> | 144:ef7eb2e8f9f7 | 906 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 907 | [..] |
<> | 144:ef7eb2e8f9f7 | 908 | This subsection provides functions to get in run-time the status of the |
<> | 144:ef7eb2e8f9f7 | 909 | peripheral. |
<> | 144:ef7eb2e8f9f7 | 910 | (+) Check the ADC state |
<> | 144:ef7eb2e8f9f7 | 911 | (+) Check the ADC error code |
<> | 144:ef7eb2e8f9f7 | 912 | |
<> | 144:ef7eb2e8f9f7 | 913 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 914 | * @{ |
<> | 144:ef7eb2e8f9f7 | 915 | */ |
<> | 144:ef7eb2e8f9f7 | 916 | |
<> | 144:ef7eb2e8f9f7 | 917 | /** |
<> | 144:ef7eb2e8f9f7 | 918 | * @brief return the ADC state |
<> | 144:ef7eb2e8f9f7 | 919 | * @note ADC state machine is managed by bitfield, state must be compared |
<> | 144:ef7eb2e8f9f7 | 920 | * with bit by bit. |
<> | 144:ef7eb2e8f9f7 | 921 | * For example: |
<> | 144:ef7eb2e8f9f7 | 922 | * " if (HAL_IS_BIT_SET(HAL_ADC_GetState(hadc1), HAL_ADC_STATE_REG_BUSY)) " |
<> | 144:ef7eb2e8f9f7 | 923 | * " if (HAL_IS_BIT_SET(HAL_ADC_GetState(hadc1), HAL_ADC_STATE_AWD1) ) " |
<> | 144:ef7eb2e8f9f7 | 924 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 925 | * @retval HAL state |
<> | 144:ef7eb2e8f9f7 | 926 | */ |
<> | 144:ef7eb2e8f9f7 | 927 | uint32_t HAL_ADC_GetState(ADC_HandleTypeDef* hadc) |
<> | 144:ef7eb2e8f9f7 | 928 | { |
<> | 144:ef7eb2e8f9f7 | 929 | /* Check the parameters */ |
<> | 144:ef7eb2e8f9f7 | 930 | assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance)); |
<> | 144:ef7eb2e8f9f7 | 931 | |
<> | 144:ef7eb2e8f9f7 | 932 | /* Return ADC state */ |
<> | 144:ef7eb2e8f9f7 | 933 | return hadc->State; |
<> | 144:ef7eb2e8f9f7 | 934 | } |
<> | 144:ef7eb2e8f9f7 | 935 | |
<> | 144:ef7eb2e8f9f7 | 936 | /** |
<> | 144:ef7eb2e8f9f7 | 937 | * @brief Return the ADC error code |
<> | 144:ef7eb2e8f9f7 | 938 | * @param hadc: ADC handle |
<> | 144:ef7eb2e8f9f7 | 939 | * @retval ADC Error Code |
<> | 144:ef7eb2e8f9f7 | 940 | */ |
<> | 144:ef7eb2e8f9f7 | 941 | uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc) |
<> | 144:ef7eb2e8f9f7 | 942 | { |
<> | 144:ef7eb2e8f9f7 | 943 | return hadc->ErrorCode; |
<> | 144:ef7eb2e8f9f7 | 944 | } |
<> | 144:ef7eb2e8f9f7 | 945 | |
<> | 144:ef7eb2e8f9f7 | 946 | /** |
<> | 144:ef7eb2e8f9f7 | 947 | * @} |
<> | 144:ef7eb2e8f9f7 | 948 | */ |
<> | 144:ef7eb2e8f9f7 | 949 | |
<> | 144:ef7eb2e8f9f7 | 950 | /** |
<> | 144:ef7eb2e8f9f7 | 951 | * @} |
<> | 144:ef7eb2e8f9f7 | 952 | */ |
<> | 144:ef7eb2e8f9f7 | 953 | |
<> | 144:ef7eb2e8f9f7 | 954 | #endif /* HAL_ADC_MODULE_ENABLED */ |
<> | 144:ef7eb2e8f9f7 | 955 | /** |
<> | 144:ef7eb2e8f9f7 | 956 | * @} |
<> | 144:ef7eb2e8f9f7 | 957 | */ |
<> | 144:ef7eb2e8f9f7 | 958 | |
<> | 144:ef7eb2e8f9f7 | 959 | /** |
<> | 144:ef7eb2e8f9f7 | 960 | * @} |
<> | 144:ef7eb2e8f9f7 | 961 | */ |
<> | 144:ef7eb2e8f9f7 | 962 | |
<> | 144:ef7eb2e8f9f7 | 963 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |