diff options
Diffstat (limited to 'c/src/lib/libbsp/sparc/shared/uart/apbuart_termios.c')
-rw-r--r-- | c/src/lib/libbsp/sparc/shared/uart/apbuart_termios.c | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/c/src/lib/libbsp/sparc/shared/uart/apbuart_termios.c b/c/src/lib/libbsp/sparc/shared/uart/apbuart_termios.c index 4b69e1b3d2..58822c522b 100644 --- a/c/src/lib/libbsp/sparc/shared/uart/apbuart_termios.c +++ b/c/src/lib/libbsp/sparc/shared/uart/apbuart_termios.c @@ -223,6 +223,57 @@ static void apbuart_last_close_interrupt( rtems_interrupt_handler_remove(uart->irq, apbuart_isr, tty); } +/* + * apbuart_outbyte_polled + * + * This routine transmits a character using polling. + */ +void apbuart_outbyte_polled( + struct apbuart_regs *regs, + unsigned char ch, + int do_cr_on_newline, + int wait_sent +) +{ +send: + while ( (regs->status & APBUART_STATUS_TE) == 0 ) { + /* Lower bus utilization while waiting for UART */ + __asm__ volatile ("nop"::); __asm__ volatile ("nop"::); + __asm__ volatile ("nop"::); __asm__ volatile ("nop"::); + __asm__ volatile ("nop"::); __asm__ volatile ("nop"::); + __asm__ volatile ("nop"::); __asm__ volatile ("nop"::); + } + regs->data = (unsigned int) ch; + + if ((ch == '\n') && do_cr_on_newline) { + ch = '\r'; + goto send; + } + + /* Wait until the character has been sent? */ + if (wait_sent) { + while ((regs->status & APBUART_STATUS_TE) == 0) + ; + } +} + +/* + * apbuart_inbyte_nonblocking + * + * This routine polls for a character. + */ +int apbuart_inbyte_nonblocking(struct apbuart_regs *regs) +{ + /* Clear errors */ + if (regs->status & APBUART_STATUS_ERR) + regs->status = ~APBUART_STATUS_ERR; + + if ((regs->status & APBUART_STATUS_DR) == 0) + return -1; + else + return (int) regs->data; +} + const rtems_termios_device_handler apbuart_handler_interrupt = { .first_open = apbuart_first_open_interrupt, .last_close = apbuart_last_close_interrupt, |