没有合适的资源?快使用搜索试试~ 我知道了~
STM32 F2系列LL库和HAL库文档
需积分: 5 0 下载量 7 浏览量
2024-09-15
16:28:15
上传
评论
收藏 29.74MB PDF 举报
温馨提示
STM32是意法半导体(STMicroelectronics)推出的一系列32位微控制器(MCU),基于ARM Cortex-M处理器核心。这些微控制器以其高性能、低成本和广泛的应用领域而闻名,广泛应用于嵌入式系统设计。 STM32系列提供了多种不同的产品线,包括但不限于STM32F(Foundation Line)、STM32G(General Purpose)、STM32L(Low Power)、STM32H(High Performance)等,以满足不同性能和功耗的需求。它们通常包含丰富的外设,如模数转换器(ADC)、数模转换器(DAC)、通用同步异步收发器(USART)、I2C、SPI、CAN、USB、以太网等,以及多种内存配置选项,包括闪存和RAM。 STM32微控制器支持多种开发工具和软件库,如STM32CubeMX、HAL库和LL库,这些工具大大简化了开发流程,使得开发者能够快速地开发和部署应用程序。此外,STM32还提供了丰富的文档和社区支持,帮助开发者解决开发过程中遇到的问题。 由于其强大的功能和灵活性,STM32微控制器被广泛应用于工业自动化、消费电子、医疗
资源推荐
资源详情
资源评论
March 2017
DocID028236 Rev 2
1/1371
www.st.com
UM1940
User Manual
Description of STM32F2 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 asSTM32CubeF2
forSTM32F2 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).
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 functions offered by the IP such as basic timer, capture, or pulse width
modulation (PWM). 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 FMC, 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 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
UM1940
2/1371
DocID028236 Rev 2
Contents
1 Acronyms and definitions ............................................................. 26
2 Overview of HAL drivers ............................................................... 28
2.1 HAL and user-application files......................................................... 28
2.1.1 HAL driver files ................................................................................. 28
2.1.2 User-application files ........................................................................ 30
2.2 HAL data structures ........................................................................ 31
2.2.1 Peripheral handle structures ............................................................ 31
2.2.2 Initialization and configuration structure ........................................... 33
2.2.3 Specific process structures .............................................................. 33
2.3 API classification ............................................................................. 33
2.4 Devices supported by HAL drivers .................................................. 34
2.5 HAL driver rules .............................................................................. 36
2.5.1 HAL API naming rules ...................................................................... 36
2.5.2 HAL general naming rules ................................................................ 37
2.5.3 HAL interrupt handler and callback functions ................................... 38
2.6 HAL generic APIs ............................................................................ 39
2.7 HAL extension APIs ........................................................................ 40
2.7.1 HAL extension model overview ........................................................ 40
2.7.2 HAL extension model cases ............................................................. 41
2.8 File inclusion model ......................................................................... 43
2.9 HAL common resources .................................................................. 43
2.10 HAL configuration ............................................................................ 44
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 ................................................................................................. 48
2.11.5 EXTI .................................................................................................. 48
2.11.6 DMA .................................................................................................. 49
2.12 How to use HAL drivers .................................................................. 51
2.12.1 HAL usage models ........................................................................... 51
2.12.2 HAL initialization ............................................................................... 52
2.12.3 HAL IO operation process ................................................................ 54
2.12.4 Timeout and error management ....................................................... 57
3 Overview of Low Layer drivers ..................................................... 61
UM1940
Contents
DocID028236 Rev 2
3/1371
3.1 Low Layer files ................................................................................ 61
3.2 Overview of Low Layer APIs and naming rules ............................... 63
3.2.1 Peripheral initialization functions ...................................................... 63
3.2.2 Peripheral register-level configuration functions .............................. 67
4 Cohabiting of HAL and LL ............................................................ 69
4.1 Low Layer driver used in standalone mode ..................................... 69
4.2 Mixed use of Low Layer APIs and HAL drivers ............................... 69
5 HAL System Driver ........................................................................ 70
5.1 HAL Firmware driver API description .............................................. 70
5.1.1 How to use this driver ....................................................................... 70
5.1.2 Initialization and de-initialization functions ....................................... 70
5.1.3 HAL Control functions....................................................................... 70
5.1.4 Detailed description of functions ...................................................... 71
5.2 HAL Firmware driver defines ........................................................... 75
5.2.1 HAL ................................................................................................... 75
6 HAL ADC Generic Driver ............................................................... 77
6.1 ADC Firmware driver registers structures ....................................... 77
6.1.1 ADC_InitTypeDef .............................................................................. 77
6.1.2 ADC_ChannelConfTypeDef ............................................................. 78
6.1.3 ADC_AnalogWDGConfTypeDef ....................................................... 79
6.1.4 ADC_HandleTypeDef ....................................................................... 80
6.2 ADC Firmware driver API description .............................................. 80
6.2.1 ADC Peripheral features................................................................... 80
6.2.2 How to use this driver ....................................................................... 81
6.2.3 Initialization and de-initialization functions ....................................... 83
6.2.4 IO operation functions ...................................................................... 83
6.2.5 Peripheral Control functions ............................................................. 83
6.2.6 Peripheral State and errors functions ............................................... 84
6.2.7 Detailed description of functions ...................................................... 84
6.3 ADC Firmware driver defines .......................................................... 89
6.3.1 ADC .................................................................................................. 89
7 HAL ADC Extension Driver ........................................................... 96
7.1 ADCEx Firmware driver registers structures ................................... 96
7.1.1 ADC_InjectionConfTypeDef ............................................................. 96
7.1.2 ADC_MultiModeTypeDef .................................................................. 97
7.2 ADCEx Firmware driver API description ......................................... 98
Contents
UM1940
4/1371
DocID028236 Rev 2
7.2.1 How to use this driver ....................................................................... 98
7.2.2 Extended features functions ............................................................. 99
7.2.3 Detailed description of functions .................................................... 100
7.3 ADCEx Firmware driver defines .................................................... 103
7.3.1 ADCEx ............................................................................................ 103
8 HAL CAN Generic Driver ............................................................. 105
8.1 CAN Firmware driver registers structures ..................................... 105
8.1.1 CAN_InitTypeDef ............................................................................ 105
8.1.2 CAN_FilterConfTypeDef ................................................................. 106
8.1.3 CanTxMsgTypeDef ......................................................................... 107
8.1.4 CanRxMsgTypeDef ........................................................................ 107
8.1.5 CAN_HandleTypeDef ..................................................................... 108
8.2 CAN Firmware driver API description ............................................ 108
8.2.1 How to use this driver ..................................................................... 108
8.2.2 Initialization and de-initialization functions ..................................... 109
8.2.3 IO operation functions .................................................................... 110
8.2.4 Peripheral State and Error functions .............................................. 110
8.2.5 Detailed description of functions .................................................... 110
8.3 CAN Firmware driver defines ........................................................ 114
8.3.1 CAN ................................................................................................ 114
9 HAL CORTEX Generic Driver ...................................................... 122
9.1 CORTEX Firmware driver registers structures .............................. 122
9.1.1 MPU_Region_InitTypeDef .............................................................. 122
9.2 CORTEX Firmware driver API description .................................... 123
9.2.1 How to use this driver ..................................................................... 123
9.2.2 Initialization and de-initialization functions ..................................... 123
9.2.3 Peripheral Control functions ........................................................... 124
9.2.4 Detailed description of functions .................................................... 124
9.3 CORTEX Firmware driver defines ................................................. 129
9.3.1 CORTEX ......................................................................................... 129
10 HAL CRC Generic Driver ............................................................. 132
10.1 CRC Firmware driver registers structures ..................................... 132
10.1.1 CRC_HandleTypeDef ..................................................................... 132
10.2 CRC Firmware driver API description ........................................... 132
10.2.1 How to use this driver ..................................................................... 132
10.2.2 Initialization and de-initialization functions ..................................... 132
10.2.3 Peripheral Control functions ........................................................... 133
UM1940
Contents
DocID028236 Rev 2
5/1371
10.2.4 Peripheral State functions .............................................................. 133
10.2.5 Detailed description of functions .................................................... 133
10.3 CRC Firmware driver defines ........................................................ 135
10.3.1 CRC ................................................................................................ 135
11 HAL CRYP Generic Driver ........................................................... 136
11.1 CRYP Firmware driver registers structures ................................... 136
11.1.1 CRYP_InitTypeDef ......................................................................... 136
11.1.2 CRYP_HandleTypeDef................................................................... 136
11.2 CRYP Firmware driver API description ......................................... 137
11.2.1 How to use this driver ..................................................................... 137
11.2.2 Initialization and de-initialization functions ..................................... 138
11.2.3 AES processing functions .............................................................. 138
11.2.4 DES processing functions .............................................................. 139
11.2.5 TDES processing functions ............................................................ 139
11.2.6 DMA callback functions .................................................................. 140
11.2.7 CRYP IRQ handler management ................................................... 140
11.2.8 Peripheral State functions .............................................................. 140
11.2.9 Detailed description of functions .................................................... 140
11.3 CRYP Firmware driver defines ...................................................... 155
11.3.1 CRYP .............................................................................................. 155
12 HAL DAC Generic Driver ............................................................. 159
12.1 DAC Firmware driver registers structures ..................................... 159
12.1.1 DAC_HandleTypeDef ..................................................................... 159
12.1.2 DAC_ChannelConfTypeDef ........................................................... 159
12.2 DAC Firmware driver API description ............................................ 160
12.2.1 DAC Peripheral features................................................................. 160
12.2.2 How to use this driver ..................................................................... 161
12.2.3 Initialization and de-initialization functions ..................................... 162
12.2.4 IO operation functions .................................................................... 162
12.2.5 Peripheral Control functions ........................................................... 162
12.2.6 Peripheral State and Errors functions ............................................ 162
12.2.7 Detailed description of functions .................................................... 163
12.3 DAC Firmware driver defines ........................................................ 167
12.3.1 DAC ................................................................................................ 167
13 HAL DAC Extension Driver ......................................................... 171
13.1 DACEx Firmware driver API description ....................................... 171
剩余1370页未读,继续阅读
资源评论
GRshark
- 粉丝: 303
- 资源: 12
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- SimpleComTools开发的TCP Test Tool和UDP Test Tool
- PLC小车自动控制往返系统设计与仿真 《可编程控制器原理与应用》综合设计性实验 s7-1200系列,博途V15 基于博途平台小车自动往返控制系统的设计与仿真,包括硬件组态、变量定义、PLC程序设计
- 企业管理-OKR计划表
- Jmeter-01、08
- 改进二进制粒子群算法配电网重构 可以动态生成配电网重构过程,目标函数为功率损耗,算例为IEEE33节点系统 程序简洁明了,注释详细
- 多智能体、一致性、时滞 含通信时滞和输入时滞的多智能体一致性仿真 简单的多智能体一致性性仿真图,包含状态轨迹图和控制输入图 适用于初学者
- 齿轮、行星齿轮、端面齿轮、斜齿轮、非圆齿轮、圆弧齿轮……啮合理论、啮合原理、齿面求解、传动特性、接触分析tca、传动误差等技术matlab程序实现 参照李特文《齿轮几何学与啮合理论》
- 直流无刷电机模型+三闭环-simulink
- Java毕设项目:基于spring+mybatis+maven+mysql实现的养老院老人健康监护平台【含源码+数据库+开题报告+任务书+毕业论文】
- 51单片机开发的光照强度检测程序源码,用滑动变阻器分压代替采集电压信号光敏电阻, 包括程序源码和原理图和protues仿真, 程序源码注释详细,非常适合单片机开发人员,
- 1.Python简介.ipynb
- 基于simulink的永磁同步电机DTC控制系统仿真 基于模糊控制的pmsm的DTC控制系统仿真
- Java毕设项目:基于spring+mybatis+maven+mysql实现的农家乐系统分前后台【含源码+数据库+毕业论文】
- 双向LLC比较新的拓扑结构,双变压器,CDT-LC双向直流变器 只有开环仿真,可实现软开关 送对应参考文县
- Java毕设项目:基于spring+mybatis+maven+mysql实现的药品管理系统【含源码+数据库+毕业论文】
- 光伏发电并网逆变simulink matlab仿真 两级三相 单相系统 前级采用boost升压斩波电路 mppt最大功率点跟踪采用扰动观察法 可接单相或者三相并网逆变
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功