Ejemplo n.º 1
0
static int uart_getc(uint32_t uart_base)
{
	uint16_t uart_rbr_val;

	/* wait for data ! */
	while (!uart_tstc(uart_base))
		continue;

	/* grab the new byte */
	uart_rbr_val = bfin_read(&pUART->rbr);

#ifdef CONFIG_DEBUG_SERIAL
	/* grab & clear the LSR */
	uart_lsr_t uart_lsr_val = uart_lsr_read(uart_base);

	cached_lsr[cache_count] = uart_lsr_val;
	cached_rbr[cache_count] = uart_rbr_val;
	cache_count = (cache_count + 1) % ARRAY_SIZE(cached_lsr);

	if (uart_lsr_val & (OE|PE|FE|BI)) {
		printf("\n[SERIAL ERROR]\n");
		do {
			--cache_count;
			printf("\t%3zu: RBR=0x%02x LSR=0x%02x\n", cache_count,
				cached_rbr[cache_count], cached_lsr[cache_count]);
		} while (cache_count > 0);
		return -1;
	}
#endif
	uart_lsr_clear(uart_base);

	return uart_rbr_val;
}
Ejemplo n.º 2
0
/*==============================================================================
 * - serial_read()
 *
 * - try to receive <max> char from FIFO
 */
int serial_read (char *buf, int max)
{
    int nbyte = 0;

    if (serial_tstc() == 0)
        uart_pend (WAIT_FOREVER);

    SERIAL_FIFO_LOCK();
    while ((uart_tstc() != 0) && (max-- != 0)) {
        *buf++ = uart_getc();
        nbyte++;
    }
    SERIAL_FIFO_UNLOCK();

    return nbyte;
}
Ejemplo n.º 3
0
int lldebug_tstc(void)
{
	return uart_tstc();
}
Ejemplo n.º 4
0
/*==============================================================================
 * - serial_tstc()
 *
 * - check whether have received char in FIFO
 */
int serial_tstc(void)
{
    return uart_tstc ();
}