热搜关键词: 电路基础ADC数字信号处理封装库PLC

pdf

STM32 HAL驱动详解

  • 1星
  • 2015-11-02
  • 4.48MB
  • 需要2积分
  • 14次下载
标签: STM32HAL

STM32HAL

STM32

STM32

STM32  HAL驱动详解

文档内容节选

UM1725 Contents UM1725 User Manual Description of STM32F4xx HAL drivers Introduction STM32CubeTM is an STMicroelectronics original initiative to ease developers life by reducing development efforts time and cost STM32CubeTM covers STM32 portfolio STM32CubeTM Version 1x includes The STM32CubeMX a graphical software configuration tool that allows generating C initialization code using graphical wizards A comprehensive embedded software platform......

UM1725
Contents
UM1725
User Manual
Description of STM32F4xx HAL drivers
Introduction
STM32Cube is an STMicroelectronics original initiative to ease developers life by reducing
TM
development efforts, time and cost. STM32Cube covers STM32 portfolio.
STM32Cube
TM
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 HAL, an STM32 abstraction layer embedded software, ensuring maximized
portability across STM32 portfolio
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 drivers 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 an easy portability on 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 drivers 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), etc..
The drivers source code is developed in Strict ANSI-C which makes it independent from the
TM
development tools. It is checked with CodeSonar static analysis tool. It is fully documented and is
MISRA-C 2004 compliant.
The HAL drivers 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.
This user manual is structured as follows:
Overview of the HAL drivers
Detailed description of each peripheral driver: configuration structures, functions, and how to use
the given API to build your application.
May 2014
DocID025834 Rev 1
1/865
Contents
UM1725
Contents
1
2
Acronyms and definitions............................................................. 26
Overview of HAL drivers ............................................................... 28
2.1
HAL and user application files ......................................................... 28
2.1.1
2.1.2
HAL driver files ................................................................................. 28
User-application files ........................................................................ 29
2.2
HAL data structures ........................................................................ 31
2.2.1
2.2.2
2.2.3
Peripheral handle structures ............................................................ 31
Initialization and configuration structure ........................................... 32
Specific process structures .............................................................. 33
2.3
2.4
2.5
API classification ............................................................................. 33
Devices supported by HAL drivers .................................................. 34
HAL drivers rules............................................................................. 37
2.5.1
2.5.2
2.5.3
HAL API naming rules ...................................................................... 37
HAL general naming rules ................................................................ 38
HAL interrupt handler and callback functions ................................... 39
2.6
2.7
HAL generic APIs ............................................................................ 39
HAL extension APIs ........................................................................ 41
2.7.1
2.7.2
HAL extension model overview ........................................................ 41
HAL extension model cases ............................................................. 41
2.8
2.9
2.10
2.11
File inclusion model......................................................................... 43
HAL common resources .................................................................. 44
HAL configuration............................................................................ 45
HAL system peripheral handling ..................................................... 46
2.11.1
2.11.2
2.11.3
2.11.4
2.11.5
2.11.6
Clock ................................................................................................. 46
GPIOs ............................................................................................... 47
Cortex NVIC and SysTick timer........................................................ 49
PWR ................................................................................................. 49
EXTI .................................................................................................. 50
DMA .................................................................................................. 50
2.12
How to use HAL drivers .................................................................. 52
2.12.1
2.12.2
2.12.3
2.12.4
HAL usage models ........................................................................... 52
HAL initialization ............................................................................... 53
HAL IO operation process ................................................................ 55
Timeout and error management ....................................................... 58
2/865
DocID025834 Rev 1
UM1725
Contents
3
HAL common driver ...................................................................... 62
3.1
HAL Firmware driver API description .............................................. 62
3.1.1
3.1.2
3.1.3
3.1.4
3.1.5
How to use this driver ....................................................................... 62
Initialization and de-initialization functions ....................................... 62
HAL Control functions....................................................................... 62
Initialization and de-initialization Functions ...................................... 63
HAL Control functions....................................................................... 64
3.2
HAL Firmware driver defines ........................................................... 69
3.2.1
HAL ................................................................................................... 69
4
HAL ADC Generic Driver ............................................................... 70
4.1
ADC Firmware driver registers structures ....................................... 70
4.1.1
4.1.2
4.1.3
4.1.4
4.1.5
4.1.6
ADC_HandleTypeDef ....................................................................... 70
ADC_InitTypeDef .............................................................................. 70
ADC_ChannelConfTypeDef ............................................................. 72
ADC_AnalogWDGConfTypeDef ....................................................... 72
ADC_Common_TypeDef .................................................................. 73
ADC_TypeDef .................................................................................. 73
4.2
ADC Firmware driver API description .............................................. 75
4.2.1
4.2.2
4.2.3
4.2.4
4.2.5
4.2.6
4.2.7
4.2.8
4.2.9
4.2.10
ADC Peripheral features................................................................... 75
How to use this driver ....................................................................... 75
Initialization and de-initialization functions ....................................... 77
IO operation functions ...................................................................... 77
Peripheral Control functions ............................................................. 77
Peripheral State and errors functions ............................................... 78
Initialization and de-initialization functions ....................................... 78
IO operation functions ...................................................................... 79
Peripheral Control functions ............................................................. 84
ADC Peripheral State functions ........................................................ 85
4.3
ADC Firmware driver defines .......................................................... 86
4.3.1
ADC .................................................................................................. 86
5
HAL ADC Extension Driver ........................................................... 95
5.1
ADCEx Firmware driver registers structures ................................... 95
5.1.1
5.1.2
ADC_InjectionConfTypeDef ............................................................. 95
ADC_MultiModeTypeDef .................................................................. 96
5.2
ADCEx Firmware driver API description ......................................... 96
5.2.1
5.2.2
How to use this driver ....................................................................... 96
Extended features functions ............................................................. 98
DocID025834 Rev 1
3/865
Contents
5.2.3
UM1725
Extended features functions ............................................................. 98
5.3
ADCEx Firmware driver defines .................................................... 103
5.3.1
ADCEx ............................................................................................ 103
6
HAL CAN Generic Driver ............................................................. 110
6.1
CAN Firmware driver registers structures ..................................... 110
6.1.1
6.1.2
6.1.3
6.1.4
6.1.5
6.1.6
6.1.7
CAN_HandleTypeDef ..................................................................... 110
CAN_InitTypeDef ............................................................................ 110
CAN_FilterConfTypeDef ................................................................. 111
CAN_FIFOMailBox_TypeDef ......................................................... 112
CAN_FilterRegister_TypeDef ......................................................... 113
CAN_TxMailBox_TypeDef ............................................................. 113
CAN_TypeDef ................................................................................ 114
6.2
CAN Firmware driver API description............................................ 115
6.2.1
6.2.2
6.2.3
6.2.4
6.2.5
6.2.6
6.2.7
How to use this driver ..................................................................... 115
Initialization and de-initialization functions ..................................... 116
IO operation functions .................................................................... 117
Peripheral State and Error functions .............................................. 117
Initialization and de-initialization functions ..................................... 117
IO operation functions .................................................................... 119
Peripheral State and Error functions .............................................. 123
6.3
CAN Firmware driver defines ........................................................ 123
6.3.1
CAN ................................................................................................ 123
7
HAL CORTEX Generic Driver ...................................................... 133
7.1
CORTEX Firmware driver API description .................................... 133
7.1.1
7.1.2
7.1.3
7.1.4
7.1.5
How to use this driver ..................................................................... 133
Initialization and de-initialization functions ..................................... 134
Peripheral Control functions ........................................................... 134
Initialization and de-initialization functions ..................................... 134
Peripheral Control functions ........................................................... 137
7.2
CORTEX Firmware driver defines ................................................. 140
7.2.1
CORTEX ......................................................................................... 140
8
HAL CRC Generic Driver ............................................................. 142
8.1
CRC Firmware driver registers structures ..................................... 142
8.1.1
8.1.2
CRC_HandleTypeDef ..................................................................... 142
CRC_TypeDef ................................................................................ 142
8.2
CRC Firmware driver API description ........................................... 143
8.2.1
How to use this driver ..................................................................... 143
4/865
DocID025834 Rev 1
UM1725
8.2.2
8.2.3
8.2.4
8.2.5
8.2.6
8.2.7
Contents
Initialization and de-initialization functions ..................................... 143
Peripheral Control functions ........................................................... 143
Peripheral State functions .............................................................. 143
Initialization and de-initialization functions ..................................... 144
Peripheral Control functions ........................................................... 145
Peripheral State functions .............................................................. 146
8.3
CRC Firmware driver defines ........................................................ 146
8.3.1
CRC ................................................................................................ 146
9
HAL CRYP Generic Driver........................................................... 147
9.1
CRYP Firmware driver registers structures ................................... 147
9.1.1
9.1.2
9.1.3
CRYP_HandleTypeDef................................................................... 147
CRYP_InitTypeDef ......................................................................... 148
CRYP_TypeDef .............................................................................. 148
9.2
CRYP Firmware driver API description ......................................... 151
9.2.1
9.2.2
9.2.3
9.2.4
9.2.5
9.2.6
9.2.7
9.2.8
9.2.9
9.2.10
9.2.11
9.2.12
9.2.13
9.2.14
9.2.15
How to use this driver ..................................................................... 151
Initialization and de-initialization functions ..................................... 152
AES processing functions .............................................................. 152
DES processing functions .............................................................. 153
TDES processing functions ............................................................ 153
DMA callback functions .................................................................. 153
CRYP IRQ handler management ................................................... 154
Peripheral State functions .............................................................. 154
Initialization and de-initialization functions ..................................... 154
AES processing functions .............................................................. 155
DES processing functions .............................................................. 164
TDES processing functions ............................................................ 169
DMA callback functions .................................................................. 174
CRYP IRQ handler management ................................................... 175
Peripheral State functions .............................................................. 176
9.3
CRYP Firmware driver defines ...................................................... 176
9.3.1
CRYP .............................................................................................. 176
10
HAL DAC Generic Driver ............................................................. 180
10.1
DAC Firmware driver registers structures ..................................... 180
10.1.1
10.1.2
10.1.3
DAC_HandleTypeDef ..................................................................... 180
DAC_ChannelConfTypeDef ........................................................... 180
DAC_TypeDef ................................................................................ 181
10.2
DAC Firmware driver API description ............................................ 182
DocID025834 Rev 1
5/865
展开预览

猜您喜欢

评论

登录/注册

意见反馈

求资源

回顶部

推荐内容

热门活动

热门器件

随便看看

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved
×