mbed library sources
Dependents: frdm_kl05z_gpio_test
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_L053R8/stm32l0xx_hal_adc_ex.c@323:9e901b0a5aa1, 2014-09-13 (annotated)
- Committer:
- shaoziyang
- Date:
- Sat Sep 13 14:25:46 2014 +0000
- Revision:
- 323:9e901b0a5aa1
- Parent:
- 181:a4cbdfbbd2f4
test with CLOCK_SETUP = 0
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 181:a4cbdfbbd2f4 | 1 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 2 | ****************************************************************************** |
mbed_official | 181:a4cbdfbbd2f4 | 3 | * @file stm32l0xx_hal_adc_ex.c |
mbed_official | 181:a4cbdfbbd2f4 | 4 | * @author MCD Application Team |
mbed_official | 181:a4cbdfbbd2f4 | 5 | * @version V1.0.0 |
mbed_official | 181:a4cbdfbbd2f4 | 6 | * @date 22-April-2014 |
mbed_official | 181:a4cbdfbbd2f4 | 7 | * @brief This file provides firmware functions to manage the following |
mbed_official | 181:a4cbdfbbd2f4 | 8 | * functionalities of the Analog to Digital Convertor (ADC) |
mbed_official | 181:a4cbdfbbd2f4 | 9 | * peripheral: |
mbed_official | 181:a4cbdfbbd2f4 | 10 | * + Start calibration. |
mbed_official | 181:a4cbdfbbd2f4 | 11 | * + Read the calibration factor. |
mbed_official | 181:a4cbdfbbd2f4 | 12 | * + Set a calibration factor. |
mbed_official | 181:a4cbdfbbd2f4 | 13 | * |
mbed_official | 181:a4cbdfbbd2f4 | 14 | @verbatim |
mbed_official | 181:a4cbdfbbd2f4 | 15 | ============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 16 | ##### ADC specific features ##### |
mbed_official | 181:a4cbdfbbd2f4 | 17 | ============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 18 | [..] |
mbed_official | 181:a4cbdfbbd2f4 | 19 | (#) Self calibration. |
mbed_official | 181:a4cbdfbbd2f4 | 20 | |
mbed_official | 181:a4cbdfbbd2f4 | 21 | |
mbed_official | 181:a4cbdfbbd2f4 | 22 | ##### How to use this driver ##### |
mbed_official | 181:a4cbdfbbd2f4 | 23 | ============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 24 | [..] |
mbed_official | 181:a4cbdfbbd2f4 | 25 | |
mbed_official | 181:a4cbdfbbd2f4 | 26 | (#) Call HAL_ADCEx_Calibration_Start() to start calibration |
mbed_official | 181:a4cbdfbbd2f4 | 27 | |
mbed_official | 181:a4cbdfbbd2f4 | 28 | (#) Read the calibration factor using HAL_ADCEx_Calibration_GetValue() |
mbed_official | 181:a4cbdfbbd2f4 | 29 | |
mbed_official | 181:a4cbdfbbd2f4 | 30 | (#) User can set a his calibration factor using HAL_ADCEx_Calibration_SetValue() |
mbed_official | 181:a4cbdfbbd2f4 | 31 | |
mbed_official | 181:a4cbdfbbd2f4 | 32 | @endverbatim |
mbed_official | 181:a4cbdfbbd2f4 | 33 | ****************************************************************************** |
mbed_official | 181:a4cbdfbbd2f4 | 34 | * @attention |
mbed_official | 181:a4cbdfbbd2f4 | 35 | * |
mbed_official | 181:a4cbdfbbd2f4 | 36 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 181:a4cbdfbbd2f4 | 37 | * |
mbed_official | 181:a4cbdfbbd2f4 | 38 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 181:a4cbdfbbd2f4 | 39 | * are permitted provided that the following conditions are met: |
mbed_official | 181:a4cbdfbbd2f4 | 40 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 181:a4cbdfbbd2f4 | 41 | * this list of conditions and the following disclaimer. |
mbed_official | 181:a4cbdfbbd2f4 | 42 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 181:a4cbdfbbd2f4 | 43 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 181:a4cbdfbbd2f4 | 44 | * and/or other materials provided with the distribution. |
mbed_official | 181:a4cbdfbbd2f4 | 45 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 181:a4cbdfbbd2f4 | 46 | * may be used to endorse or promote products derived from this software |
mbed_official | 181:a4cbdfbbd2f4 | 47 | * without specific prior written permission. |
mbed_official | 181:a4cbdfbbd2f4 | 48 | * |
mbed_official | 181:a4cbdfbbd2f4 | 49 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 181:a4cbdfbbd2f4 | 50 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 181:a4cbdfbbd2f4 | 51 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 181:a4cbdfbbd2f4 | 52 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 181:a4cbdfbbd2f4 | 53 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 181:a4cbdfbbd2f4 | 54 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 181:a4cbdfbbd2f4 | 55 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 181:a4cbdfbbd2f4 | 56 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 181:a4cbdfbbd2f4 | 57 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 181:a4cbdfbbd2f4 | 58 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 181:a4cbdfbbd2f4 | 59 | * |
mbed_official | 181:a4cbdfbbd2f4 | 60 | ****************************************************************************** |
mbed_official | 181:a4cbdfbbd2f4 | 61 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 62 | |
mbed_official | 181:a4cbdfbbd2f4 | 63 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 64 | #include "stm32l0xx_hal.h" |
mbed_official | 181:a4cbdfbbd2f4 | 65 | |
mbed_official | 181:a4cbdfbbd2f4 | 66 | /** @addtogroup STM32L0xx_HAL_Driver |
mbed_official | 181:a4cbdfbbd2f4 | 67 | * @{ |
mbed_official | 181:a4cbdfbbd2f4 | 68 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 69 | |
mbed_official | 181:a4cbdfbbd2f4 | 70 | /** @addtogroup ADCEx |
mbed_official | 181:a4cbdfbbd2f4 | 71 | * @brief ADC driver modules |
mbed_official | 181:a4cbdfbbd2f4 | 72 | * @{ |
mbed_official | 181:a4cbdfbbd2f4 | 73 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 74 | |
mbed_official | 181:a4cbdfbbd2f4 | 75 | #ifdef HAL_ADC_MODULE_ENABLED |
mbed_official | 181:a4cbdfbbd2f4 | 76 | |
mbed_official | 181:a4cbdfbbd2f4 | 77 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 78 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 79 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 80 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 81 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 82 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 181:a4cbdfbbd2f4 | 83 | |
mbed_official | 181:a4cbdfbbd2f4 | 84 | |
mbed_official | 181:a4cbdfbbd2f4 | 85 | /** @defgroup ADCEx_Group ADC Extended features functions |
mbed_official | 181:a4cbdfbbd2f4 | 86 | * @brief ADC Extended features functions |
mbed_official | 181:a4cbdfbbd2f4 | 87 | * |
mbed_official | 181:a4cbdfbbd2f4 | 88 | @verbatim |
mbed_official | 181:a4cbdfbbd2f4 | 89 | =============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 90 | ##### ADC Extended features functions ##### |
mbed_official | 181:a4cbdfbbd2f4 | 91 | =============================================================================== |
mbed_official | 181:a4cbdfbbd2f4 | 92 | [..] |
mbed_official | 181:a4cbdfbbd2f4 | 93 | This subsection provides functions allowing to: |
mbed_official | 181:a4cbdfbbd2f4 | 94 | (+) Start calibration. |
mbed_official | 181:a4cbdfbbd2f4 | 95 | (+) Get calibration factor. |
mbed_official | 181:a4cbdfbbd2f4 | 96 | (+) Set calibration factor. |
mbed_official | 181:a4cbdfbbd2f4 | 97 | |
mbed_official | 181:a4cbdfbbd2f4 | 98 | @endverbatim |
mbed_official | 181:a4cbdfbbd2f4 | 99 | * @{ |
mbed_official | 181:a4cbdfbbd2f4 | 100 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 101 | |
mbed_official | 181:a4cbdfbbd2f4 | 102 | |
mbed_official | 181:a4cbdfbbd2f4 | 103 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 104 | * @brief Start an automatic calibration |
mbed_official | 181:a4cbdfbbd2f4 | 105 | * @param hadc: pointer to a ADC_HandleTypeDef structure that contains |
mbed_official | 181:a4cbdfbbd2f4 | 106 | * the configuration information for the specified ADC. |
mbed_official | 181:a4cbdfbbd2f4 | 107 | * @param SingleDiff: Selection of single-ended or differential input |
mbed_official | 181:a4cbdfbbd2f4 | 108 | * This parameter can be only of the following values: |
mbed_official | 181:a4cbdfbbd2f4 | 109 | * @arg ADC_SINGLE_ENDED: Channel in mode input single ended |
mbed_official | 181:a4cbdfbbd2f4 | 110 | * @retval HAL status |
mbed_official | 181:a4cbdfbbd2f4 | 111 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 112 | HAL_StatusTypeDef HAL_ADCEx_Calibration_Start(ADC_HandleTypeDef* hadc, uint32_t SingleDiff) |
mbed_official | 181:a4cbdfbbd2f4 | 113 | { |
mbed_official | 181:a4cbdfbbd2f4 | 114 | uint32_t tickstart = 0; |
mbed_official | 181:a4cbdfbbd2f4 | 115 | |
mbed_official | 181:a4cbdfbbd2f4 | 116 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 117 | assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance)); |
mbed_official | 181:a4cbdfbbd2f4 | 118 | assert_param(IS_ADC_SINGLE_DIFFERENTIAL(SingleDiff)); |
mbed_official | 181:a4cbdfbbd2f4 | 119 | |
mbed_official | 181:a4cbdfbbd2f4 | 120 | /* Process locked */ |
mbed_official | 181:a4cbdfbbd2f4 | 121 | __HAL_LOCK(hadc); |
mbed_official | 181:a4cbdfbbd2f4 | 122 | |
mbed_official | 181:a4cbdfbbd2f4 | 123 | /* Disable the ADC (if not already disabled) */ |
mbed_official | 181:a4cbdfbbd2f4 | 124 | if (__HAL_ADC_IS_ENABLED(hadc) != RESET ) |
mbed_official | 181:a4cbdfbbd2f4 | 125 | { |
mbed_official | 181:a4cbdfbbd2f4 | 126 | /* Check if conditions to disable the ADC are fulfilled */ |
mbed_official | 181:a4cbdfbbd2f4 | 127 | if (__HAL_ADC_DISABLING_CONDITIONS(hadc) != RESET) |
mbed_official | 181:a4cbdfbbd2f4 | 128 | { |
mbed_official | 181:a4cbdfbbd2f4 | 129 | __HAL_ADC_DISABLE(hadc); |
mbed_official | 181:a4cbdfbbd2f4 | 130 | } |
mbed_official | 181:a4cbdfbbd2f4 | 131 | else |
mbed_official | 181:a4cbdfbbd2f4 | 132 | { |
mbed_official | 181:a4cbdfbbd2f4 | 133 | hadc->State= HAL_ADC_STATE_ERROR; |
mbed_official | 181:a4cbdfbbd2f4 | 134 | |
mbed_official | 181:a4cbdfbbd2f4 | 135 | /* Process unlocked */ |
mbed_official | 181:a4cbdfbbd2f4 | 136 | __HAL_UNLOCK(hadc); |
mbed_official | 181:a4cbdfbbd2f4 | 137 | |
mbed_official | 181:a4cbdfbbd2f4 | 138 | return HAL_ERROR; |
mbed_official | 181:a4cbdfbbd2f4 | 139 | } |
mbed_official | 181:a4cbdfbbd2f4 | 140 | |
mbed_official | 181:a4cbdfbbd2f4 | 141 | /* Wait for ADC effectively disabled */ |
mbed_official | 181:a4cbdfbbd2f4 | 142 | /* Get timeout */ |
mbed_official | 181:a4cbdfbbd2f4 | 143 | tickstart = HAL_GetTick(); |
mbed_official | 181:a4cbdfbbd2f4 | 144 | |
mbed_official | 181:a4cbdfbbd2f4 | 145 | /* Wait for disabling completion */ |
mbed_official | 181:a4cbdfbbd2f4 | 146 | while(HAL_IS_BIT_SET(hadc->Instance->CR, ADC_CR_ADEN)) |
mbed_official | 181:a4cbdfbbd2f4 | 147 | { |
mbed_official | 181:a4cbdfbbd2f4 | 148 | /* Check for the Timeout */ |
mbed_official | 181:a4cbdfbbd2f4 | 149 | if(ADC_DISABLE_TIMEOUT != HAL_MAX_DELAY) |
mbed_official | 181:a4cbdfbbd2f4 | 150 | { |
mbed_official | 181:a4cbdfbbd2f4 | 151 | if((HAL_GetTick() - tickstart ) > ADC_DISABLE_TIMEOUT) |
mbed_official | 181:a4cbdfbbd2f4 | 152 | { |
mbed_official | 181:a4cbdfbbd2f4 | 153 | hadc->State= HAL_ADC_STATE_TIMEOUT; |
mbed_official | 181:a4cbdfbbd2f4 | 154 | |
mbed_official | 181:a4cbdfbbd2f4 | 155 | /* Process unlocked */ |
mbed_official | 181:a4cbdfbbd2f4 | 156 | __HAL_UNLOCK(hadc); |
mbed_official | 181:a4cbdfbbd2f4 | 157 | |
mbed_official | 181:a4cbdfbbd2f4 | 158 | return HAL_TIMEOUT; |
mbed_official | 181:a4cbdfbbd2f4 | 159 | } |
mbed_official | 181:a4cbdfbbd2f4 | 160 | } |
mbed_official | 181:a4cbdfbbd2f4 | 161 | } |
mbed_official | 181:a4cbdfbbd2f4 | 162 | } |
mbed_official | 181:a4cbdfbbd2f4 | 163 | |
mbed_official | 181:a4cbdfbbd2f4 | 164 | /* Start ADC calibration */ |
mbed_official | 181:a4cbdfbbd2f4 | 165 | hadc->Instance->CR |= ADC_CR_ADCAL; |
mbed_official | 181:a4cbdfbbd2f4 | 166 | |
mbed_official | 181:a4cbdfbbd2f4 | 167 | /* Get timeout */ |
mbed_official | 181:a4cbdfbbd2f4 | 168 | tickstart = HAL_GetTick(); |
mbed_official | 181:a4cbdfbbd2f4 | 169 | |
mbed_official | 181:a4cbdfbbd2f4 | 170 | /* Wait for calibration completion */ |
mbed_official | 181:a4cbdfbbd2f4 | 171 | while(HAL_IS_BIT_SET(hadc->Instance->CR, ADC_CR_ADCAL)) |
mbed_official | 181:a4cbdfbbd2f4 | 172 | { |
mbed_official | 181:a4cbdfbbd2f4 | 173 | /* Check for the Timeout */ |
mbed_official | 181:a4cbdfbbd2f4 | 174 | if(ADC_CALIBRATION_TIMEOUT != HAL_MAX_DELAY) |
mbed_official | 181:a4cbdfbbd2f4 | 175 | { |
mbed_official | 181:a4cbdfbbd2f4 | 176 | if((HAL_GetTick() - tickstart ) > ADC_CALIBRATION_TIMEOUT) |
mbed_official | 181:a4cbdfbbd2f4 | 177 | { |
mbed_official | 181:a4cbdfbbd2f4 | 178 | hadc->State= HAL_ADC_STATE_TIMEOUT; |
mbed_official | 181:a4cbdfbbd2f4 | 179 | |
mbed_official | 181:a4cbdfbbd2f4 | 180 | /* Process unlocked */ |
mbed_official | 181:a4cbdfbbd2f4 | 181 | __HAL_UNLOCK(hadc); |
mbed_official | 181:a4cbdfbbd2f4 | 182 | |
mbed_official | 181:a4cbdfbbd2f4 | 183 | return HAL_TIMEOUT; |
mbed_official | 181:a4cbdfbbd2f4 | 184 | } |
mbed_official | 181:a4cbdfbbd2f4 | 185 | } |
mbed_official | 181:a4cbdfbbd2f4 | 186 | } |
mbed_official | 181:a4cbdfbbd2f4 | 187 | |
mbed_official | 181:a4cbdfbbd2f4 | 188 | /* Process unlocked */ |
mbed_official | 181:a4cbdfbbd2f4 | 189 | __HAL_UNLOCK(hadc); |
mbed_official | 181:a4cbdfbbd2f4 | 190 | |
mbed_official | 181:a4cbdfbbd2f4 | 191 | /* Return function status */ |
mbed_official | 181:a4cbdfbbd2f4 | 192 | return HAL_OK; |
mbed_official | 181:a4cbdfbbd2f4 | 193 | |
mbed_official | 181:a4cbdfbbd2f4 | 194 | } |
mbed_official | 181:a4cbdfbbd2f4 | 195 | |
mbed_official | 181:a4cbdfbbd2f4 | 196 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 197 | * @brief Get the calibration factor. |
mbed_official | 181:a4cbdfbbd2f4 | 198 | * @param hadc: ADC handle. |
mbed_official | 181:a4cbdfbbd2f4 | 199 | * @param SingleDiff: This parameter can be only: |
mbed_official | 181:a4cbdfbbd2f4 | 200 | * @arg ADC_SINGLE_ENDED: Channel in mode input single ended. |
mbed_official | 181:a4cbdfbbd2f4 | 201 | * @retval Calibration value. |
mbed_official | 181:a4cbdfbbd2f4 | 202 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 203 | uint32_t HAL_ADCEx_Calibration_GetValue(ADC_HandleTypeDef* hadc, uint32_t SingleDiff) |
mbed_official | 181:a4cbdfbbd2f4 | 204 | { |
mbed_official | 181:a4cbdfbbd2f4 | 205 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 206 | assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance)); |
mbed_official | 181:a4cbdfbbd2f4 | 207 | assert_param(IS_ADC_SINGLE_DIFFERENTIAL(SingleDiff)); |
mbed_official | 181:a4cbdfbbd2f4 | 208 | |
mbed_official | 181:a4cbdfbbd2f4 | 209 | /* Return the ADC calibration value */ |
mbed_official | 181:a4cbdfbbd2f4 | 210 | return ((hadc->Instance->CALFACT) & 0x0000007F); |
mbed_official | 181:a4cbdfbbd2f4 | 211 | } |
mbed_official | 181:a4cbdfbbd2f4 | 212 | |
mbed_official | 181:a4cbdfbbd2f4 | 213 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 214 | * @brief Set the calibration factor to overwrite automatic conversion result. |
mbed_official | 181:a4cbdfbbd2f4 | 215 | * ADC must be enabled and no conversion is ongoing. |
mbed_official | 181:a4cbdfbbd2f4 | 216 | * @param hadc: ADC handle |
mbed_official | 181:a4cbdfbbd2f4 | 217 | * @param SingleDiff: This parameter can be only: |
mbed_official | 181:a4cbdfbbd2f4 | 218 | * @arg ADC_SINGLE_ENDED: Channel in mode input single ended. |
mbed_official | 181:a4cbdfbbd2f4 | 219 | * @param CalibrationFactor: Calibration factor (coded on 7 bits maximum) |
mbed_official | 181:a4cbdfbbd2f4 | 220 | * @retval HAL state |
mbed_official | 181:a4cbdfbbd2f4 | 221 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 222 | HAL_StatusTypeDef HAL_ADCEx_Calibration_SetValue(ADC_HandleTypeDef* hadc, uint32_t SingleDiff, uint32_t CalibrationFactor) |
mbed_official | 181:a4cbdfbbd2f4 | 223 | { |
mbed_official | 181:a4cbdfbbd2f4 | 224 | HAL_StatusTypeDef tmpHALStatus = HAL_OK; |
mbed_official | 181:a4cbdfbbd2f4 | 225 | |
mbed_official | 181:a4cbdfbbd2f4 | 226 | /* Check the parameters */ |
mbed_official | 181:a4cbdfbbd2f4 | 227 | assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance)); |
mbed_official | 181:a4cbdfbbd2f4 | 228 | assert_param(IS_ADC_SINGLE_DIFFERENTIAL(SingleDiff)); |
mbed_official | 181:a4cbdfbbd2f4 | 229 | assert_param(IS_ADC_CALFACT(CalibrationFactor)); |
mbed_official | 181:a4cbdfbbd2f4 | 230 | |
mbed_official | 181:a4cbdfbbd2f4 | 231 | /* Process locked */ |
mbed_official | 181:a4cbdfbbd2f4 | 232 | __HAL_LOCK(hadc); |
mbed_official | 181:a4cbdfbbd2f4 | 233 | |
mbed_official | 181:a4cbdfbbd2f4 | 234 | /* Verification of hardware constraints before modifying the calibration */ |
mbed_official | 181:a4cbdfbbd2f4 | 235 | /* factors register: ADC must be enabled, no conversion on going. */ |
mbed_official | 181:a4cbdfbbd2f4 | 236 | if ( (__HAL_ADC_IS_ENABLED(hadc) != RESET) && |
mbed_official | 181:a4cbdfbbd2f4 | 237 | (__HAL_ADC_IS_CONVERSION_ONGOING(hadc) == RESET) ) |
mbed_official | 181:a4cbdfbbd2f4 | 238 | { |
mbed_official | 181:a4cbdfbbd2f4 | 239 | /* Set the selected ADC calibration value */ |
mbed_official | 181:a4cbdfbbd2f4 | 240 | hadc->Instance->CALFACT &= ~ADC_CALFACT_CALFACT; |
mbed_official | 181:a4cbdfbbd2f4 | 241 | hadc->Instance->CALFACT |= CalibrationFactor; |
mbed_official | 181:a4cbdfbbd2f4 | 242 | } |
mbed_official | 181:a4cbdfbbd2f4 | 243 | else |
mbed_official | 181:a4cbdfbbd2f4 | 244 | { |
mbed_official | 181:a4cbdfbbd2f4 | 245 | /* Update ADC state machine to error */ |
mbed_official | 181:a4cbdfbbd2f4 | 246 | hadc->State = HAL_ADC_STATE_ERROR; |
mbed_official | 181:a4cbdfbbd2f4 | 247 | |
mbed_official | 181:a4cbdfbbd2f4 | 248 | /* Update ADC state machine to error */ |
mbed_official | 181:a4cbdfbbd2f4 | 249 | tmpHALStatus = HAL_ERROR; |
mbed_official | 181:a4cbdfbbd2f4 | 250 | } |
mbed_official | 181:a4cbdfbbd2f4 | 251 | |
mbed_official | 181:a4cbdfbbd2f4 | 252 | /* Process unlocked */ |
mbed_official | 181:a4cbdfbbd2f4 | 253 | __HAL_UNLOCK(hadc); |
mbed_official | 181:a4cbdfbbd2f4 | 254 | |
mbed_official | 181:a4cbdfbbd2f4 | 255 | /* Return function status */ |
mbed_official | 181:a4cbdfbbd2f4 | 256 | return tmpHALStatus; |
mbed_official | 181:a4cbdfbbd2f4 | 257 | } |
mbed_official | 181:a4cbdfbbd2f4 | 258 | |
mbed_official | 181:a4cbdfbbd2f4 | 259 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 260 | * @} |
mbed_official | 181:a4cbdfbbd2f4 | 261 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 262 | |
mbed_official | 181:a4cbdfbbd2f4 | 263 | |
mbed_official | 181:a4cbdfbbd2f4 | 264 | #endif /* HAL_ADC_MODULE_ENABLED */ |
mbed_official | 181:a4cbdfbbd2f4 | 265 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 266 | * @} |
mbed_official | 181:a4cbdfbbd2f4 | 267 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 268 | |
mbed_official | 181:a4cbdfbbd2f4 | 269 | /** |
mbed_official | 181:a4cbdfbbd2f4 | 270 | * @} |
mbed_official | 181:a4cbdfbbd2f4 | 271 | */ |
mbed_official | 181:a4cbdfbbd2f4 | 272 | |
mbed_official | 181:a4cbdfbbd2f4 | 273 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |