Browse Source

fixed a bug in Send: write position was used instead of read position

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@8537 8c9fc860-2736-0410-a75d-ab315db34111
eth.morozova 6 years ago
parent
commit
e6b03b125d
1 changed files with 5 additions and 5 deletions
  1. 5 5
      source/Zynq.PsUart.Mod

+ 5 - 5
source/Zynq.PsUart.Mod

@@ -31,6 +31,8 @@ CONST
 	(* TX error interrupts *)
 	TxErrorInterrupts = {PsUartMin.XUARTPS_IXR_TOVR};
 
+	TxOverrunError = 9;
+
 TYPE
 
 	UartController* = POINTER TO RECORD
@@ -120,9 +122,7 @@ VAR
 	BEGIN
 		IF intrStatus * TxErrorInterrupts # {} THEN
 			IF PsUartMin.XUARTPS_IXR_TOVR IN intrStatus THEN
-				INCL(uart.errors,OverrunError);
-				Trace.String("---tx overrun---: intrStatus="); Trace.Set(intrStatus); Trace.Ln;
-				RETURN;
+				INCL(uart.errors,TxOverrunError);
 			END;
 		END;
 
@@ -342,7 +342,7 @@ VAR
 		WHILE uart.open & (len > 0) DO
 
 			bufWrPos := uart.txBufWrPos;
-			n := AvailableBufSpace(bufWrPos,uart.txBufWrPos,LEN(uart.txBuf));
+			n := AvailableBufSpace(bufWrPos,uart.txBufRdPos,LEN(uart.txBuf));
 
 			IF n # 0 THEN
 
@@ -384,7 +384,7 @@ VAR
 		IF uart.open THEN
 			res := 0;
 		ELSE
-			IF OverrunError IN uart.errors THEN res := OverrunError;
+			IF TxOverrunError IN uart.errors THEN res := OverrunError;
 			ELSE res := PsUartMin.Closed;
 			END;
 		END;