欢迎来到天天文库
浏览记录
ID:38584496
大小:56.00 KB
页数:8页
时间:2019-06-15
《STM32F407 USART +DMA共思路DMA通道,进行数据转发》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、/*********************************************************************************@fileIO_Toggle/main.c*@authorMCDApplicationTeam*@versionV1.0.0*@date19-September-2011*@briefMainprogrambody*******************************************************************
2、************@attention**THEPRESENTFIRMWAREWHICHISFORGUIDANCEONLYAIMSATPROVIDINGCUSTOMERS*WITHCODINGINFORMATIONREGARDINGTHEIRPRODUCTSINORDERFORTHEMTOSAVE*TIME.ASARESULT,STMICROELECTRONICSSHALLNOTBEHELDLIABLEFORANY*DIRECT,INDIRECTORCONSEQUENTIALDAMAGESWITHRE
3、SPECTTOANYCLAIMSARISING*FROMTHECONTENTOFSUCHFIRMWAREAND/ORTHEUSEMADEBYCUSTOMERSOFTHE*CODINGINFORMATIONCONTAINEDHEREININCONNECTIONWITHTHEIRPRODUCTS.**
4、***********************************//*Includes------------------------------------------------------------------*/#include"stm32f4xx.h"//串口1连接电脑的USB-TTL小板子,串口2连接MAX485/*Privatetypedef-----------------------------------------------------------*/#defineTX_MO
5、DE0#defineRX_MODE1unsignedlongboundrate[7]={600,2400,4800,9600,19200,38400,57600};/*Privatevariables---------------------------------------------------------*/__IOunsignedcharuart_rx_tx_buf[2];USART_InitTypeDefUSART_InitStruct;DMA_InitTypeDefDMA_InitStruct
6、;GPIO_InitTypeDefGPIO_InitStruct;NVIC_InitTypeDefNVIC_InitStructure;/*Privatefunctionprototypes-----------------------------------------------*//*Privatefunctions---------------------------------------------------------*//***@briefMainprogram*@paramNone*@r
7、etvalNone*/voiduart_1_dma_init(void);voiduart_2_dma_init(void);voidSet485Mode(unsignedcharflag);voidSet_1_rate(unsignedcharrate_num);voidSet_2_rate(unsignedcharrate_num);void_485PinConfig(void);intmain(void){uart_1_dma_init();uart_2_dma_init();Set485Mode(T
8、X_MODE);while(1);}voiduart_1_dma_init(void){/*Enableuart1,DMA2andGPIOclocks****************************************/RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_DMA2
9、RCC_AHB1Periph_GPIOB,ENABLE);//B6-TX,B7-RX;RCC_AP
此文档下载收益归作者所有