当前位置:网站首页>[Teach you to use the serial port idle interrupt of the STM32HAL library]
[Teach you to use the serial port idle interrupt of the STM32HAL library]
2022-08-04 20:56:00 【xixiaohuanqaq】
I. Test environment
STM32H750VBTX development board
Second, Steps
1, open serial port idle interrupt
HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)// Open IDLE in front of the main function, this size is the size of the buffer array you set yourself, the file posted below has the definition of this function
This function is in stm32h7xx_hal_uart_ex.c, which has already opened the serial port idle interrupt. What I checked before is not correct. Only in a communication group did I know that it was so simple.
2. Use the serial port idle callback function directly
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_tspan> Size){if(huart->Instance == USART1){//Call the serial port idle callback function directly, this size is the number of bytes received by the serial port each time}HAL_UARTEx_ReceiveToIdle_IT() //Open serial port idle interrupt again}
3, HAL_UART_IRQHandler(&huart1);
void USART1_IRQHandler(void){/* USER CODE BEGIN USART1_IRQn 0 *//* USER CODE END USART1_IRQn 0 */HAL_UART_IRQHandler(&huart1);//The processing of the flag bit has helped us deal with it. We directly call the callback function, namelyCan!/* USER CODE BEGIN USART1_IRQn 1 *//* USER CODE END USART1_IRQn 1 */}
III. Summary
**Using the serial port idle interrupt through the HAL library is so simple. I have checked a lot of information before, but they are not using the HAL library. They are all rewritten.Stuff, it's a lot easier to actually use the HAL library.At present, only the serial port idle interrupt is used, and the update will continue after the subsequent use of DMA.Thank you to the big guys in the group who have carefully guided and answered questions!!!**
边栏推荐
猜你喜欢
C语言小笔记+题
遇到MapStruct后,再也不手写PO,DTO,VO对象之间的转换了
SAP ABAP OData 服务如何支持 $select 有选择性地仅读取部分模型字段值试读版
构建Buildroot根文件系统(I.MX6ULL)
【学术相关】清华教授发文劝退读博:我见过太多博士生精神崩溃、心态失衡、身体垮掉、一事无成!...
宝塔实测-搭建中小型民宿酒店管理源码
After the tester with 10 years of service "naked resignation" from the big factory...
PriorityQueue类的使用及底层原理
某男子因用本地虚拟机做压测,惨遭字节面试官当场嘲笑
使用堡塔应用管理器配置laravel队列方法
随机推荐
C语言之实现扫雷小游戏
Tear down the underlying mechanism of the five JOINs of SparkSQL
数据仓库(1)什么是数据仓库,数仓有什么特点
vim clear last search highlighting
Latex分章节、分段落编译:input{}与include{}的区别
手撕SparkSQL五大JOIN的底层机制
mysql的存储过程介绍、创建、案例、删除、查看「建议收藏」
Comic | Two weeks after the boss laid me off, he hired me back and doubled my salary!
如何进行AI业务诊断,快速识别降本提效增长点?
[TypeScript] In-depth study of TypeScript enumeration
vs Code 运行一个本地WEB服务器
vs Code runs a local web server
关于 SAP 电商云 Spartacus UI SSR 的 state transfer 问题
两种白名单限流方案(redis lua限流,guava方案)
dotnet 启动 JIT 多核心编译提升启动性能
win10 uwp 使用 ScaleTransform 放大某个元素
【debug】postgres数据存储错乱
Uniapp微信雪糕刺客单页小程序源码
推荐系统_刘老师
How to train a deep learning model?