真正实现了STM32 HAL串口不定长数据的接收发送功能(DMA方式,不用限定单次接收长度和添加结束标志)

上传者: xia0816 | 上传时间: 2020-02-22 03:16:36 | 文件大小: 1.37MB | 文件类型: zip
网上使用HAL串口时很多都没有实现不定长数据的接收,要么是限定数据长度,要么是加“0x0a 0x0d”来控制接收完成,找了很久都没有真正找到一个能用的,在很多通信中不可能是定义的,或是加上“0x0a 0x0d”来实现的,由于项目需要,自己阅读STM32 HAL的文档,写出了一个Demo程序,可以实现回显功能(就是通过给STM32发送不定长的数据,可以实现一模一样接收发送的数据),在STM32F429IGT6上验证过,跑了一天没有出现丢失数据的问题,使用DMA发送与接收方式,可以释放CPU部分运算资源,程序中的UART_RX_BUF_SIZE定义为128,就是一次最大接收为128,我在项目中通过改为2048也可以通过一次接收2k的数据,代码量很少,才200多行,很容易看懂,可以移植到不同系列的STM32上,希望这程序能帮助到曾经跟我一样到处找资源解决HAL库与标准库串口使用上不同而痛苦的朋友们

文件下载

资源详情

[{"title":"( 89 个子文件 1.37MB ) 真正实现了STM32 HAL串口不定长数据的接收发送功能(DMA方式,不用限定单次接收长度和添加结束标志)","children":[{"title":"usart","children":[{"title":"usart.ioc <span style='color:#111;'> 5.27KB </span>","children":null,"spread":false},{"title":"Inc","children":[{"title":"stm32f4xx_hal_conf.h <span style='color:#111;'> 17.21KB </span>","children":null,"spread":false},{"title":"mxconstants.h <span style='color:#111;'> 2.38KB </span>","children":null,"spread":false},{"title":"stm32f4xx_it.h <span style='color:#111;'> 2.96KB </span>","children":null,"spread":false},{"title":"TypeDef.h <span style='color:#111;'> 1.08KB </span>","children":null,"spread":false}],"spread":true},{"title":".mxproject <span style='color:#111;'> 5.00KB </span>","children":null,"spread":false},{"title":"MDK-ARM","children":[{"title":"RTE","children":[{"title":"RTE_Components.h <span style='color:#111;'> 342B </span>","children":null,"spread":false}],"spread":true},{"title":"DebugConfig","children":[{"title":"usart_STM32F429IGTx.dbgconf <span style='color:#111;'> 2.04KB </span>","children":null,"spread":false}],"spread":true},{"title":"usart.uvguix.Administrator <span style='color:#111;'> 166.03KB </span>","children":null,"spread":false},{"title":"JLinkLog.txt <span style='color:#111;'> 44.90KB </span>","children":null,"spread":false},{"title":"startup_stm32f429xx.lst <span style='color:#111;'> 76.12KB </span>","children":null,"spread":false},{"title":"usart.uvoptx <span style='color:#111;'> 17.31KB </span>","children":null,"spread":false},{"title":"usart.uvguix.csw <span style='color:#111;'> 70.28KB </span>","children":null,"spread":false},{"title":"startup_stm32f429xx.s <span style='color:#111;'> 30.94KB </span>","children":null,"spread":false},{"title":"usart","children":null,"spread":false},{"title":"JLinkSettings.ini <span style='color:#111;'> 755B </span>","children":null,"spread":false},{"title":"usart.uvprojx <span style='color:#111;'> 18.56KB </span>","children":null,"spread":false}],"spread":false},{"title":"Src","children":[{"title":"stm32f4xx_it.c <span style='color:#111;'> 5.95KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_msp.c <span style='color:#111;'> 8.58KB </span>","children":null,"spread":false},{"title":"main.c <span style='color:#111;'> 5.48KB </span>","children":null,"spread":false}],"spread":true},{"title":"Drivers","children":[{"title":"STM32F4xx_HAL_Driver","children":[{"title":"Inc","children":[{"title":"stm32f4xx_hal_flash.h <span style='color:#111;'> 15.96KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_rcc.h <span style='color:#111;'> 69.36KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_dma_ex.h <span style='color:#111;'> 4.14KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_pwr.h <span style='color:#111;'> 15.80KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_flash_ramfunc.h <span style='color:#111;'> 3.47KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_rcc_ex.h <span style='color:#111;'> 327.88KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_uart.h <span style='color:#111;'> 38.23KB </span>","children":null,"spread":false},{"title":"Legacy","children":[{"title":"stm32_hal_legacy.h <span style='color:#111;'> 165.36KB </span>","children":null,"spread":false}],"spread":false},{"title":"stm32f4xx_hal.h <span style='color:#111;'> 12.98KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_tim_ex.h <span style='color:#111;'> 14.79KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_tim.h <span style='color:#111;'> 73.68KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_dma.h <span style='color:#111;'> 36.48KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_gpio.h <span style='color:#111;'> 13.62KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_gpio_ex.h <span style='color:#111;'> 67.82KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_flash_ex.h <span style='color:#111;'> 56.33KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_pwr_ex.h <span style='color:#111;'> 16.92KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_def.h <span style='color:#111;'> 8.33KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_cortex.h <span style='color:#111;'> 19.76KB </span>","children":null,"spread":false}],"spread":false},{"title":"Src","children":[{"title":"stm32f4xx_hal_pwr_ex.c <span style='color:#111;'> 24.35KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_cortex.c <span style='color:#111;'> 19.18KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_flash_ex.c <span style='color:#111;'> 50.39KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_tim_ex.c <span style='color:#111;'> 66.79KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_flash.c <span style='color:#111;'> 24.78KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_rcc_ex.c <span style='color:#111;'> 95.77KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_pwr.c <span style='color:#111;'> 21.06KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal.c <span style='color:#111;'> 18.34KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_dma_ex.c <span style='color:#111;'> 10.90KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_uart.c <span style='color:#111;'> 60.72KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_dma.c <span style='color:#111;'> 31.81KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_flash_ramfunc.c <span style='color:#111;'> 7.26KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_tim.c <span style='color:#111;'> 175.54KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_gpio.c <span style='color:#111;'> 20.48KB </span>","children":null,"spread":false},{"title":"stm32f4xx_hal_rcc.c <span style='color:#111;'> 42.71KB </span>","children":null,"spread":false}],"spread":false}],"spread":true},{"title":"CMSIS","children":[{"title":"Include","children":[{"title":"core_cm3.h <span style='color:#111;'> 101.47KB </span>","children":null,"spread":false},{"title":"cmsis_armcc.h <span style='color:#111;'> 23.85KB </span>","children":null,"spread":false},{"title":"core_cmFunc.h <span style='color:#111;'> 3.54KB </span>","children":null,"spread":false},{"title":"cmsis_gcc.h <span style='color:#111;'> 40.46KB </span>","children":null,"spread":false},{"title":"core_cm4.h <span style='color:#111;'> 111.81KB </span>","children":null,"spread":false},{"title":"core_cmInstr.h <span style='color:#111;'> 3.55KB </span>","children":null,"spread":false},{"title":"core_cm7.h <span style='color:#111;'> 136.39KB </span>","children":null,"spread":false},{"title":"arm_math.h <span style='color:#111;'> 246.42KB </span>","children":null,"spread":false},{"title":"arm_const_structs.h <span style='color:#111;'> 3.85KB </span>","children":null,"spread":false},{"title":"core_cm0plus.h <span style='color:#111;'> 43.75KB </span>","children":null,"spread":false},{"title":"core_sc300.h <span style='color:#111;'> 100.40KB </span>","children":null,"spread":false},{"title":"core_cmSimd.h <span style='color:#111;'> 3.58KB </span>","children":null,"spread":false},{"title":"arm_common_tables.h <span style='color:#111;'> 7.09KB </span>","children":null,"spread":false},{"title":"cmsis_armcc_V6.h <span style='color:#111;'> 53.79KB </span>","children":null,"spread":false},{"title":"core_sc000.h <span style='color:#111;'> 44.20KB </span>","children":null,"spread":false},{"title":"core_cm0.h <span style='color:#111;'> 36.35KB </span>","children":null,"spread":false}],"spread":false},{"title":"Device","children":[{"title":"ST","children":[{"title":"STM32F4xx","children":[{"title":"Source","children":[{"title":"Templates","children":[{"title":"system_stm32f4xx.c <span style='color:#111;'> 27.26KB </span>","children":null,"spread":false},{"title":"arm","children":[{"title":"startup_stm32f429xx.s <span style='color:#111;'> 30.96KB </span>","children":null,"spread":false}],"spread":false}],"spread":true}],"spread":true},{"title":"Include","children":[{"title":"stm32f437xx.h <span style='color:#111;'> 682.40KB </span>","children":null,"spread":false},{"title":"stm32f479xx.h <span style='color:#111;'> 783.26KB </span>","children":null,"spread":false},{"title":"stm32f469xx.h <span style='color:#111;'> 770.25KB </span>","children":null,"spread":false},{"title":"stm32f405xx.h <span style='color:#111;'> 570.68KB </span>","children":null,"spread":false},{"title":"stm32f410rx.h <span style='color:#111;'> 283.06KB </span>","children":null,"spread":false},{"title":"stm32f415xx.h <span style='color:#111;'> 583.91KB </span>","children":null,"spread":false},{"title":"stm32f401xc.h <span style='color:#111;'> 346.26KB </span>","children":null,"spread":false},{"title":"stm32f411xe.h <span style='color:#111;'> 347.87KB </span>","children":null,"spread":false},{"title":"stm32f4xx.h <span style='color:#111;'> 9.37KB </span>","children":null,"spread":false},{"title":"stm32f429xx.h <span style='color:#111;'> 683.84KB </span>","children":null,"spread":false},{"title":"stm32f410tx.h <span style='color:#111;'> 280.62KB </span>","children":null,"spread":false},{"title":"stm32f439xx.h <span style='color:#111;'> 696.86KB </span>","children":null,"spread":false},{"title":"stm32f427xx.h <span style='color:#111;'> 669.13KB </span>","children":null,"spread":false},{"title":"system_stm32f4xx.h <span style='color:#111;'> 3.60KB </span>","children":null,"spread":false},{"title":"stm32f417xx.h <span style='color:#111;'> 627.37KB </span>","children":null,"spread":false},{"title":"stm32f407xx.h <span style='color:#111;'> 614.49KB </span>","children":null,"spread":false},{"title":"stm32f446xx.h <span style='color:#111;'> 638.06KB </span>","children":null,"spread":false},{"title":"stm32f401xe.h <span style='color:#111;'> 346.26KB </span>","children":null,"spread":false},{"title":"stm32f410cx.h <span style='color:#111;'> 282.87KB </span>","children":null,"spread":false}],"spread":false}],"spread":true}],"spread":true}],"spread":true}],"spread":true}],"spread":true}],"spread":true}],"spread":true}]

评论信息

  • changing_better :
    stm32 hal库不熟悉可以参考下
    2020-07-07
  • wyl123237 :
    大佬,串口发送不回显,没反应。重烧程序后,回显个上次发送的数据,然后发送又不回显了。这个程序确定测试过吗??
    2019-12-26
  • Ch_champion :
    不是很好,但可以借鉴
    2019-08-21

免责申明

【只为小站】的资源来自网友分享,仅供学习研究,请务必在下载后24小时内给予删除,不得用于其他任何用途,否则后果自负。基于互联网的特殊性,【只为小站】 无法对用户传输的作品、信息、内容的权属或合法性、合规性、真实性、科学性、完整权、有效性等进行实质审查;无论 【只为小站】 经营者是否已进行审查,用户均应自行承担因其传输的作品、信息、内容而可能或已经产生的侵权或权属纠纷等法律责任。
本站所有资源不代表本站的观点或立场,基于网友分享,根据中国法律《信息网络传播权保护条例》第二十二条之规定,若资源存在侵权或相关问题请联系本站客服人员,zhiweidada#qq.com,请把#换成@,本站将给予最大的支持与配合,做到及时反馈和处理。关于更多版权及免责申明参见 版权及免责申明