예제 #1
0
파일: msba2-uart0.c 프로젝트: A-L-E-X/RIOT
void UART0_IRQHandler(void)
{
    int iir;
    iir = U0IIR;

    switch (iir & UIIR_ID_MASK) {
        case UIIR_THRE_INT:               // Transmit Holding Register Empty
            fifo = 0;
            push_queue();
            break;

        case UIIR_CTI_INT:                // Character Timeout Indicator
        case UIIR_RDA_INT:                // Receive Data Available
#ifdef MODULE_UART0
            if (uart0_handler_pid != KERNEL_PID_UNDEF) {
                do {
                    int c = U0RBR;
                    uart0_handle_incoming(c);
                }
                while (U0LSR & ULSR_RDR);

                uart0_notify_thread();
            }

#endif
            break;

        default:
            U0LSR;
            U0RBR;
            break;
    } // switch

    VICVectAddr = 0;                    // Acknowledge Interrupt
}
예제 #2
0
파일: uart1.c 프로젝트: AntonisVafeas/RIOT
/**
 * \brief the interrupt function
 */
interrupt(USART1RX_VECTOR) usart0irq(void)
{
    U1TCTL &= ~URXSE; /* Clear the URXS signal */
    U1TCTL |= URXSE;  /* Re-enable URXS - needed here?*/
    /* Check status register for receive errors. */
    if(U1RCTL & RXERR) {
        if (U1RCTL & FE) {
           puts("rx framing error");
        }
        if (U1RCTL & OE) {
            puts("rx overrun error");
        }
        if (U1RCTL & PE) {
            puts("rx parity error");
        }
        if (U1RCTL & BRK) {
            puts("rx break error");
        }
        /* Clear error flags by forcing a dummy read. */
        volatile int c = U1RXBUF;
        (void) c;
    }
#ifdef MODULE_UART0
    else if (uart0_handler_pid) {
        volatile int c = U1RXBUF;
        uart0_handle_incoming(c);
        uart0_notify_thread();
    }
#endif
}
예제 #3
0
파일: syscalls.c 프로젝트: AnonMall/RIOT
/**
 * @brief Receive a new character from the UART and put it into the receive buffer
 */
void rx_cb(void *arg, char data)
{
    (void)arg;

#ifndef MODULE_UART0
    ringbuffer_add_one(&rx_buf, data);
    mutex_unlock(&uart_rx_mutex);
#else
    if (uart0_handler_pid) {
        uart0_handle_incoming(data);
        uart0_notify_thread();
    }
#endif
}
예제 #4
0
파일: uart.c 프로젝트: A-L-E-X/RIOT
/**
 * \brief the interrupt handler for UART reception
 */
interrupt(USCIAB0RX_VECTOR) __attribute__ ((naked)) usart1irq(void)
{
    __enter_isr();

#ifndef MODULE_UART0
    int __attribute__ ((unused)) c;
#else
    int c;
#endif

    /* Check status register for receive errors. */
    if (UCA0STAT & UCRXERR) {
        if (UCA0STAT & UCFE) {
            puts("UART RX framing error");
        }
        if (UCA0STAT & UCOE) {
            puts("UART RX overrun error");
        }
        if (UCA0STAT & UCPE) {
            puts("UART RX parity error");
        }
        if (UCA0STAT & UCBRK) {
            puts("UART RX break condition -> error");
        }
        /* Clear error flags by forcing a dummy read. */
        c = UCA0RXBUF;
#ifdef MODULE_UART0
    } else if (uart0_handler_pid != KERNEL_PID_UNDEF) {
        /* All went well -> let's signal the reception to adequate callbacks */
        c = UCA0RXBUF;
        uart0_handle_incoming(c);
        uart0_notify_thread();
#endif
    }

    __exit_isr();
}
예제 #5
0
파일: native-uart0.c 프로젝트: ajf58/RIOT
void handle_uart_in()
{
    char buf[42];
    int nread;

    DEBUG("handle_uart_in\n");

    nread = _native_read(STDIN_FILENO, buf, sizeof(buf));
    if (nread == -1) {
        err(1, "handle_uart_in(): read()");
    }
    else if (nread == 0) {
        /* end of file / socket closed */
        if (_native_uart_conn != 0) {
            if (_native_null_out_file != -1) {
                if (dup2(_native_null_out_file, STDOUT_FILENO) == -1) {
                    err(EXIT_FAILURE, "handle_uart_in: dup2(STDOUT_FILENO)");
                }
            }
            if (dup2(_native_null_in_pipe[0], STDIN_FILENO) == -1) {
                err(EXIT_FAILURE, "handle_uart_in: dup2(STDIN_FILENO)");
            }
            _native_uart_conn = 0;
            warnx("closed stdio");
        }
        else {
            errx(EXIT_FAILURE, "handle_uart_in: unhandled situation!");
        }
    }
    for(int pos = 0; pos < nread; pos++) {
        uart0_handle_incoming(buf[pos]);
    }
    uart0_notify_thread();

    thread_yield();
}