+static int
+uart_getc( void )
+{
+ /*
+ * This function returns:
+ * -1 : no data
+ * -2 : receiver error
+ * >0 : character received
+ */
+
+ unsigned char lsr;
+
+ if (!uart_initted) return -1;
+
+ lsr = READ( LSR );
+
+ if ( lsr & (UART_LSR_FE | UART_LSR_PE | UART_LSR_OE) )
+ {
+ READ( RBR ); /* discard */
+ return -2;
+ }
+
+ if ( lsr & UART_LSR_DR )
+ {
+ return READ( RBR );
+ }
+
+ return -1;
+}
+