Ejemplo n.º 1
0
void rt_fh_uart_handler(int vector, void *param)
{
    int status;
    unsigned int ret;
    struct fh_uart *uart;
    unsigned int reg_status;
    rt_device_t dev = (rt_device_t)param;
    uart = (struct fh_uart *)dev->user_data;
    status = uart_get_iir_status(uart->uart_port);
    if (status & UART_IIR_NOINT)
    {
        return;
    }
    if(status & UART_IIR_THREMPTY) {
        //first close tx isr
        uart_disable_irq(uart->uart_port,UART_IER_ETBEI);

        rt_hw_serial_isr((struct rt_serial_device *)dev, RT_SERIAL_EVENT_TX_DONE);
    }
    else if((status & UART_IIR_CHRTOUT)==UART_IIR_CHRTOUT) {
        //bug....
        //if no data in rx fifo
        reg_status = uart_get_status(uart->uart_port);
        if((reg_status & 1<<3) == 0)
            ret = uart_getc(uart->uart_port);
    }
    else {
        rt_interrupt_enter();
        rt_hw_serial_isr((struct rt_serial_device *)dev, RT_SERIAL_EVENT_RX_IND);
        rt_interrupt_leave();
    }
}
Ejemplo n.º 2
0
void UART0_IRQHandler(void)
{
    if (nrf_uart_int_enable_check(NRF_UART0, NRF_UART_INT_MASK_ERROR)
        && nrf_uart_event_check(NRF_UART0, NRF_UART_EVENT_ERROR))
    {
        nrf_uart_event_clear(NRF_UART0, NRF_UART_EVENT_ERROR);
    }

    if (nrf_uart_int_enable_check(NRF_UART0, NRF_UART_INT_MASK_RXDRDY)
        && nrf_uart_event_check(NRF_UART0, NRF_UART_EVENT_RXDRDY))
    {
        rt_hw_serial_isr(working_cfg->serial, RT_SERIAL_EVENT_RX_IND);
    }

    if (nrf_uart_int_enable_check(NRF_UART0, NRF_UART_INT_MASK_TXDRDY)
        && nrf_uart_event_check(NRF_UART0, NRF_UART_EVENT_TXDRDY))
    {
        rt_hw_serial_isr(working_cfg->serial, RT_SERIAL_EVENT_TX_DONE);
    }

    if (nrf_uart_event_check(NRF_UART0, NRF_UART_EVENT_RXTO))
    {
        rt_hw_serial_isr(working_cfg->serial, RT_SERIAL_EVENT_RX_TIMEOUT);
    }
}
void USART1_IRQHandler(void)
{
    struct stm32_uart* uart;

    uart = &uart1;

    /* enter interrupt */
    rt_interrupt_enter();
    if(USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
    {
        rt_hw_serial_isr(&serial1, RT_SERIAL_EVENT_RX_IND);
        /* clear interrupt */
        USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE);
    }

    if (USART_GetITStatus(uart->uart_device, uart->tx_irq_type) != RESET)
    {
        /* clear interrupt */
        rt_hw_serial_isr(&serial1, RT_SERIAL_EVENT_TX_DONE);
        if (uart->tx_irq_type == USART_IT_TC)
        {
            USART_ClearITPendingBit(uart->uart_device, uart->tx_irq_type);
        }
    }
    if (USART_GetFlagStatus(uart->uart_device, USART_FLAG_ORE) == SET)
    {
        stm32_getc(&serial1);
    }
    /* leave interrupt */
    rt_interrupt_leave();
}
Ejemplo n.º 4
0
/* Implementation of UART0 handler named in startup code. */
void UART0_RX_TX_IRQHandler(void)
{
    rt_interrupt_enter();
    rt_hw_serial_isr((struct rt_serial_device*)&_kinetis_serial, RT_SERIAL_EVENT_RX_IND);
    //UART_DRV_IRQHandler(0);
    rt_interrupt_leave();
}
Ejemplo n.º 5
0
/**
 * Uart common interrupt process. This need add to uart ISR.
 *
 * @param serial serial device
 */
