HAL generic APIs. STMicroelectronics STM32F4
जाहिरात
जाहिरात
UM1725
2.6 HAL generic APIs
The generic APIs provide common generic functions applying to all STM32 devices. They are composed of four APIs groups:
Initialization and de-initialization functions:HAL_PPP_Init(), HAL_PPP_DeInit()
IO operation functions: HAL_PPP_Read(), HAL_PPP_Write(),HAL_PPP_Transmit(),
HAL_PPP_Receive()
Control functions:HAL_PPP_Set (), HAL_PPP_Get ().
State and Errors functions: HAL_PPP_GetState (), HAL_PPP_GetError ().
For some peripheral/module drivers, these groups are modified depending on the peripheral/module implementation.
Example: in the timer driver, the API grouping is based on timer features (PWM, OC, IC...).
The initialization and de-initialization functions allow initializing a peripheral and configuring the low-level resources, mainly clocks, GPIO, alternate functions (AF) and possibly DMA and interrupts. The HAL_DeInit()function restores the peripheral default state, frees the low-level resources and removes any direct dependency with the hardware.
The IO operation functions perform a row access to the peripheral payload data in write and read modes.
The control functions are used to change dynamically the peripheral configuration and set another operating mode.
The peripheral state and errors functions allow retrieving in runtime the peripheral and data flow states, and identifying the type of errors that occurred. The example below is based on the ADC peripheral. The list of generic APIs is not exhaustive. It is only given as an example.
Table 9: HAL generic APIs
Function
Group
Common API Name Description
Initialization
group
IO operation
group
HAL_ADC_Init()
HAL_ADC_DeInit()
HAL_ADC_Start ()
HAL_ADC_Stop ()
HAL_ADC_PollForConversion()
HAL_ADC_Start_IT()
This function initializes the peripheral and configures the low -level resources (clocks,
GPIO, AF..)
This function restores the peripheral default state, frees the low-level resources and removes any direct dependency with the hardware.
This function starts ADC conversions when the polling method is used
This function stops ADC conversions when the polling method is used
This function allows waiting for the end of conversions when the polling method is used. In this case, a timout value is specified by the user according to the application.
This function starts ADC conversions when the interrupt method is used
HAL_ADC_Stop_IT()
HAL_ADC_IRQHandler()
This function stops ADC conversions when the interrupt method is used
This function handles ADC interrupt requests
DOCID025834 Rev 3 73/963
डाउनलोड
जाहिरात