void USART3_Configuration(u32 BaudRate)
{
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3 , ENABLE); //RCC_APB2Periph_GPIOB
RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD,ENABLE);
USART_InitTypeDef USART_InitStructure;
// USART_ClockInitTypeDef USART_ClockInitStructure;
GPIO_InitTypeDef GPIO_InitStructure;
/* Configure USART3 Tx (PB.10) as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_5;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOD, &GPIO_InitStructure);
USART_InitStructure.USART_BaudRate = BaudRate; /*设置波特率为38400*/
USART_InitStructure.USART_WordLength = USART_WordLength_8b;/*设置数据位为8*/
USART_InitStructure.USART_StopBits = USART_StopBits_1; /*设置停止位为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; /*发送和接收*/
USART_Init(USART3, &USART_InitStructure);
/*使能串口3的发送和接收中断*/
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
USART_ITConfig(USART3, USART_IT_TXE, ENABLE);
/* 使能串口3 */
USART_Cmd(USART3, ENABLE);
}