コード例 #1
0
ファイル: debug.c プロジェクト: DSKIM3/lk
void stellaris_uart0_irq(void)
{
	arm_cm_irq_entry();

	//
	// Get the interrrupt status.
	//
	unsigned long ulStatus = UARTIntStatus(DEBUG_UART, true);

	//
	// Clear the asserted interrupts.
	//
	UARTIntClear(DEBUG_UART, ulStatus);

	//
	// Loop while there are characters in the receive FIFO.
	//
	bool resched = false;
	while (UARTCharsAvail(DEBUG_UART)) {
		//
		// Read the next character from the UART and write it back to the UART.
		//
		unsigned char c = UARTCharGetNonBlocking(DEBUG_UART);
		cbuf_write_char(&debug_rx_buf, c, false);

		resched = true;
	}

	arm_cm_irq_exit(resched);
}
コード例 #2
0
ファイル: uart.c プロジェクト: nroychowdhury/lk
void stm32_USART1_IRQ(void)
{
    bool resched = false;

    arm_cm_irq_entry();

    /* UART parity error interrupt occurred -------------------------------------*/
    if ((__HAL_UART_GET_IT(&handle, UART_IT_PE) != RESET) && (__HAL_UART_GET_IT_SOURCE(&handle, UART_IT_PE) != RESET)) {
        __HAL_UART_CLEAR_PEFLAG(&handle);

        printf("UART PARITY ERROR\n");
    }

    /* UART frame error interrupt occurred --------------------------------------*/
    if ((__HAL_UART_GET_IT(&handle, UART_IT_FE) != RESET) && (__HAL_UART_GET_IT_SOURCE(&handle, UART_IT_ERR) != RESET)) {
        __HAL_UART_CLEAR_FEFLAG(&handle);

        printf("UART FRAME ERROR\n");
    }

    /* UART noise error interrupt occurred --------------------------------------*/
    if ((__HAL_UART_GET_IT(&handle, UART_IT_NE) != RESET) && (__HAL_UART_GET_IT_SOURCE(&handle, UART_IT_ERR) != RESET)) {
        __HAL_UART_CLEAR_NEFLAG(&handle);

        printf("UART NOISE ERROR\n");
    }

    /* UART Over-Run interrupt occurred -----------------------------------------*/
    if ((__HAL_UART_GET_IT(&handle, UART_IT_ORE) != RESET) && (__HAL_UART_GET_IT_SOURCE(&handle, UART_IT_ERR) != RESET)) {
        __HAL_UART_CLEAR_OREFLAG(&handle);

        printf("UART OVERRUN ERROR\n");
    }

    /* UART in mode Receiver ---------------------------------------------------*/
    if ((__HAL_UART_GET_IT(&handle, UART_IT_RXNE) != RESET) && (__HAL_UART_GET_IT_SOURCE(&handle, UART_IT_RXNE) != RESET)) {

        /* we got a character */
        uint8_t c = (uint8_t)(handle.Instance->RDR & 0xff);
        if (cbuf_write_char(&uart1_rx_buf, c, false) != 1) {
            printf("WARNING: uart cbuf overrun!\n");
        }
        resched = true;

        /* Clear RXNE interrupt flag */
        __HAL_UART_SEND_REQ(&handle, UART_RXDATA_FLUSH_REQUEST);
    }

    /* UART in mode Transmitter ------------------------------------------------*/
    if ((__HAL_UART_GET_IT(&handle, UART_IT_TXE) != RESET) &&(__HAL_UART_GET_IT_SOURCE(&handle, UART_IT_TXE) != RESET)) {
        ;
    }

    /* UART in mode Transmitter (transmission end) -----------------------------*/
    if ((__HAL_UART_GET_IT(&handle, UART_IT_TC) != RESET) &&(__HAL_UART_GET_IT_SOURCE(&handle, UART_IT_TC) != RESET)) {
        ;
    }

    arm_cm_irq_exit(resched);
}
コード例 #3
0
ファイル: debug.c プロジェクト: ianloic/lk
void sam3_uart_irq(void)
{
	inc_critical_section();

	unsigned char c;
	if (uart_read(UART, &c) == 0) {
		cbuf_write_char(&debug_rx_buf, c, false);
		cm3_trigger_preempt();
	}

	dec_critical_section();
}
コード例 #4
0
ファイル: debug.c プロジェクト: gabemblack/lk
static enum handler_return uart_irq_handler(void *arg)
{
    unsigned char c;
    bool resched = false;

    while (inp(uart_io_port + 5) & (1<<0)) {
        c = inp(uart_io_port + 0);
        cbuf_write_char(&uart_rx_buf, c, false);
        resched = true;
    }

    return resched ? INT_RESCHEDULE : INT_NO_RESCHEDULE;
}
コード例 #5
0
ファイル: debug.c プロジェクト: M1cha/lk
void sam3_uart_irq(void)
{
	arm_cm_irq_entry();

	bool resched = false;
	unsigned char c;
	if (uart_read(UART, &c) == 0) {
		cbuf_write_char(&debug_rx_buf, c, false);
		resched = true;
	}

	arm_cm_irq_exit(resched);
}
コード例 #6
0
ファイル: uart.cpp プロジェクト: saltstar/smartnix
static interrupt_eoi uart_irq_handler(void* arg) {
    /* read interrupt status and mask */
    while ((UARTREG(MX8_USR1) & USR1_RRDY)) {
        if (cbuf_space_avail(&uart_rx_buf) == 0) {
            break;
        }
        char c = UARTREG(MX8_URXD) & 0xFF;
        cbuf_write_char(&uart_rx_buf, c);
    }

    /* Signal if anyone is waiting to TX */
    if (UARTREG(MX8_UCR1) & UCR1_TRDYEN) {
        spin_lock(&uart_spinlock);
        if (!(UARTREG(MX8_USR2) & UTS_TXFULL)) {
            // signal
            event_signal(&uart_dputc_event, true);
        }
        spin_unlock(&uart_spinlock);
    }

    return IRQ_EOI_DEACTIVATE;
}