【E1166】可靠的STM2串口DMA发送&接收(高速通信不丢数据)

2021-09-13 19:14:46      索炜达电子      990     

项目编号:E1166

文件大小:1.36M

源码说明:带中文注释

开发环境:C编译器

简要概述:

STM32串口DMA模式发送&接收实现,高速串口通信(1.5Mbps)不丢数据

【1】环形FIFO作为发送和接收缓存
【2】DMA 接收半满中断、溢满中断、串口空闲中断
【3】不定长串口数据接收
【4】高波特率通信不翻车(实测1.5Mbps毫无压力)

测试平台

【E1166】可靠的STM2串口DMA发送&接收(高速通信不丢数据)

实现功能

-收/发环形缓冲区

-不定长度接收处理

-高速(1.5Mbps)通信不丢数据


关键实现

DMA发送模式

-线程循环查询发送环形缓冲区数据,然后启动MDA传输

-DMA传输完成中断,连续发送

-定时器中断周期发送


DMA接收模式

-DMA缓存半满中断(如CPU硬件支持,可使用DMA双缓存机制)

-DMA缓存传输完成中断

-串口空闲中断实现

目录│文件列表:

 └ stm32-uart-dma

    │ .editorconfig

    ├ stm32f0-uart-dma

    │  ├ Projects

    │  │  ├ EWARM

    │  │  │  │ clear.bat

    │  │  │  │ Project.dep

    │  │  │  │ Project.ewd

    │  │  │  │ Project.ewp

    │  │  │  │ Project.ewt

    │  │  │  │ Project.eww

    │  │  │  └ stm32f030x8_app.icf

    │  │  └ MDK

    │  │     │ clear.bat

    │  │     │ EventRecorderStub.scvd

    │  │     │ JLinkSettings.ini

    │  │     │ Project.uvoptx

    │  │     └ Project.uvprojx

    │  └ Source

    │     ├ App

    │     │  │ dev_uart.c

    │     │  │ dev_uart.h

    │     │  │ main.c

    │     │  │ stm32f0xx_conf.h

    │     │  └ system_stm32f0xx.c

    │     ├ Bsp

    │     │  │ bsp_uart.c

    │     │  │ bsp_uart.h

    │     │  │ stm32f0xx_it.c

    │     │  └ stm32f0xx_it.h

    │     ├ Components

    │     │  │ fifo.c

    │     │  └ fifo.h

    │     └ Libraries

    │        ├ CMSIS

    │        │  ├ Core

    │        │  │  │ arm_common_tables.h

    │        │  │  │ arm_const_structs.h

    │        │  │  │ arm_math.h

    │        │  │  │ core_cm0.h

    │        │  │  │ core_cm0plus.h

    │        │  │  │ core_cm3.h

    │        │  │  │ core_cm4.h

    │        │  │  │ core_cm4_simd.h

    │        │  │  │ core_cmFunc.h

    │        │  │  │ core_cmInstr.h

    │        │  │  │ core_sc000.h

    │        │  │  └ core_sc300.h

    │        │  └ Device

    │        │     │ stm32f0xx.h

    │        │     │ system_stm32f0xx.h

    │        │     └ startup

    │        │        ├ iar

    │        │        │  │ startup_stm32f030.s

    │        │        │  │ startup_stm32f031.s

    │        │        │  │ startup_stm32f042.s

    │        │        │  │ startup_stm32f051.s

    │        │        │  │ startup_stm32f072.s

    │        │        │  │ startup_stm32f0xx.s

    │        │        │  └ startup_stm32f0xx_ld.s

    │        │        └ mdk

    │        │           │ startup_stm32f030.s

    │        │           │ startup_stm32f031.s

    │        │           │ startup_stm32f042.s

    │        │           │ startup_stm32f051.s

    │        │           │ startup_stm32f072.s

    │        │           │ startup_stm32f0xx.s

    │        │           └ startup_stm32f0xx_ld.s

    │        └ STM32F0xx_StdPeriph_Driver

    │           ├ inc

    │           │  │ stm32f0xx_adc.h

    │           │  │ stm32f0xx_can.h

    │           │  │ stm32f0xx_cec.h

    │           │  │ stm32f0xx_comp.h

    │           │  │ stm32f0xx_crc.h

    │           │  │ stm32f0xx_crs.h

    │           │  │ stm32f0xx_dac.h

    │           │  │ stm32f0xx_dbgmcu.h

    │           │  │ stm32f0xx_dma.h

    │           │  │ stm32f0xx_exti.h

    │           │  │ stm32f0xx_flash.h

    │           │  │ stm32f0xx_gpio.h

    │           │  │ stm32f0xx_i2c.h

    │           │  │ stm32f0xx_iwdg.h

    │           │  │ stm32f0xx_misc.h

    │           │  │ stm32f0xx_pwr.h

    │           │  │ stm32f0xx_rcc.h

    │           │  │ stm32f0xx_rtc.h

    │           │  │ stm32f0xx_spi.h

    │           │  │ stm32f0xx_syscfg.h

    │           │  │ stm32f0xx_tim.h

    │           │  │ stm32f0xx_usart.h

    │           │  └ stm32f0xx_wwdg.h

    │           └ src

    │              │ stm32f0xx_adc.c

    │              │ stm32f0xx_can.c

    │              │ stm32f0xx_cec.c

    │              │ stm32f0xx_comp.c

    │              │ stm32f0xx_crc.c

    │              │ stm32f0xx_crs.c

    │              │ stm32f0xx_dac.c

    │              │ stm32f0xx_dbgmcu.c

    │              │ stm32f0xx_dma.c

    │              │ stm32f0xx_exti.c

    │              │ stm32f0xx_flash.c

    │              │ stm32f0xx_gpio.c

    │              │ stm32f0xx_i2c.c

    │              │ stm32f0xx_iwdg.c

    │              │ stm32f0xx_misc.c

    │              │ stm32f0xx_pwr.c

    │              │ stm32f0xx_rcc.c

    │              │ stm32f0xx_rtc.c

    │              │ stm32f0xx_spi.c

    │              │ stm32f0xx_syscfg.c

    │              │ stm32f0xx_tim.c

    │              │ stm32f0xx_usart.c

    │              └ stm32f0xx_wwdg.c

    ├ stm32f1-rtthread-nano

    │  ├ Projects

    │  │  ├ EWARM

    │  │  │  │ clear.bat

    │  │  │  │ Project.dep

    │  │  │  │ Project.ewd

    │  │  │  │ Project.ewp

    │  │  │  │ Project.ewt

    │  │  │  │ Project.eww

    │  │  │  │ stm32f1x_app.icf

    │  │  │  └ settings

    │  │  │     │ Project.cspy.bat

    │  │  │     │ Project.dbgdt

    │  │  │     │ Project.dni

    │  │  │     │ Project.wsdt

    │  │  │     └ Project_App.jlink

    │  │  └ MDK

    │  │     │ clear.bat

    │  │     │ EventRecorderStub.scvd

    │  │     │ JLinkSettings.ini

    │  │     │ Project.uvoptx

    │  │     │ Project.uvprojx

    │  │     └ RTE

    │  │        ├ RTOS

    │  │        │  │ board.c

    │  │        │  └ rtconfig.h

    │  │        └ _uart-dma

    │  │           └ RTE_Components.h

    │  └ Source

    │     ├ App

    │     │  │ dev_uart.c

    │     │  │ dev_uart.h

    │     │  └ main.c

    │     ├ Bsp

    │     │  │ bsp_uart.c

    │     │  │ bsp_uart.h

    │     │  │ stm32f10x_conf.h

    │     │  │ stm32f10x_it.c

    │     │  └ stm32f10x_it.h

    │     ├ Components

    │     │  │ fifo.c

    │     │  └ fifo.h

    │     ├ Libraries

    │     │  ├ CMSIS

    │     │  │  └ CM3

    │     │  │     ├ CoreSupport

    │     │  │     │  │ core_cm3.c

    │     │  │     │  └ core_cm3.h

    │     │  │     └ DeviceSupport

    │     │  │        └ ST

    │     │  │           │ Release_Notes_for_STM32F10x_CMSIS.html

    │     │  │           └ STM32F10x

    │     │  │              │ Release_Notes.html

    │     │  │              │ stm32f10x.h

    │     │  │              │ system_stm32f10x.c

    │     │  │              │ system_stm32f10x.h

    │     │  │              └ startup

    │     │  │                 ├ arm

    │     │  │                 │  │ startup_stm32f10x_cl.s

    │     │  │                 │  │ startup_stm32f10x_hd.s

    │     │  │                 │  │ startup_stm32f10x_hd_vl.s

    │     │  │                 │  │ startup_stm32f10x_ld.s

    │     │  │                 │  │ startup_stm32f10x_ld_vl.s

    │     │  │                 │  │ startup_stm32f10x_md.s

    │     │  │                 │  │ startup_stm32f10x_md_vl.s

    │     │  │                 │  └ startup_stm32f10x_xl.s

    │     │  │                 ├ gcc_ride7

    │     │  │                 │  │ startup_stm32f10x_cl.s

    │     │  │                 │  │ startup_stm32f10x_hd.s

    │     │  │                 │  │ startup_stm32f10x_hd_vl.s

    │     │  │                 │  │ startup_stm32f10x_ld.s

    │     │  │                 │  │ startup_stm32f10x_ld_vl.s

    │     │  │                 │  │ startup_stm32f10x_md.s

    │     │  │                 │  │ startup_stm32f10x_md_vl.s

    │     │  │                 │  └ startup_stm32f10x_xl.s

    │     │  │                 ├ iar

    │     │  │                 │  │ startup_stm32f10x_cl.s

    │     │  │                 │  │ startup_stm32f10x_hd.s

    │     │  │                 │  │ startup_stm32f10x_hd_vl.s

    │     │  │                 │  │ startup_stm32f10x_ld.s

    │     │  │                 │  │ startup_stm32f10x_ld_vl.s

    │     │  │                 │  │ startup_stm32f10x_md.s

    │     │  │                 │  │ startup_stm32f10x_md_vl.s

    │     │  │                 │  └ startup_stm32f10x_xl.s

    │     │  │                 └ TrueSTUDIO

    │     │  │                    │ startup_stm32f10x_cl.s

    │     │  │                    │ startup_stm32f10x_hd.s

    │     │  │                    │ startup_stm32f10x_hd_vl.s

    │     │  │                    │ startup_stm32f10x_ld.s

    │     │  │                    │ startup_stm32f10x_ld_vl.s

    │     │  │                    │ startup_stm32f10x_md.s

    │     │  │                    │ startup_stm32f10x_md_vl.s

    │     │  │                    └ startup_stm32f10x_xl.s

    │     │  └ STM32F10x_StdPeriph_Driver

    │     │     ├ inc

    │     │     │  │ misc.h

    │     │     │  │ stm32f10x_adc.h

    │     │     │  │ stm32f10x_bkp.h

    │     │     │  │ stm32f10x_can.h

    │     │     │  │ stm32f10x_cec.h

    │     │     │  │ stm32f10x_crc.h

    │     │     │  │ stm32f10x_dac.h

    │     │     │  │ stm32f10x_dbgmcu.h

    │     │     │  │ stm32f10x_dma.h

    │     │     │  │ stm32f10x_exti.h

    │     │     │  │ stm32f10x_flash.h

    │     │     │  │ stm32f10x_fsmc.h

    │     │     │  │ stm32f10x_gpio.h

    │     │     │  │ stm32f10x_i2c.h

    │     │     │  │ stm32f10x_iwdg.h

    │     │     │  │ stm32f10x_pwr.h

    │     │     │  │ stm32f10x_rcc.h

    │     │     │  │ stm32f10x_rtc.h

    │     │     │  │ stm32f10x_sdio.h

    │     │     │  │ stm32f10x_spi.h

    │     │     │  │ stm32f10x_tim.h

    │     │     │  │ stm32f10x_usart.h

    │     │     │  └ stm32f10x_wwdg.h

    │     │     └ src

    │     │        │ misc.c

    │     │        │ stm32f10x_adc.c

    │     │        │ stm32f10x_bkp.c

    │     │        │ stm32f10x_can.c

    │     │        │ stm32f10x_cec.c

    │     │        │ stm32f10x_crc.c

    │     │        │ stm32f10x_dac.c

    │     │        │ stm32f10x_dbgmcu.c

    │     │        │ stm32f10x_dma.c

    │     │        │ stm32f10x_exti.c

    │     │        │ stm32f10x_flash.c

    │     │        │ stm32f10x_fsmc.c

    │     │        │ stm32f10x_gpio.c

    │     │        │ stm32f10x_i2c.c

    │     │        │ stm32f10x_iwdg.c

    │     │        │ stm32f10x_pwr.c

    │     │        │ stm32f10x_rcc.c

    │     │        │ stm32f10x_rtc.c

    │     │        │ stm32f10x_sdio.c

    │     │        │ stm32f10x_spi.c

    │     │        │ stm32f10x_tim.c

    │     │        │ stm32f10x_usart.c

    │     │        └ stm32f10x_wwdg.c

    │     └ RT-Thread

    │        │ board.c

    │        │ rtconfig.h

TAGSTM2
  • 10 次
  • 1 分