示例#1
0
/*******************************************************************************
 * Function Name  : USART4_IRQHandler
 * Description    : This function handles USART0 global interrupt request.
 * Input          : None
 * Output         : None
 * Return         : None
 *******************************************************************************/
void USART4_IRQHandler(void)
{
	uint32_t intsrc;
	uint8_t lineStatus;
	
	OSIntEnter();																		/****通知os进入中断*/
	
	intsrc=UART_GetIntId(UART_4);
	if((intsrc&0x0f)==UART_IIR_INTID_RLS)						/****接收线中断****/
	{
		//2.1 检查线状态
		lineStatus = UART_GetLineStatus(UART_4);//读取LSR时中断会被清除
		prvvUARTRxISR(RS485_4);
					
	}
	/****接收数据或者超时中断****/
	else if (((intsrc&0x0f) == UART_IIR_INTID_RDA) || ((intsrc&0x0f) == UART_IIR_INTID_CTI))
	{
		prvvUARTRxISR(RS485_4);
	}
	/******发送中断*************/
	else if((intsrc&0x0f) == UART_IIR_INTID_THRE)
	{	
		prvvUARTTxReadyISR(RS485_4);
	}
	OSIntExit();											/*****通知os退出中断******/
}
/**
 * Software simulation serial transmit IRQ handler.
 *
 * @param parameter parameter
 */
static void serial_soft_trans_irq(void* parameter) {
    rt_uint32_t recved_event;
    while (1)
    {
        /* waiting for serial transmit start */
        rt_event_recv(&event_serial, EVENT_SERIAL_TRANS_START, RT_EVENT_FLAG_OR,
                RT_WAITING_FOREVER, &recved_event);
        /* execute modbus callback */
        prvvUARTTxReadyISR();
    }
}
示例#3
0
// Cam - This is called every 1mS to simulate Rx character received ISR and
// Tx buffer empty ISR.
static void
prvvUARTISR( void )
{
    if (TxEnable)
        if(pc.writeable())
            prvvUARTTxReadyISR();
            
    if (RxEnable)
        if(pc.readable())
            prvvUARTRxISR();          
}
示例#4
0
void USART3_IRQHandler( void )
{
    if (USART_GetITStatus(USART3, USART_IT_TXE))
    {
        prvvUARTTxReadyISR();
    }
    if (USART_GetITStatus(USART3, USART_IT_RXNE))
    {
        prvvUARTRxISR();
    }
    if (USART_GetITStatus(USART3, USART_IT_RTO))
    {
        prvvTIMERExpiredISR();
    }
}
示例#5
0
/*******************************************************************************
 * Function Name  : USART1_IRQHandler
 * Description    : This function handles USART1 global interrupt request.
 * Input          : None
 * Output         : None
 * Return         : None
 *******************************************************************************/
void USART1_IRQHandler(void)
{
	rt_interrupt_enter();
	//接收中断
	if (USART_GetITStatus(USART1, USART_IT_RXNE) == SET)
	{
		USART_ClearITPendingBit(USART1, USART_IT_RXNE);
		prvvUARTRxISR();
	}
	//发送中断
	if (USART_GetITStatus(USART1, USART_IT_TXE) == SET)
	{
		prvvUARTTxReadyISR();
	}
	rt_interrupt_leave();
}
示例#6
0
/*******************************************************************************
 * Function Name  : USART2_IRQHandler
 * Description    : This function handles USART2 global interrupt request.
 * Input          : None
 * Output         : None
 * Return         : None
 *******************************************************************************/
void USART2_IRQHandler(void)
{

	//接收中断
	if (USART_GetITStatus(USART2, USART_IT_RXNE) == SET)
	{
		USART_ClearITPendingBit(USART2, USART_IT_RXNE);
		prvvUARTRxISR();
	}
	//发送中断
	if (USART_GetITStatus(USART2, USART_IT_TXE) == SET)
	{
		prvvUARTTxReadyISR();
	}
	  
}
示例#7
0
/*******************************************************************************
 * Function Name  : USART0_IRQHandler
 * Description    : This function handles USART0 global interrupt request.
 * Input          : None
 * Output         : None
 * Return         : None
 *******************************************************************************/
