没有合适的资源?快使用搜索试试~ 我知道了~
首页Description of STM32F4 HAL and LL drivers.pdf
Description of STM32F4 HAL and LL drivers.pdf

Description of STM32F4 HAL and LL drivers.pdf
资源详情
资源评论
资源推荐

February 2017
DocID025834 Rev 5
1/1838
www.st.com
UM1725
User Manual
Description of STM32F4 HAL and LL drivers
Introduction
STM32Cube
TM
is STMicroelectronics's original initiative to ease developers' life by reducing
development efforts, time and cost. STM32Cube
TM
covers the STM32 portfolio.
STM32Cube
TM
Version 1.x includes:
The STM32CubeMX, a graphical software configuration tool that allows generating C initialization
code using graphical wizards.
A comprehensive embedded software platform, delivered per series (such as STM32CubeF4 for
STM32F4 Series)
The STM32Cube hardware abstraction layer (HAL), an STM32 abstraction layer embedded
software, ensuring maximized portability across the STM32 portfolio
The Low Layer APIs (LL) offering a fast light-weight expert-oriented layer which is closer to the
hardware than the HAL. The LL APIs are available only for a set of peripherals
A consistent set of middleware components such as RTOS, USB, TCP/IP, Graphics
All embedded software utilities coming with a full set of examples.
The HAL driver layer provides a generic multi instance simple set of APIs (application programming
interfaces) to interact with the upper layer (application, libraries and stacks). It is composed of generic
and extension APIs. It is directly built around a generic architecture and allows the built-upon layers,
such as the middleware layer, to implement their functions without knowing in-depth how to use the
MCU. This structure improves the library code reusability and guarantees easy portability to other
devices.
The HAL drivers include a complete set of ready-to-use APIs which simplify the user application
implementation. As an example, the communication peripherals contain APIs to initialize and configure
the peripheral, to manage data transfers based on polling, to handle interrupts or DMA, and to manage
communication errors.
The HAL driver APIs are split into two categories: generic APIs which provide common and generic
functions for all the STM32 series and extension APIs which include specific and customized functions
for a given family or part number.
The HAL drivers are feature-oriented instead of IP-oriented. As an example, the timer APIs are split into
several categories following the functions offered by the IP: basic timer, capture, pulse width modulation
(PWM), and so on.
The HAL driver layer implements run-time failure detection by checking the input values of all functions.
Such dynamic checking contributes to enhance the firmware robustness. Run-time detection is also
suitable for user application development and debugging.
The LL drivers offer hardware services based on the available features of the STM32 peripherals. These
services reflect exactly the hardware capabilities and provide atomic operations that must be called
following the programming model described in the product line reference manual. As a result, the LL
services are not based on standalone processes and do not require any additional memory resources to
save their states, counter or data pointers: all operations are performed by changing the associated
peripheral registers content. Contrary to the HAL, the LL APIs are not provided for peripherals for which

Introduction
UM1725
2/1838
DocID025834 Rev 5
optimized access is not a key feature, or for those requiring heavy software configuration and/or
complex upper level stack (such as FSMC, USB, SDMMC).
The HAL and LL are complementary and cover a wide range of applications requirements:
The HAL offers high-level and feature-oriented APIs, with a high-portability level. They hide the
MCU and peripheral complexity to end-user.
The LL offers low-level APIs at registers level, with better optimization but less portability. They
require deep knowledge of the MCU and peripherals specifications.
The source code of drivers is developed in Strict ANSI-C, which makes it independent from the
development tools. It is checked with CodeSonar
TM
static analysis tool. It is fully documented and is
MISRA-C 2004 compliant.
This user manual is structured as follows:
Overview of HAL drivers
Overview of LL drivers
Detailed description of each peripheral driver: configuration structures, functions, and how to use
the given API to build your application.

UM1725
Contents
DocID025834 Rev 5
3/1838
Contents
1 Acronyms and definitions ............................................................. 34
2 Overview of HAL drivers ............................................................... 36
2.1 HAL and user-application files......................................................... 36
2.1.1 HAL driver files ................................................................................. 36
2.1.2 User-application files ........................................................................ 37
2.2 HAL data structures ........................................................................ 39
2.2.1 Peripheral handle structures ............................................................ 39
2.2.2 Initialization and configuration structure ........................................... 40
2.2.3 Specific process structures .............................................................. 41
2.3 API classification ............................................................................. 41
2.4 Devices supported by HAL drivers .................................................. 42
2.5 HAL driver rules .............................................................................. 47
2.5.1 HAL API naming rules ...................................................................... 47
2.5.2 HAL general naming rules ................................................................ 48
2.5.3 HAL interrupt handler and callback functions ................................... 49
2.6 HAL generic APIs ............................................................................ 49
2.7 HAL extension APIs ........................................................................ 51
2.7.1 HAL extension model overview ........................................................ 51
2.7.2 HAL extension model cases ............................................................. 51
2.8 File inclusion model ......................................................................... 53
2.9 HAL common resources .................................................................. 54
2.10 HAL configuration ............................................................................ 55
2.11 HAL system peripheral handling ..................................................... 56
2.11.1 Clock ................................................................................................. 56
2.11.2 GPIOs ............................................................................................... 57
2.11.3 Cortex NVIC and SysTick timer ........................................................ 58
2.11.4 PWR ................................................................................................. 59
2.11.5 EXTI .................................................................................................. 59
2.11.6 DMA .................................................................................................. 60
2.12 How to use HAL drivers .................................................................. 61
2.12.1 HAL usage models ........................................................................... 61
2.12.2 HAL initialization ............................................................................... 62
2.12.3 HAL IO operation process ................................................................ 64
2.12.4 Timeout and error management ....................................................... 67

