当前位置:网站首页>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#####
边栏推荐
- Detection and tracking evaluation index
- 32. Longest valid bracket (difficult stack string)
- Wechat applet uses canvas drawing, round avatar, network background, text, dotted line, straight line
- Sword finger offer II 065. The shortest word code (medium dictionary tree string array)
- 6K6w5LiA5qyh5pS75Ye75YiG5p6Q
- 职场pua但有道理
- DOM programming + events
- For loops and functions
- JS获取当前时间(年月日时分秒)
- Day3 classification management of Ruiji takeout project
猜你喜欢

PC side web page special effects (offset series, obtain the coordinates of the mouse in the box, pop-up drag effect, magnifying glass effect)

STM32CUBEIDE(10)----ADC在DMA模式下扫描多个通道

Ruiji takeout project - development of business development function Day2

【转载】token令牌在登录场景使用

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

Sword finger offer II 054. Sum of all values greater than or equal to nodes (medium binary search tree DFS)
![[Ruiji takeout project] Day5 - Chapter 6 mobile verification code login](/img/53/c578e0d1428ea569fb412a20019924.png)
[Ruiji takeout project] Day5 - Chapter 6 mobile verification code login
![[Ruiji takeout project]day4 - dish management](/img/2a/2d9deb7a583aa37b38a67ef2c74ee7.png)
[Ruiji takeout project]day4 - dish management

Att & CK preliminary understanding

STM32 - systick timer (cubemx configures systick)
随机推荐
Baidu map usage
MySQL installation and configuration (super detailed, simple and practical)
Target segmentation learning
Sword finger offer II 064. magic Dictionary (medium dictionary tree string design)
redis相关
Research cup element recognition multi label classification task based on ernie-3.0 cail2019 method
Awk blank line filtering
Using nodejs to operate MySQL
ES6 concept
Idea generate class diagram plug-in UML (super detailed)
Sword finger offer II 054. Sum of all values greater than or equal to nodes (medium binary search tree DFS)
Imx6q GPIO multiplexing
How to install WiFi correctly
[CS231N]Lecture_ 2:Image Classification pipelin
删除容器镜像报错解决image is referenced in multiple repositories
JS array merging, de duplication, dimensionality reduction (es6: extended operator, set)
Leetcode question brushing series - sum of majority type
SQL injection less38 (Stack Injection)
75. Color classification (medium array double pointer sorting)
微信小程序使用canvas绘图,圆形头像,网络背景图,文字,虚线,直线