1、#include“stm32f10x.h“void USART_Config(void)USART_InitTypeDef USART_InitStructure;USART_InitStructure.USART_BaudRate = 9600; /波特率为 9600HzUSART_InitStructure.USART_WordLength = USART_WordLength_8b; /8 位数据USART_InitStructure.USART_StopBits = USART_StopBits_1; /在帧结尾传输 1 个停止位USART_InitStructure.USART_Pa
2、rity = USART_Parity_No; /奇偶失能USART_InitStructure.USART_HardwareFlowControl =USART_HardwareFlowControl_None; /硬件流控制失能USART_InitStructure.USART_Mode = USART_Mode_Tx | USART_Mode_Rx; /发送使能,接收使能USART_Init(USART1, USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); /USART_ITConfig:使能或者失能指定的 USART 中断 USART_IT_RXNE, ENABLE:接收中断USART_Cmd(USART1, ENABLE); /使能 USART 外设USART_ClearFlag(USART1,USART_FLAG_TC); /清除 USARTx 的待处理标志位 USART_FLAG_TC:发送完成标志位