static void uart_isr(struct rt_serial_device *serial)
{
    struct imxrt_uart *uart;
    LPUART_Type *base;

    RT_ASSERT(serial != RT_NULL);

    uart = (struct imxrt_uart *) serial->parent.user_data;
    RT_ASSERT(uart != RT_NULL);

    base = uart->uart_base;
    RT_ASSERT(base != RT_NULL);

    /* enter interrupt */
    rt_interrupt_enter();

    /* UART in mode Receiver -------------------------------------------------*/
    if (LPUART_GetStatusFlags(base) & kLPUART_RxDataRegFullFlag)
    {
        rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
    }

    /* If RX overrun. */
    if (LPUART_STAT_OR_MASK & base->STAT)
    {
        /* Clear overrun flag, otherwise the RX does not work. */
        base->STAT = ((base->STAT & 0x3FE00000U) | LPUART_STAT_OR_MASK);
    }

    /* leave interrupt */
    rt_interrupt_leave();
}
/**
 * This function will handle cdc bulk out endpoint request.
 *
 * @param func the usb function object.
 * @param size request size.
 *
 * @return RT_EOK.
 */
static rt_err_t _ep_out_handler(ufunction_t func, rt_size_t size)
{
    rt_uint32_t level;
    struct vcom *data;

    RT_ASSERT(func != RT_NULL);

    RT_DEBUG_LOG(RT_DEBUG_USB, ("_ep_out_handler %d\n", size));
    
    data = (struct vcom*)func->user_data;
    /* receive data from USB VCOM */
    level = rt_hw_interrupt_disable();

    rt_ringbuffer_put(&data->rx_ringbuffer, data->ep_out->buffer, size);
    rt_hw_interrupt_enable(level);

    /* notify receive data */
    rt_hw_serial_isr(&data->serial);

    data->ep_out->request.buffer = data->ep_out->buffer;
    data->ep_out->request.size = EP_MAXPACKET(data->ep_out);
    data->ep_out->request.req_type = UIO_REQUEST_READ_MOST;    
    rt_usbd_io_request(func->device, data->ep_out, &data->ep_out->request);

    return RT_EOK;
}
Ejemplo n.º 7
0
void UART4_IRQHandler(void)
{
    struct stm32_uart* uart;

    uart = &uart4;

    /* enter interrupt */
    rt_interrupt_enter();
    if(USART_GetITStatus(uart->uart_device, USART_IT_RXNE) != RESET)
    {
        rt_hw_serial_isr(&serial4, RT_SERIAL_EVENT_RX_IND);
        /* clear interrupt */
        USART_ClearITPendingBit(uart->uart_device, USART_IT_RXNE);
    }
    if (USART_GetITStatus(uart->uart_device, USART_IT_TC) != RESET)
    {
        /* clear interrupt */
        USART_ClearITPendingBit(uart->uart_device, USART_IT_TC);
    }
    if (USART_GetFlagStatus(uart->uart_device, USART_FLAG_ORE) == SET)
    {
        stm32_getc(&serial4);
    }

    /* leave interrupt */
    rt_interrupt_leave();
}
Ejemplo n.º 8
0
static void CME_UART_IRQHandler(struct rt_serial_device *serial)
{
    struct CME_M7_uart* uart;

    RT_ASSERT(serial != RT_NULL);
    uart = (struct CME_M7_uart *)serial->parent.user_data;

    if(UART_GetIntStatus(uart->uart_device, UART_Int_RxNotEmpty))
    {
        UART_ClearInt(uart->uart_device, UART_Int_RxNotEmpty);
        rt_hw_serial_isr(&serial2, RT_SERIAL_EVENT_RX_IND);
    }

    if(UART_GetIntStatus(uart->uart_device, UART_Int_RxThresholdReach))
    {
        UART_ClearInt(uart->uart_device, UART_Int_RxThresholdReach);
    }

    if(UART_GetIntStatus(uart->uart_device, UART_Int_OverrunError))
    {
        UART_ClearInt(uart->uart_device, UART_Int_OverrunError);
    }

    if(UART_GetIntStatus(uart->uart_device, UART_Int_FrameError))
    {
        UART_ClearInt(uart->uart_device, UART_Int_FrameError);
    }

    if(UART_GetIntStatus(uart->uart_device, UART_Int_ParityError))
    {
        UART_ClearInt(uart->uart_device, UART_Int_ParityError);
    }
}
Ejemplo n.º 9
0
void MFS3RX_IRQHandler(void)
{
	/* enter interrupt */
	rt_interrupt_enter();
	rt_hw_serial_isr(&serial3, RT_SERIAL_EVENT_RX_IND);
	/* leave interrupt */
	rt_interrupt_leave();
}
Ejemplo n.º 10
0
void USART1_IRQHandler(void) {
    struct usart_dev* usart_dev = Serial1.c_dev();

    rt_interrupt_enter();
    if (usart_dev->regs->SR & USART_SR_RXNE) {
        rt_hw_serial_isr(&serial1, RT_SERIAL_EVENT_RX_IND);
    }
    rt_interrupt_leave();
}
Ejemplo n.º 11
0
void USART2_Handler(void)
{
    /* enter interrupt */
    rt_interrupt_enter();

    rt_hw_serial_isr(&usart2.serial);

    /* leave interrupt */
    rt_interrupt_leave();
}
Ejemplo n.º 12
0
void dbg_uart_irq_handler(void * data)
{
    u32 IrqEn = DiagGetIsrEnReg();

    DiagSetIsrEnReg(0);

    rt_hw_serial_isr(&ameba_dbg_serial, RT_SERIAL_EVENT_RX_IND);
    
    DiagSetIsrEnReg(IrqEn);
}
Ejemplo n.º 13
0
/* Implementation of UART1 handler named in startup code. */
void UART1_RX_TX_IRQHandler(void)
{
    rt_interrupt_enter();
    rt_hw_serial_isr((struct rt_serial_device*)&_kinetis_serial, RT_SERIAL_EVENT_RX_IND);
    /* Disable receive data full and rx overrun interrupt */
    //UART_BWR_C2_RIE(g_uartBase[1], 0U);
    //UART_HAL_SetIntMode(g_uartBase[1], kUartIntRxOverrun, false);
    //UART_BWR_C2_TIE(g_uartBase[1], 0U);
    rt_interrupt_leave();
}
Ejemplo n.º 14
0
static void ameba_uart_irq(uint32_t id, SerialIrq event)
{
    struct rt_serial_device *serial = (struct rt_serial_device *)id;
	if(event == RxIrq)
    {
        rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
	}
	else if(event == TxIrq)
    {
	}
}
Ejemplo n.º 15
0
/*******************************************************************************
* Function Name  : USART1_IRQHandler
* Description    : This function handles USART1 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void USART1_IRQHandler(void)
{
#ifdef RT_USING_UART1
    extern struct rt_device uart1_device;
    /* enter interrupt */
    rt_interrupt_enter();

    rt_hw_serial_isr(&uart1_device);

    /* leave interrupt */
    rt_interrupt_leave();