void USART0_IRQHandler(void)
{
//	rt_interrupt_enter();
//	//溢出错误
//	if (USART_GetFlagStatus(USART2, USART_FLAG_ORE) == SET)
//	{
//		prvvUARTRxISR();
//	}
//	//接收中断
//	if (USART_GetITStatus(USART2, USART_IT_RXNE) == SET)
//	{
//		USART_ClearITPendingBit(USART2, USART_IT_RXNE);
//		prvvUARTRxISR();
//	}
//	//发送中断
//	if (USART_GetITStatus(USART2, USART_IT_TXE) == SET)
//	{
//		prvvUARTTxReadyISR();
//	}
//	rt_interrupt_leave();
	
	uint32_t intsrc;
	uint8_t lineStatus;
	
	OSIntEnter();																		/****通知os进入中断*/
	
	intsrc=UART_GetIntId(UART_0);
	if((intsrc&0x0f)==UART_IIR_INTID_RLS)						/****接收线中断****/
	{
		//2.1 检查线状态
		lineStatus = UART_GetLineStatus(UART_0);//读取LSR时中断会被清除
		prvvUARTRxISR(RS485_1);
					
	}
	/****接收数据或者超时中断****/
	else if (((intsrc&0x0f) == UART_IIR_INTID_RDA) || ((intsrc&0x0f) == UART_IIR_INTID_CTI))
	{
		prvvUARTRxISR(RS485_1);
	}
	/******发送中断*************/
	else if((intsrc&0x0f) == UART_IIR_INTID_THRE)
	{	
		prvvUARTTxReadyISR(RS485_1);
	}
	OSIntExit();											/*****通知os退出中断******/
	
}
示例#8
0
/**
* @brief This function handles USART1 global interrupt / USART1 wake-up interrupt through EXTI line 25.
*/
void USART1_IRQHandler(void)
{
  /* USER CODE BEGIN USART1_IRQn 0 */
  if(__HAL_UART_GET_IT_SOURCE(&huart1, UART_IT_RXNE)!= RESET) 
	{
		prvvUARTRxISR();
	}
	if(__HAL_UART_GET_IT_SOURCE(&huart1, UART_IT_TXE)!= RESET) 
	{
		prvvUARTTxReadyISR();
	}
  /* USER CODE END USART1_IRQn 0 */
  HAL_UART_IRQHandler(&huart1);
  /* USER CODE BEGIN USART1_IRQn 1 */

  /* USER CODE END USART1_IRQn 1 */
}
示例#9
0
/* ----------------------- Start implementation -----------------------------*/
void
vMBPortSerialEnable( BOOL xRxEnable, BOOL xTxEnable )
{
    if(xRxEnable){
        UART0->IER.RDA_IEN = 1;
    }
    else{
        UART0->IER.RDA_IEN = 0;
    }
    if(xTxEnable){
        UART0->IER.THRE_IEN = 1;
        prvvUARTTxReadyISR();
    }
    else{
        UART0->IER.THRE_IEN = 0;
    }
}
示例#10
0
文件: portserial.c 项目: Alizyt/Git
void USART2_IRQHandler(void)
{
	//发生接收中断
	if(USART_GetITStatus(USART2, USART_IT_RXNE) == SET)
	{
		prvvUARTRxISR(); 
		//清除中断标志位 
		USART_ClearITPendingBit(USART2, USART_IT_RXNE); 
	}

	//发送完成中断
	if(USART_GetITStatus(USART2, USART_IT_TC) == SET)
	{
		prvvUARTTxReadyISR();
		//清除中断标志
		USART_ClearITPendingBit(USART2, USART_IT_TC);
	}
}
示例#11
0
static void
UART0Handler(u32bit Uart0IntStatus)
{   
    if(UART0->ISR.RLS_INT){                                 //清楚RLS中断标志
        if(UART0->FSR.BIF)  UART0->FSR.BIF = 1;
        if(UART0->FSR.FEF)  UART0->FSR.FEF = 1;
        if(UART0->FSR.PEF)  UART0->FSR.PEF = 1;
    }
    if(UART0->ISR.TOUT_INT){
        (void)pxMBPortCBTimerExpired();
    }
    if(UART0->ISR.RDA_INT){
        prvvUARTRxISR();
    }
    if(UART0->ISR.THRE_INT){
        prvvUARTTxReadyISR();
    }
}
示例#12
0
/* ----------------------- Start implementation -----------------------------*/
     void            vMBPortSerialEnable( BOOL xRxEnable, BOOL xTxEnable )
{
    if( xRxEnable )
    {
        U0IER |= 0x01;
    }
    else
    {
        U0IER &= ~0x01;
    }
    if( xTxEnable )
    {
        U0IER |= 0x02;
        prvvUARTTxReadyISR(  );
    }
    else
    {
        U0IER &= ~0x02;
    }
}
示例#13
0
文件: portserial.c 项目: cyceron/TML
void
sio_irq( void )
{
    volatile char   dummy;
    volatile char   IIR;

    while( ( ( IIR = U0IIR ) & 0x01 ) == 0 )
    {
        switch ( IIR & 0x0E )
        {
        case 0x06:             /* Receive Line Status */
            dummy = U0LSR;      /* Just clear the interrupt source */
            break;

        case 0x04:             /* Receive Data Available */
        case 0x0C:             /* Character Time-Out */
			{ 
            prvvUARTRxISR(  );
            break;
			}

        case 0x02:             /* THRE Interrupt */
		{
            prvvUARTTxReadyISR(  );
            break;
		}

        case 0x00:             /* Modem Interrupt */
            dummy = U0MSR;      /* Just clear the interrupt source */
            break;

        default:
            break;
        }
    }

    VICVectAddr = 0xFF;         /* Acknowledge Interrupt */
}
示例#14
0
void sio_irq( void ) {
	portSAVE_CONTEXT();
	
    volatile char   dummy;
    volatile char   IIR;
	
	berhitung_serial3++;
    while( ( ( IIR = U3IIR ) & 0x01 ) == 0 )
    {
        switch ( IIR & 0x0E )
        {
        case 0x06:             // Receive Line Status //
            dummy = U3LSR;      // Just clear the interrupt source //
            break;

        case 0x04:             // Receive Data Available //
        case 0x0C:             // Character Time-Out //
            prvvUARTRxISR();
            break;

        case 0x02:             // THRE Interrupt //
            prvvUARTTxReadyISR();
            break;
//
//        case 0x00:             // Modem Interrupt //
//            //dummy = U3MSR;      // Just clear the interrupt source //
//            break;

        default:
            break;
        }
    }
//*/
    VICVectAddr = serCLEAR_VIC_INTERRUPT;         // Acknowledge Interrupt //
    portRESTORE_CONTEXT();
}
示例#15
0
/**
  * @brief  MB_USARTx中断服务函数
  * @param  None
  * @retval None
  */
