void USART3_IRQHandler(void)
{
uint8_t ch;
// 接收数据
if(USART_GetITStatus(USART3, USART_IT_RXNE) != RESET)
{
USART_ClearITPendingBit(USART3, USART_IT_RXNE);// 清除中断标志
ch = USART_ReceiveData(USART3);
Com3RBuf[Com3Index]=(uint8_t)ch;
printf("ch=%d\r\n",(uint8_t)Com3RBuf[Com3Index]);
Com3Index++;
if(Com3RBuf[2]==0x0A))
{
Rec3FinishF=1;
Com3Index=0;
}
}
// 发送数据
else if(USART_GetITStatus(USART3, USART_IT_TXE) != RESET)
{
USART_ClearITPendingBit(USART3, USART_IT_TXE);
if(Com3Index<Index3End)
{
USART_SendData(USART3, (uint8_t)Com3TBuf[Com3Index++]);
while(USART_GetFlagStatus(USART3,USART_FLAG_TXE) == RESET);
}
else
{
Com3Index=0;
USART_ITConfig(USART3, USART_IT_TXE, DISABLE);
}
}
}
|