#endif
}
Ejemplo n.º 16
0
/* Implementation of UART5 handler named in startup code. */
void UART0_UART1_UART2_UART3_IRQHandler(void)
{
  rt_interrupt_enter();
      rt_hw_serial_isr((struct rt_serial_device*)&_kinetis_serial, RT_SERIAL_EVENT_RX_IND);
    for(uint32_t i=0; i < UART_INSTANCE_COUNT; i++)
    {
        if (CLOCK_SYS_GetUartGateCmd(i))
        {
            UART_DRV_IRQHandler(i);   
        }
    }
       rt_interrupt_leave();
}
/**/void USART2_IRQHandler(void)
{
    extern struct rt_device uart2_device;
	extern void rt_hw_serial_isr(struct rt_device *device);

    // enter interrupt 
    rt_interrupt_enter();

    rt_hw_serial_isr(&uart2_device);

    // leave interrupt 
    rt_interrupt_leave();
}
/*******************************************************************************
* Function Name  : USART3_IRQHandler
* Description    : This function handles USART3 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
 void USART3_IRQHandler(void)
{
#ifdef RT_USING_UART3
    extern struct rt_device uart3_device;
	extern void rt_hw_serial_isr(struct rt_device *device);

    // enter interrupt 
    rt_interrupt_enter();

    rt_hw_serial_isr(&uart3_device);

    // leave interrupt 
    rt_interrupt_leave();
#endif
}
Ejemplo n.º 19
0
/**
 * Uart common interrupt process. This need add to uart ISR.
 *
 * @param serial serial device
 */
