2021-11-16 10:02:13
先贴出中断函数:
[plain] view plain copy void USART1_IRQHandler(void){ IF (USART_GetiTStatus(USART1, USART_IT_RXNE) != RESET) { USART_ClearITPendingBit(USART1, USART_IT_RXNE); USART1_Buffer[i++]=USART_ReceiveData(USART1); //USART1_Buffesh是一个自己定义的接收数组 if(i>3){ SendFlag = 1; } } if(USART_GetITStatus(USART1, USART_IT_TXE) != RESET){ //USART_IT_TC这里也可替换 if(Open_Send_Flag){ //这是一个发送的标志 uart1_sendstring(temp_data); USART_ITConfig(USART1, USART_IT_TXE, DISABLE); //USART_IT_TC Open_Send_Flag = 0; } else{ USART_ITConfig(USART1, USART_IT_TXE, DISABLE); //USART_IT_TC } } }
发送字符串的函数:
[plain] view plain copy void uart1_sendstring(uint8_t* cp) { while((*cp)!='