void USARTy_IRQHandler(void)
{
if(USART_GetITStatus(USARTy, USART_IT_RXNE) != RESET)
{
/* Read one byte from the receive data register */
RxBuffer1[RxCounter1++] = USART_ReceiveData(USARTy);
if(RxCounter1 == NbrOfDataToRead1)
{
/* Disable the USARTy Receive interrupt */
USART_ITConfig(USARTy, USART_IT_RXNE, DISABLE);
}
}
if(USART_GetITStatus(USARTy, USART_IT_TXE) != RESET)
{
/* Write one byte to the transmit data register */
USART_SendData(USARTy, TxBuffer1[TxCounter1++]);
if(TxCounter1 == NbrOfDataToTransfer1)
{
/* Disable the USARTy Transmit interrupt */
USART_ITConfig(USARTy, USART_IT_TXE, DISABLE);
}
}
}
中断的代码就是这样子的,USARTy就是USART1,这是网上找的~~
|