static void uart_isr(struct rt_serial_device *serial)
{
    struct gd32_uart *uart = (struct gd32_uart *) serial->parent.user_data;

    RT_ASSERT(uart != RT_NULL);

    /* UART in mode Receiver */
    if ((usart_interrupt_flag_get(uart->uart_periph, USART_INT_FLAG_RBNE) != RESET) &&
            (usart_flag_get(uart->uart_periph, USART_FLAG_RBNE) != RESET))
    {
        rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
        /* Clear RXNE interrupt flag */
        usart_flag_clear(uart->uart_periph, USART_FLAG_RBNE);
    }
}
Ejemplo n.º 20
0
/**
 * 中断处理函数
 */
static void uart_isr(usart_t serial)
{
    // 获取串口基地址
    UART_T *uart_base = ((usart_t)serial)->usart_base;

    // 获取中断事件
    uint32_t u32IntSts= uart_base->INTSTS;

    // 接收中断
    if(u32IntSts & (UART_INTSTS_RDAINT_Msk | UART_INTSTS_RXTOINT_Msk))
    {
        rt_hw_serial_isr(&serial->dev, RT_SERIAL_EVENT_RX_IND);
    }

}
Ejemplo n.º 21
0
/**
 * This function will handle serial
 */
void rt_at91_usart_handler(int vector, void *param)
{
    int status;
    struct at91_uart *uart;
    rt_device_t dev = (rt_device_t)param;
    uart = (struct at91_uart *)dev->user_data;
    status = uart->port->CSR;
    if (!(status & uart->port->IMR))
    {
        return;
    }
    rt_interrupt_enter();
    rt_hw_serial_isr((struct rt_serial_device *)dev, RT_SERIAL_EVENT_RX_IND);
    rt_interrupt_leave();
}
Ejemplo n.º 22
0
/*******************************************************************************
* Function Name  : USART1_IRQHandler
* Description    : This function handles USART1 global interrupt request.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
__weak void USART1_IRQHandler(void)
{

#if UART_ENABLE
	os_irq_Enter();

#ifdef RT_USING_FINSH
	rt_hw_serial_isr(&uart1_device);
#else
	arch_UartISR(0);
#endif

	os_irq_Leave();
#endif
}
Ejemplo n.º 23
0
/**
 * This function will handle serial
 */
void rt_serial_handler(int vector)
{
	#ifdef USE_UART1
	int status;
	status = readl(AT91SAM9260_BASE_US1+AT91_US_CSR);
	if (!(status & readl(AT91SAM9260_BASE_US1+AT91_US_IMR)))
	{
		return;
	}
	#endif
	#ifdef USE_UART3
	at91_sys_read(AT91_USART3+AT91_US_CSR);
	#endif
	rt_hw_serial_isr(&uart0_device);

}
Ejemplo n.º 24
0
/**
 * This function will handle serial
 */
