当前位置:网站首页>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#####
边栏推荐
- LVS+KeepAlived高可用部署实战应用
- [leetcode] maximum depth of binary tree
- LeetCode刷题系列之-多数之和类型
- The blueprint of flask complements openpyxl
- JS array merging, de duplication, dimensionality reduction (es6: extended operator, set)
- 32. Longest valid bracket (difficult stack string)
- PaddleNLP基于ERNIR3.0文本分类以中医疗搜索检索词意图分类(KUAKE-QIC)为例【多分类(单标签)】
- STM32 - external interrupt application (exti) (use cubemx to configure interrupts)
- Concise history of graphic technology
- PaddleNLP基于ERNIR3.0文本分类以CAIL2018-SMALL数据集罪名预测任务为例【多标签】
猜你喜欢

Summary of common error types in JS

基于Ernie-3.0 CAIL2019法研杯要素识别多标签分类任务

STM32 - interrupt overview (interrupt priority)

6K6w5LiA5qyh5pS75Ye75YiG5p6Q

Vscode ROS configuration GDB debugging error record

(翻译)图技术简明历史

静态成员static详解

CMD common commands

Soft exam network engineer
![[connect your mobile phone wirelessly] - debug your mobile device wirelessly via LAN](/img/7f/c49fd8c2cbe21585a080852833dcb4.png)
[connect your mobile phone wirelessly] - debug your mobile device wirelessly via LAN
随机推荐
微信小程序里button点击的时候会边框有黑线
JS convert numbers to letters
PHP库neo4j怎么安装及使用
winServer运维技术栈
Day3 classification management of Ruiji takeout project
96. Different binary search trees (medium binary search tree dynamic planning)
Win11 how to open software notification
776. 字符串移位包含问题
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
105. Construct binary tree from preorder and inorder traversal sequence (medium binary tree DFS hash table binary tree)
使用PCL批量将点云.bin文件转.pcd
Win11怎么打开软件通知
JS implementation generates a random key of specified length
Sword finger offer II 066. sum of words (medium prefix tree design string)
Sword finger offer II 052. flatten binary search tree (simple binary search tree DFS)
近期bug总结
Paddlenlp is based on ernir3.0 text classification. Take the crime prediction task of cail2018-small dataset as an example [multiple tags]
Sword finger offer II 055. Binary search tree iterator (medium binary search tree iterator)
Awk blank line filtering
纪念一下第一次写的线段树了喽(对应洛谷3372)