ARMAPI void BSP_IntHandlerUSART1_0(void)
{
#if defined(__GSF_VER2)
    //发生接收中断
    if (USART1.Event(USART_FLAG_RXNE))
    {
        prvvUARTRxISR(NULL);
		//清除中断标志位
		USART1.Clear(USART_FLAG_RXNE);
    }
    //发生完成中断
    if (USART1.Event(USART_FLAG_TC))
    {
        prvvUARTTxReadyISR(NULL);
		//清除中断标志
		USART1.Clear(USART_FLAG_TC);
    }
	//清除错误
    if (USART1.Event(USART_FLAG_ORE))
    {
		//清除中断标志
		USART1.Clear(USART_FLAG_ORE);
    }
#elif defined(__GSF_VER1)
    //发生接收中断
    if (Serial1.Received())
    {
//		Serial1.Read_ISR();
        prvvUARTRxISR();
		//清除中断标志位
		Serial1.ClearITPendingBit(RXNE_FLAG);
    }
    //发生完成中断
    if (Serial1.Transmitted())
    {
        prvvUARTTxReadyISR();
		//清除中断标志
		Serial1.ClearITPendingBit(TC_FLAG);
    }
#else
	if(USART_GetITStatus(MB_USARTx, USART_IT_RXNE) == SET)
	{
		prvvUARTRxISR();
		//清除中断标志位
		USART_ClearITPendingBit(MB_USARTx, USART_IT_RXNE);
	}
    //发生完成中断
	if(USART_GetITStatus(MB_USARTx, USART_IT_TC) == SET)
	{
		prvvUARTTxReadyISR();
		//清除中断标志
		USART_ClearITPendingBit(MB_USARTx, USART_IT_TC);
	}
    //测试看是否可以去除 2012-07-23
    //溢出-如果发生溢出需要先读SR,再读DR寄存器 则可清除不断入中断的问题
    /*
    if(USART_GetFlagStatus(MB_USARTx,USART_FLAG_ORE)==SET)
    {
      USART_ClearFlag(MB_USARTx,USART_FLAG_ORE); 	//读SR
      USART_ReceiveData(MB_USARTx);              	//读DR
    }
    */
#endif
}