/*Includes------------------------------------------------------------------*/#includestm32f4xx_conf.h#includestdio.hvoidDelay(__IOuint32_tnCount);//***********************************************//函数功能:延时ms//入口参数:延时长度//出口参数:无//备注://************************************************voidDelay_ms(u16ms){u32j;for(;ms0;ms--)for(j=0;j9700;j++);}//***********************************************//函数功能:IO配置//入口参数:无//出口参数:无//备注://************************************************voidGPIO_Configuration(void){GPIO_InitTypeDefGPIO_InitStructure;/*GPIODPeriphclockenable*/RCC_AHB1PeriphClockCmd(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_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);}//***********************************************//函数功能:UART配置//入口参数:无//出口参数:无//备注://************************************************voidUSART_Configuration(void){USART_InitTypeDefUSART_InitStructure;USART_InitStructure.USART_BaudRate=9600;//波特率USART_InitStructure.USART_WordLength=USART_WordLength_8b;//8位数据USART_InitStructure.USART_StopBits=USART_StopBits_1;//停止位USART_InitStructure.USART_Parity=USART_Parity_No;//校验方式:无USART_InitStructure.USART_HardwareFlowControl=USART_HardwareFlowControl_None;//硬件流控制失能USART_InitStructure.USART_Mode=USART_Mode_Rx|USART_Mode_Tx;//发送/接收使能/*EnableGPIOclock*/RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC,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,GPIO_AF_USART3);GPIO_StructInit(&GPIO_InitStructure);/*ConfigureUSARTTxasalternatefunction*/GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_UP;GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF;GPIO_InitStructure.GPIO_Pin=GPIO_Pin_10;GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;GPIO_Init(GPIOC,&GPIO_InitStructure);/*ConfigureUSARTRxasalternatefunction*/GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF;GPIO_InitStructure.GPIO_Pin=GPIO_Pin_11;GPIO_Init(GPIOC,&GPIO_InitStructure);/*USARTconfiguration*/USART_Init(USART3,&USART_InitStructure);USART_ITConfig(USART3,USART_IT_RXNE,ENABLE);USART_ITConfig(USART3,USART_IT_TXE,ENABLE);/*EnableUSART*/USART_Cmd(USART3,ENABLE);/*EnableUARTclock*/RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART6,ENABLE);/*ConnectPXxtoUSARTx_Tx*/GPIO_PinAFConfig(GPIOC,GPIO_PinSource6,GPIO_AF_USART6);/*ConnectPXxtoUSARTx_Rx*/GPIO_PinAFConfig(GPIOC,GPIO_PinSource7,GPIO_AF_USART6);GPIO_StructInit(&GPIO_InitStructure);/*ConfigureUSARTTxasalternatefunction*/GPIO_InitStructure.GPIO_OType=GPIO_OType_PP;GPIO_InitStructure.GPIO_PuPd=GPIO_PuPd_UP;GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF;GPIO_InitStructure.GPIO_Pin=GPIO_Pin_6;GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;GPIO_Init(GPIOC,&GPIO_InitStructure);/*ConfigureUSARTRxasalternatefunction*/GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF;GPIO_InitStructure.GPIO_Pin=GPIO_Pin_7;GPIO_Init(GPIOC,&GPIO_InitStructure);/*USARTconfiguration*/USART_Init(USART6,&USART_InitStructure);USART_ITConfig(USART6,USART_IT_RXNE,ENABLE);//USART_ITConfig(USART6,USART_IT_TXE,ENABLE);/*EnableUSART*/USART_Cmd(USART6,ENABLE);}voidNVIC_Config(void){NVIC_InitTypeDefNVIC_InitStructure;NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0);//嵌套优先级分组为1NVIC_InitStructure.NVIC_IRQChannel=USART3_IRQn;//嵌套通道为USART3_IRQnNVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0;//抢占优先级为0NVIC_InitStructure.NVIC_IRQChannelSubPriority=0;//响应优先级为0NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;//通道中断使能NVIC_Init(&NVIC_InitStructure);NVIC_InitStructure.NVIC_IRQChannel=USART6_IRQn;//嵌套通道为USART6_IRQnNVIC_InitStructure.NVIC_IRQChannelPreemptionPriority=0;//抢占优先级为0NVIC_InitStructure.NVIC_IRQChannelSubPriority=0;//响应优先级为0NVIC_InitStructure.NVIC_IRQChannelCmd=ENABLE;//通道中断使能NVIC_Init(&NVIC_InitStructure);}/***@briefMainprogram*@paramNone*@retvalNone***@briefDelayFunction.*@paramnCount:specifiestheDelaytimelength.*@retvalNone*/voidDelay(__IOuint32_tnCount){while(nCount--){}}/**intfputc(intch,FILE*f){/*Placeyourimplementationoffputchere*//*e.g.writeacharactertotheUSART*/USART_SendData(USART6,(uint8_t)ch);/*Loopuntiltheendoftransmission*/while(USART_GetFlagStatus(USART6,USART_FLAG_TC)==RESET){}returnch;}#ifdefUSE_FULL_ASSERT/***@briefReportsthenameofthesourcefileandthesourcelinenumber*wheretheassert_paramerrorhasoccurred.*@paramfile:pointertothesourcefilename*@paramline:assert_paramerrorlinesourcenumber*@retvalNone*/voidassert_failed(uint8_t*file,uint32_tline){/*Usercanaddhisownimplementationtoreportthefilenameandlinenumber,ex:printf(Wrongp