Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of TUKS-COURSE-TIMER by
stm32l4xx_hal_adc.c File Reference
This file provides firmware functions to manage the following functionalities of the Analog to Digital Convertor (ADC) peripheral: + Initialization and de-initialization functions ++ Configuration of ADC + Operation functions ++ Start, stop, get result of regular conversions of regular using 3 possible modes: polling, interruption or DMA. + Control functions ++ Analog Watchdog configuration ++ Channels configuration on regular group + State functions ++ ADC state machine management ++ Interrupts and flags management. More...
Go to the source code of this file.
Functions | |
HAL_StatusTypeDef | HAL_ADC_Init (ADC_HandleTypeDef *hadc) |
Initialize the ADC peripheral and regular group according to parameters specified in structure "ADC_InitTypeDef". | |
HAL_StatusTypeDef | HAL_ADC_DeInit (ADC_HandleTypeDef *hadc) |
Deinitialize the ADC peripheral registers to their default reset values, with deinitialization of the ADC MSP. | |
__weak void | HAL_ADC_MspInit (ADC_HandleTypeDef *hadc) |
Initialize the ADC MSP. | |
__weak void | HAL_ADC_MspDeInit (ADC_HandleTypeDef *hadc) |
DeInitialize the ADC MSP. | |
HAL_StatusTypeDef | HAL_ADC_Start (ADC_HandleTypeDef *hadc) |
Enable ADC, start conversion of regular group. | |
HAL_StatusTypeDef | HAL_ADC_Stop (ADC_HandleTypeDef *hadc) |
Stop ADC conversion of regular and injected groups, disable ADC peripheral. | |
HAL_StatusTypeDef | HAL_ADC_PollForConversion (ADC_HandleTypeDef *hadc, uint32_t Timeout) |
Wait for regular group conversion to be completed. | |
HAL_StatusTypeDef | HAL_ADC_PollForEvent (ADC_HandleTypeDef *hadc, uint32_t EventType, uint32_t Timeout) |
Poll for ADC event. | |
HAL_StatusTypeDef | HAL_ADC_Start_IT (ADC_HandleTypeDef *hadc) |
Enable ADC, start conversion of regular group with interruption. | |
HAL_StatusTypeDef | HAL_ADC_Stop_IT (ADC_HandleTypeDef *hadc) |
Stop ADC conversion of regular groups when interruptions are enabled. | |
HAL_StatusTypeDef | HAL_ADC_Start_DMA (ADC_HandleTypeDef *hadc, uint32_t *pData, uint32_t Length) |
Enable ADC, start conversion of regular group and transfer result through DMA. | |
HAL_StatusTypeDef | HAL_ADC_Stop_DMA (ADC_HandleTypeDef *hadc) |
Stop ADC conversion of regular groups and disable ADC DMA transfer. | |
uint32_t | HAL_ADC_GetValue (ADC_HandleTypeDef *hadc) |
Get ADC regular group conversion result. | |
void | HAL_ADC_IRQHandler (ADC_HandleTypeDef *hadc) |
Handle ADC interrupt request. | |
__weak void | HAL_ADC_ConvCpltCallback (ADC_HandleTypeDef *hadc) |
Conversion complete callback in non-blocking mode. | |
__weak void | HAL_ADC_ConvHalfCpltCallback (ADC_HandleTypeDef *hadc) |
Conversion DMA half-transfer callback in non-blocking mode. | |
__weak void | HAL_ADC_LevelOutOfWindowCallback (ADC_HandleTypeDef *hadc) |
Analog watchdog 1 callback in non-blocking mode. | |
__weak void | HAL_ADC_ErrorCallback (ADC_HandleTypeDef *hadc) |
ADC error callback in non-blocking mode (ADC conversion with interruption or transfer by DMA). | |
HAL_StatusTypeDef | HAL_ADC_ConfigChannel (ADC_HandleTypeDef *hadc, ADC_ChannelConfTypeDef *sConfig) |
Configure the selected channel to be linked to the regular group. | |
HAL_StatusTypeDef | HAL_ADC_AnalogWDGConfig (ADC_HandleTypeDef *hadc, ADC_AnalogWDGConfTypeDef *AnalogWDGConfig) |
Configure the analog watchdog. | |
uint32_t | HAL_ADC_GetState (ADC_HandleTypeDef *hadc) |
Return the ADC handle state. | |
uint32_t | HAL_ADC_GetError (ADC_HandleTypeDef *hadc) |
Return the ADC error code. | |
HAL_StatusTypeDef | ADC_ConversionStop (ADC_HandleTypeDef *hadc, uint32_t ConversionGroup) |
Stop ADC conversion. | |
HAL_StatusTypeDef | ADC_Enable (ADC_HandleTypeDef *hadc) |
Enable the selected ADC. | |
HAL_StatusTypeDef | ADC_Disable (ADC_HandleTypeDef *hadc) |
Disable the selected ADC. | |
void | ADC_DMAConvCplt (DMA_HandleTypeDef *hdma) |
DMA transfer complete callback. | |
void | ADC_DMAHalfConvCplt (DMA_HandleTypeDef *hdma) |
DMA half transfer complete callback. | |
void | ADC_DMAError (DMA_HandleTypeDef *hdma) |
DMA error callback. |
Detailed Description
This file provides firmware functions to manage the following functionalities of the Analog to Digital Convertor (ADC) peripheral: + Initialization and de-initialization functions ++ Configuration of ADC + Operation functions ++ Start, stop, get result of regular conversions of regular using 3 possible modes: polling, interruption or DMA. + Control functions ++ Analog Watchdog configuration ++ Channels configuration on regular group + State functions ++ ADC state machine management ++ Interrupts and flags management.
- Version:
- V1.5.1
- Date:
- 31-May-2016
============================================================================== ##### ADC specific features ##### ============================================================================== [..] (#) 12-bit, 10-bit, 8-bit or 6-bit configurable resolution. (#) Interrupt generation at the end of regular conversion and in case of analog watchdog and overrun events. (#) Single and continuous conversion modes. (#) Scan mode for automatic conversion of channel 0 to channel 'n'. (#) Data alignment with in-built data coherency. (#) Channel-wise programmable sampling time. (#) External trigger (timer or EXTI) with configurable polarity for regular groups. (#) DMA request generation for transfer of regular group converted data. (#) Configurable delay between conversions in Dual interleaved mode. (#) ADC channels selectable single/differential input. (#) ADC offset on regular groups. (#) ADC supply requirements: 1.62 V to 3.6 V. (#) ADC input range: from Vref_ (connected to Vssa) to Vref+ (connected to Vdda or to an external voltage reference). ##### How to use this driver ##### ============================================================================== [..] (#) Enable the ADC interface As prerequisite, in HAL_ADC_MspInit(), ADC clock source must be configured at RCC top level. Two different clock sources are available: (++) - the ADC clock can be a specific clock source, coming from the system clock, the PLLSAI1 or the PLLSAI2 running up to 80MHz. (++) - or the ADC clock can be derived from the AHB clock of the ADC bus interface, divided by a programmable factor (++) For example, in case of PLLSAI2: (+++) __HAL_RCC_ADC_CLK_ENABLE(); (+++) HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit); (+++) where (+++) PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC (+++) PeriphClkInit.AdcClockSelection = RCC_ADCCLKSOURCE_PLLSAI2 (#) ADC pins configuration (++) Enable the clock for the ADC GPIOs using the following function: __HAL_RCC_GPIOx_CLK_ENABLE(); (++) Configure these ADC pins in analog mode using HAL_GPIO_Init(); (#) Configure the ADC parameters (conversion resolution, data alignment, continuous mode, ...) using the HAL_ADC_Init() function. (#) Optionally, perform an automatic ADC calibration to improve the conversion accuracy using function HAL_ADCEx_Calibration_Start(). (#) Activate the ADC peripheral using one of the start functions: HAL_ADC_Start(), HAL_ADC_Start_IT(), HAL_ADC_Start_DMA(), HAL_ADCEx_InjectedStart(), HAL_ADCEx_InjectedStart_IT() or HAL_ADCEx_MultiModeStart_DMA() when multimode feature is available. *** Channels to regular group configuration *** ============================================ [..] (+) To configure the ADC regular group features, use HAL_ADC_Init() and HAL_ADC_ConfigChannel() functions. (+) To activate the continuous mode, use the HAL_ADC_Init() function. (+) To read the ADC converted values, use the HAL_ADC_GetValue() function. *** DMA for regular configuration *** ============================================================= [..] (+) To enable the DMA mode for regular group, use the HAL_ADC_Start_DMA() function. (+) To enable the generation of DMA requests continuously at the end of the last DMA transfer, resort to DMAContinuousRequests parameter of ADC handle initialization structure.
- Attention:
© COPYRIGHT(c) 2016 STMicroelectronics
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file stm32l4xx_hal_adc.c.
Generated on Tue Jul 12 2022 17:38:51 by
