当前位置:网站首页>STM32_ Hal library driven framework
STM32_ Hal library driven framework
2022-07-28 22:39:00 【Green hedgerow bamboo maple】
HAL Library uses mainline : Peripheral initialization and peripheral use
1. Packaging of peripherals
xx_HandleTypeDef (xx Time peripheral handle structure ,xx Represents any peripheral name , such as GPIO,UART etc. ),
xx_HandleTypeDef Members include the following objects
| Instance member | xx_TypeDef type ( Specific peripheral objects , such as GPIOA,GPIOB, A serial port 1, A serial port 2,IIC1,IIC2,DMA1 And so on ) Generally, it points to a peripheral base address |
| Init member | xx_InitTypeDef type ( Working parameters of peripheral objects , Used to configure how peripherals work ), Configure how peripherals work |
| Hdma* member | DMA_HandleTypeDef type , There may be more than one handle structure ( If the peripheral supports DMA function , This member links to a specific DMA passageway ) |
| LOCK lock | HAL_LockTypeDef type ( Prevent resource competition , When operating external devices , Some operations cannot be re entered , Ensure the integrity of the operation ) |
| STATUS state | HAL_xx_StateTypeDef type ( Prompt the status of peripherals ) |
2. Peripheral initialization method
| HAL_xx_Init | The parameter is generally xx Handle structure of peripheral ( Initialize peripheral functions , adopt xx_HandleTypeDef Under the init Member configuration parameters of , Configure the relevant registers of the corresponding peripheral , Before configuring registers , Will call first hal_xx_mspinit function , Initialize the underlying related resources , Like a clock , Pins used , Interrupt enable ,DMA Turn on, etc ) |
| HAL_xx_MspInit | The parameter is generally xx Handle structure of peripheral ( Initialize the relevant resources applicable to the peripheral , Like the clock , Pin, etc ), You need to set it yourself |
| other Init Method | Specific reference HAL Library drive .c Medium ####How to use this driver#### Comments under block |
3. Peripherals use logic
Use peripherals , Is to start peripheral functions , Generally, it is similar to the following methods
3.1 Blocking polling (Polling)
| xx_start | |
| xx_read\write | |
| ... Wait for the function , features , The incoming parameter requires a Tomeout Parameters |
3.2 interrupt
| xx_start_it | HAL_XX_IRQHandler,(xx Peripheral interrupt handling function , In interrupt entry function call , The parameters passed in by this function are generally xxx_HandleTypeDef), In this function , Generally, the flag of peripheral status register will be detected , According to different signs , Eventually, different callback functions will be called back ) Various HAL_XX_xxCallback |
| xx_read\write_it | |
| xx-xx_it |
3.3 DMA( Data transfer , stay CPU Data handling under incomplete monitoring )
| xx_start_dma | DMA function |
| xx_read\write_dma | |
| xx_xx_dma... wait DMA Start studying in Anhui , features , The function name is dma ending |
3.4 Other features
Flag query / eliminate , Terminal function enable \ Disability , Clock enable / Disability
| _HAL_xx_ENABLE_IT | |
| _HAL_xx_GET_FLAG | |
| ... wait |
Yes HAL Comprehensive understanding and use of the Library
####how to use this driver####

summary :
1. Define and populate xxx Peripheral handle structure
2. If you follow HAL Library specification , adopt HAL_xxx_MspInit() function , Realize the initialization of peripheral underlying resources , Including but not limited to GPIO, The clock ,DMA, Interrupt and other resources initialization
3. call HAL The corresponding peripheral initialization function of the library , Form like HAL_XXX_Init()
4. Initialization complete , Start using peripherals
5. Use the method to check the corresponding peripheral HAL Description in Library driver package
#####How to use this driver#####
边栏推荐
- Solve various problems of sudo rosdep init and rosdep update
- Att & CK preliminary understanding
- Excel-VBA 快速上手(十三、日期的常见用法)
- Can the MySQL create statement be used to create a table structure and append new records
- Which is the file transfer command in the basic services of the Internet
- 96. Different binary search trees (medium binary search tree dynamic planning)
- 76. Minimum coverage substring (hard sliding window hash table string)
- When can I sign up for the 2022 class I constructor examination?
- 2022年一级建造师考试什么时候才能报名?
- LVS+KeepAlived高可用部署实战应用
猜你喜欢

Install PCL and VTK under the background of ROS installation, and solve VTK and PCL_ ROS conflict problem

Idea generate class diagram plug-in UML (super detailed)

Ngrok intranet penetration

ATT&CK初步了解

Static route and default route experiment

STM32 - external interrupt application (exti) (use cubemx to configure interrupts)

Solve Jupiter: the term 'Jupiter' is not recognized as the name of a cmdlet, function, script file
![[get mobile information] - get mobile information through ADB command](/img/ad/b10c5d09a21fb0cb22aa8a002fbd99.png)
[get mobile information] - get mobile information through ADB command

When can I sign up for the 2022 class I constructor examination?

Overall introduction of Ruiji takeout project
随机推荐
How about the actual use effect of common source oscilloscope
Paddlenlp is based on ernir3.0 text classification. Take the traditional Chinese medicine search and retrieval semantic map classification (kuake-qic) as an example [multi classification (single label
基于Ernie-3.0 CAIL2019法研杯要素识别多标签分类任务
winServer运维技术栈
ATT&CK初步了解
98. Verify binary search tree (medium binary search tree DFS)
Solve Jupiter: the term 'Jupiter' is not recognized as the name of a cmdlet, function, script file
使用PCL批量将点云.bin文件转.pcd
【转载】token令牌在登录场景使用
Install PCL and VTK under the background of ROS installation, and solve VTK and PCL_ ROS conflict problem
MySQL command (add, delete, check and modify)
When can I sign up for the 2022 class I constructor examination?
AWK空行过滤
79. Word search (medium string array matrix backtracking)
[CS231N]Lecture_ 2:Image Classification pipelin
Idea generate class diagram plug-in UML (super detailed)
[virtual machine _2]-hyper-v and vmware/virtualbox cannot coexist
Lvs+keepalived high availability deployment practical application
105. Construct binary tree from preorder and inorder traversal sequence (medium binary tree DFS hash table binary tree)
Day3 classification management of Ruiji takeout project