Exemplo n.º 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退出中断******/
}
Exemplo n.º 2
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退出中断******/
	
}
Exemplo n.º 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();          
}
Exemplo n.º 4
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_GetFlagStatus(USART1, USART_FLAG_ORE) == SET)
	{
		prvvUARTRxISR();
	}
	//接收中断
	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();
}
Exemplo n.º 5
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();
    }
}
Exemplo n.º 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();
	}
	  
}
Exemplo n.º 7
0
/*******************************************************************************
* Function Name  : Bsp_Modbus_Irqhandler
* Description    : This function handles USART2 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void $Sub$$USART3_IRQHandler(void)
{
	rt_interrupt_enter();
	//接收中断
	if (USART_GetITStatus(MODBUS_USE_USART, USART_IT_RXNE) == SET)
	{
		USART_ClearITPendingBit(MODBUS_USE_USART, USART_IT_RXNE);
		prvvUARTRxISR();
	}
	//发送中断
	if (USART_GetITStatus(MODBUS_USE_USART, USART_IT_TXE) == SET)
	{
		prvvUARTTxReadyISR();
	}
	rt_interrupt_leave();
}
Exemplo n.º 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 */
}
Exemplo n.º 9
0
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);
	}
}
Exemplo n.º 10
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();
    }
}
Exemplo n.º 11
0
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 */
}
Exemplo n.º 12
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);
		if(master_slave != 0)
			prvvUARTRxISR();
		else
			prvvUARTRxISR_Master();
	}
	//发送中断
	if (USART_GetITStatus(USART1, USART_IT_TXE) == SET)
	{
//		USART_ClearITPendingBit(USART1, USART_IT_TXE);
		if(master_slave != 0)
		prvvUARTTxReadyISR();
		else
		prvvUARTTxReadyISR_Master();
	}
	rt_interrupt_leave();
}
Exemplo n.º 13
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();
}
Exemplo n.º 14
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
}
/**
 * This function is serial receive callback function
 *
 * @param dev the device of serial
 * @param size the data size that receive
 *
 * @return return RT_EOK
 */
static rt_err_t serial_rx_ind(rt_device_t dev, rt_size_t size) {
    prvvUARTRxISR();
    return RT_EOK;
}