|
有的是
void Uart_Init(void){ USART_InitStructure.USART_BaudRate = 9600; //9600 bps USART_InitStructure.USART_WordLength = USART_WordLength_8b; //8 Bits USART_InitStructure.USART_Parity = USART_Parity_No; //One Stop Bit USART_InitStructure.USART_StopBits = USART_StopBits_1; //One Stop Bit USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; //Hardware flow control disabled (RTS and CTS signals) USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; //Receive and transmit enabled
USART_Init(USART1, &USART_InitStructure); USART_Init(USART2, &USART_InitStructure); USART_Init(USART3, &USART_InitStructure); USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); //使能UART1接收中断 USART_ITConfig(USART1, USART_IT_TXE, ENABLE); //使能UART1发送中断
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE); //使能UART2接收中断 USART_ITConfig(USART2, USART_IT_TXE, ENABLE); //使能UART2发送中断 USART_ITConfig(USART3, USART_IT_RXNE, ENABLE); //使能UART3接收中断 USART_ITConfig(USART3, USART_IT_TXE, ENABLE); //使能UART3发送中断
USART_Cmd(USART1, ENABLE); USART_Cmd(USART2, ENABLE); USART_Cmd(USART3, ENABLE); } |
|