示例#1
0
static void clear_iir() {
    uint8_t iir;
    while (! ((iir = read_iir()) & IIR_PENDING)) {
        switch(iir & IIR_REASON) {
        case IIR_MSR:
            read_msr();
            break;
        case IIR_THR:
            break;
        case IIR_RDA:
        case IIR_TIME:
            while (read_lsr() & LSR_DATA_READY) {
                handle_char(read_rbr());
            }
            break;
        case IIR_LSR:
            read_lsr();
            break;
        }
    }
}
示例#2
0
static bool clear_iir(void) {
    uint8_t iir;
    while (! ((iir = read_iir()) & IIR_PENDING)) {
        switch(iir & IIR_REASON) {
        case IIR_RDA:
        case IIR_TIME:
            while (read_lsr() & LSR_DATA_READY) {
                bool result = handle_char();
                if (result) {
                    return result;
                }
            }
        default:
            break;
        }
    }
    return false;
}
示例#3
0
文件: uart.c 项目: vbendeb/ci20-tools
void uart_init(unsigned uart, unsigned baud)
{
	unsigned divisor;

	uart_base = (void *)(0xb0030000 + (uart * 0x1000));
	uart_baud = baud;
	divisor = (uart_clk + (uart_baud * (16 / 2))) / (16 * uart_baud);

	if (configure_uart_clock_and_pinmux(uart))
		return; /* No Uart support is possible */

	while (!(read_lsr() & LSR_TEMT));
	write_ier(0);
	write_lcr(LCR_BKSE | LCR_8N1);
	write_dll(0);
	write_dlm(0);
	write_lcr(LCR_8N1);
	write_mcr(MCR_DTR | MCR_RTS);
	write_fcr(FCR_FIFO_EN | FCR_RXSR | FCR_TXSR | FCR_UME);
	write_lcr(LCR_BKSE | LCR_8N1);
	write_dll(divisor & 0xff);
	write_dlm((divisor >> 8) & 0xff);
	write_lcr(LCR_8N1);
}
示例#4
0
static void wait_for_fifo() {
    while(! (read_lsr() & (LSR_EMPTY_DHR | LSR_EMPTY_THR)));
    fifo_used = 0;
}