예제 #1
0
void USART2_IRQHandler(void)
{
	u8 SendData;
    if(SET == USART_GetITStatus(USART2, USART_IT_TXE))
    {
        USART_ClearITPendingBit(USART2, USART_IT_TXE);
	#if 1
		if(FIFO_GET_ONE(McuUart2_TxFifo,&SendData))
		{
		   USART_SendData(USART2,SendData);
		}				  
		else
		{
		 	USART_ITConfig(USART2, USART_IT_TXE, DISABLE);
		 	USART_ITConfig(USART2, USART_IT_TC, ENABLE);
		}
	#else
        if (m_SendBuff.len > 0 )
        {
            USART_SendData(USART2, m_SendBuff.buf[m_SendBuff.ind++]);
            m_SendBuff.len--;
        }
        else
        {
            USART_ITConfig(USART2, USART_IT_TXE, DISABLE);
            USART_ITConfig(USART2, USART_IT_TC, ENABLE);
        }
	#endif
    }
    if (USART_GetITStatus(USART2, USART_IT_TC) != RESET)//去掉else
    {
        USART_ClearITPendingBit(USART2, USART_IT_TC);
        USART_ITConfig(USART2, USART_IT_TC, DISABLE);
        m_SendBuff.len = 0;
        eTXIdle = TRUE;
    }
    if (USART_GetITStatus(USART2, USART_IT_RXNE) != RESET)//去掉else
    {
        u8 ch;
        
        USART_ClearITPendingBit(USART2, USART_IT_RXNE);	
        ch = USART_ReceiveData(USART2);
        if(UpgradeReady == 1)
		{
			ReceOneChar(ch);	//IAP
		}
		else
		{
			#ifdef ANDROID_UPGRADE
				FIFO_PUT_ONE(McuUart2_RxFifo,ch);
				//ReceOneCharByandroid(ch);
			#else
				ReceOneCharVerify(ch);
			#endif
		}
//        if (receChar != NULL)
//            (*receChar)(ch);
		
    }	
}
예제 #2
0
/*********************************************************************************************************
** Function name: UART1_Exception
** Descriptions:  串口中断处理函数
** Input:无       
** Output:        无
** Created by:    周立山
** Created Date:  2006-02-21
**-------------------------------------------------------------------------------------------------------
** Modified by:
** Modified Date: 
**------------------------------------------------------------------------------------------------------
********************************************************************************************************/
void  UART1_Exception(void)
{
	rINTSUBMSK|=(BIT_SUB_RXD1|BIT_SUB_ERR1);

	if(rUTRSTAT1 & 0x01)			
	{

		ReceOneChar(rURXH1);		// 调用MODBUS接收字符函数,;
	}

 	ClearPending(BIT_UART1);
   rSUBSRCPND =(BIT_SUB_RXD1|BIT_SUB_ERR1);
   rINTSUBMSK &=~(BIT_SUB_RXD1|BIT_SUB_ERR1);
    
}
예제 #3
0
void USART1_IRQHandler(void)
{
    if(SET == USART_GetITStatus(USART1, USART_IT_TXE))
    {
        USART_ClearITPendingBit(USART1, USART_IT_TXE);
        if (m_SendBuff.len > 0 )
        {
            USART_SendData(USART1, m_SendBuff.buf[m_SendBuff.ind++]);
            m_SendBuff.len--;
        }
        else
        {
            USART_ITConfig(USART1, USART_IT_TXE, DISABLE);
            USART_ITConfig(USART1, USART_IT_TC, ENABLE);
        }
    }
    else if (USART_GetITStatus(USART1, USART_IT_TC) != RESET)
    {
        USART_ClearITPendingBit(USART1, USART_IT_TC);
        USART_ITConfig(USART1, USART_IT_TC, DISABLE);
        m_SendBuff.len = 0;
        eTXIdle = TRUE;
    }
    else if (USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
    {
        u8 ch;
        
        USART_ClearITPendingBit(USART1, USART_IT_RXNE);	
        ch = USART_ReceiveData(USART1);
        
		ReceOneChar(ch);	//IAP
//        if (receChar != NULL)
//            (*receChar)(ch);
		
    }	
}