| void USART_Configuration(void) {
 USART_InitTypeDef USART_InitStructure;               //串口设置恢复默认参数
 //初始化参数设置
 USART_InitStructure.USART_BaudRate = 9600;                                   //波特率9600
 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;//打开Rx接收和Tx发送功能
 USART_Init(USART2, &USART_InitStructure);                                          //初始化
 USART_Cmd(USART2, ENABLE);   //开启USART;
 }
 这是串口配置
 |