shithub: n900

Download patch

ref: 019fef4c1f57889951c43d5b9e0e7500602f5872
parent: a58600b637b2150a36007b8626d4faa03b5ad2df
author: mia soweli <[email protected]>
date: Fri Sep 1 23:25:38 EDT 2023

uart: timeout in putc and getc

--- a/sys/src/9/omap/uartomap.c
+++ b/sys/src/9/omap/uartomap.c
@@ -213,11 +213,16 @@
 omapuartgetc(Uart *uart)
 {
 	Ctlr *ctlr;
+	int i;
 
 	ctlr = uart->regs;
-	while(!(csr32r(ctlr, Rlsr) & LSRrxempty))
-		;
+	for(i = 0; i < 128; i++) {
+		if(csr32r(ctlr, Rlsr) & LSRrxempty)
+			break;
 
+		delay(1);
+	}
+
 	return csr32r(ctlr, Rrhr);
 }
 
@@ -225,10 +230,15 @@
 omapuartputc(Uart *uart, int c)
 {
 	Ctlr *ctlr;
+	int i;
 
 	ctlr = uart->regs;
-	while(!(csr32r(ctlr, Rlsr) & LSRtxempty))
-		;
+	for(i = 0; i < 128; i++) {
+		if(csr32r(ctlr, Rlsr) & LSRtxempty)
+			break;
+
+		delay(1);
+	}
 
 	csr32w(ctlr, Rthr, c);
 }