欢迎来到天天文库
浏览记录
ID:59783231
大小:11.77 KB
页数:8页
时间:2020-11-24
《STM32f407-一个串口收传给另一个串口再发送出去串口收发设置.docx》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、/*Includes------------------------------------------------------------------*/#include"stm32f4xx_conf.h"#includevoidDelay(__IOuint32_tnCount);//***********************************************//函数功能:延时ms//入口参数:延时长度//出口参数:无//备注://************************************************voidDelay_
2、ms(u16ms){u32j;for(;ms>0;ms--)for(j=0;j<9700;j++);}//***********************************************//函数功能:IO配置//入口参数:无//出口参数:无//备注://************************************************voidGPIO_Configuration(void){GPIO_InitTypeDefGPIO_InitStructure;/*GPIODPeriphclockenable*/RCC_AHB1PeriphClockCmd(
3、RCC_AHB1Periph_GPIOC,ENABLE);/*ConfigurePD12,PD13,PD14andPD15inoutputpushpullmode*/GPIO_InitStructure.GPIO_Pin=GPIO_Pin_8;GPIO_InitStructure.GPIO_Mode=GPIO_Mode_OUT;GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_
4、NOPULL;GPIO_Init(GPIOC,&GPIO_InitStructure);/*ConfigurePA0pinasinputfloating*///GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN;//GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_NOPULL;//GPIO_InitStructure.GPIO_Pin=GPIO_Pin_0;//GPIO_Init(GPIOA,&GPIO_InitStructure);}//******************************************
5、*****//函数功能:UART配置//入口参数:无//出口参数:无//备注://************************************************voidUSART_Configuration(void){USART_InitTypeDefUSART_InitStructure;USART_InitStructure.USART_BaudRate=9600;//波特率USART_InitStructure.USART_WordLength=USART_WordLength_8b;//8位数据USART_InitStructure.USART_StopB
6、its=USART_StopBits_1;//停止位USART_InitStructure.USART_Parity=USART_Parity_No;//校验方式:无USART_InitStructure.USART_HardwareFlowControl=USART_HardwareFlowControl_None;//硬件流控制失能USART_InitStructure.USART_Mode=USART_Mode_Rx
7、USART_Mode_Tx;//发送/接收使能/*EnableGPIOclock*/RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_G
8、PIOC,ENABLE);/*EnableUARTclock*/RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3,ENABLE);/*ConnectPXxtoUSARTx_Tx*/GPIO_PinAFConfig(GPIOC,GPIO_PinSource10,GPIO_AF_USART3);/*ConnectPXxtoUSARTx_Rx*/GPIO_PinAFConfig(GPIOC,GPIO_PinSource11
此文档下载收益归作者所有