当前位置:网站首页>32 project code area meaning based on Hal library, and common function examples
32 project code area meaning based on Hal library, and common function examples
2022-07-18 05:49:00 【Hua Weiyun】
1、 The meaning of the engineering code area
I believe many beginners HAL library , use CubeMx After the generated project , There are many annotation codes , You don't understand what I mean? , I don't know why the code is written there . Today we will talk about ~


2、 Here we are HAL Common in Library API( Predefined functions , That is, we operate GPIO Function of )
HAL_GPIO_Init: Initialization pin , Working speed of pins 、 Whether to reuse the mode 、 Up and down parameters .
void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
example :HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
HAL_GPIO_Deinit: After function initialization, the pin returns to the default state , That is, the value when each register is reset
void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin)
example :HAL_GPIO_DeInit(GPIOA, GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2);
HAL_GPIO_ReadPin: Read the level status of the pin 、 The return value of the function is 0 or 1
void HAL_GPIO_WritePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
example :HAL_GPIO_WritePin(GPIOA, GPIO_PIN_0,GPIO_PIN_RESET)
HAL_GPIO_WritePin: Write pin level , Pin write 0 or 1
void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
example :HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_0);
HAL_GPIO_TogglePin: Flip pin level
void HAL_GPIO_TogglePin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin)
example :HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_0);
HAL_GPIO_LockPin: Lock pin level , For example, the current state of a pin is 1, When this pin level changes, the value when locking is maintained .
HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef* GPIOx, uint16_t GPIO_Pin);
example :HAL_GPIO_LockPin(GPIOA, GPIO_PIN_0);
HAL_GPIO_EXTI_IRQHandler: Interrupt service function of pin , External interrupt service function , Clears the interrupt flag bit
void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin)
example :HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_3);
HAL_GPIO_EXTI_Callback: Interrupt callback function of pin , It can be understood as the specific action to be responded by the interrupt function .
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
example :HAL_GPIO_EXTI_Callback(GPIO_Pin);
3、 Digression
In our previous articles, lighting has been used (HAL_GPIO_WritePin) This API, Here we can also use (HAL_GPIO_TogglePin) This API, It can flip the level of the pin , It can also make our code concise and clear .
while (1){/* USER CODE END WHILE */ // Running water lamp HAL_GPIO_TogglePin(GPIOA,LED0_Pin); HAL_Delay(250); HAL_GPIO_TogglePin(GPIOA,LED1_Pin); HAL_Delay(250); HAL_GPIO_TogglePin(GPIOA,LED2_Pin); HAL_Delay(250);}/* USER CODE END 3 */边栏推荐
猜你喜欢

xiamarin整合Braze实现送信和端末通知

【2022微信小程序排雷】云开发和非云开发环境下如何正确获取openid?

【动态规划】—— 数位统计DP

测试开发的六大能力

单视图重构—影消点、影消线与相机内参、平面法向量的推导

Foundation of deep learning: 9 Reproduce classic networks: lenet5 and alexnet

About security details timing attack

Huawei cloud stack opens its framework to the south to help ecological partners enter the cloud efficiently

Win11如何设置多任务窗口?Win11设置多任务窗口的方法

要想不踩SaaS那些坑,得先了解“SaaS架构”
随机推荐
干货|语义网、Web3.0、Web3、元宇宙这些概念还傻傻分不清楚?(上)
【用户文章】P4合并实践指南之实例拆解Resolve
[dynamic planning] - state compression DP
Comparable to headhunter resume sorting skills how to quickly sort out resumes
工程监测仪器多通道振弦无线采集仪的采集数据发送方式和在线监测管理系统
直播带货系统源码
Transplantation and analysis of freemodbus on stm32f1 platform
CEO干货| CSDN演讲回顾:如何利用低代码提升研发和IT效能?
3D reconstruction line structured light (1)
OPENGL学习(一)认识OPENGL和各种库
理财平台选择哪个安全可靠
DBeaver连接mysql错误:The server time zone value ‘Öйú±ê׼ʱ¼ä‘ is unrecognized or represents more than
SourceInsight plug-in use
送你的代码上太空,与华为云一起开发“最伟大的作品”
不知道如何提高视觉语言大模型?浙大与联汇研究院提出新型多维度评测框架
北航&信工所&美团提出LBDT,基于语言桥接的时空交互来进行准确指向性视频对象分割,性能SOTA!代码开源(CVPR 2022)...
Comboboxedit setting option value (single or multiple choice)
启牛证券开户安全吗?靠谱吗?
使用Excel2016的函数生成随机16、32、36位ID字符串内容
Sql笔记