6.2.2 How to use this driver
1. Initialize the ADC low level resources by implementing the HAL_ADC_MspInit():
a. Enable the ADC interface clock using __HAL_RCC_ADC_CLK_ENABLE()
b. 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()
c. In case of using interrupts (e.g. HAL_ADC_Start_IT())
Configure the ADC interrupt priority using HAL_NVIC_SetPriority()
Enable the ADC IRQ handler using HAL_NVIC_EnableIRQ()
In ADC IRQ handler, call HAL_ADC_IRQHandler()
d. In case of using DMA to control data transfer (e.g. HAL_ADC_Start_DMA())
Enable the DMAx interface clock using
__HAL_RCC_DMAx_CLK_ENABLE()
Configure and enable two DMA streams stream for managing data transfer
from peripheral to memory (output stream)
Associate the initialized DMA handle to the CRYP DMA handle using
__HAL_LINKDMA()
Configure the priority and enable the NVIC for the transfer complete interrupt
on the two DMA Streams. The output stream should have higher priority
than the input stream.
Configuration of ADC, groups regular/injected, channels parameters
1. Configure the ADC parameters (resolution, data alignment, ...) and regular group
parameters (conversion trigger, sequencer, ...) using function HAL_ADC_Init().
2. Configure the channels for regular group parameters (channel number, channel rank
into sequencer, ..., into regular group) using function HAL_ADC_ConfigChannel().
3. Optionally, configure the injected group parameters (conversion trigger, sequencer, ...,
of injected group) and the channels for injected group parameters (channel number,
channel rank into sequencer, ..., into injected group) using function
HAL_ADCEx_InjectedConfigChannel().
4. Optionally, configure the analog watchdog parameters (channels monitored,
thresholds, ...) using function HAL_ADC_AnalogWDGConfig().
5. Optionally, for devices with several ADC instances: configure the multimode
parameters using function HAL_ADCEx_MultiModeConfigChannel().
Execution of ADC conversions
1. ADC driver can be used among three modes: polling, interruption, transfer by DMA.
Polling mode IO operation
Start the ADC peripheral using HAL_ADC_Start()
Wait for end of conversion using HAL_ADC_PollForConversion(), at this stage user
can specify the value of timeout according to his end application
To read the ADC converted values, use the HAL_ADC_GetValue() function.
Stop the ADC peripheral using HAL_ADC_Stop()
Interrupt mode IO operation
Start the ADC peripheral using HAL_ADC_Start_IT()
Use HAL_ADC_IRQHandler() called under ADC_IRQHandler() Interrupt subroutine