summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/sparc/shared/uart
diff options
context:
space:
mode:
authorChristian Mauderer <Christian.Mauderer@embedded-brains.de>2014-07-01 15:09:49 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2014-07-09 12:07:49 +0200
commit8448a4defcd2f41328628468c4f96547f98beb43 (patch)
treef78b256e24ec5480c0efc1639f3ce79539660937 /c/src/lib/libbsp/sparc/shared/uart
parentbsps/sparc: Add and use shared APBUART console (diff)
downloadrtems-8448a4defcd2f41328628468c4f96547f98beb43.tar.bz2
bsps/sparc: Move APBUART printk support
Diffstat (limited to 'c/src/lib/libbsp/sparc/shared/uart')
-rw-r--r--c/src/lib/libbsp/sparc/shared/uart/apbuart_termios.c51
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,