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