mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F401RE/stm32f4xx_hal_adc_ex.c@226:b062af740e40, 2014-06-11 (annotated)
- Committer:
- mbed_official
- Date:
- Wed Jun 11 09:45:09 2014 +0100
- Revision:
- 226:b062af740e40
- Parent:
- 106:ced8cbb51063
Synchronized with git revision 42deb9ac55f9bdf9835e9c41dc757117d344ffda
Full URL: https://github.com/mbedmicro/mbed/commit/42deb9ac55f9bdf9835e9c41dc757117d344ffda/
[NUCLEO_F401RE] Remove call to Systick + bug fixes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 87:085cde657901 | 1 | /** |
mbed_official | 87:085cde657901 | 2 | ****************************************************************************** |
mbed_official | 87:085cde657901 | 3 | * @file stm32f4xx_hal_adc_ex.c |
mbed_official | 87:085cde657901 | 4 | * @author MCD Application Team |
mbed_official | 226:b062af740e40 | 5 | * @version V1.1.0RC2 |
mbed_official | 226:b062af740e40 | 6 | * @date 14-May-2014 |
mbed_official | 87:085cde657901 | 7 | * @brief This file provides firmware functions to manage the following |
mbed_official | 87:085cde657901 | 8 | * functionalities of the ADC extension peripheral: |
mbed_official | 87:085cde657901 | 9 | * + Extended features functions |
mbed_official | 87:085cde657901 | 10 | * |
mbed_official | 87:085cde657901 | 11 | @verbatim |
mbed_official | 87:085cde657901 | 12 | ============================================================================== |
mbed_official | 87:085cde657901 | 13 | ##### How to use this driver ##### |
mbed_official | 87:085cde657901 | 14 | ============================================================================== |
mbed_official | 87:085cde657901 | 15 | [..] |
mbed_official | 87:085cde657901 | 16 | (#)Initialize the ADC low level resources by implementing the HAL_ADC_MspInit(): |
mbed_official | 87:085cde657901 | 17 | (##) Enable the ADC interface clock using __ADC_CLK_ENABLE() |
mbed_official | 87:085cde657901 | 18 | (##) ADC pins configuration |
mbed_official | 87:085cde657901 | 19 | (+++) Enable the clock for the ADC GPIOs using the following function: |
mbed_official | 87:085cde657901 | 20 | __GPIOx_CLK_ENABLE() |
mbed_official | 87:085cde657901 | 21 | (+++) Configure these ADC pins in analog mode using HAL_GPIO_Init() |
mbed_official | 87:085cde657901 | 22 | (##) In case of using interrupts (e.g. HAL_ADC_Start_IT()) |
mbed_official | 87:085cde657901 | 23 | (+++) Configure the ADC interrupt priority using HAL_NVIC_SetPriority() |
mbed_official | 87:085cde657901 | 24 | (+++) Enable the ADC IRQ handler using HAL_NVIC_EnableIRQ() |
mbed_official | 87:085cde657901 | 25 | (+++) In ADC IRQ handler, call HAL_ADC_IRQHandler() |
mbed_official | 87:085cde657901 | 26 | (##) In case of using DMA to control data transfer (e.g. HAL_ADC_Start_DMA()) |
mbed_official | 226:b062af740e40 | 27 | (+++) Enable the DMAx interface clock using __DMAx_CLK_ENABLE() |
mbed_official | 226:b062af740e40 | 28 | (+++) Configure and enable two DMA streams stream for managing data |
mbed_official | 87:085cde657901 | 29 | transfer from peripheral to memory (output stream) |
mbed_official | 226:b062af740e40 | 30 | (+++) Associate the initilalized DMA handle to the ADC DMA handle |
mbed_official | 87:085cde657901 | 31 | using __HAL_LINKDMA() |
mbed_official | 226:b062af740e40 | 32 | (+++) Configure the priority and enable the NVIC for the transfer complete |
mbed_official | 87:085cde657901 | 33 | interrupt on the two DMA Streams. The output stream should have higher |
mbed_official | 226:b062af740e40 | 34 | priority than the input stream. |
mbed_official | 87:085cde657901 | 35 | (#) Configure the ADC Prescaler, conversion resolution and data alignment |
mbed_official | 87:085cde657901 | 36 | using the HAL_ADC_Init() function. |
mbed_official | 87:085cde657901 | 37 | |
mbed_official | 87:085cde657901 | 38 | (#) Configure the ADC Injected channels group features, use HAL_ADC_Init() |
mbed_official | 87:085cde657901 | 39 | and HAL_ADC_ConfigChannel() functions. |
mbed_official | 87:085cde657901 | 40 | |
mbed_official | 226:b062af740e40 | 41 | (#) Three operation modes are available within this driver : |
mbed_official | 87:085cde657901 | 42 | |
mbed_official | 87:085cde657901 | 43 | *** Polling mode IO operation *** |
mbed_official | 87:085cde657901 | 44 | ================================= |
mbed_official | 87:085cde657901 | 45 | [..] |
mbed_official | 87:085cde657901 | 46 | (+) Start the ADC peripheral using HAL_ADCEx_InjectedStart() |
mbed_official | 87:085cde657901 | 47 | (+) Wait for end of conversion using HAL_ADC_PollForConversion(), at this stage |
mbed_official | 87:085cde657901 | 48 | user can specify the value of timeout according to his end application |
mbed_official | 87:085cde657901 | 49 | (+) To read the ADC converted values, use the HAL_ADCEx_InjectedGetValue() function. |
mbed_official | 87:085cde657901 | 50 | (+) Stop the ADC peripheral using HAL_ADCEx_InjectedStop() |
mbed_official | 87:085cde657901 | 51 | |
mbed_official | 87:085cde657901 | 52 | *** Interrupt mode IO operation *** |
mbed_official | 87:085cde657901 | 53 | =================================== |
mbed_official | 87:085cde657901 | 54 | [..] |
mbed_official | 87:085cde657901 | 55 | (+) Start the ADC peripheral using HAL_ADCEx_InjectedStart_IT() |
mbed_official | 87:085cde657901 | 56 | (+) Use HAL_ADC_IRQHandler() called under ADC_IRQHandler() Interrupt subroutine |
mbed_official | 87:085cde657901 | 57 | (+) At ADC end of conversion HAL_ADCEx_InjectedConvCpltCallback() function is executed and user can |
mbed_official | 87:085cde657901 | 58 | add his own code by customization of function pointer HAL_ADCEx_InjectedConvCpltCallback |
mbed_official | 87:085cde657901 | 59 | (+) In case of ADC Error, HAL_ADCEx_InjectedErrorCallback() function is executed and user can |
mbed_official | 87:085cde657901 | 60 | add his own code by customization of function pointer HAL_ADCEx_InjectedErrorCallback |
mbed_official | 87:085cde657901 | 61 | (+) Stop the ADC peripheral using HAL_ADCEx_InjectedStop_IT() |
mbed_official | 87:085cde657901 | 62 | |
mbed_official | 87:085cde657901 | 63 | |
mbed_official | 87:085cde657901 | 64 | *** DMA mode IO operation *** |
mbed_official | 87:085cde657901 | 65 | ============================== |
mbed_official | 87:085cde657901 | 66 | [..] |
mbed_official | 87:085cde657901 | 67 | (+) Start the ADC peripheral using HAL_ADCEx_InjectedStart_DMA(), at this stage the user specify the length |
mbed_official | 226:b062af740e40 | 68 | of data to be transferred at each end of conversion |
mbed_official | 87:085cde657901 | 69 | (+) At The end of data transfer ba HAL_ADCEx_InjectedConvCpltCallback() function is executed and user can |
mbed_official | 87:085cde657901 | 70 | add his own code by customization of function pointer HAL_ADCEx_InjectedConvCpltCallback |
mbed_official | 87:085cde657901 | 71 | (+) In case of transfer Error, HAL_ADCEx_InjectedErrorCallback() function is executed and user can |
mbed_official | 87:085cde657901 | 72 | add his own code by customization of function pointer HAL_ADCEx_InjectedErrorCallback |
mbed_official | 87:085cde657901 | 73 | (+) Stop the ADC peripheral using HAL_ADCEx_InjectedStop_DMA() |
mbed_official | 87:085cde657901 | 74 | |
mbed_official | 87:085cde657901 | 75 | *** Multi mode ADCs Regular channels configuration *** |
mbed_official | 87:085cde657901 | 76 | ====================================================== |
mbed_official | 87:085cde657901 | 77 | [..] |
mbed_official | 87:085cde657901 | 78 | (+) Select the Multi mode ADC regular channels features (dual or triple mode) |
mbed_official | 87:085cde657901 | 79 | and configure the DMA mode using HAL_ADCEx_MultiModeConfigChannel() functions. |
mbed_official | 87:085cde657901 | 80 | (+) Start the ADC peripheral using HAL_ADCEx_MultiModeStart_DMA(), at this stage the user specify the length |
mbed_official | 226:b062af740e40 | 81 | of data to be transferred at each end of conversion |
mbed_official | 87:085cde657901 | 82 | (+) Read the ADCs converted values using the HAL_ADCEx_MultiModeGetValue() function. |
mbed_official | 87:085cde657901 | 83 | |
mbed_official | 87:085cde657901 | 84 | |
mbed_official | 87:085cde657901 | 85 | @endverbatim |
mbed_official | 87:085cde657901 | 86 | ****************************************************************************** |
mbed_official | 87:085cde657901 | 87 | * @attention |
mbed_official | 87:085cde657901 | 88 | * |
mbed_official | 87:085cde657901 | 89 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 87:085cde657901 | 90 | * |
mbed_official | 87:085cde657901 | 91 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 87:085cde657901 | 92 | * are permitted provided that the following conditions are met: |
mbed_official | 87:085cde657901 | 93 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 87:085cde657901 | 94 | * this list of conditions and the following disclaimer. |
mbed_official | 87:085cde657901 | 95 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 87:085cde657901 | 96 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 87:085cde657901 | 97 | * and/or other materials provided with the distribution. |
mbed_official | 87:085cde657901 | 98 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 87:085cde657901 | 99 | * may be used to endorse or promote products derived from this software |
mbed_official | 87:085cde657901 | 100 | * without specific prior written permission. |
mbed_official | 87:085cde657901 | 101 | * |
mbed_official | 87:085cde657901 | 102 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 87:085cde657901 | 103 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 87:085cde657901 | 104 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 87:085cde657901 | 105 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 87:085cde657901 | 106 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 87:085cde657901 | 107 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 87:085cde657901 | 108 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 87:085cde657901 | 109 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 87:085cde657901 | 110 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 87:085cde657901 | 111 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 87:085cde657901 | 112 | * |
mbed_official | 87:085cde657901 | 113 | ****************************************************************************** |
mbed_official | 87:085cde657901 | 114 | */ |
mbed_official | 87:085cde657901 | 115 | |
mbed_official | 87:085cde657901 | 116 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 117 | #include "stm32f4xx_hal.h" |
mbed_official | 87:085cde657901 | 118 | |
mbed_official | 87:085cde657901 | 119 | /** @addtogroup STM32F4xx_HAL_Driver |
mbed_official | 87:085cde657901 | 120 | * @{ |
mbed_official | 87:085cde657901 | 121 | */ |
mbed_official | 87:085cde657901 | 122 | |
mbed_official | 87:085cde657901 | 123 | /** @defgroup ADCEx |
mbed_official | 87:085cde657901 | 124 | * @brief ADC Extended driver modules |
mbed_official | 87:085cde657901 | 125 | * @{ |
mbed_official | 87:085cde657901 | 126 | */ |
mbed_official | 87:085cde657901 | 127 | |
mbed_official | 87:085cde657901 | 128 | #ifdef HAL_ADC_MODULE_ENABLED |
mbed_official | 87:085cde657901 | 129 | |
mbed_official | 87:085cde657901 | 130 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 131 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 132 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 133 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 134 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 87:085cde657901 | 135 | static void ADC_MultiModeDMAConvCplt(DMA_HandleTypeDef *hdma); |
mbed_official | 87:085cde657901 | 136 | static void ADC_MultiModeDMAError(DMA_HandleTypeDef *hdma); |
mbed_official | 87:085cde657901 | 137 | static void ADC_MultiModeDMAHalfConvCplt(DMA_HandleTypeDef *hdma); |
mbed_official | 87:085cde657901 | 138 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 87:085cde657901 | 139 | |
mbed_official | 87:085cde657901 | 140 | /** @defgroup ADCEx_Private_Functions |
mbed_official | 87:085cde657901 | 141 | * @{ |
mbed_official | 87:085cde657901 | 142 | */ |
mbed_official | 87:085cde657901 | 143 | |
mbed_official | 87:085cde657901 | 144 | /** @defgroup ADCEx_Group1 Extended features functions |
mbed_official | 87:085cde657901 | 145 | * @brief Extended features functions |
mbed_official | 87:085cde657901 | 146 | * |
mbed_official | 87:085cde657901 | 147 | @verbatim |
mbed_official | 87:085cde657901 | 148 | =============================================================================== |
mbed_official | 87:085cde657901 | 149 | ##### Extended features functions ##### |
mbed_official | 87:085cde657901 | 150 | =============================================================================== |
mbed_official | 87:085cde657901 | 151 | [..] This section provides functions allowing to: |
mbed_official | 87:085cde657901 | 152 | (+) Start conversion of injected channel. |
mbed_official | 87:085cde657901 | 153 | (+) Stop conversion of injected channel. |
mbed_official | 87:085cde657901 | 154 | (+) Start multimode and enable DMA transfer. |
mbed_official | 87:085cde657901 | 155 | (+) Stop multimode and disable DMA transfer. |
mbed_official | 87:085cde657901 | 156 | (+) Get result of injected channel conversion. |
mbed_official | 87:085cde657901 | 157 | (+) Get result of multimode conversion. |
mbed_official | 87:085cde657901 | 158 | (+) Configure injected channels. |
mbed_official | 87:085cde657901 | 159 | (+) Configure multimode. |
mbed_official | 87:085cde657901 | 160 | |
mbed_official | 87:085cde657901 | 161 | @endverbatim |
mbed_official | 87:085cde657901 | 162 | * @{ |
mbed_official | 87:085cde657901 | 163 | */ |
mbed_official | 87:085cde657901 | 164 | |
mbed_official | 87:085cde657901 | 165 | /** |
mbed_official | 87:085cde657901 | 166 | * @brief Enables the selected ADC software start conversion of the injected channels. |
mbed_official | 87:085cde657901 | 167 | * @param hadc: pointer to a ADC_HandleTypeDef structure that contains |
mbed_official | 87:085cde657901 | 168 | * the configuration information for the specified ADC. |
mbed_official | 87:085cde657901 | 169 | * @retval HAL status |
mbed_official | 87:085cde657901 | 170 | */ |
mbed_official | 87:085cde657901 | 171 | HAL_StatusTypeDef HAL_ADCEx_InjectedStart(ADC_HandleTypeDef* hadc) |
mbed_official | 87:085cde657901 | 172 | { |
mbed_official | 87:085cde657901 | 173 | uint32_t i = 0, tmp1 = 0, tmp2 = 0; |
mbed_official | 87:085cde657901 | 174 | |
mbed_official | 87:085cde657901 | 175 | /* Process locked */ |
mbed_official | 87:085cde657901 | 176 | __HAL_LOCK(hadc); |
mbed_official | 87:085cde657901 | 177 | |
mbed_official | 87:085cde657901 | 178 | /* Check if a regular conversion is ongoing */ |
mbed_official | 87:085cde657901 | 179 | if(hadc->State == HAL_ADC_STATE_BUSY_REG) |
mbed_official | 87:085cde657901 | 180 | { |
mbed_official | 87:085cde657901 | 181 | /* Change ADC state */ |
mbed_official | 87:085cde657901 | 182 | hadc->State = HAL_ADC_STATE_BUSY_INJ_REG; |
mbed_official | 87:085cde657901 | 183 | } |
mbed_official | 87:085cde657901 | 184 | else |
mbed_official | 87:085cde657901 | 185 | { |
mbed_official | 87:085cde657901 | 186 | /* Change ADC state */ |
mbed_official | 87:085cde657901 | 187 | hadc->State = HAL_ADC_STATE_BUSY_INJ; |
mbed_official | 87:085cde657901 | 188 | } |
mbed_official | 87:085cde657901 | 189 | |
mbed_official | 87:085cde657901 | 190 | /* Check if ADC peripheral is disabled in order to enable it and wait during |
mbed_official | 87:085cde657901 | 191 | Tstab time the ADC's stabilization */ |
mbed_official | 87:085cde657901 | 192 | if((hadc->Instance->CR2 & ADC_CR2_ADON) != ADC_CR2_ADON) |
mbed_official | 87:085cde657901 | 193 | { |
mbed_official | 87:085cde657901 | 194 | /* Enable the Peripheral */ |
mbed_official | 87:085cde657901 | 195 | __HAL_ADC_ENABLE(hadc); |
mbed_official | 87:085cde657901 | 196 | |
mbed_official | 87:085cde657901 | 197 | /* Delay inserted to wait during Tstab time the ADC's stabilazation */ |
mbed_official | 87:085cde657901 | 198 | for(; i <= 540; i++) |
mbed_official | 87:085cde657901 | 199 | { |
mbed_official | 87:085cde657901 | 200 | __NOP(); |
mbed_official | 87:085cde657901 | 201 | } |
mbed_official | 87:085cde657901 | 202 | } |
mbed_official | 87:085cde657901 | 203 | |
mbed_official | 87:085cde657901 | 204 | /* Check if Multimode enabled */ |
mbed_official | 87:085cde657901 | 205 | if(HAL_IS_BIT_CLR(ADC->CCR, ADC_CCR_MULTI)) |
mbed_official | 87:085cde657901 | 206 | { |
mbed_official | 87:085cde657901 | 207 | tmp1 = HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_JEXTEN); |
mbed_official | 87:085cde657901 | 208 | tmp2 = HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO); |
mbed_official | 87:085cde657901 | 209 | if(tmp1 && tmp2) |
mbed_official | 87:085cde657901 | 210 | { |
mbed_official | 87:085cde657901 | 211 | /* Enable the selected ADC software conversion for injected group */ |
mbed_official | 87:085cde657901 | 212 | hadc->Instance->CR2 |= ADC_CR2_JSWSTART; |
mbed_official | 87:085cde657901 | 213 | } |
mbed_official | 87:085cde657901 | 214 | } |
mbed_official | 87:085cde657901 | 215 | else |
mbed_official | 87:085cde657901 | 216 | { |
mbed_official | 87:085cde657901 | 217 | tmp1 = HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_JEXTEN); |
mbed_official | 87:085cde657901 | 218 | tmp2 = HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO); |
mbed_official | 87:085cde657901 | 219 | if((hadc->Instance == ADC1) && tmp1 && tmp2) |
mbed_official | 87:085cde657901 | 220 | { |
mbed_official | 87:085cde657901 | 221 | /* Enable the selected ADC software conversion for injected group */ |
mbed_official | 87:085cde657901 | 222 | hadc->Instance->CR2 |= ADC_CR2_JSWSTART; |
mbed_official | 87:085cde657901 | 223 | } |
mbed_official | 87:085cde657901 | 224 | } |
mbed_official | 87:085cde657901 | 225 | |
mbed_official | 87:085cde657901 | 226 | /* Process unlocked */ |
mbed_official | 87:085cde657901 | 227 | __HAL_UNLOCK(hadc); |
mbed_official | 87:085cde657901 | 228 | |
mbed_official | 87:085cde657901 | 229 | /* Return function status */ |
mbed_official | 87:085cde657901 | 230 | return HAL_OK; |
mbed_official | 87:085cde657901 | 231 | } |
mbed_official | 87:085cde657901 | 232 | |
mbed_official | 87:085cde657901 | 233 | /** |
mbed_official | 87:085cde657901 | 234 | * @brief Enables the interrupt and starts ADC conversion of injected channels. |
mbed_official | 87:085cde657901 | 235 | * @param hadc: pointer to a ADC_HandleTypeDef structure that contains |
mbed_official | 87:085cde657901 | 236 | * the configuration information for the specified ADC. |
mbed_official | 87:085cde657901 | 237 | * |
mbed_official | 87:085cde657901 | 238 | * @retval HAL status. |
mbed_official | 87:085cde657901 | 239 | */ |
mbed_official | 87:085cde657901 | 240 | HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT(ADC_HandleTypeDef* hadc) |
mbed_official | 87:085cde657901 | 241 | { |
mbed_official | 87:085cde657901 | 242 | uint32_t i = 0, tmp1 = 0, tmp2 =0; |
mbed_official | 87:085cde657901 | 243 | |
mbed_official | 87:085cde657901 | 244 | /* Process locked */ |
mbed_official | 87:085cde657901 | 245 | __HAL_LOCK(hadc); |
mbed_official | 87:085cde657901 | 246 | |
mbed_official | 87:085cde657901 | 247 | /* Check if a regular conversion is ongoing */ |
mbed_official | 87:085cde657901 | 248 | if(hadc->State == HAL_ADC_STATE_BUSY_REG) |
mbed_official | 87:085cde657901 | 249 | { |
mbed_official | 87:085cde657901 | 250 | /* Change ADC state */ |
mbed_official | 87:085cde657901 | 251 | hadc->State = HAL_ADC_STATE_BUSY_INJ_REG; |
mbed_official | 87:085cde657901 | 252 | } |
mbed_official | 87:085cde657901 | 253 | else |
mbed_official | 87:085cde657901 | 254 | { |
mbed_official | 87:085cde657901 | 255 | /* Change ADC state */ |
mbed_official | 87:085cde657901 | 256 | hadc->State = HAL_ADC_STATE_BUSY_INJ; |
mbed_official | 87:085cde657901 | 257 | } |
mbed_official | 87:085cde657901 | 258 | |
mbed_official | 87:085cde657901 | 259 | /* Set ADC error code to none */ |
mbed_official | 87:085cde657901 | 260 | hadc->ErrorCode = HAL_ADC_ERROR_NONE; |
mbed_official | 87:085cde657901 | 261 | |
mbed_official | 87:085cde657901 | 262 | /* Check if ADC peripheral is disabled in order to enable it and wait during |
mbed_official | 87:085cde657901 | 263 | Tstab time the ADC's stabilization */ |
mbed_official | 87:085cde657901 | 264 | if((hadc->Instance->CR2 & ADC_CR2_ADON) != ADC_CR2_ADON) |
mbed_official | 87:085cde657901 | 265 | { |
mbed_official | 87:085cde657901 | 266 | /* Enable the Peripheral */ |
mbed_official | 87:085cde657901 | 267 | __HAL_ADC_ENABLE(hadc); |
mbed_official | 87:085cde657901 | 268 | |
mbed_official | 87:085cde657901 | 269 | /* Delay inserted to wait during Tstab time the ADC's stabilazation */ |
mbed_official | 87:085cde657901 | 270 | for(; i <= 540; i++) |
mbed_official | 87:085cde657901 | 271 | { |
mbed_official | 87:085cde657901 | 272 | __NOP(); |
mbed_official | 87:085cde657901 | 273 | } |
mbed_official | 87:085cde657901 | 274 | } |
mbed_official | 87:085cde657901 | 275 | |
mbed_official | 87:085cde657901 | 276 | /* Enable the ADC end of conversion interrupt for injected group */ |
mbed_official | 87:085cde657901 | 277 | __HAL_ADC_ENABLE_IT(hadc, ADC_IT_JEOC); |
mbed_official | 87:085cde657901 | 278 | |
mbed_official | 87:085cde657901 | 279 | /* Enable the ADC overrun interrupt */ |
mbed_official | 87:085cde657901 | 280 | __HAL_ADC_ENABLE_IT(hadc, ADC_IT_OVR); |
mbed_official | 87:085cde657901 | 281 | |
mbed_official | 87:085cde657901 | 282 | /* Check if Multimode enabled */ |
mbed_official | 87:085cde657901 | 283 | if(HAL_IS_BIT_CLR(ADC->CCR, ADC_CCR_MULTI)) |
mbed_official | 87:085cde657901 | 284 | { |
mbed_official | 87:085cde657901 | 285 | tmp1 = HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_JEXTEN); |
mbed_official | 87:085cde657901 | 286 | tmp2 = HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO); |
mbed_official | 87:085cde657901 | 287 | if(tmp1 && tmp2) |
mbed_official | 87:085cde657901 | 288 | { |
mbed_official | 87:085cde657901 | 289 | /* Enable the selected ADC software conversion for injected group */ |
mbed_official | 87:085cde657901 | 290 | hadc->Instance->CR2 |= ADC_CR2_JSWSTART; |
mbed_official | 87:085cde657901 | 291 | } |
mbed_official | 87:085cde657901 | 292 | } |
mbed_official | 87:085cde657901 | 293 | else |
mbed_official | 87:085cde657901 | 294 | { |
mbed_official | 87:085cde657901 | 295 | tmp1 = HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_JEXTEN); |
mbed_official | 87:085cde657901 | 296 | tmp2 = HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO); |
mbed_official | 87:085cde657901 | 297 | if((hadc->Instance == ADC1) && tmp1 && tmp2) |
mbed_official | 87:085cde657901 | 298 | { |
mbed_official | 87:085cde657901 | 299 | /* Enable the selected ADC software conversion for injected group */ |
mbed_official | 87:085cde657901 | 300 | hadc->Instance->CR2 |= ADC_CR2_JSWSTART; |
mbed_official | 87:085cde657901 | 301 | } |
mbed_official | 87:085cde657901 | 302 | } |
mbed_official | 87:085cde657901 | 303 | |
mbed_official | 87:085cde657901 | 304 | /* Process unlocked */ |
mbed_official | 87:085cde657901 | 305 | __HAL_UNLOCK(hadc); |
mbed_official | 87:085cde657901 | 306 | |
mbed_official | 87:085cde657901 | 307 | /* Return function status */ |
mbed_official | 87:085cde657901 | 308 | return HAL_OK; |
mbed_official | 87:085cde657901 | 309 | } |
mbed_official | 87:085cde657901 | 310 | |
mbed_official | 87:085cde657901 | 311 | /** |
mbed_official | 87:085cde657901 | 312 | * @brief Disables ADC and stop conversion of injected channels. |
mbed_official | 87:085cde657901 | 313 | * |
mbed_official | 87:085cde657901 | 314 | * @note Caution: This function will stop also regular channels. |
mbed_official | 87:085cde657901 | 315 | * |
mbed_official | 87:085cde657901 | 316 | * @param hadc: pointer to a ADC_HandleTypeDef structure that contains |
mbed_official | 87:085cde657901 | 317 | * the configuration information for the specified ADC. |
mbed_official | 87:085cde657901 | 318 | * @retval HAL status. |
mbed_official | 87:085cde657901 | 319 | */ |
mbed_official | 87:085cde657901 | 320 | HAL_StatusTypeDef HAL_ADCEx_InjectedStop(ADC_HandleTypeDef* hadc) |
mbed_official | 87:085cde657901 | 321 | { |
mbed_official | 87:085cde657901 | 322 | /* Disable the Peripheral */ |
mbed_official | 87:085cde657901 | 323 | __HAL_ADC_DISABLE(hadc); |
mbed_official | 87:085cde657901 | 324 | |
mbed_official | 87:085cde657901 | 325 | /* Change ADC state */ |
mbed_official | 87:085cde657901 | 326 | hadc->State = HAL_ADC_STATE_READY; |
mbed_official | 87:085cde657901 | 327 | |
mbed_official | 87:085cde657901 | 328 | /* Return function status */ |
mbed_official | 87:085cde657901 | 329 | return HAL_OK; |
mbed_official | 87:085cde657901 | 330 | } |
mbed_official | 87:085cde657901 | 331 | |
mbed_official | 87:085cde657901 | 332 | /** |
mbed_official | 87:085cde657901 | 333 | * @brief Poll for injected conversion complete |
mbed_official | 87:085cde657901 | 334 | * @param hadc: pointer to a ADC_HandleTypeDef structure that contains |
mbed_official | 87:085cde657901 | 335 | * the configuration information for the specified ADC. |
mbed_official | 87:085cde657901 | 336 | * @param Timeout: Timeout value in millisecond. |
mbed_official | 87:085cde657901 | 337 | * @retval HAL status |
mbed_official | 87:085cde657901 | 338 | */ |
mbed_official | 87:085cde657901 | 339 | HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout) |
mbed_official | 87:085cde657901 | 340 | { |
mbed_official | 87:085cde657901 | 341 | uint32_t timeout; |
mbed_official | 87:085cde657901 | 342 | |
mbed_official | 87:085cde657901 | 343 | /* Get timeout */ |
mbed_official | 87:085cde657901 | 344 | timeout = HAL_GetTick() + Timeout; |
mbed_official | 87:085cde657901 | 345 | |
mbed_official | 87:085cde657901 | 346 | /* Check End of conversion flag */ |
mbed_official | 87:085cde657901 | 347 | while(!(__HAL_ADC_GET_FLAG(hadc, ADC_FLAG_JEOC))) |
mbed_official | 87:085cde657901 | 348 | { |
mbed_official | 87:085cde657901 | 349 | /* Check for the Timeout */ |
mbed_official | 87:085cde657901 | 350 | if(Timeout != HAL_MAX_DELAY) |
mbed_official | 87:085cde657901 | 351 | { |
mbed_official | 87:085cde657901 | 352 | if(HAL_GetTick() >= timeout) |
mbed_official | 87:085cde657901 | 353 | { |
mbed_official | 87:085cde657901 | 354 | hadc->State= HAL_ADC_STATE_TIMEOUT; |
mbed_official | 87:085cde657901 | 355 | /* Process unlocked */ |
mbed_official | 87:085cde657901 | 356 | __HAL_UNLOCK(hadc); |
mbed_official | 87:085cde657901 | 357 | return HAL_TIMEOUT; |
mbed_official | 87:085cde657901 | 358 | } |
mbed_official | 87:085cde657901 | 359 | } |
mbed_official | 87:085cde657901 | 360 | } |
mbed_official | 87:085cde657901 | 361 | |
mbed_official | 87:085cde657901 | 362 | /* Check if a regular conversion is ready */ |
mbed_official | 87:085cde657901 | 363 | if(hadc->State == HAL_ADC_STATE_EOC_REG) |
mbed_official | 87:085cde657901 | 364 | { |
mbed_official | 87:085cde657901 | 365 | /* Change ADC state */ |
mbed_official | 87:085cde657901 | 366 | hadc->State = HAL_ADC_STATE_EOC_INJ_REG; |
mbed_official | 87:085cde657901 | 367 | } |
mbed_official | 87:085cde657901 | 368 | else |
mbed_official | 87:085cde657901 | 369 | { |
mbed_official | 87:085cde657901 | 370 | /* Change ADC state */ |
mbed_official | 87:085cde657901 | 371 | hadc->State = HAL_ADC_STATE_EOC_INJ; |
mbed_official | 87:085cde657901 | 372 | } |
mbed_official | 87:085cde657901 | 373 | |
mbed_official | 87:085cde657901 | 374 | /* Return ADC state */ |
mbed_official | 87:085cde657901 | 375 | return HAL_OK; |
mbed_official | 87:085cde657901 | 376 | } |
mbed_official | 87:085cde657901 | 377 | |
mbed_official | 87:085cde657901 | 378 | /** |
mbed_official | 87:085cde657901 | 379 | * @brief Disables the interrupt and stop ADC conversion of injected channels. |
mbed_official | 87:085cde657901 | 380 | * |
mbed_official | 87:085cde657901 | 381 | * @note Caution: This function will stop also regular channels. |
mbed_official | 87:085cde657901 | 382 | * |
mbed_official | 87:085cde657901 | 383 | * @param hadc: pointer to a ADC_HandleTypeDef structure that contains |
mbed_official | 87:085cde657901 | 384 | * the configuration information for the specified ADC. |
mbed_official | 87:085cde657901 | 385 | * @retval HAL status. |
mbed_official | 87:085cde657901 | 386 | */ |
mbed_official | 87:085cde657901 | 387 | HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT(ADC_HandleTypeDef* hadc) |
mbed_official | 87:085cde657901 | 388 | { |
mbed_official | 87:085cde657901 | 389 | /* Disable the ADC end of conversion interrupt for regular group */ |
mbed_official | 87:085cde657901 | 390 | __HAL_ADC_DISABLE_IT(hadc, ADC_IT_EOC); |
mbed_official | 87:085cde657901 | 391 | |
mbed_official | 87:085cde657901 | 392 | /* Disable the ADC end of conversion interrupt for injected group */ |
mbed_official | 87:085cde657901 | 393 | __HAL_ADC_DISABLE_IT(hadc, ADC_CR1_JEOCIE); |
mbed_official | 87:085cde657901 | 394 | |
mbed_official | 87:085cde657901 | 395 | /* Enable the Periphral */ |
mbed_official | 87:085cde657901 | 396 | __HAL_ADC_DISABLE(hadc); |
mbed_official | 87:085cde657901 | 397 | |
mbed_official | 87:085cde657901 | 398 | /* Change ADC state */ |
mbed_official | 87:085cde657901 | 399 | hadc->State = HAL_ADC_STATE_READY; |
mbed_official | 87:085cde657901 | 400 | |
mbed_official | 87:085cde657901 | 401 | /* Return function status */ |
mbed_official | 87:085cde657901 | 402 | return HAL_OK; |
mbed_official | 87:085cde657901 | 403 | } |
mbed_official | 87:085cde657901 | 404 | |
mbed_official | 87:085cde657901 | 405 | /** |
mbed_official | 87:085cde657901 | 406 | * @brief Gets the converted value from data register of injected channel. |
mbed_official | 87:085cde657901 | 407 | * @param hadc: pointer to a ADC_HandleTypeDef structure that contains |
mbed_official | 87:085cde657901 | 408 | * the configuration information for the specified ADC. |
mbed_official | 87:085cde657901 | 409 | * @param InjectedRank: the ADC injected rank. |
mbed_official | 87:085cde657901 | 410 | * This parameter can be one of the following values: |
mbed_official | 226:b062af740e40 | 411 | * @arg ADC_INJECTED_RANK_1: Injected Channel1 selected |
mbed_official | 226:b062af740e40 | 412 | * @arg ADC_INJECTED_RANK_2: Injected Channel2 selected |
mbed_official | 226:b062af740e40 | 413 | * @arg ADC_INJECTED_RANK_3: Injected Channel3 selected |
mbed_official | 226:b062af740e40 | 414 | * @arg ADC_INJECTED_RANK_4: Injected Channel4 selected |
mbed_official | 87:085cde657901 | 415 | * @retval None |
mbed_official | 87:085cde657901 | 416 | */ |
mbed_official | 87:085cde657901 | 417 | uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t InjectedRank) |
mbed_official | 87:085cde657901 | 418 | { |
mbed_official | 87:085cde657901 | 419 | __IO uint32_t tmp = 0; |
mbed_official | 87:085cde657901 | 420 | |
mbed_official | 87:085cde657901 | 421 | /* Check the parameters */ |
mbed_official | 87:085cde657901 | 422 | assert_param(IS_ADC_INJECTED_RANK(InjectedRank)); |
mbed_official | 87:085cde657901 | 423 | |
mbed_official | 87:085cde657901 | 424 | /* Clear the ADCx's flag for injected end of conversion */ |
mbed_official | 87:085cde657901 | 425 | __HAL_ADC_CLEAR_FLAG(hadc,ADC_FLAG_JEOC); |
mbed_official | 87:085cde657901 | 426 | |
mbed_official | 87:085cde657901 | 427 | /* Return the selected ADC converted value */ |
mbed_official | 87:085cde657901 | 428 | switch(InjectedRank) |
mbed_official | 87:085cde657901 | 429 | { |
mbed_official | 87:085cde657901 | 430 | case ADC_INJECTED_RANK_4: |
mbed_official | 87:085cde657901 | 431 | { |
mbed_official | 87:085cde657901 | 432 | tmp = hadc->Instance->JDR4; |
mbed_official | 87:085cde657901 | 433 | } |
mbed_official | 87:085cde657901 | 434 | break; |
mbed_official | 87:085cde657901 | 435 | case ADC_INJECTED_RANK_3: |
mbed_official | 87:085cde657901 | 436 | { |
mbed_official | 87:085cde657901 | 437 | tmp = hadc->Instance->JDR3; |
mbed_official | 87:085cde657901 | 438 | } |
mbed_official | 87:085cde657901 | 439 | break; |
mbed_official | 87:085cde657901 | 440 | case ADC_INJECTED_RANK_2: |
mbed_official | 87:085cde657901 | 441 | { |
mbed_official | 87:085cde657901 | 442 | tmp = hadc->Instance->JDR2; |
mbed_official | 87:085cde657901 | 443 | } |
mbed_official | 87:085cde657901 | 444 | break; |
mbed_official | 87:085cde657901 | 445 | case ADC_INJECTED_RANK_1: |
mbed_official | 87:085cde657901 | 446 | { |
mbed_official | 87:085cde657901 | 447 | tmp = hadc->Instance->JDR1; |
mbed_official | 87:085cde657901 | 448 | } |
mbed_official | 87:085cde657901 | 449 | break; |
mbed_official | 87:085cde657901 | 450 | default: |
mbed_official | 87:085cde657901 | 451 | break; |
mbed_official | 87:085cde657901 | 452 | } |
mbed_official | 87:085cde657901 | 453 | return tmp; |
mbed_official | 87:085cde657901 | 454 | } |
mbed_official | 87:085cde657901 | 455 | |
mbed_official | 87:085cde657901 | 456 | /** |
mbed_official | 87:085cde657901 | 457 | * @brief Enables ADC DMA request after last transfer (Multi-ADC mode) and enables ADC peripheral |
mbed_official | 87:085cde657901 | 458 | * |
mbed_official | 87:085cde657901 | 459 | * @note Caution: This function must be used only with the ADC master. |
mbed_official | 87:085cde657901 | 460 | * |
mbed_official | 87:085cde657901 | 461 | * @param hadc: pointer to a ADC_HandleTypeDef structure that contains |
mbed_official | 87:085cde657901 | 462 | * the configuration information for the specified ADC. |
mbed_official | 87:085cde657901 | 463 | * @param pData: Pointer to buffer in which transferred from ADC peripheral to memory will be stored. |
mbed_official | 87:085cde657901 | 464 | * @param Length: The length of data to be transferred from ADC peripheral to memory. |
mbed_official | 226:b062af740e40 | 465 | * @retval HAL status |
mbed_official | 87:085cde657901 | 466 | */ |
mbed_official | 87:085cde657901 | 467 | HAL_StatusTypeDef HAL_ADCEx_MultiModeStart_DMA(ADC_HandleTypeDef* hadc, uint32_t* pData, uint32_t Length) |
mbed_official | 87:085cde657901 | 468 | { |
mbed_official | 87:085cde657901 | 469 | uint16_t counter = 0; |
mbed_official | 87:085cde657901 | 470 | |
mbed_official | 87:085cde657901 | 471 | /* Check the parameters */ |
mbed_official | 87:085cde657901 | 472 | assert_param(IS_FUNCTIONAL_STATE(hadc->Init.ContinuousConvMode)); |
mbed_official | 87:085cde657901 | 473 | assert_param(IS_ADC_EXT_TRIG_EDGE(hadc->Init.ExternalTrigConvEdge)); |
mbed_official | 87:085cde657901 | 474 | assert_param(IS_FUNCTIONAL_STATE(hadc->Init.DMAContinuousRequests)); |
mbed_official | 87:085cde657901 | 475 | |
mbed_official | 87:085cde657901 | 476 | /* Process locked */ |
mbed_official | 87:085cde657901 | 477 | __HAL_LOCK(hadc); |
mbed_official | 87:085cde657901 | 478 | |
mbed_official | 87:085cde657901 | 479 | /* Enable ADC overrun interrupt */ |
mbed_official | 87:085cde657901 | 480 | __HAL_ADC_ENABLE_IT(hadc, ADC_IT_OVR); |
mbed_official | 87:085cde657901 | 481 | |
mbed_official | 87:085cde657901 | 482 | if (hadc->Init.DMAContinuousRequests != DISABLE) |
mbed_official | 87:085cde657901 | 483 | { |
mbed_official | 87:085cde657901 | 484 | /* Enable the selected ADC DMA request after last transfer */ |
mbed_official | 87:085cde657901 | 485 | ADC->CCR |= ADC_CCR_DDS; |
mbed_official | 87:085cde657901 | 486 | } |
mbed_official | 87:085cde657901 | 487 | else |
mbed_official | 87:085cde657901 | 488 | { |
mbed_official | 87:085cde657901 | 489 | /* Disable the selected ADC EOC rising on each regular channel conversion */ |
mbed_official | 87:085cde657901 | 490 | ADC->CCR &= ~ADC_CCR_DDS; |
mbed_official | 87:085cde657901 | 491 | } |
mbed_official | 87:085cde657901 | 492 | |
mbed_official | 87:085cde657901 | 493 | /* Set the DMA transfer complete callback */ |
mbed_official | 87:085cde657901 | 494 | hadc->DMA_Handle->XferCpltCallback = ADC_MultiModeDMAConvCplt; |
mbed_official | 87:085cde657901 | 495 | |
mbed_official | 87:085cde657901 | 496 | /* Set the DMA half transfer complete callback */ |
mbed_official | 87:085cde657901 | 497 | hadc->DMA_Handle->XferHalfCpltCallback = ADC_MultiModeDMAHalfConvCplt; |
mbed_official | 87:085cde657901 | 498 | |
mbed_official | 87:085cde657901 | 499 | /* Set the DMA error callback */ |
mbed_official | 87:085cde657901 | 500 | hadc->DMA_Handle->XferErrorCallback = ADC_MultiModeDMAError ; |
mbed_official | 87:085cde657901 | 501 | |
mbed_official | 87:085cde657901 | 502 | /* Enable the DMA Stream */ |
mbed_official | 87:085cde657901 | 503 | HAL_DMA_Start_IT(hadc->DMA_Handle, (uint32_t)&ADC->CDR, (uint32_t)pData, Length); |
mbed_official | 87:085cde657901 | 504 | |
mbed_official | 87:085cde657901 | 505 | /* Change ADC state */ |
mbed_official | 87:085cde657901 | 506 | hadc->State = HAL_ADC_STATE_BUSY_REG; |
mbed_official | 87:085cde657901 | 507 | |
mbed_official | 87:085cde657901 | 508 | /* Check if ADC peripheral is disabled in order to enable it and wait during |
mbed_official | 87:085cde657901 | 509 | Tstab time the ADC's stabilization */ |
mbed_official | 87:085cde657901 | 510 | if((hadc->Instance->CR2 & ADC_CR2_ADON) != ADC_CR2_ADON) |
mbed_official | 87:085cde657901 | 511 | { |
mbed_official | 87:085cde657901 | 512 | /* Enable the Peripheral */ |
mbed_official | 87:085cde657901 | 513 | __HAL_ADC_ENABLE(hadc); |
mbed_official | 87:085cde657901 | 514 | |
mbed_official | 87:085cde657901 | 515 | /* Delay inserted to wait during Tstab time the ADC's stabilazation */ |
mbed_official | 87:085cde657901 | 516 | for(; counter <= 540; counter++) |
mbed_official | 87:085cde657901 | 517 | { |
mbed_official | 87:085cde657901 | 518 | __NOP(); |
mbed_official | 87:085cde657901 | 519 | } |
mbed_official | 87:085cde657901 | 520 | } |
mbed_official | 87:085cde657901 | 521 | |
mbed_official | 87:085cde657901 | 522 | /* if no external trigger present enable software conversion of regular channels */ |
mbed_official | 87:085cde657901 | 523 | if (hadc->Init.ExternalTrigConvEdge == ADC_EXTERNALTRIGCONVEDGE_NONE) |
mbed_official | 87:085cde657901 | 524 | { |
mbed_official | 87:085cde657901 | 525 | /* Enable the selected ADC software conversion for regular group */ |
mbed_official | 87:085cde657901 | 526 | hadc->Instance->CR2 |= (uint32_t)ADC_CR2_SWSTART; |
mbed_official | 87:085cde657901 | 527 | } |
mbed_official | 87:085cde657901 | 528 | |
mbed_official | 87:085cde657901 | 529 | /* Process unlocked */ |
mbed_official | 87:085cde657901 | 530 | __HAL_UNLOCK(hadc); |
mbed_official | 87:085cde657901 | 531 | |
mbed_official | 87:085cde657901 | 532 | /* Return function status */ |
mbed_official | 87:085cde657901 | 533 | return HAL_OK; |
mbed_official | 87:085cde657901 | 534 | } |
mbed_official | 87:085cde657901 | 535 | |
mbed_official | 87:085cde657901 | 536 | /** |
mbed_official | 87:085cde657901 | 537 | * @brief Disables ADC DMA (multi-ADC mode) and disables ADC peripheral |
mbed_official | 87:085cde657901 | 538 | * @param hadc: pointer to a ADC_HandleTypeDef structure that contains |
mbed_official | 87:085cde657901 | 539 | * the configuration information for the specified ADC. |
mbed_official | 226:b062af740e40 | 540 | * @retval HAL status |
mbed_official | 87:085cde657901 | 541 | */ |
mbed_official | 87:085cde657901 | 542 | HAL_StatusTypeDef HAL_ADCEx_MultiModeStop_DMA(ADC_HandleTypeDef* hadc) |
mbed_official | 87:085cde657901 | 543 | { |
mbed_official | 87:085cde657901 | 544 | /* Process locked */ |
mbed_official | 87:085cde657901 | 545 | __HAL_LOCK(hadc); |
mbed_official | 87:085cde657901 | 546 | |
mbed_official | 87:085cde657901 | 547 | /* Enable the Peripheral */ |
mbed_official | 87:085cde657901 | 548 | __HAL_ADC_DISABLE(hadc); |
mbed_official | 87:085cde657901 | 549 | |
mbed_official | 87:085cde657901 | 550 | /* Disable ADC overrun interrupt */ |
mbed_official | 87:085cde657901 | 551 | __HAL_ADC_DISABLE_IT(hadc, ADC_IT_OVR); |
mbed_official | 87:085cde657901 | 552 | |
mbed_official | 87:085cde657901 | 553 | /* Disable the selected ADC DMA request after last transfer */ |
mbed_official | 87:085cde657901 | 554 | ADC->CCR &= ~ADC_CCR_DDS; |
mbed_official | 87:085cde657901 | 555 | |
mbed_official | 87:085cde657901 | 556 | /* Disable the ADC DMA Stream */ |
mbed_official | 87:085cde657901 | 557 | HAL_DMA_Abort(hadc->DMA_Handle); |
mbed_official | 87:085cde657901 | 558 | |
mbed_official | 87:085cde657901 | 559 | /* Change ADC state */ |
mbed_official | 87:085cde657901 | 560 | hadc->State = HAL_ADC_STATE_READY; |
mbed_official | 87:085cde657901 | 561 | |
mbed_official | 87:085cde657901 | 562 | /* Process unlocked */ |
mbed_official | 87:085cde657901 | 563 | __HAL_UNLOCK(hadc); |
mbed_official | 87:085cde657901 | 564 | |
mbed_official | 87:085cde657901 | 565 | /* Return function status */ |
mbed_official | 87:085cde657901 | 566 | return HAL_OK; |
mbed_official | 87:085cde657901 | 567 | } |
mbed_official | 87:085cde657901 | 568 | |
mbed_official | 87:085cde657901 | 569 | /** |
mbed_official | 87:085cde657901 | 570 | * @brief Returns the last ADC1, ADC2 and ADC3 regular conversions results |
mbed_official | 87:085cde657901 | 571 | * data in the selected multi mode. |
mbed_official | 87:085cde657901 | 572 | * @param hadc: pointer to a ADC_HandleTypeDef structure that contains |
mbed_official | 87:085cde657901 | 573 | * the configuration information for the specified ADC. |
mbed_official | 87:085cde657901 | 574 | * @retval The converted data value. |
mbed_official | 87:085cde657901 | 575 | */ |
mbed_official | 87:085cde657901 | 576 | uint32_t HAL_ADCEx_MultiModeGetValue(ADC_HandleTypeDef* hadc) |
mbed_official | 87:085cde657901 | 577 | { |
mbed_official | 87:085cde657901 | 578 | /* Return the multi mode conversion value */ |
mbed_official | 87:085cde657901 | 579 | return ADC->CDR; |
mbed_official | 87:085cde657901 | 580 | } |
mbed_official | 87:085cde657901 | 581 | |
mbed_official | 87:085cde657901 | 582 | /** |
mbed_official | 87:085cde657901 | 583 | * @brief Injected conversion complete callback in non blocking mode |
mbed_official | 87:085cde657901 | 584 | * @param hadc: pointer to a ADC_HandleTypeDef structure that contains |
mbed_official | 87:085cde657901 | 585 | * the configuration information for the specified ADC. |
mbed_official | 87:085cde657901 | 586 | * @retval None |
mbed_official | 87:085cde657901 | 587 | */ |
mbed_official | 87:085cde657901 | 588 | __weak void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc) |
mbed_official | 87:085cde657901 | 589 | { |
mbed_official | 87:085cde657901 | 590 | /* NOTE : This function Should not be modified, when the callback is needed, |
mbed_official | 87:085cde657901 | 591 | the HAL_ADC_InjectedConvCpltCallback could be implemented in the user file |
mbed_official | 87:085cde657901 | 592 | */ |
mbed_official | 87:085cde657901 | 593 | } |
mbed_official | 87:085cde657901 | 594 | |
mbed_official | 87:085cde657901 | 595 | /** |
mbed_official | 87:085cde657901 | 596 | * @brief Configures for the selected ADC injected channel its corresponding |
mbed_official | 87:085cde657901 | 597 | * rank in the sequencer and its sample time. |
mbed_official | 87:085cde657901 | 598 | * @param hadc: pointer to a ADC_HandleTypeDef structure that contains |
mbed_official | 87:085cde657901 | 599 | * the configuration information for the specified ADC. |
mbed_official | 87:085cde657901 | 600 | * @param sConfigInjected: ADC configuration structure for injected channel. |
mbed_official | 87:085cde657901 | 601 | * @retval None |
mbed_official | 87:085cde657901 | 602 | */ |
mbed_official | 87:085cde657901 | 603 | HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef* hadc, ADC_InjectionConfTypeDef* sConfigInjected) |
mbed_official | 87:085cde657901 | 604 | { |
mbed_official | 87:085cde657901 | 605 | |
mbed_official | 87:085cde657901 | 606 | #ifdef USE_FULL_ASSERT |
mbed_official | 87:085cde657901 | 607 | uint32_t tmp = 0; |
mbed_official | 87:085cde657901 | 608 | #endif /* USE_FULL_ASSERT */ |
mbed_official | 87:085cde657901 | 609 | |
mbed_official | 87:085cde657901 | 610 | /* Check the parameters */ |
mbed_official | 87:085cde657901 | 611 | assert_param(IS_ADC_CHANNEL(sConfigInjected->InjectedChannel)); |
mbed_official | 87:085cde657901 | 612 | assert_param(IS_ADC_INJECTED_RANK(sConfigInjected->InjectedRank)); |
mbed_official | 87:085cde657901 | 613 | assert_param(IS_ADC_SAMPLE_TIME(sConfigInjected->InjectedSamplingTime)); |
mbed_official | 87:085cde657901 | 614 | assert_param(IS_ADC_EXT_INJEC_TRIG(sConfigInjected->ExternalTrigInjecConv)); |
mbed_official | 87:085cde657901 | 615 | assert_param(IS_ADC_EXT_INJEC_TRIG_EDGE(sConfigInjected->ExternalTrigInjecConvEdge)); |
mbed_official | 87:085cde657901 | 616 | assert_param(IS_ADC_INJECTED_LENGTH(sConfigInjected->InjectedNbrOfConversion)); |
mbed_official | 87:085cde657901 | 617 | assert_param(IS_FUNCTIONAL_STATE(sConfigInjected->AutoInjectedConv)); |
mbed_official | 87:085cde657901 | 618 | assert_param(IS_FUNCTIONAL_STATE(sConfigInjected->InjectedDiscontinuousConvMode)); |
mbed_official | 87:085cde657901 | 619 | |
mbed_official | 87:085cde657901 | 620 | #ifdef USE_FULL_ASSERT |
mbed_official | 87:085cde657901 | 621 | tmp = __HAL_ADC_GET_RESOLUTION(hadc); |
mbed_official | 87:085cde657901 | 622 | assert_param(IS_ADC_RANGE(tmp, sConfigInjected->InjectedOffset)); |
mbed_official | 87:085cde657901 | 623 | #endif /* USE_FULL_ASSERT */ |
mbed_official | 87:085cde657901 | 624 | |
mbed_official | 87:085cde657901 | 625 | /* Process locked */ |
mbed_official | 87:085cde657901 | 626 | __HAL_LOCK(hadc); |
mbed_official | 87:085cde657901 | 627 | |
mbed_official | 87:085cde657901 | 628 | /* if ADC_Channel_10 ... ADC_Channel_18 is selected */ |
mbed_official | 87:085cde657901 | 629 | if (sConfigInjected->InjectedChannel > ADC_CHANNEL_9) |
mbed_official | 87:085cde657901 | 630 | { |
mbed_official | 87:085cde657901 | 631 | /* Clear the old sample time */ |
mbed_official | 87:085cde657901 | 632 | hadc->Instance->SMPR1 &= ~__HAL_ADC_SMPR1(ADC_SMPR1_SMP10, sConfigInjected->InjectedChannel); |
mbed_official | 87:085cde657901 | 633 | |
mbed_official | 87:085cde657901 | 634 | /* Set the new sample time */ |
mbed_official | 87:085cde657901 | 635 | hadc->Instance->SMPR1 |= __HAL_ADC_SMPR1(sConfigInjected->InjectedSamplingTime, sConfigInjected->InjectedChannel); |
mbed_official | 87:085cde657901 | 636 | } |
mbed_official | 87:085cde657901 | 637 | else /* ADC_Channel include in ADC_Channel_[0..9] */ |
mbed_official | 87:085cde657901 | 638 | { |
mbed_official | 87:085cde657901 | 639 | /* Clear the old sample time */ |
mbed_official | 87:085cde657901 | 640 | hadc->Instance->SMPR2 &= ~__HAL_ADC_SMPR2(ADC_SMPR2_SMP0, sConfigInjected->InjectedChannel); |
mbed_official | 87:085cde657901 | 641 | |
mbed_official | 87:085cde657901 | 642 | /* Set the new sample time */ |
mbed_official | 87:085cde657901 | 643 | hadc->Instance->SMPR2 |= __HAL_ADC_SMPR2(sConfigInjected->InjectedSamplingTime, sConfigInjected->InjectedChannel); |
mbed_official | 87:085cde657901 | 644 | } |
mbed_official | 87:085cde657901 | 645 | |
mbed_official | 87:085cde657901 | 646 | /*---------------------------- ADCx JSQR Configuration -----------------*/ |
mbed_official | 87:085cde657901 | 647 | hadc->Instance->JSQR &= ~(ADC_JSQR_JL); |
mbed_official | 87:085cde657901 | 648 | hadc->Instance->JSQR |= __HAL_ADC_SQR1(sConfigInjected->InjectedNbrOfConversion); |
mbed_official | 87:085cde657901 | 649 | |
mbed_official | 87:085cde657901 | 650 | /* Rank configuration */ |
mbed_official | 87:085cde657901 | 651 | |
mbed_official | 87:085cde657901 | 652 | /* Clear the old SQx bits for the selected rank */ |
mbed_official | 87:085cde657901 | 653 | hadc->Instance->JSQR &= ~__HAL_ADC_JSQR(ADC_JSQR_JSQ1, sConfigInjected->InjectedRank,sConfigInjected->InjectedNbrOfConversion); |
mbed_official | 87:085cde657901 | 654 | |
mbed_official | 87:085cde657901 | 655 | /* Set the SQx bits for the selected rank */ |
mbed_official | 87:085cde657901 | 656 | hadc->Instance->JSQR |= __HAL_ADC_JSQR(sConfigInjected->InjectedChannel, sConfigInjected->InjectedRank,sConfigInjected->InjectedNbrOfConversion); |
mbed_official | 87:085cde657901 | 657 | |
mbed_official | 87:085cde657901 | 658 | /* Select external trigger to start conversion */ |
mbed_official | 87:085cde657901 | 659 | hadc->Instance->CR2 &= ~(ADC_CR2_JEXTSEL); |
mbed_official | 87:085cde657901 | 660 | hadc->Instance->CR2 |= sConfigInjected->ExternalTrigInjecConv; |
mbed_official | 87:085cde657901 | 661 | |
mbed_official | 87:085cde657901 | 662 | /* Select external trigger polarity */ |
mbed_official | 87:085cde657901 | 663 | hadc->Instance->CR2 &= ~(ADC_CR2_JEXTEN); |
mbed_official | 87:085cde657901 | 664 | hadc->Instance->CR2 |= sConfigInjected->ExternalTrigInjecConvEdge; |
mbed_official | 87:085cde657901 | 665 | |
mbed_official | 87:085cde657901 | 666 | if (sConfigInjected->AutoInjectedConv != DISABLE) |
mbed_official | 87:085cde657901 | 667 | { |
mbed_official | 87:085cde657901 | 668 | /* Enable the selected ADC automatic injected group conversion */ |
mbed_official | 87:085cde657901 | 669 | hadc->Instance->CR1 |= ADC_CR1_JAUTO; |
mbed_official | 87:085cde657901 | 670 | } |
mbed_official | 87:085cde657901 | 671 | else |
mbed_official | 87:085cde657901 | 672 | { |
mbed_official | 87:085cde657901 | 673 | /* Disable the selected ADC automatic injected group conversion */ |
mbed_official | 87:085cde657901 | 674 | hadc->Instance->CR1 &= ~(ADC_CR1_JAUTO); |
mbed_official | 87:085cde657901 | 675 | } |
mbed_official | 87:085cde657901 | 676 | |
mbed_official | 87:085cde657901 | 677 | if (sConfigInjected->InjectedDiscontinuousConvMode != DISABLE) |
mbed_official | 87:085cde657901 | 678 | { |
mbed_official | 87:085cde657901 | 679 | /* Enable the selected ADC injected discontinuous mode */ |
mbed_official | 87:085cde657901 | 680 | hadc->Instance->CR1 |= ADC_CR1_JDISCEN; |
mbed_official | 87:085cde657901 | 681 | } |
mbed_official | 87:085cde657901 | 682 | else |
mbed_official | 87:085cde657901 | 683 | { |
mbed_official | 87:085cde657901 | 684 | /* Disable the selected ADC injected discontinuous mode */ |
mbed_official | 87:085cde657901 | 685 | hadc->Instance->CR1 &= ~(ADC_CR1_JDISCEN); |
mbed_official | 87:085cde657901 | 686 | } |
mbed_official | 87:085cde657901 | 687 | |
mbed_official | 87:085cde657901 | 688 | switch(sConfigInjected->InjectedRank) |
mbed_official | 87:085cde657901 | 689 | { |
mbed_official | 87:085cde657901 | 690 | case 1: |
mbed_official | 87:085cde657901 | 691 | /* Set injected channel 1 offset */ |
mbed_official | 87:085cde657901 | 692 | hadc->Instance->JOFR1 &= ~(ADC_JOFR1_JOFFSET1); |
mbed_official | 87:085cde657901 | 693 | hadc->Instance->JOFR1 |= sConfigInjected->InjectedOffset; |
mbed_official | 87:085cde657901 | 694 | break; |
mbed_official | 87:085cde657901 | 695 | case 2: |
mbed_official | 87:085cde657901 | 696 | /* Set injected channel 2 offset */ |
mbed_official | 87:085cde657901 | 697 | hadc->Instance->JOFR2 &= ~(ADC_JOFR2_JOFFSET2); |
mbed_official | 87:085cde657901 | 698 | hadc->Instance->JOFR2 |= sConfigInjected->InjectedOffset; |
mbed_official | 87:085cde657901 | 699 | break; |
mbed_official | 87:085cde657901 | 700 | case 3: |
mbed_official | 87:085cde657901 | 701 | /* Set injected channel 3 offset */ |
mbed_official | 87:085cde657901 | 702 | hadc->Instance->JOFR3 &= ~(ADC_JOFR3_JOFFSET3); |
mbed_official | 87:085cde657901 | 703 | hadc->Instance->JOFR3 |= sConfigInjected->InjectedOffset; |
mbed_official | 87:085cde657901 | 704 | break; |
mbed_official | 87:085cde657901 | 705 | default: |
mbed_official | 87:085cde657901 | 706 | /* Set injected channel 4 offset */ |
mbed_official | 87:085cde657901 | 707 | hadc->Instance->JOFR4 &= ~(ADC_JOFR4_JOFFSET4); |
mbed_official | 87:085cde657901 | 708 | hadc->Instance->JOFR4 |= sConfigInjected->InjectedOffset; |
mbed_official | 87:085cde657901 | 709 | break; |
mbed_official | 87:085cde657901 | 710 | } |
mbed_official | 87:085cde657901 | 711 | |
mbed_official | 87:085cde657901 | 712 | /* if ADC1 Channel_18 is selected enable VBAT Channel */ |
mbed_official | 87:085cde657901 | 713 | if ((hadc->Instance == ADC1) && (sConfigInjected->InjectedChannel == ADC_CHANNEL_VBAT)) |
mbed_official | 87:085cde657901 | 714 | { |
mbed_official | 87:085cde657901 | 715 | /* Enable the VBAT channel*/ |
mbed_official | 87:085cde657901 | 716 | ADC->CCR |= ADC_CCR_VBATE; |
mbed_official | 87:085cde657901 | 717 | } |
mbed_official | 87:085cde657901 | 718 | |
mbed_official | 87:085cde657901 | 719 | /* if ADC1 Channel_16 or Channel_17 is selected enable TSVREFE Channel(Temperature sensor and VREFINT) */ |
mbed_official | 87:085cde657901 | 720 | if ((hadc->Instance == ADC1) && ((sConfigInjected->InjectedChannel == ADC_CHANNEL_TEMPSENSOR) || (sConfigInjected->InjectedChannel == ADC_CHANNEL_VREFINT))) |
mbed_official | 87:085cde657901 | 721 | { |
mbed_official | 87:085cde657901 | 722 | /* Enable the TSVREFE channel*/ |
mbed_official | 87:085cde657901 | 723 | ADC->CCR |= ADC_CCR_TSVREFE; |
mbed_official | 87:085cde657901 | 724 | } |
mbed_official | 87:085cde657901 | 725 | |
mbed_official | 87:085cde657901 | 726 | /* Process unlocked */ |
mbed_official | 87:085cde657901 | 727 | __HAL_UNLOCK(hadc); |
mbed_official | 87:085cde657901 | 728 | |
mbed_official | 87:085cde657901 | 729 | /* Return function status */ |
mbed_official | 87:085cde657901 | 730 | return HAL_OK; |
mbed_official | 87:085cde657901 | 731 | } |
mbed_official | 87:085cde657901 | 732 | |
mbed_official | 87:085cde657901 | 733 | /** |
mbed_official | 87:085cde657901 | 734 | * @brief Configures the ADC multi-mode |
mbed_official | 87:085cde657901 | 735 | * @param hadc : pointer to a ADC_HandleTypeDef structure that contains |
mbed_official | 87:085cde657901 | 736 | * the configuration information for the specified ADC. |
mbed_official | 87:085cde657901 | 737 | * @param multimode : pointer to an ADC_MultiModeTypeDef structure that contains |
mbed_official | 87:085cde657901 | 738 | * the configuration information for multimode. |
mbed_official | 87:085cde657901 | 739 | * @retval HAL status |
mbed_official | 87:085cde657901 | 740 | */ |
mbed_official | 87:085cde657901 | 741 | HAL_StatusTypeDef HAL_ADCEx_MultiModeConfigChannel(ADC_HandleTypeDef* hadc, ADC_MultiModeTypeDef* multimode) |
mbed_official | 87:085cde657901 | 742 | { |
mbed_official | 87:085cde657901 | 743 | /* Check the parameters */ |
mbed_official | 87:085cde657901 | 744 | assert_param(IS_ADC_MODE(multimode->Mode)); |
mbed_official | 87:085cde657901 | 745 | assert_param(IS_ADC_DMA_ACCESS_MODE(multimode->DMAAccessMode)); |
mbed_official | 87:085cde657901 | 746 | assert_param(IS_ADC_SAMPLING_DELAY(multimode->TwoSamplingDelay)); |
mbed_official | 87:085cde657901 | 747 | |
mbed_official | 87:085cde657901 | 748 | /* Process locked */ |
mbed_official | 87:085cde657901 | 749 | __HAL_LOCK(hadc); |
mbed_official | 87:085cde657901 | 750 | |
mbed_official | 87:085cde657901 | 751 | /* Set ADC mode */ |
mbed_official | 87:085cde657901 | 752 | ADC->CCR &= ~(ADC_CCR_MULTI); |
mbed_official | 87:085cde657901 | 753 | ADC->CCR |= multimode->Mode; |
mbed_official | 87:085cde657901 | 754 | |
mbed_official | 87:085cde657901 | 755 | /* Set the ADC DMA access mode */ |
mbed_official | 87:085cde657901 | 756 | ADC->CCR &= ~(ADC_CCR_DMA); |
mbed_official | 87:085cde657901 | 757 | ADC->CCR |= multimode->DMAAccessMode; |
mbed_official | 87:085cde657901 | 758 | |
mbed_official | 87:085cde657901 | 759 | /* Set delay between two sampling phases */ |
mbed_official | 87:085cde657901 | 760 | ADC->CCR &= ~(ADC_CCR_DELAY); |
mbed_official | 87:085cde657901 | 761 | ADC->CCR |= multimode->TwoSamplingDelay; |
mbed_official | 87:085cde657901 | 762 | |
mbed_official | 87:085cde657901 | 763 | /* Process unlocked */ |
mbed_official | 87:085cde657901 | 764 | __HAL_UNLOCK(hadc); |
mbed_official | 87:085cde657901 | 765 | |
mbed_official | 87:085cde657901 | 766 | /* Return function status */ |
mbed_official | 87:085cde657901 | 767 | return HAL_OK; |
mbed_official | 87:085cde657901 | 768 | } |
mbed_official | 87:085cde657901 | 769 | |
mbed_official | 87:085cde657901 | 770 | /** |
mbed_official | 87:085cde657901 | 771 | * @} |
mbed_official | 87:085cde657901 | 772 | */ |
mbed_official | 87:085cde657901 | 773 | |
mbed_official | 87:085cde657901 | 774 | /** |
mbed_official | 87:085cde657901 | 775 | * @brief DMA transfer complete callback. |
mbed_official | 226:b062af740e40 | 776 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 226:b062af740e40 | 777 | * the configuration information for the specified DMA module. |
mbed_official | 87:085cde657901 | 778 | * @retval None |
mbed_official | 87:085cde657901 | 779 | */ |
mbed_official | 87:085cde657901 | 780 | static void ADC_MultiModeDMAConvCplt(DMA_HandleTypeDef *hdma) |
mbed_official | 87:085cde657901 | 781 | { |
mbed_official | 87:085cde657901 | 782 | ADC_HandleTypeDef* hadc = ( ADC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
mbed_official | 87:085cde657901 | 783 | |
mbed_official | 87:085cde657901 | 784 | /* Check if an injected conversion is ready */ |
mbed_official | 87:085cde657901 | 785 | if(hadc->State == HAL_ADC_STATE_EOC_INJ) |
mbed_official | 87:085cde657901 | 786 | { |
mbed_official | 87:085cde657901 | 787 | /* Change ADC state */ |
mbed_official | 87:085cde657901 | 788 | hadc->State = HAL_ADC_STATE_EOC_INJ_REG; |
mbed_official | 87:085cde657901 | 789 | } |
mbed_official | 87:085cde657901 | 790 | else |
mbed_official | 87:085cde657901 | 791 | { |
mbed_official | 87:085cde657901 | 792 | /* Change ADC state */ |
mbed_official | 87:085cde657901 | 793 | hadc->State = HAL_ADC_STATE_EOC_REG; |
mbed_official | 87:085cde657901 | 794 | } |
mbed_official | 87:085cde657901 | 795 | |
mbed_official | 87:085cde657901 | 796 | HAL_ADC_ConvCpltCallback(hadc); |
mbed_official | 87:085cde657901 | 797 | } |
mbed_official | 87:085cde657901 | 798 | |
mbed_official | 87:085cde657901 | 799 | /** |
mbed_official | 87:085cde657901 | 800 | * @brief DMA half transfer complete callback. |
mbed_official | 226:b062af740e40 | 801 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 226:b062af740e40 | 802 | * the configuration information for the specified DMA module. |
mbed_official | 87:085cde657901 | 803 | * @retval None |
mbed_official | 87:085cde657901 | 804 | */ |
mbed_official | 87:085cde657901 | 805 | static void ADC_MultiModeDMAHalfConvCplt(DMA_HandleTypeDef *hdma) |
mbed_official | 87:085cde657901 | 806 | { |
mbed_official | 87:085cde657901 | 807 | ADC_HandleTypeDef* hadc = ( ADC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
mbed_official | 87:085cde657901 | 808 | /* Conversion complete callback */ |
mbed_official | 87:085cde657901 | 809 | HAL_ADC_ConvHalfCpltCallback(hadc); |
mbed_official | 87:085cde657901 | 810 | } |
mbed_official | 87:085cde657901 | 811 | |
mbed_official | 87:085cde657901 | 812 | /** |
mbed_official | 87:085cde657901 | 813 | * @brief DMA error callback |
mbed_official | 226:b062af740e40 | 814 | * @param hdma: pointer to a DMA_HandleTypeDef structure that contains |
mbed_official | 226:b062af740e40 | 815 | * the configuration information for the specified DMA module. |
mbed_official | 87:085cde657901 | 816 | * @retval None |
mbed_official | 87:085cde657901 | 817 | */ |
mbed_official | 87:085cde657901 | 818 | static void ADC_MultiModeDMAError(DMA_HandleTypeDef *hdma) |
mbed_official | 87:085cde657901 | 819 | { |
mbed_official | 87:085cde657901 | 820 | ADC_HandleTypeDef* hadc = ( ADC_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent; |
mbed_official | 87:085cde657901 | 821 | hadc->State= HAL_ADC_STATE_ERROR; |
mbed_official | 87:085cde657901 | 822 | /* Set ADC error code to DMA error */ |
mbed_official | 87:085cde657901 | 823 | hadc->ErrorCode |= HAL_ADC_ERROR_DMA; |
mbed_official | 87:085cde657901 | 824 | HAL_ADC_ErrorCallback(hadc); |
mbed_official | 87:085cde657901 | 825 | } |
mbed_official | 87:085cde657901 | 826 | |
mbed_official | 87:085cde657901 | 827 | /** |
mbed_official | 87:085cde657901 | 828 | * @} |
mbed_official | 87:085cde657901 | 829 | */ |
mbed_official | 87:085cde657901 | 830 | |
mbed_official | 87:085cde657901 | 831 | #endif /* HAL_ADC_MODULE_ENABLED */ |
mbed_official | 87:085cde657901 | 832 | /** |
mbed_official | 87:085cde657901 | 833 | * @} |
mbed_official | 87:085cde657901 | 834 | */ |
mbed_official | 87:085cde657901 | 835 | |
mbed_official | 87:085cde657901 | 836 | /** |
mbed_official | 87:085cde657901 | 837 | * @} |
mbed_official | 87:085cde657901 | 838 | */ |
mbed_official | 87:085cde657901 | 839 | |
mbed_official | 87:085cde657901 | 840 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |