没有合适的资源?快使用搜索试试~ 我知道了~
STM32 HAL库函数说明手册

温馨提示
第一次弄STM32,觉着HAL库很好用,新手入门很快,文档里面有详细的函数使用描述
资源推荐
资源详情
资源评论










December 2016
DocID026232 Rev 6
1/1466
www.st.com
UM1749
User Manual
Description of STM32L0 HAL and Low Layer drivers
Introduction
STMCube
TM
is STMicroelectronics's original initiative to ease developers' life by reducing development
efforts, time and cost. STM32Cube covers the STM32 portfolio.
STM32Cube 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 STM32CubeL0
forSTM32L0 Series)
The STM32Cube Hardware Abstraction Layer (HAL), an STM32 abstraction layer embedded
software ensuring maximized portability across the STM32 portfolio. The HAL is available for
all peripherals.
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.
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).
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 line or part number. 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, manage data transfers in polling mode, handle interrupts
or DMA, and manage communication errors.
The HAL drivers are feature-oriented instead of IP-oriented. As an example, the timer APIs are split into
several categories following the IP functions: basic timer, capture, pulse width modulation (PWM), etc..
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
optimized access is not a key feature, or for those requiring heavy software configuration and/or
complex upper level stack (such as USB).
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 HAL and LL drivers is developed in Strict ANSI-C which makes it independent from
the development tools. It is checked with CodeSonar™ static analysis tool. It is fully documented and is
MISRA-C 2004 compliant.

Contents
UM1749
2/1466
DocID026232 Rev 6
Contents
1 Acronyms and definitions ............................................................. 25
2 Overview of HAL drivers ............................................................... 27
2.1 HAL and user-application files......................................................... 27
2.1.1 HAL driver files ................................................................................. 27
2.1.2 User-application files ........................................................................ 28
2.2 HAL data structures ........................................................................ 30
2.2.1 Peripheral handle structures ............................................................ 30
2.2.2 Initialization and configuration structure ........................................... 31
2.2.3 Specific process structures .............................................................. 31
2.3 API classification ............................................................................. 32
2.4 Devices supported by HAL drivers .................................................. 33
2.5 HAL driver rules .............................................................................. 37
2.5.1 HAL API naming rules ...................................................................... 37
2.5.2 HAL general naming rules ................................................................ 38
2.5.3 HAL interrupt handler and callback functions ................................... 39
2.6 HAL generic APIs ............................................................................ 39
2.7 HAL extension APIs ........................................................................ 41
2.7.1 HAL extension model overview ........................................................ 41
2.7.2 HAL extension model cases ............................................................. 41
2.8 File inclusion model ......................................................................... 43
2.9 HAL common resources .................................................................. 44
2.10 HAL configuration ............................................................................ 45
2.11 HAL system peripheral handling ..................................................... 46
2.11.1 Clock ................................................................................................. 46
2.11.2 GPIOs ............................................................................................... 46
2.11.3 Cortex NVIC and SysTick timer ........................................................ 48
2.11.4 PWR ................................................................................................. 49
2.11.5 EXTI .................................................................................................. 49
2.11.6 DMA .................................................................................................. 50
2.12 How to use HAL drivers .................................................................. 52
2.12.1 HAL usage models ........................................................................... 52
2.12.2 HAL initialization ............................................................................... 53
2.12.3 HAL IO operation process ................................................................ 55
2.12.4 Timeout and error management ....................................................... 58

UM1749
Contents
DocID026232 Rev 6
3/1466
3 Overview of Low Layer drivers ..................................................... 62
3.1 Low Layer files ................................................................................ 62
3.2 Overview of Low Layer APIs and naming rules ............................... 64
3.2.1 Peripheral initialization functions ...................................................... 64
3.2.2 Register-level peripheral configuration functions ............................. 67
4 Cohabiting of HAL and LL ............................................................ 70
4.1 Low Layer driver used in standalone mode ..................................... 70
4.2 Mixed use of Low Layer APIs and HAL drivers ............................... 70
5 HAL System Driver ........................................................................ 71
5.1 HAL Firmware driver API description .............................................. 71
5.1.1 How to use this driver ....................................................................... 71
5.1.2 Initialization and de-initialization functions ....................................... 71
5.1.3 HAL Control functions....................................................................... 71
5.1.4 Detailed description of functions ...................................................... 72
5.2 HAL Firmware driver defines ........................................................... 77
5.2.1 HAL ................................................................................................... 77
6 HAL ADC Generic Driver ............................................................... 83
6.1 ADC Firmware driver registers structures ....................................... 83
6.1.1 ADC_OversamplingTypeDef ............................................................ 83
6.1.2 ADC_InitTypeDef .............................................................................. 83
6.1.3 ADC_ChannelConfTypeDef ............................................................. 86
6.1.4 ADC_AnalogWDGConfTypeDef ....................................................... 86
6.1.5 ADC_HandleTypeDef ....................................................................... 87
6.2 ADC Firmware driver API description .............................................. 87
6.2.1 ADC peripheral features ................................................................... 87
6.2.2 How to use this driver ....................................................................... 88
6.2.3 Peripheral Control functions ............................................................. 90
6.2.4 Peripheral state and errors functions ............................................... 90
6.2.5 Detailed description of functions ...................................................... 90
6.3 ADC Firmware driver defines .......................................................... 97
6.3.1 ADC .................................................................................................. 97
7 HAL ADC Extension Driver ......................................................... 110
7.1 ADCEx Firmware driver API description ....................................... 110
7.1.1 IO operation functions .................................................................... 110
7.1.2 Detailed description of functions .................................................... 110
7.2 ADCEx Firmware driver defines .................................................... 112

Contents
UM1749
4/1466
DocID026232 Rev 6
7.2.1 ADCEx ............................................................................................ 112
8 HAL COMP Generic Driver .......................................................... 113
8.1 COMP Firmware driver registers structures .................................. 113
8.1.1 COMP_InitTypeDef ........................................................................ 113
8.1.2 COMP_HandleTypeDef .................................................................. 113
8.2 COMP Firmware driver API description ........................................ 114
8.2.1 COMP Peripheral features ............................................................. 114
8.2.2 How to use this driver ..................................................................... 114
8.2.3 Initialization and de-initialization functions ..................................... 115
8.2.4 IO operation functions .................................................................... 115
8.2.5 Peripheral Control functions ........................................................... 115
8.2.6 Peripheral State functions .............................................................. 115
8.2.7 Detailed description of functions .................................................... 116
8.3 COMP Firmware driver defines ..................................................... 118
8.3.1 COMP ............................................................................................. 118
9 HAL COMP Extension Driver ...................................................... 127
9.1 COMPEx Firmware driver API description .................................... 127
9.1.1 COMP peripheral Extended features ............................................. 127
9.1.2 Detailed description of functions .................................................... 127
10 HAL CORTEX Generic Driver ...................................................... 128
10.1 CORTEX Firmware driver registers structures .............................. 128
10.1.1 MPU_Region_InitTypeDef .............................................................. 128
10.2 CORTEX Firmware driver API description .................................... 129
10.2.1 How to use this driver ..................................................................... 129
10.2.2 Initialization and de-initialization functions ..................................... 129
10.2.3 Peripheral Control functions ........................................................... 130
10.2.4 Detailed description of functions .................................................... 130
10.3 CORTEX Firmware driver defines ................................................. 133
10.3.1 CORTEX ......................................................................................... 133
11 HAL CRC Generic Driver ............................................................. 136
11.1 CRC Firmware driver registers structures ..................................... 136
11.1.1 CRC_InitTypeDef ........................................................................... 136
11.1.2 CRC_HandleTypeDef ..................................................................... 137
11.2 CRC Firmware driver API description ........................................... 137
11.2.1 Initialization and de-initialization functions ..................................... 137
11.2.2 Peripheral Control functions ........................................................... 137

UM1749
Contents
DocID026232 Rev 6
5/1466
11.2.3 Peripheral State functions .............................................................. 138
11.2.4 Detailed description of functions .................................................... 138
11.3 CRC Firmware driver defines ........................................................ 140
11.3.1 CRC ................................................................................................ 140
12 HAL CRC Extension Driver ......................................................... 142
12.1 CRCEx Firmware driver API description ....................................... 142
12.1.1 CRC Extended features functions .................................................. 142
12.1.2 Detailed description of functions .................................................... 142
12.2 CRCEx Firmware driver defines .................................................... 143
12.2.1 CRCEx ............................................................................................ 143
13 HAL CRYP Generic Driver ........................................................... 145
13.1 CRYP Firmware driver registers structures ................................... 145
13.1.1 CRYP_InitTypeDef ......................................................................... 145
13.1.2 CRYP_HandleTypeDef................................................................... 145
13.2 CRYP Firmware driver API description ......................................... 146
13.2.1 Initialization and de-initialization functions ..................................... 146
13.2.2 AES processing functions .............................................................. 146
13.2.3 CRYP IRQ handler management ................................................... 147
13.2.4 Peripheral State functions .............................................................. 147
13.2.5 DMA callback functions .................................................................. 147
13.2.6 Detailed description of functions .................................................... 147
13.3 CRYP Firmware driver defines ...................................................... 155
13.3.1 CRYP .............................................................................................. 155
14 HAL CRYP Extension Driver ....................................................... 159
14.1 CRYPEx Firmware driver API description ..................................... 159
14.1.1 Extended features functions ........................................................... 159
14.1.2 Detailed description of functions .................................................... 159
15 HAL DAC Generic Driver ............................................................. 160
15.1 DAC Firmware driver registers structures ..................................... 160
15.1.1 DAC_HandleTypeDef ..................................................................... 160
15.1.2 DAC_ChannelConfTypeDef ........................................................... 160
15.2 DAC Firmware driver API description ............................................ 161
15.2.1 DAC Peripheral features................................................................. 161
15.2.2 How to use this driver ..................................................................... 162
15.2.3 Initialization and de-initialization functions ..................................... 163
15.2.4 IO operation functions .................................................................... 163
剩余1465页未读,继续阅读
资源评论

- qq7826113702020-05-21可以的 正在使用
- wenqimc2019-08-12英文,可以用

一横一竖一撇一捺想笑就笑开心就好
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


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