fix LPC812 PWM
Fork of mbed-dev by
targets/cmsis/TARGET_STM/TARGET_STM32F3/stm32f3xx_hal_adc.c@129:2e517c56bcfb, 2016-05-16 (annotated)
- Committer:
- nameless129
- Date:
- Mon May 16 16:50:30 2016 +0000
- Revision:
- 129:2e517c56bcfb
- Parent:
- 0:9b334a45a8ff
PWM Fix:Duty 0%??H???????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bogdanm | 0:9b334a45a8ff | 1 | /** |
bogdanm | 0:9b334a45a8ff | 2 | ****************************************************************************** |
bogdanm | 0:9b334a45a8ff | 3 | * @file stm32f3xx_hal_adc.c |
bogdanm | 0:9b334a45a8ff | 4 | * @author MCD Application conversion |
bogdanm | 0:9b334a45a8ff | 5 | * @version V1.1.0 |
bogdanm | 0:9b334a45a8ff | 6 | * @date 12-Sept-2014 |
bogdanm | 0:9b334a45a8ff | 7 | * @brief This file provides firmware functions to manage the following |
bogdanm | 0:9b334a45a8ff | 8 | * functionalities of the Analog to Digital Convertor (ADC) |
bogdanm | 0:9b334a45a8ff | 9 | * peripheral: |
bogdanm | 0:9b334a45a8ff | 10 | * + Initialization and de-initialization functions |
bogdanm | 0:9b334a45a8ff | 11 | * ++ Initialization and Configuration of ADC |
bogdanm | 0:9b334a45a8ff | 12 | * + Operation functions |
bogdanm | 0:9b334a45a8ff | 13 | * ++ Start, stop, get result of conversions of regular and injected |
bogdanm | 0:9b334a45a8ff | 14 | * groups, using 3 possible modes: polling, interruption or DMA. |
bogdanm | 0:9b334a45a8ff | 15 | * + Control functions |
bogdanm | 0:9b334a45a8ff | 16 | * ++ Analog Watchdog configuration |
bogdanm | 0:9b334a45a8ff | 17 | * ++ Channels configuration on regular group |
bogdanm | 0:9b334a45a8ff | 18 | * + State functions |
bogdanm | 0:9b334a45a8ff | 19 | * ++ ADC state machine management |
bogdanm | 0:9b334a45a8ff | 20 | * ++ Interrupts and flags management |
bogdanm | 0:9b334a45a8ff | 21 | * |
bogdanm | 0:9b334a45a8ff | 22 | @verbatim |
bogdanm | 0:9b334a45a8ff | 23 | ============================================================================== |
bogdanm | 0:9b334a45a8ff | 24 | ##### ADC specific features ##### |
bogdanm | 0:9b334a45a8ff | 25 | ============================================================================== |
bogdanm | 0:9b334a45a8ff | 26 | [..] |
bogdanm | 0:9b334a45a8ff | 27 | (#) 12-bit, 10-bit, 8-bit or 6-bit configurable resolution (available only on |
bogdanm | 0:9b334a45a8ff | 28 | STM32F30xxC devices). |
bogdanm | 0:9b334a45a8ff | 29 | |
bogdanm | 0:9b334a45a8ff | 30 | (#) Interrupt generation at the end of regular conversion, end of injected |
bogdanm | 0:9b334a45a8ff | 31 | conversion, and in case of analog watchdog or overrun events. |
bogdanm | 0:9b334a45a8ff | 32 | |
bogdanm | 0:9b334a45a8ff | 33 | (#) Single and continuous conversion modes. |
bogdanm | 0:9b334a45a8ff | 34 | |
bogdanm | 0:9b334a45a8ff | 35 | (#) Scan mode for automatic conversion of channel 0 to channel 'n'. |
bogdanm | 0:9b334a45a8ff | 36 | |
bogdanm | 0:9b334a45a8ff | 37 | (#) Data alignment with in-built data coherency. |
bogdanm | 0:9b334a45a8ff | 38 | |
bogdanm | 0:9b334a45a8ff | 39 | (#) Channel-wise programmable sampling time. |
bogdanm | 0:9b334a45a8ff | 40 | |
bogdanm | 0:9b334a45a8ff | 41 | (#) ADC conversion Regular or Injected groups. |
bogdanm | 0:9b334a45a8ff | 42 | |
bogdanm | 0:9b334a45a8ff | 43 | (#) External trigger (timer or EXTI) with configurable polarity for both |
bogdanm | 0:9b334a45a8ff | 44 | regular and injected groups. |
bogdanm | 0:9b334a45a8ff | 45 | |
bogdanm | 0:9b334a45a8ff | 46 | (#) DMA request generation for transfer of conversions data of regular group. |
bogdanm | 0:9b334a45a8ff | 47 | |
bogdanm | 0:9b334a45a8ff | 48 | (#) Multimode Dual mode (available on devices with 2 ADCs or more). |
bogdanm | 0:9b334a45a8ff | 49 | |
bogdanm | 0:9b334a45a8ff | 50 | (#) Configurable DMA data storage in Multimode Dual mode (available on devices |
bogdanm | 0:9b334a45a8ff | 51 | with 2 DCs or more). |
bogdanm | 0:9b334a45a8ff | 52 | |
bogdanm | 0:9b334a45a8ff | 53 | (#) Configurable delay between conversions in Dual interleaved mode (available |
bogdanm | 0:9b334a45a8ff | 54 | on devices with 2 DCs or more). |
bogdanm | 0:9b334a45a8ff | 55 | |
bogdanm | 0:9b334a45a8ff | 56 | (#) ADC calibration |
bogdanm | 0:9b334a45a8ff | 57 | |
bogdanm | 0:9b334a45a8ff | 58 | (#) ADC channels selectable single/differential input (available only on |
bogdanm | 0:9b334a45a8ff | 59 | STM32F30xxC devices) |
bogdanm | 0:9b334a45a8ff | 60 | |
bogdanm | 0:9b334a45a8ff | 61 | (#) ADC Injected sequencer&channels configuration context queue (available |
bogdanm | 0:9b334a45a8ff | 62 | only on STM32F30xxC devices) |
bogdanm | 0:9b334a45a8ff | 63 | |
bogdanm | 0:9b334a45a8ff | 64 | (#) ADC offset on injected and regular groups (offset on regular group |
bogdanm | 0:9b334a45a8ff | 65 | available only on STM32F30xxC devices) |
bogdanm | 0:9b334a45a8ff | 66 | |
bogdanm | 0:9b334a45a8ff | 67 | (#) ADC supply requirements: 2.4 V to 3.6 V at full speed and down to 1.8 V at |
bogdanm | 0:9b334a45a8ff | 68 | slower speed. |
bogdanm | 0:9b334a45a8ff | 69 | |
bogdanm | 0:9b334a45a8ff | 70 | (#) ADC input range: from Vref (connected to Vssa) to Vref+ (connected to |
bogdanm | 0:9b334a45a8ff | 71 | Vdda or to an external voltage reference). |
bogdanm | 0:9b334a45a8ff | 72 | |
bogdanm | 0:9b334a45a8ff | 73 | |
bogdanm | 0:9b334a45a8ff | 74 | ##### How to use this driver ##### |
bogdanm | 0:9b334a45a8ff | 75 | ============================================================================== |
bogdanm | 0:9b334a45a8ff | 76 | [..] |
bogdanm | 0:9b334a45a8ff | 77 | |
bogdanm | 0:9b334a45a8ff | 78 | (#) Enable the ADC interface |
bogdanm | 0:9b334a45a8ff | 79 | As prerequisite, into HAL_ADC_MspInit(), ADC clock must be configured |
bogdanm | 0:9b334a45a8ff | 80 | at RCC top level: clock source and clock prescaler. |
bogdanm | 0:9b334a45a8ff | 81 | |
bogdanm | 0:9b334a45a8ff | 82 | For STM32F30x/STM32F33x devices: |
bogdanm | 0:9b334a45a8ff | 83 | Two possible clock sources: synchronous clock derived from AHB clock |
bogdanm | 0:9b334a45a8ff | 84 | or asynchronous clock derived from ADC dedicated PLL 72MHz. |
bogdanm | 0:9b334a45a8ff | 85 | |
bogdanm | 0:9b334a45a8ff | 86 | For example, in case of device with a single ADC: |
bogdanm | 0:9b334a45a8ff | 87 | __ADC1_CLK_ENABLE() (mandatory) |
bogdanm | 0:9b334a45a8ff | 88 | __HAL_RCC_ADC1_CONFIG(RCC_ADC1PLLCLK_DIV1); (optional) |
bogdanm | 0:9b334a45a8ff | 89 | |
bogdanm | 0:9b334a45a8ff | 90 | For example, in case of device with several ADCs: |
bogdanm | 0:9b334a45a8ff | 91 | if((hadc->Instance == ADC1) || (hadc->Instance == ADC2)) |
bogdanm | 0:9b334a45a8ff | 92 | { |
bogdanm | 0:9b334a45a8ff | 93 | __ADC12_CLK_ENABLE() (mandatory) |
bogdanm | 0:9b334a45a8ff | 94 | __HAL_RCC_ADC12_CONFIG(RCC_ADC12PLLCLK_DIV1); (optional) |
bogdanm | 0:9b334a45a8ff | 95 | } |
bogdanm | 0:9b334a45a8ff | 96 | else |
bogdanm | 0:9b334a45a8ff | 97 | { |
bogdanm | 0:9b334a45a8ff | 98 | __ADC34_CLK_ENABLE() (mandatory) |
bogdanm | 0:9b334a45a8ff | 99 | __HAL_RCC_ADC34_CONFIG(RCC_ADC34PLLCLK_DIV1); (optional) |
bogdanm | 0:9b334a45a8ff | 100 | } |
bogdanm | 0:9b334a45a8ff | 101 | |
bogdanm | 0:9b334a45a8ff | 102 | For STM32F37x devices: |
bogdanm | 0:9b334a45a8ff | 103 | Only one clock source: APB2 clock. |
bogdanm | 0:9b334a45a8ff | 104 | Example: |
bogdanm | 0:9b334a45a8ff | 105 | __HAL_RCC_ADC1_CONFIG(RCC_ADC1PCLK2_DIV2); |
bogdanm | 0:9b334a45a8ff | 106 | |
bogdanm | 0:9b334a45a8ff | 107 | (#) ADC pins configuration |
bogdanm | 0:9b334a45a8ff | 108 | (++) Enable the clock for the ADC GPIOs using the following function: |
bogdanm | 0:9b334a45a8ff | 109 | __GPIOx_CLK_ENABLE(); |
bogdanm | 0:9b334a45a8ff | 110 | (++) Configure these ADC pins in analog mode using HAL_GPIO_Init(); |
bogdanm | 0:9b334a45a8ff | 111 | |
bogdanm | 0:9b334a45a8ff | 112 | (#) Configure the ADC parameters (conversion resolution, data alignment, |
bogdanm | 0:9b334a45a8ff | 113 | continuous mode, ...) using the HAL_ADC_Init() function. |
bogdanm | 0:9b334a45a8ff | 114 | |
bogdanm | 0:9b334a45a8ff | 115 | (#) Activate the ADC peripheral using one of the start functions: |
bogdanm | 0:9b334a45a8ff | 116 | HAL_ADC_Start(), HAL_ADC_Start_IT(), HAL_ADC_Start_DMA() |
bogdanm | 0:9b334a45a8ff | 117 | HAL_ADCEx_InjectedStart(), HAL_ADCEx_InjectedStart_IT() or |
bogdanm | 0:9b334a45a8ff | 118 | HAL_ADC_MultiModeStart_DMA(). |
bogdanm | 0:9b334a45a8ff | 119 | |
bogdanm | 0:9b334a45a8ff | 120 | *** Channels to regular group configuration *** |
bogdanm | 0:9b334a45a8ff | 121 | ============================================ |
bogdanm | 0:9b334a45a8ff | 122 | [..] |
bogdanm | 0:9b334a45a8ff | 123 | (+) To configure the ADC regular group features, use |
bogdanm | 0:9b334a45a8ff | 124 | HAL_ADC_Init() and HAL_ADC_ConfigChannel() functions. |
bogdanm | 0:9b334a45a8ff | 125 | (+) To activate the continuous mode, use the HAL_ADC_Init() function. |
bogdanm | 0:9b334a45a8ff | 126 | (+) To read the ADC converted values, use the HAL_ADC_GetValue() function. |
bogdanm | 0:9b334a45a8ff | 127 | |
bogdanm | 0:9b334a45a8ff | 128 | *** Multimode ADCs configuration *** |
bogdanm | 0:9b334a45a8ff | 129 | ====================================================== |
bogdanm | 0:9b334a45a8ff | 130 | [..] |
bogdanm | 0:9b334a45a8ff | 131 | (+) Multimode feature is available on devices with 2 ADCs or more. |
bogdanm | 0:9b334a45a8ff | 132 | (+) Refer to "Channels to regular group" description to |
bogdanm | 0:9b334a45a8ff | 133 | configure the ADC1 and ADC2 regular groups. |
bogdanm | 0:9b334a45a8ff | 134 | (+) Select the Multi mode ADC features (dual mode |
bogdanm | 0:9b334a45a8ff | 135 | simultaneous, interleaved, ...) and configure the DMA mode using |
bogdanm | 0:9b334a45a8ff | 136 | HAL_ADCEx_MultiModeConfigChannel() functions. |
bogdanm | 0:9b334a45a8ff | 137 | (+) Read the ADCs converted values using the HAL_ADCEx_MultiModeGetValue() |
bogdanm | 0:9b334a45a8ff | 138 | function. |
bogdanm | 0:9b334a45a8ff | 139 | |
bogdanm | 0:9b334a45a8ff | 140 | *** DMA for regular configuration *** |
bogdanm | 0:9b334a45a8ff | 141 | ============================================================= |
bogdanm | 0:9b334a45a8ff | 142 | [..] |
bogdanm | 0:9b334a45a8ff | 143 | (+) To enable the DMA mode for regular group, use the |
bogdanm | 0:9b334a45a8ff | 144 | HAL_ADC_Start_DMA() function. |
bogdanm | 0:9b334a45a8ff | 145 | (+) To enable the generation of DMA requests continuously at the end of |
bogdanm | 0:9b334a45a8ff | 146 | the last DMA transfer, use the HAL_ADC_Init() function. |
bogdanm | 0:9b334a45a8ff | 147 | |
bogdanm | 0:9b334a45a8ff | 148 | *** Channels to injected group configuration *** |
bogdanm | 0:9b334a45a8ff | 149 | ============================================= |
bogdanm | 0:9b334a45a8ff | 150 | [..] |
bogdanm | 0:9b334a45a8ff | 151 | (+) To configure the ADC Injected channels group features, use |
bogdanm | 0:9b334a45a8ff | 152 | HAL_ADCEx_InjectedConfigChannel() functions. |
bogdanm | 0:9b334a45a8ff | 153 | (+) To activate the continuous mode, use the HAL_ADC_Init() function. |
bogdanm | 0:9b334a45a8ff | 154 | (+) To read the ADC converted values, use the HAL_ADCEx_InjectedGetValue() |
bogdanm | 0:9b334a45a8ff | 155 | function. |
bogdanm | 0:9b334a45a8ff | 156 | |
bogdanm | 0:9b334a45a8ff | 157 | @endverbatim |
bogdanm | 0:9b334a45a8ff | 158 | ****************************************************************************** |
bogdanm | 0:9b334a45a8ff | 159 | * @attention |
bogdanm | 0:9b334a45a8ff | 160 | * |
bogdanm | 0:9b334a45a8ff | 161 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
bogdanm | 0:9b334a45a8ff | 162 | * |
bogdanm | 0:9b334a45a8ff | 163 | * Redistribution and use in source and binary forms, with or without modification, |
bogdanm | 0:9b334a45a8ff | 164 | * are permitted provided that the following conditions are met: |
bogdanm | 0:9b334a45a8ff | 165 | * 1. Redistributions of source code must retain the above copyright notice, |
bogdanm | 0:9b334a45a8ff | 166 | * this list of conditions and the following disclaimer. |
bogdanm | 0:9b334a45a8ff | 167 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
bogdanm | 0:9b334a45a8ff | 168 | * this list of conditions and the following disclaimer in the documentation |
bogdanm | 0:9b334a45a8ff | 169 | * and/or other materials provided with the distribution. |
bogdanm | 0:9b334a45a8ff | 170 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
bogdanm | 0:9b334a45a8ff | 171 | * may be used to endorse or promote products derived from this software |
bogdanm | 0:9b334a45a8ff | 172 | * without specific prior written permission. |
bogdanm | 0:9b334a45a8ff | 173 | * |
bogdanm | 0:9b334a45a8ff | 174 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
bogdanm | 0:9b334a45a8ff | 175 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
bogdanm | 0:9b334a45a8ff | 176 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
bogdanm | 0:9b334a45a8ff | 177 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
bogdanm | 0:9b334a45a8ff | 178 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
bogdanm | 0:9b334a45a8ff | 179 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
bogdanm | 0:9b334a45a8ff | 180 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
bogdanm | 0:9b334a45a8ff | 181 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
bogdanm | 0:9b334a45a8ff | 182 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
bogdanm | 0:9b334a45a8ff | 183 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
bogdanm | 0:9b334a45a8ff | 184 | * |
bogdanm | 0:9b334a45a8ff | 185 | ****************************************************************************** |
bogdanm | 0:9b334a45a8ff | 186 | */ |
bogdanm | 0:9b334a45a8ff | 187 | |
bogdanm | 0:9b334a45a8ff | 188 | /* Includes ------------------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 189 | #include "stm32f3xx_hal.h" |
bogdanm | 0:9b334a45a8ff | 190 | |
bogdanm | 0:9b334a45a8ff | 191 | /** @addtogroup STM32F3xx_HAL_Driver |
bogdanm | 0:9b334a45a8ff | 192 | * @{ |
bogdanm | 0:9b334a45a8ff | 193 | */ |
bogdanm | 0:9b334a45a8ff | 194 | |
bogdanm | 0:9b334a45a8ff | 195 | /** @defgroup ADC ADC HAL module driver |
bogdanm | 0:9b334a45a8ff | 196 | * @brief ADC HAL module driver |
bogdanm | 0:9b334a45a8ff | 197 | * @{ |
bogdanm | 0:9b334a45a8ff | 198 | */ |
bogdanm | 0:9b334a45a8ff | 199 | |
bogdanm | 0:9b334a45a8ff | 200 | #ifdef HAL_ADC_MODULE_ENABLED |
bogdanm | 0:9b334a45a8ff | 201 | |
bogdanm | 0:9b334a45a8ff | 202 | /* Private typedef -----------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 203 | /* Private define ------------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 204 | /* Private macro -------------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 205 | /* Private variables ---------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 206 | /* Private function prototypes -----------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 207 | /* Exported functions --------------------------------------------------------*/ |
bogdanm | 0:9b334a45a8ff | 208 | |
bogdanm | 0:9b334a45a8ff | 209 | /** @defgroup ADC_Exported_Functions ADC Exported Functions |
bogdanm | 0:9b334a45a8ff | 210 | * @{ |
bogdanm | 0:9b334a45a8ff | 211 | */ |
bogdanm | 0:9b334a45a8ff | 212 | |
bogdanm | 0:9b334a45a8ff | 213 | /** @defgroup ADC_Exported_Functions_Group1 Initialization and de-initialization functions |
bogdanm | 0:9b334a45a8ff | 214 | * @brief Initialization and Configuration functions |
bogdanm | 0:9b334a45a8ff | 215 | * |
bogdanm | 0:9b334a45a8ff | 216 | @verbatim |
bogdanm | 0:9b334a45a8ff | 217 | =============================================================================== |
bogdanm | 0:9b334a45a8ff | 218 | ##### Initialization and de-initialization functions ##### |
bogdanm | 0:9b334a45a8ff | 219 | =============================================================================== |
bogdanm | 0:9b334a45a8ff | 220 | [..] This section provides functions allowing to: |
bogdanm | 0:9b334a45a8ff | 221 | (+) Initialize and configure the ADC. |
bogdanm | 0:9b334a45a8ff | 222 | (+) De-initialize the ADC. |
bogdanm | 0:9b334a45a8ff | 223 | |
bogdanm | 0:9b334a45a8ff | 224 | @endverbatim |
bogdanm | 0:9b334a45a8ff | 225 | * @{ |
bogdanm | 0:9b334a45a8ff | 226 | */ |
bogdanm | 0:9b334a45a8ff | 227 | |
bogdanm | 0:9b334a45a8ff | 228 | /** |
bogdanm | 0:9b334a45a8ff | 229 | * @brief Initializes the ADC peripheral and regular group according to |
bogdanm | 0:9b334a45a8ff | 230 | * parameters specified in structure "ADC_InitTypeDef". |
bogdanm | 0:9b334a45a8ff | 231 | * @note As prerequisite, ADC clock must be configured at RCC top level |
bogdanm | 0:9b334a45a8ff | 232 | * depending on both possible clock sources: PLL clock or AHB clock. |
bogdanm | 0:9b334a45a8ff | 233 | * See commented example code below that can be copied and uncommented |
bogdanm | 0:9b334a45a8ff | 234 | * into HAL_ADC_MspInit(). |
bogdanm | 0:9b334a45a8ff | 235 | * @note Possibility to update parameters on the fly: |
bogdanm | 0:9b334a45a8ff | 236 | * This function initializes the ADC MSP (HAL_ADC_MspInit()) only when |
bogdanm | 0:9b334a45a8ff | 237 | * coming from ADC state reset. Following calls to this function can |
bogdanm | 0:9b334a45a8ff | 238 | * be used to reconfigure some parameters of ADC_InitTypeDef |
bogdanm | 0:9b334a45a8ff | 239 | * structure on the fly, without modifying MSP configuration. If ADC |
bogdanm | 0:9b334a45a8ff | 240 | * MSP has to be modified again, HAL_ADC_DeInit() must be called |
bogdanm | 0:9b334a45a8ff | 241 | * before HAL_ADC_Init(). |
bogdanm | 0:9b334a45a8ff | 242 | * The setting of these parameters is conditioned to ADC state. |
bogdanm | 0:9b334a45a8ff | 243 | * For parameters constraints, see comments of structure |
bogdanm | 0:9b334a45a8ff | 244 | * "ADC_InitTypeDef". |
bogdanm | 0:9b334a45a8ff | 245 | * @note This function configures the ADC within 2 scopes: scope of entire |
bogdanm | 0:9b334a45a8ff | 246 | * ADC and scope of regular group. For parameters details, see comments |
bogdanm | 0:9b334a45a8ff | 247 | * of structure "ADC_InitTypeDef". |
bogdanm | 0:9b334a45a8ff | 248 | * @note For devices with several ADCs: parameters related to common ADC |
bogdanm | 0:9b334a45a8ff | 249 | * registers (ADC clock mode) are set only if all ADCs sharing the |
bogdanm | 0:9b334a45a8ff | 250 | * same common group are disabled. |
bogdanm | 0:9b334a45a8ff | 251 | * If this is not the case, these common parameters setting are |
bogdanm | 0:9b334a45a8ff | 252 | * bypassed without error reporting: it can be the intended behaviour in |
bogdanm | 0:9b334a45a8ff | 253 | * case of update of a parameter of ADC_InitTypeDef on the fly, |
bogdanm | 0:9b334a45a8ff | 254 | * without disabling the other ADCs sharing the same common group. |
bogdanm | 0:9b334a45a8ff | 255 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 256 | * @retval HAL status |
bogdanm | 0:9b334a45a8ff | 257 | */ |
bogdanm | 0:9b334a45a8ff | 258 | __weak HAL_StatusTypeDef HAL_ADC_Init(ADC_HandleTypeDef* hadc) |
bogdanm | 0:9b334a45a8ff | 259 | { |
bogdanm | 0:9b334a45a8ff | 260 | /* Note : This function is defined into this file for library reference. */ |
bogdanm | 0:9b334a45a8ff | 261 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
bogdanm | 0:9b334a45a8ff | 262 | |
bogdanm | 0:9b334a45a8ff | 263 | /* Return function status */ |
bogdanm | 0:9b334a45a8ff | 264 | return HAL_ERROR; |
bogdanm | 0:9b334a45a8ff | 265 | } |
bogdanm | 0:9b334a45a8ff | 266 | |
bogdanm | 0:9b334a45a8ff | 267 | /** |
bogdanm | 0:9b334a45a8ff | 268 | * @brief Deinitialize the ADC peripheral registers to their default reset |
bogdanm | 0:9b334a45a8ff | 269 | * values, with deinitialization of the ADC MSP. |
bogdanm | 0:9b334a45a8ff | 270 | * @note For devices with several ADCs: reset of ADC common registers is done |
bogdanm | 0:9b334a45a8ff | 271 | * only if all ADCs sharing the same common group are disabled. |
bogdanm | 0:9b334a45a8ff | 272 | * If this is not the case, reset of these common parameters reset is |
bogdanm | 0:9b334a45a8ff | 273 | * bypassed without error reporting: it can be the intended behaviour in |
bogdanm | 0:9b334a45a8ff | 274 | * case of reset of a single ADC while the other ADCs sharing the same |
bogdanm | 0:9b334a45a8ff | 275 | * common group is still running. |
bogdanm | 0:9b334a45a8ff | 276 | * @note For devices with several ADCs: Global reset of all ADCs sharing a |
bogdanm | 0:9b334a45a8ff | 277 | * common group is possible. |
bogdanm | 0:9b334a45a8ff | 278 | * As this function is intended to reset a single ADC, to not impact |
bogdanm | 0:9b334a45a8ff | 279 | * other ADCs, instructions for global reset of multiple ADCs have been |
bogdanm | 0:9b334a45a8ff | 280 | * let commented below. |
bogdanm | 0:9b334a45a8ff | 281 | * If needed, the example code can be copied and uncommented into |
bogdanm | 0:9b334a45a8ff | 282 | * function HAL_ADC_MspDeInit(). |
bogdanm | 0:9b334a45a8ff | 283 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 284 | * @retval HAL status |
bogdanm | 0:9b334a45a8ff | 285 | */ |
bogdanm | 0:9b334a45a8ff | 286 | __weak HAL_StatusTypeDef HAL_ADC_DeInit(ADC_HandleTypeDef* hadc) |
bogdanm | 0:9b334a45a8ff | 287 | { |
bogdanm | 0:9b334a45a8ff | 288 | /* Note : This function is defined into this file for library reference. */ |
bogdanm | 0:9b334a45a8ff | 289 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
bogdanm | 0:9b334a45a8ff | 290 | |
bogdanm | 0:9b334a45a8ff | 291 | /* Return function status */ |
bogdanm | 0:9b334a45a8ff | 292 | return HAL_ERROR; |
bogdanm | 0:9b334a45a8ff | 293 | } |
bogdanm | 0:9b334a45a8ff | 294 | |
bogdanm | 0:9b334a45a8ff | 295 | /** |
bogdanm | 0:9b334a45a8ff | 296 | * @brief Initializes the ADC MSP. |
bogdanm | 0:9b334a45a8ff | 297 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 298 | * @retval None |
bogdanm | 0:9b334a45a8ff | 299 | */ |
bogdanm | 0:9b334a45a8ff | 300 | __weak void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc) |
bogdanm | 0:9b334a45a8ff | 301 | { |
bogdanm | 0:9b334a45a8ff | 302 | /* NOTE : This function should not be modified. When the callback is needed, |
bogdanm | 0:9b334a45a8ff | 303 | function HAL_ADC_MspInit must be implemented in the user file. |
bogdanm | 0:9b334a45a8ff | 304 | */ |
bogdanm | 0:9b334a45a8ff | 305 | } |
bogdanm | 0:9b334a45a8ff | 306 | |
bogdanm | 0:9b334a45a8ff | 307 | /** |
bogdanm | 0:9b334a45a8ff | 308 | * @brief DeInitializes the ADC MSP. |
bogdanm | 0:9b334a45a8ff | 309 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 310 | * @retval None |
bogdanm | 0:9b334a45a8ff | 311 | */ |
bogdanm | 0:9b334a45a8ff | 312 | __weak void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc) |
bogdanm | 0:9b334a45a8ff | 313 | { |
bogdanm | 0:9b334a45a8ff | 314 | /* NOTE : This function should not be modified. When the callback is needed, |
bogdanm | 0:9b334a45a8ff | 315 | function HAL_ADC_MspDeInit must be implemented in the user file. |
bogdanm | 0:9b334a45a8ff | 316 | */ |
bogdanm | 0:9b334a45a8ff | 317 | } |
bogdanm | 0:9b334a45a8ff | 318 | |
bogdanm | 0:9b334a45a8ff | 319 | /** |
bogdanm | 0:9b334a45a8ff | 320 | * @} |
bogdanm | 0:9b334a45a8ff | 321 | */ |
bogdanm | 0:9b334a45a8ff | 322 | |
bogdanm | 0:9b334a45a8ff | 323 | /** @defgroup ADC_Exported_Functions_Group2 Input and Output operation functions |
bogdanm | 0:9b334a45a8ff | 324 | * @brief IO operation functions |
bogdanm | 0:9b334a45a8ff | 325 | * |
bogdanm | 0:9b334a45a8ff | 326 | @verbatim |
bogdanm | 0:9b334a45a8ff | 327 | =============================================================================== |
bogdanm | 0:9b334a45a8ff | 328 | ##### IO operation functions ##### |
bogdanm | 0:9b334a45a8ff | 329 | =============================================================================== |
bogdanm | 0:9b334a45a8ff | 330 | [..] This section provides functions allowing to: |
bogdanm | 0:9b334a45a8ff | 331 | (+) Start conversion of regular group. |
bogdanm | 0:9b334a45a8ff | 332 | (+) Stop conversion of regular group. |
bogdanm | 0:9b334a45a8ff | 333 | (+) Poll for conversion complete on regular group. |
bogdanm | 0:9b334a45a8ff | 334 | (+) Poll for conversion event. |
bogdanm | 0:9b334a45a8ff | 335 | (+) Get result of regular channel conversion. |
bogdanm | 0:9b334a45a8ff | 336 | (+) Start conversion of regular group and enable interruptions. |
bogdanm | 0:9b334a45a8ff | 337 | (+) Stop conversion of regular group and disable interruptions. |
bogdanm | 0:9b334a45a8ff | 338 | (+) Handle ADC interrupt request |
bogdanm | 0:9b334a45a8ff | 339 | (+) Start conversion of regular group and enable DMA transfer. |
bogdanm | 0:9b334a45a8ff | 340 | (+) Stop conversion of regular group and disable ADC DMA transfer. |
bogdanm | 0:9b334a45a8ff | 341 | |
bogdanm | 0:9b334a45a8ff | 342 | @endverbatim |
bogdanm | 0:9b334a45a8ff | 343 | * @{ |
bogdanm | 0:9b334a45a8ff | 344 | */ |
bogdanm | 0:9b334a45a8ff | 345 | /** |
bogdanm | 0:9b334a45a8ff | 346 | * @brief Enables ADC, starts conversion of regular group. |
bogdanm | 0:9b334a45a8ff | 347 | * Interruptions enabled in this function: None. |
bogdanm | 0:9b334a45a8ff | 348 | * @note: Case of multimode enabled (for devices with several ADCs): This |
bogdanm | 0:9b334a45a8ff | 349 | * function must be called for ADC slave first, then ADC master. |
bogdanm | 0:9b334a45a8ff | 350 | * For ADC slave, ADC is enabled only (conversion is not started). |
bogdanm | 0:9b334a45a8ff | 351 | * For ADC master, ADC is enabled and multimode conversion is started. |
bogdanm | 0:9b334a45a8ff | 352 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 353 | * @retval HAL status |
bogdanm | 0:9b334a45a8ff | 354 | */ |
bogdanm | 0:9b334a45a8ff | 355 | __weak HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef* hadc) |
bogdanm | 0:9b334a45a8ff | 356 | { |
bogdanm | 0:9b334a45a8ff | 357 | /* Return function status */ |
bogdanm | 0:9b334a45a8ff | 358 | return HAL_ERROR; |
bogdanm | 0:9b334a45a8ff | 359 | } |
bogdanm | 0:9b334a45a8ff | 360 | |
bogdanm | 0:9b334a45a8ff | 361 | /** |
bogdanm | 0:9b334a45a8ff | 362 | * @brief Stop ADC conversion of regular group (and injected group in |
bogdanm | 0:9b334a45a8ff | 363 | * case of auto_injection mode), disable ADC peripheral. |
bogdanm | 0:9b334a45a8ff | 364 | * @note: ADC peripheral disable is forcing interruption of potential |
bogdanm | 0:9b334a45a8ff | 365 | * conversion on injected group. If injected group is under use, it |
bogdanm | 0:9b334a45a8ff | 366 | * should be preliminarily stopped using HAL_ADCEx_InjectedStop function. |
bogdanm | 0:9b334a45a8ff | 367 | * @note: Case of multimode enabled (for devices with several ADCs): This |
bogdanm | 0:9b334a45a8ff | 368 | * function must be called for ADC master first, then ADC slave. |
bogdanm | 0:9b334a45a8ff | 369 | * For ADC master, converson is stopped and ADC is disabled. |
bogdanm | 0:9b334a45a8ff | 370 | * For ADC slave, ADC is disabled only (conversion stop of ADC master |
bogdanm | 0:9b334a45a8ff | 371 | * has already stopped conversion of ADC slave). |
bogdanm | 0:9b334a45a8ff | 372 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 373 | * @retval HAL status. |
bogdanm | 0:9b334a45a8ff | 374 | */ |
bogdanm | 0:9b334a45a8ff | 375 | __weak HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef* hadc) |
bogdanm | 0:9b334a45a8ff | 376 | { |
bogdanm | 0:9b334a45a8ff | 377 | /* Note : This function is defined into this file for library reference. */ |
bogdanm | 0:9b334a45a8ff | 378 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
bogdanm | 0:9b334a45a8ff | 379 | |
bogdanm | 0:9b334a45a8ff | 380 | /* Return function status */ |
bogdanm | 0:9b334a45a8ff | 381 | return HAL_ERROR; |
bogdanm | 0:9b334a45a8ff | 382 | } |
bogdanm | 0:9b334a45a8ff | 383 | |
bogdanm | 0:9b334a45a8ff | 384 | /** |
bogdanm | 0:9b334a45a8ff | 385 | * @brief Wait for regular group conversion to be completed. |
bogdanm | 0:9b334a45a8ff | 386 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 387 | * @param Timeout: Timeout value in millisecond. |
bogdanm | 0:9b334a45a8ff | 388 | * @retval HAL status |
bogdanm | 0:9b334a45a8ff | 389 | */ |
bogdanm | 0:9b334a45a8ff | 390 | __weak HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout) |
bogdanm | 0:9b334a45a8ff | 391 | { |
bogdanm | 0:9b334a45a8ff | 392 | /* Note : This function is defined into this file for library reference. */ |
bogdanm | 0:9b334a45a8ff | 393 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
bogdanm | 0:9b334a45a8ff | 394 | |
bogdanm | 0:9b334a45a8ff | 395 | /* Return function status */ |
bogdanm | 0:9b334a45a8ff | 396 | return HAL_ERROR; |
bogdanm | 0:9b334a45a8ff | 397 | } |
bogdanm | 0:9b334a45a8ff | 398 | |
bogdanm | 0:9b334a45a8ff | 399 | /** |
bogdanm | 0:9b334a45a8ff | 400 | * @brief Poll for conversion event. |
bogdanm | 0:9b334a45a8ff | 401 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 402 | * @param EventType: the ADC event type. |
bogdanm | 0:9b334a45a8ff | 403 | * This parameter can be one of the following values: |
bogdanm | 0:9b334a45a8ff | 404 | * @arg AWD_EVENT: ADC Analog watchdog 1 event (main analog watchdog, present on all STM32 devices) |
bogdanm | 0:9b334a45a8ff | 405 | * @arg AWD2_EVENT: ADC Analog watchdog 2 event (additional analog watchdog, present only on STM32F3 devices) |
bogdanm | 0:9b334a45a8ff | 406 | * @arg AWD3_EVENT: ADC Analog watchdog 3 event (additional analog watchdog, present only on STM32F3 devices) |
bogdanm | 0:9b334a45a8ff | 407 | * @arg OVR_EVENT: ADC Overrun event |
bogdanm | 0:9b334a45a8ff | 408 | * @arg JQOVF_EVENT: ADC Injected context queue overflow event |
bogdanm | 0:9b334a45a8ff | 409 | * @param Timeout: Timeout value in millisecond. |
bogdanm | 0:9b334a45a8ff | 410 | * @retval HAL status |
bogdanm | 0:9b334a45a8ff | 411 | */ |
bogdanm | 0:9b334a45a8ff | 412 | __weak HAL_StatusTypeDef HAL_ADC_PollForEvent(ADC_HandleTypeDef* hadc, uint32_t EventType, uint32_t Timeout) |
bogdanm | 0:9b334a45a8ff | 413 | { |
bogdanm | 0:9b334a45a8ff | 414 | /* Note : This function is defined into this file for library reference. */ |
bogdanm | 0:9b334a45a8ff | 415 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
bogdanm | 0:9b334a45a8ff | 416 | |
bogdanm | 0:9b334a45a8ff | 417 | /* Return function status */ |
bogdanm | 0:9b334a45a8ff | 418 | return HAL_ERROR; |
bogdanm | 0:9b334a45a8ff | 419 | } |
bogdanm | 0:9b334a45a8ff | 420 | |
bogdanm | 0:9b334a45a8ff | 421 | /** |
bogdanm | 0:9b334a45a8ff | 422 | * @brief Enables ADC, starts conversion of regular group with interruption. |
bogdanm | 0:9b334a45a8ff | 423 | * Interruptions enabled in this function: EOC (end of conversion), |
bogdanm | 0:9b334a45a8ff | 424 | * overrun (if available). |
bogdanm | 0:9b334a45a8ff | 425 | * Each of these interruptions has its dedicated callback function. |
bogdanm | 0:9b334a45a8ff | 426 | * @note: Case of multimode enabled (for devices with several ADCs): This |
bogdanm | 0:9b334a45a8ff | 427 | * function must be called for ADC slave first, then ADC master. |
bogdanm | 0:9b334a45a8ff | 428 | * For ADC slave, ADC is enabled only (conversion is not started). |
bogdanm | 0:9b334a45a8ff | 429 | * For ADC master, ADC is enabled and multimode conversion is started. |
bogdanm | 0:9b334a45a8ff | 430 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 431 | * @retval HAL status |
bogdanm | 0:9b334a45a8ff | 432 | */ |
bogdanm | 0:9b334a45a8ff | 433 | __weak HAL_StatusTypeDef HAL_ADC_Start_IT(ADC_HandleTypeDef* hadc) |
bogdanm | 0:9b334a45a8ff | 434 | { |
bogdanm | 0:9b334a45a8ff | 435 | /* Note : This function is defined into this file for library reference. */ |
bogdanm | 0:9b334a45a8ff | 436 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
bogdanm | 0:9b334a45a8ff | 437 | |
bogdanm | 0:9b334a45a8ff | 438 | /* Return function status */ |
bogdanm | 0:9b334a45a8ff | 439 | return HAL_ERROR; |
bogdanm | 0:9b334a45a8ff | 440 | } |
bogdanm | 0:9b334a45a8ff | 441 | |
bogdanm | 0:9b334a45a8ff | 442 | /** |
bogdanm | 0:9b334a45a8ff | 443 | * @brief Stop ADC conversion of regular group (and injected group in |
bogdanm | 0:9b334a45a8ff | 444 | * case of auto_injection mode), disable interruption of |
bogdanm | 0:9b334a45a8ff | 445 | * end-of-conversion, disable ADC peripheral. |
bogdanm | 0:9b334a45a8ff | 446 | * @note: ADC peripheral disable is forcing interruption of potential |
bogdanm | 0:9b334a45a8ff | 447 | * conversion on injected group. If injected group is under use, it |
bogdanm | 0:9b334a45a8ff | 448 | * should be preliminarily stopped using HAL_ADCEx_InjectedStop function. |
bogdanm | 0:9b334a45a8ff | 449 | * @note: Case of multimode enabled (for devices with several ADCs): This |
bogdanm | 0:9b334a45a8ff | 450 | * function must be called for ADC master first, then ADC slave. |
bogdanm | 0:9b334a45a8ff | 451 | * For ADC master, conversion is stopped and ADC is disabled. |
bogdanm | 0:9b334a45a8ff | 452 | * For ADC slave, ADC is disabled only (conversion stop of ADC master |
bogdanm | 0:9b334a45a8ff | 453 | * has already stopped conversion of ADC slave). |
bogdanm | 0:9b334a45a8ff | 454 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 455 | * @retval HAL status. |
bogdanm | 0:9b334a45a8ff | 456 | */ |
bogdanm | 0:9b334a45a8ff | 457 | __weak HAL_StatusTypeDef HAL_ADC_Stop_IT(ADC_HandleTypeDef* hadc) |
bogdanm | 0:9b334a45a8ff | 458 | { |
bogdanm | 0:9b334a45a8ff | 459 | /* Note : This function is defined into this file for library reference. */ |
bogdanm | 0:9b334a45a8ff | 460 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
bogdanm | 0:9b334a45a8ff | 461 | |
bogdanm | 0:9b334a45a8ff | 462 | /* Return function status */ |
bogdanm | 0:9b334a45a8ff | 463 | return HAL_ERROR; |
bogdanm | 0:9b334a45a8ff | 464 | } |
bogdanm | 0:9b334a45a8ff | 465 | |
bogdanm | 0:9b334a45a8ff | 466 | /** |
bogdanm | 0:9b334a45a8ff | 467 | * @brief Enables ADC, starts conversion of regular group and transfers result |
bogdanm | 0:9b334a45a8ff | 468 | * through DMA. |
bogdanm | 0:9b334a45a8ff | 469 | * Interruptions enabled in this function: |
bogdanm | 0:9b334a45a8ff | 470 | * overrun (if available), DMA half transfer, DMA transfer complete. |
bogdanm | 0:9b334a45a8ff | 471 | * Each of these interruptions has its dedicated callback function. |
bogdanm | 0:9b334a45a8ff | 472 | * @note: Case of multimode enabled (for devices with several ADCs): This |
bogdanm | 0:9b334a45a8ff | 473 | * function is for single-ADC mode only. For multimode, use the |
bogdanm | 0:9b334a45a8ff | 474 | * dedicated MultimodeStart function. |
bogdanm | 0:9b334a45a8ff | 475 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 476 | * @param pData: The destination Buffer address. |
bogdanm | 0:9b334a45a8ff | 477 | * @param Length: The length of data to be transferred from ADC peripheral to memory. |
bogdanm | 0:9b334a45a8ff | 478 | * @retval None |
bogdanm | 0:9b334a45a8ff | 479 | */ |
bogdanm | 0:9b334a45a8ff | 480 | __weak HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length) |
bogdanm | 0:9b334a45a8ff | 481 | { |
bogdanm | 0:9b334a45a8ff | 482 | /* Note : This function is defined into this file for library reference. */ |
bogdanm | 0:9b334a45a8ff | 483 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
bogdanm | 0:9b334a45a8ff | 484 | |
bogdanm | 0:9b334a45a8ff | 485 | /* Return function status */ |
bogdanm | 0:9b334a45a8ff | 486 | return HAL_ERROR; |
bogdanm | 0:9b334a45a8ff | 487 | } |
bogdanm | 0:9b334a45a8ff | 488 | |
bogdanm | 0:9b334a45a8ff | 489 | /** |
bogdanm | 0:9b334a45a8ff | 490 | * @brief Stop ADC conversion of regular group (and injected group in |
bogdanm | 0:9b334a45a8ff | 491 | * case of auto_injection mode), disable ADC DMA transfer, disable |
bogdanm | 0:9b334a45a8ff | 492 | * ADC peripheral. |
bogdanm | 0:9b334a45a8ff | 493 | * @note: ADC peripheral disable is forcing interruption of potential |
bogdanm | 0:9b334a45a8ff | 494 | * conversion on injected group. If injected group is under use, it |
bogdanm | 0:9b334a45a8ff | 495 | * should be preliminarily stopped using HAL_ADCEx_InjectedStop function. |
bogdanm | 0:9b334a45a8ff | 496 | * @note: Case of multimode enabled (for devices with several ADCs): This |
bogdanm | 0:9b334a45a8ff | 497 | * function is for single-ADC mode only. For multimode, use the |
bogdanm | 0:9b334a45a8ff | 498 | * dedicated MultimodeStop function. |
bogdanm | 0:9b334a45a8ff | 499 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 500 | * @retval HAL status. |
bogdanm | 0:9b334a45a8ff | 501 | */ |
bogdanm | 0:9b334a45a8ff | 502 | __weak HAL_StatusTypeDef HAL_ADC_Stop_DMA(ADC_HandleTypeDef* hadc) |
bogdanm | 0:9b334a45a8ff | 503 | { |
bogdanm | 0:9b334a45a8ff | 504 | /* Note : This function is defined into this file for library reference. */ |
bogdanm | 0:9b334a45a8ff | 505 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
bogdanm | 0:9b334a45a8ff | 506 | |
bogdanm | 0:9b334a45a8ff | 507 | /* Return function status */ |
bogdanm | 0:9b334a45a8ff | 508 | return HAL_ERROR; |
bogdanm | 0:9b334a45a8ff | 509 | } |
bogdanm | 0:9b334a45a8ff | 510 | |
bogdanm | 0:9b334a45a8ff | 511 | /** |
bogdanm | 0:9b334a45a8ff | 512 | * @brief Get ADC regular group conversion result. |
bogdanm | 0:9b334a45a8ff | 513 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 514 | * @retval Converted value |
bogdanm | 0:9b334a45a8ff | 515 | */ |
bogdanm | 0:9b334a45a8ff | 516 | __weak uint32_t HAL_ADC_GetValue(ADC_HandleTypeDef* hadc) |
bogdanm | 0:9b334a45a8ff | 517 | { |
bogdanm | 0:9b334a45a8ff | 518 | /* Note : This function is defined into this file for library reference. */ |
bogdanm | 0:9b334a45a8ff | 519 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
bogdanm | 0:9b334a45a8ff | 520 | |
bogdanm | 0:9b334a45a8ff | 521 | /* Return ADC converted value */ |
bogdanm | 0:9b334a45a8ff | 522 | return hadc->Instance->DR; |
bogdanm | 0:9b334a45a8ff | 523 | } |
bogdanm | 0:9b334a45a8ff | 524 | |
bogdanm | 0:9b334a45a8ff | 525 | /** |
bogdanm | 0:9b334a45a8ff | 526 | * @brief Handles ADC interrupt request. |
bogdanm | 0:9b334a45a8ff | 527 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 528 | * @retval None |
bogdanm | 0:9b334a45a8ff | 529 | */ |
bogdanm | 0:9b334a45a8ff | 530 | __weak void HAL_ADC_IRQHandler(ADC_HandleTypeDef* hadc) |
bogdanm | 0:9b334a45a8ff | 531 | { |
bogdanm | 0:9b334a45a8ff | 532 | /* Note : This function is defined into this file for library reference. */ |
bogdanm | 0:9b334a45a8ff | 533 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
bogdanm | 0:9b334a45a8ff | 534 | } |
bogdanm | 0:9b334a45a8ff | 535 | |
bogdanm | 0:9b334a45a8ff | 536 | /** |
bogdanm | 0:9b334a45a8ff | 537 | * @brief Conversion complete callback in non blocking mode |
bogdanm | 0:9b334a45a8ff | 538 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 539 | * @retval None |
bogdanm | 0:9b334a45a8ff | 540 | */ |
bogdanm | 0:9b334a45a8ff | 541 | __weak void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc) |
bogdanm | 0:9b334a45a8ff | 542 | { |
bogdanm | 0:9b334a45a8ff | 543 | /* NOTE : This function should not be modified. When the callback is needed, |
bogdanm | 0:9b334a45a8ff | 544 | function HAL_ADC_ConvCpltCallback must be implemented in the user file. |
bogdanm | 0:9b334a45a8ff | 545 | */ |
bogdanm | 0:9b334a45a8ff | 546 | } |
bogdanm | 0:9b334a45a8ff | 547 | |
bogdanm | 0:9b334a45a8ff | 548 | /** |
bogdanm | 0:9b334a45a8ff | 549 | * @brief Conversion DMA half-transfer callback in non blocking mode |
bogdanm | 0:9b334a45a8ff | 550 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 551 | * @retval None |
bogdanm | 0:9b334a45a8ff | 552 | */ |
bogdanm | 0:9b334a45a8ff | 553 | __weak void HAL_ADC_ConvHalfCpltCallback(ADC_HandleTypeDef* hadc) |
bogdanm | 0:9b334a45a8ff | 554 | { |
bogdanm | 0:9b334a45a8ff | 555 | /* NOTE : This function should not be modified. When the callback is needed, |
bogdanm | 0:9b334a45a8ff | 556 | function HAL_ADC_ConvHalfCpltCallback must be implemented in the user file. |
bogdanm | 0:9b334a45a8ff | 557 | */ |
bogdanm | 0:9b334a45a8ff | 558 | } |
bogdanm | 0:9b334a45a8ff | 559 | |
bogdanm | 0:9b334a45a8ff | 560 | /** |
bogdanm | 0:9b334a45a8ff | 561 | * @brief Analog watchdog callback in non blocking mode. |
bogdanm | 0:9b334a45a8ff | 562 | * @note: In case of several analog watchdog enabled, if needed to know |
bogdanm | 0:9b334a45a8ff | 563 | which one triggered and on which ADCx, check Analog Watchdog flag |
bogdanm | 0:9b334a45a8ff | 564 | ADC_FLAG_AWD1/2/3 into HAL_ADC_LevelOutOfWindowCallback() function. |
bogdanm | 0:9b334a45a8ff | 565 | For example:"if (__HAL_ADC_GET_FLAG(hadc1, ADC_FLAG_AWD1) != RESET)" |
bogdanm | 0:9b334a45a8ff | 566 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 567 | * @retval None |
bogdanm | 0:9b334a45a8ff | 568 | */ |
bogdanm | 0:9b334a45a8ff | 569 | __weak void HAL_ADC_LevelOutOfWindowCallback(ADC_HandleTypeDef* hadc) |
bogdanm | 0:9b334a45a8ff | 570 | { |
bogdanm | 0:9b334a45a8ff | 571 | /* NOTE : This function should not be modified. When the callback is needed, |
bogdanm | 0:9b334a45a8ff | 572 | function HAL_ADC_LevelOoutOfWindowCallback must be implemented in the user file. |
bogdanm | 0:9b334a45a8ff | 573 | */ |
bogdanm | 0:9b334a45a8ff | 574 | } |
bogdanm | 0:9b334a45a8ff | 575 | |
bogdanm | 0:9b334a45a8ff | 576 | /** |
bogdanm | 0:9b334a45a8ff | 577 | * @brief ADC error callback in non blocking mode |
bogdanm | 0:9b334a45a8ff | 578 | * (ADC conversion with interruption or transfer by DMA) |
bogdanm | 0:9b334a45a8ff | 579 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 580 | * @retval None |
bogdanm | 0:9b334a45a8ff | 581 | */ |
bogdanm | 0:9b334a45a8ff | 582 | __weak void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc) |
bogdanm | 0:9b334a45a8ff | 583 | { |
bogdanm | 0:9b334a45a8ff | 584 | /* NOTE : This function should not be modified. When the callback is needed, |
bogdanm | 0:9b334a45a8ff | 585 | function HAL_ADC_ErrorCallback must be implemented in the user file. |
bogdanm | 0:9b334a45a8ff | 586 | */ |
bogdanm | 0:9b334a45a8ff | 587 | } |
bogdanm | 0:9b334a45a8ff | 588 | |
bogdanm | 0:9b334a45a8ff | 589 | /** |
bogdanm | 0:9b334a45a8ff | 590 | * @} |
bogdanm | 0:9b334a45a8ff | 591 | */ |
bogdanm | 0:9b334a45a8ff | 592 | |
bogdanm | 0:9b334a45a8ff | 593 | /** @defgroup ADC_Exported_Functions_Group3 Peripheral Control functions |
bogdanm | 0:9b334a45a8ff | 594 | * @brief Peripheral Control functions |
bogdanm | 0:9b334a45a8ff | 595 | * |
bogdanm | 0:9b334a45a8ff | 596 | @verbatim |
bogdanm | 0:9b334a45a8ff | 597 | =============================================================================== |
bogdanm | 0:9b334a45a8ff | 598 | ##### Peripheral Control functions ##### |
bogdanm | 0:9b334a45a8ff | 599 | =============================================================================== |
bogdanm | 0:9b334a45a8ff | 600 | [..] This section provides functions allowing to: |
bogdanm | 0:9b334a45a8ff | 601 | (+) Configure channels on regular group |
bogdanm | 0:9b334a45a8ff | 602 | (+) Configure the analog watchdog |
bogdanm | 0:9b334a45a8ff | 603 | |
bogdanm | 0:9b334a45a8ff | 604 | @endverbatim |
bogdanm | 0:9b334a45a8ff | 605 | * @{ |
bogdanm | 0:9b334a45a8ff | 606 | */ |
bogdanm | 0:9b334a45a8ff | 607 | |
bogdanm | 0:9b334a45a8ff | 608 | /** |
bogdanm | 0:9b334a45a8ff | 609 | * @brief Configures the the selected channel to be linked to the regular |
bogdanm | 0:9b334a45a8ff | 610 | * group. |
bogdanm | 0:9b334a45a8ff | 611 | * @note In case of usage of internal measurement channels: |
bogdanm | 0:9b334a45a8ff | 612 | * Vbat/VrefInt/TempSensor. |
bogdanm | 0:9b334a45a8ff | 613 | * The recommended sampling time is at least: |
bogdanm | 0:9b334a45a8ff | 614 | * - For devices STM32F37x: 17.1us for temperature sensor |
bogdanm | 0:9b334a45a8ff | 615 | * - For the other STM32F3 devices: 2.2us for each of channels |
bogdanm | 0:9b334a45a8ff | 616 | * Vbat/VrefInt/TempSensor. |
bogdanm | 0:9b334a45a8ff | 617 | * These internal paths can be be disabled using function |
bogdanm | 0:9b334a45a8ff | 618 | * HAL_ADC_DeInit(). |
bogdanm | 0:9b334a45a8ff | 619 | * @note Possibility to update parameters on the fly: |
bogdanm | 0:9b334a45a8ff | 620 | * This function initializes channel into regular group, following |
bogdanm | 0:9b334a45a8ff | 621 | * calls to this function can be used to reconfigure some parameters |
bogdanm | 0:9b334a45a8ff | 622 | * of structure "ADC_ChannelConfTypeDef" on the fly, without reseting |
bogdanm | 0:9b334a45a8ff | 623 | * the ADC. |
bogdanm | 0:9b334a45a8ff | 624 | * The setting of these parameters is conditioned to ADC state. |
bogdanm | 0:9b334a45a8ff | 625 | * For parameters constraints, see comments of structure |
bogdanm | 0:9b334a45a8ff | 626 | * "ADC_ChannelConfTypeDef". |
bogdanm | 0:9b334a45a8ff | 627 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 628 | * @param sConfig: Structure of ADC channel for regular group. |
bogdanm | 0:9b334a45a8ff | 629 | * @retval HAL status |
bogdanm | 0:9b334a45a8ff | 630 | */ |
bogdanm | 0:9b334a45a8ff | 631 | __weak HAL_StatusTypeDef HAL_ADC_ConfigChannel(ADC_HandleTypeDef* hadc, ADC_ChannelConfTypeDef* sConfig) |
bogdanm | 0:9b334a45a8ff | 632 | { |
bogdanm | 0:9b334a45a8ff | 633 | /* Note : This function is defined into this file for library reference. */ |
bogdanm | 0:9b334a45a8ff | 634 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
bogdanm | 0:9b334a45a8ff | 635 | |
bogdanm | 0:9b334a45a8ff | 636 | /* Return function status */ |
bogdanm | 0:9b334a45a8ff | 637 | return HAL_ERROR; |
bogdanm | 0:9b334a45a8ff | 638 | } |
bogdanm | 0:9b334a45a8ff | 639 | |
bogdanm | 0:9b334a45a8ff | 640 | /** |
bogdanm | 0:9b334a45a8ff | 641 | * @brief Configures the analog watchdog. |
bogdanm | 0:9b334a45a8ff | 642 | * @note Possibility to update parameters on the fly: |
bogdanm | 0:9b334a45a8ff | 643 | * This function initializes the selected analog watchdog, following |
bogdanm | 0:9b334a45a8ff | 644 | * calls to this function can be used to reconfigure some parameters |
bogdanm | 0:9b334a45a8ff | 645 | * of structure "ADC_AnalogWDGConfTypeDef" on the fly, without reseting |
bogdanm | 0:9b334a45a8ff | 646 | * the ADC. |
bogdanm | 0:9b334a45a8ff | 647 | * The setting of these parameters is conditioned to ADC state. |
bogdanm | 0:9b334a45a8ff | 648 | * For parameters constraints, see comments of structure |
bogdanm | 0:9b334a45a8ff | 649 | * "ADC_AnalogWDGConfTypeDef". |
bogdanm | 0:9b334a45a8ff | 650 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 651 | * @param AnalogWDGConfig: Structure of ADC analog watchdog configuration |
bogdanm | 0:9b334a45a8ff | 652 | * @retval HAL status |
bogdanm | 0:9b334a45a8ff | 653 | */ |
bogdanm | 0:9b334a45a8ff | 654 | __weak HAL_StatusTypeDef HAL_ADC_AnalogWDGConfig(ADC_HandleTypeDef* hadc, ADC_AnalogWDGConfTypeDef* AnalogWDGConfig) |
bogdanm | 0:9b334a45a8ff | 655 | { |
bogdanm | 0:9b334a45a8ff | 656 | /* Note : This function is defined into this file for library reference. */ |
bogdanm | 0:9b334a45a8ff | 657 | /* Function content is located into file stm32f3xx_hal_adc_ex.c */ |
bogdanm | 0:9b334a45a8ff | 658 | |
bogdanm | 0:9b334a45a8ff | 659 | /* Return function status */ |
bogdanm | 0:9b334a45a8ff | 660 | return HAL_ERROR; |
bogdanm | 0:9b334a45a8ff | 661 | } |
bogdanm | 0:9b334a45a8ff | 662 | |
bogdanm | 0:9b334a45a8ff | 663 | /** |
bogdanm | 0:9b334a45a8ff | 664 | * @} |
bogdanm | 0:9b334a45a8ff | 665 | */ |
bogdanm | 0:9b334a45a8ff | 666 | |
bogdanm | 0:9b334a45a8ff | 667 | /** @defgroup ADC_Exported_Functions_Group4 Peripheral State functions |
bogdanm | 0:9b334a45a8ff | 668 | * @brief ADC Peripheral State functions |
bogdanm | 0:9b334a45a8ff | 669 | * |
bogdanm | 0:9b334a45a8ff | 670 | @verbatim |
bogdanm | 0:9b334a45a8ff | 671 | =============================================================================== |
bogdanm | 0:9b334a45a8ff | 672 | ##### Peripheral state and errors functions ##### |
bogdanm | 0:9b334a45a8ff | 673 | =============================================================================== |
bogdanm | 0:9b334a45a8ff | 674 | [..] |
bogdanm | 0:9b334a45a8ff | 675 | This subsection provides functions to get in run-time the status of the |
bogdanm | 0:9b334a45a8ff | 676 | peripheral. |
bogdanm | 0:9b334a45a8ff | 677 | (+) Check the ADC state |
bogdanm | 0:9b334a45a8ff | 678 | (+) Check the ADC error code |
bogdanm | 0:9b334a45a8ff | 679 | |
bogdanm | 0:9b334a45a8ff | 680 | @endverbatim |
bogdanm | 0:9b334a45a8ff | 681 | * @{ |
bogdanm | 0:9b334a45a8ff | 682 | */ |
bogdanm | 0:9b334a45a8ff | 683 | |
bogdanm | 0:9b334a45a8ff | 684 | /** |
bogdanm | 0:9b334a45a8ff | 685 | * @brief return the ADC state |
bogdanm | 0:9b334a45a8ff | 686 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 687 | * @retval HAL state |
bogdanm | 0:9b334a45a8ff | 688 | */ |
bogdanm | 0:9b334a45a8ff | 689 | HAL_ADC_StateTypeDef HAL_ADC_GetState(ADC_HandleTypeDef* hadc) |
bogdanm | 0:9b334a45a8ff | 690 | { |
bogdanm | 0:9b334a45a8ff | 691 | /* Check the parameters */ |
bogdanm | 0:9b334a45a8ff | 692 | assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance)); |
bogdanm | 0:9b334a45a8ff | 693 | |
bogdanm | 0:9b334a45a8ff | 694 | /* Return ADC state */ |
bogdanm | 0:9b334a45a8ff | 695 | return hadc->State; |
bogdanm | 0:9b334a45a8ff | 696 | } |
bogdanm | 0:9b334a45a8ff | 697 | |
bogdanm | 0:9b334a45a8ff | 698 | /** |
bogdanm | 0:9b334a45a8ff | 699 | * @brief Return the ADC error code |
bogdanm | 0:9b334a45a8ff | 700 | * @param hadc: ADC handle |
bogdanm | 0:9b334a45a8ff | 701 | * @retval ADC Error Code |
bogdanm | 0:9b334a45a8ff | 702 | */ |
bogdanm | 0:9b334a45a8ff | 703 | uint32_t HAL_ADC_GetError(ADC_HandleTypeDef *hadc) |
bogdanm | 0:9b334a45a8ff | 704 | { |
bogdanm | 0:9b334a45a8ff | 705 | return hadc->ErrorCode; |
bogdanm | 0:9b334a45a8ff | 706 | } |
bogdanm | 0:9b334a45a8ff | 707 | |
bogdanm | 0:9b334a45a8ff | 708 | /** |
bogdanm | 0:9b334a45a8ff | 709 | * @} |
bogdanm | 0:9b334a45a8ff | 710 | */ |
bogdanm | 0:9b334a45a8ff | 711 | |
bogdanm | 0:9b334a45a8ff | 712 | /** |
bogdanm | 0:9b334a45a8ff | 713 | * @} |
bogdanm | 0:9b334a45a8ff | 714 | */ |
bogdanm | 0:9b334a45a8ff | 715 | |
bogdanm | 0:9b334a45a8ff | 716 | #endif /* HAL_ADC_MODULE_ENABLED */ |
bogdanm | 0:9b334a45a8ff | 717 | /** |
bogdanm | 0:9b334a45a8ff | 718 | * @} |
bogdanm | 0:9b334a45a8ff | 719 | */ |
bogdanm | 0:9b334a45a8ff | 720 | |
bogdanm | 0:9b334a45a8ff | 721 | /** |
bogdanm | 0:9b334a45a8ff | 722 | * @} |
bogdanm | 0:9b334a45a8ff | 723 | */ |
bogdanm | 0:9b334a45a8ff | 724 | |
bogdanm | 0:9b334a45a8ff | 725 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |