void USART1_IRQHandler(void) //′®¿ú1ÖD¶Ï′|àíoˉêy
{
unsigned int i;
if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) //¼ì2aêÇ·ñêǽóêÕÖD¶Ï
{
/* Read one byte from the receive data register */
RxBuffer[RxCounter++] = USART_ReceiveData(USART1); //½óêÕò»×Ö½úêy¾Y
if(RxCounter == DataSizeOfReceiver) //èç1û½óêÕêy¾Yá¿μèóú×üêy¾Yá¿
{
for(i=0; i< RxCounter; i++) TxBuffer[i]=RxBuffer[i]; //½«½óêÕμ½μÄêy¾Y×a′æμ½·¢Ëíêy×é
RxCounter=0; //½óêÕ¼ÆêyÆ÷Çåáã
USART_ITConfig(USART1, USART_IT_TXE, ENABLE); //′ò¿a′®¿ú1·¢ËíÖD¶Ï£¬′ò¿aoó»áᢼ′Ö′DDÖD¶Ï·¢Ëí2ù×÷
}
}
if(USART_GetITStatus(USART1, USART_IT_TXE) != RESET) //¼ì2aêÇ·ñêÇ·¢ËíÖD¶Ï
{
/* Send one byte */
USART_SendData(USART1, TxBuffer[TxCounter++]); //·¢Ëíò»×Ö½úêy¾Y
if(TxCounter == DataSizeOfTransfer) //èç1û·¢Ëíêy¾Yá¿μèóú×üêy¾Yá¿
{
USART_ITConfig(USART1, USART_IT_TXE, DISABLE); //1رÕ′®¿ú·¢ËíÖD¶Ï£¬í£Ö1·¢Ëí
GPIO_WriteBit(GPIOA, GPIO_Pin_1, (BitAction)(!GPIO_ReadOutputDataBit(GPIOA, GPIO_Pin_1)));
TxCounter=0; //·¢Ëí¼ÆêyÆ÷Çåáã
}
}
}
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
一周热门 更多>