Contents
UM1725
4/1838
DocID025834 Rev 5
3 Overview of Low Layer drivers ..................................................... 72
3.1 Low Layer files ................................................................................ 72
3.2 Overview of Low Layer APIs and naming rules ............................... 74
3.2.1 Peripheral initialization functions ...................................................... 74
3.2.2 Peripheral register-level configuration functions .............................. 77
4 Cohabiting of HAL and LL ............................................................ 80
4.1 Low Layer driver used in standalone mode ..................................... 80
4.2 Mixed use of Low Layer APIs and HAL drivers ............................... 80
5 HAL System Driver ........................................................................ 81
5.1 HAL Firmware driver API description .............................................. 81
5.1.1 How to use this driver ....................................................................... 81
5.1.2 Initialization and de-initialization functions ....................................... 81
5.1.3 HAL Control functions....................................................................... 81
5.1.4 Detailed description of functions ...................................................... 82
5.2 HAL Firmware driver defines ........................................................... 86
5.2.1 HAL ................................................................................................... 86
6 HAL ADC Generic Driver ............................................................... 89
6.1 ADC Firmware driver registers structures ....................................... 89
6.1.1 ADC_InitTypeDef .............................................................................. 89
6.1.2 ADC_ChannelConfTypeDef ............................................................. 90
6.1.3 ADC_AnalogWDGConfTypeDef ....................................................... 91
6.1.4 ADC_HandleTypeDef ....................................................................... 91
6.2 ADC Firmware driver API description .............................................. 92
6.2.1 ADC Peripheral features................................................................... 92
6.2.2 How to use this driver ....................................................................... 92
6.2.3 Initialization and de-initialization functions ....................................... 94
6.2.4 IO operation functions ...................................................................... 95
6.2.5 Peripheral Control functions ............................................................. 95
6.2.6 Peripheral State and errors functions ............................................... 95
6.2.7 Detailed description of functions ...................................................... 96
6.3 ADC Firmware driver defines ........................................................ 101
6.3.1 ADC ................................................................................................ 101
7 HAL ADC Extension Driver ......................................................... 108
7.1 ADCEx Firmware driver registers structures ................................. 108
7.1.1 ADC_InjectionConfTypeDef ........................................................... 108
7.1.2 ADC_MultiModeTypeDef ................................................................ 109

UM1725
Contents
DocID025834 Rev 5
5/1838
7.2 ADCEx Firmware driver API description ....................................... 110
7.2.1 How to use this driver ..................................................................... 110
7.2.2 Extended features functions ........................................................... 111
7.2.3 Detailed description of functions .................................................... 112
7.3 ADCEx Firmware driver defines .................................................... 115
7.3.1 ADCEx ............................................................................................ 115
8 HAL CAN Generic Driver ............................................................. 117
8.1 CAN Firmware driver registers structures ..................................... 117
8.1.1 CAN_InitTypeDef ............................................................................ 117
8.1.2 CAN_FilterConfTypeDef ................................................................. 118
8.1.3 CanTxMsgTypeDef ......................................................................... 118
8.1.4 CanRxMsgTypeDef ........................................................................ 119
8.1.5 CAN_HandleTypeDef ..................................................................... 120
8.2 CAN Firmware driver API description ............................................ 120
8.2.1 How to use this driver ..................................................................... 120
8.2.2 Initialization and de-initialization functions ..................................... 121
8.2.3 IO operation functions .................................................................... 122
8.2.4 Peripheral State and Error functions .............................................. 122
8.2.5 Detailed description of functions .................................................... 122
8.3 CAN Firmware driver defines ........................................................ 126
8.3.1 CAN ................................................................................................ 126
9 HAL CEC Generic Driver ............................................................. 133
9.1 CEC Firmware driver registers structures ..................................... 133
9.1.1 CEC_InitTypeDef ............................................................................ 133
9.1.2 CEC_HandleTypeDef ..................................................................... 134
9.2 CEC Firmware driver API description ............................................ 135
9.2.1 How to use this driver ..................................................................... 135
9.2.2 Initialization and Configuration functions ........................................ 135
9.2.3 IO operation functions .................................................................... 136
9.2.4 Peripheral Control function ............................................................. 136
9.2.5 Detailed description of functions .................................................... 136
9.3 CEC Firmware driver defines ........................................................ 139
9.3.1 CEC ................................................................................................ 139
10 HAL CORTEX Generic Driver ...................................................... 147
10.1 CORTEX Firmware driver registers structures .............................. 147
10.1.1 MPU_Region_InitTypeDef .............................................................. 147
剩余1837页未读,继续阅读

















安全验证
文档复制为VIP权益,开通VIP直接复制

评论1