void rt_asm_usart_handler(int vector, void *param)
{
    rt_uint32_t status;
    asm_uart_t *uart;
    rt_device_t dev = (rt_device_t)param;
    uart = (asm_uart_t *)dev->user_data;
    status = uart->port->INTR[R_VAL];

    if(!(status & (ASM_UART_INTR_RXIS | ASM_UART_INTR_RTIS)))
        return;
    uart->port->INTR[R_CLR] = ASM_UART_INTR_RXIS|ASM_UART_INTR_RTIS;
    //rt_interrupt_enter();
    rt_hw_serial_isr((struct rt_serial_device *)dev, RT_SERIAL_EVENT_RX_IND);
    //rt_interrupt_leave();

}
Ejemplo n.º 25
0
static void am33xx_uart_isr(int irqno, void* param)
{
    rt_uint32_t iir;
    struct am33xx_uart* uart;
    struct rt_serial_device *serial;

    serial = (struct rt_serial_device*)param;
    uart = (struct am33xx_uart *)serial->parent.user_data;

    iir = UART_IIR_REG(uart->base);

    if ((iir & (0x02 << 1)) || (iir & (0x6 << 1)))
    {
        rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
    }
}
Ejemplo n.º 26
0
void USART2_IRQHandler(void)
{
    struct drv_uart *uart;

    uart = &uart2;
    /* enter interrupt */
    rt_interrupt_enter();

    /* UART in mode Receiver -------------------------------------------------*/
    if ((__HAL_UART_GET_FLAG(&uart->UartHandle, UART_FLAG_RXNE) != RESET) &&
            (__HAL_UART_GET_IT_SOURCE(&uart->UartHandle, UART_IT_RXNE) != RESET))
    {
        rt_hw_serial_isr(&serial2, RT_SERIAL_EVENT_RX_IND);
        /* Clear RXNE interrupt flag */
        __HAL_UART_CLEAR_FLAG(&uart->UartHandle, UART_FLAG_RXNE);
    }
    /* leave interrupt */
    rt_interrupt_leave();
}
Ejemplo n.º 27
0
void UART2_IRQHandler(void)
{
    struct mm32_uart *uart;
    uart = &uart2;
    /* enter interrupt */
    rt_interrupt_enter();
    if (UART_GetITStatus(uart->uart_device, UART_IT_RXIEN) != RESET)
    {
        UART_ClearITPendingBit(uart->uart_device, UART_IT_RXIEN);
        rt_hw_serial_isr(&serial2, RT_SERIAL_EVENT_RX_IND);
    }
    if (UART_GetITStatus(uart->uart, UART_IT_TXIEN) != RESET)
    {
        /* clear interrupt */
        UART_ClearITPendingBit(uart->uart, UART_IT_TXIEN);
    }
    /* leave interrupt */
    rt_interrupt_leave();
}
Ejemplo n.º 28
0
void USART3_IRQHandler(void)
{
    struct stm32_uart *uart;

    uart = &uart3;

    /* enter interrupt */
    rt_interrupt_enter();

    /* UART in mode Receiver ---------------------------------------------------*/
    if ((__HAL_UART_GET_IT(&uart->UartHandle, UART_IT_RXNE) != RESET) && (__HAL_UART_GET_IT_SOURCE(&uart->UartHandle, UART_IT_RXNE) != RESET))
    {
        rt_hw_serial_isr(&serial3, RT_SERIAL_EVENT_RX_IND);
        /* Clear RXNE interrupt flag */
        __HAL_UART_SEND_REQ(&uart->UartHandle, UART_RXDATA_FLUSH_REQUEST);
    }
    /* leave interrupt */
    rt_interrupt_leave();
}
Ejemplo n.º 29
0
/**
 * This function will handle cdc bulk out endpoint request.
 *
 * @param device the usb device object.
 * @param size request size.
 *
 * @return RT_EOK.
 */
static rt_err_t _ep_out_handler(udevice_t device, rt_size_t size)
{
    rt_uint32_t level;

    RT_ASSERT(device != RT_NULL);

    /* receive data from USB VCOM */
    level = rt_hw_interrupt_disable();
    rt_ringbuffer_put(&rx_ringbuffer, ep_out->buffer, size);
    rt_hw_interrupt_enable(level);

    /* notify receive data */
    rt_hw_serial_isr(&vcom_serial);

    dcd_ep_read(device->dcd, ep_out, ep_out->buffer,
                ep_out->ep_desc->wMaxPacketSize);

    return RT_EOK;
}
Ejemplo n.º 30
0
void UART2_IRQHandler(void)
{
    struct lpc_uart *uart;
    uint32_t intsrc, temp;

    uart = &uart2;

    /* enter interrupt */
    rt_interrupt_enter();

    /* Determine the interrupt source */
    intsrc = uart->USART->IIR & UART_IIR_INTID_MASK;

    switch (intsrc)
    {

    case UART_IIR_INTID_RLS:                                            /* Receive Line Status interrupt*/
        /* read the line status */
        intsrc = uart->USART->LSR;
        /* Receive an error data */
        if (intsrc & UART_LSR_PE)
        {
            temp = LPC_USART0->RBR;
        }
        break;

    case UART_IIR_INTID_RDA:                                            /*  Receive data               */
    case UART_IIR_INTID_CTI:                                            /*  Receive data timeout       */
        /* read the data to buffer  */
        while (uart->USART->LSR & UART_LSR_RDR)
        {
            rt_hw_serial_isr(&serial0, RT_SERIAL_EVENT_RX_IND);
        }
        break;

    default:
        break;
    }

    /* leave interrupt */
    rt_interrupt_leave();
}