changeset 782:badc5399d641

simagent: flush_rx_fifo() factored out
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 13 Mar 2021 21:39:34 +0000
parents 289733ff272b
children c136a1a2474b
files target-utils/simagent/byterx.c target-utils/simagent/simup.c
diffstat 2 files changed, 19 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/target-utils/simagent/byterx.c	Sat Mar 13 21:32:22 2021 +0000
+++ b/target-utils/simagent/byterx.c	Sat Mar 13 21:39:34 2021 +0000
@@ -12,6 +12,22 @@
 	return(-1);
 }
 
+flush_rx_fifo()
+{
+	unsigned count;
+
+	for (count = 0; ; ) {
+		if (SIMREGS.stat & SIM_STAT_FEMPTY)
+			break;
+		(void) SIMREGS.drx;
+		if (++count >= 32) {
+			printf("ERROR: Rx FIFO flush does not end\n");
+			return(-1);
+		}
+	}
+	return(0);
+}
+
 void
 cmd_sertimeout(argbulk)
 	char *argbulk;
--- a/target-utils/simagent/simup.c	Sat Mar 13 21:32:22 2021 +0000
+++ b/target-utils/simagent/simup.c	Sat Mar 13 21:39:34 2021 +0000
@@ -117,15 +117,9 @@
 	wait_ARM_cycles(WAIT_ONE_TDMA * 3);
 
 	/* flush any garbage in the Rx FIFO */
-	for (count = 0; ; ) {
-		if (SIMREGS.stat & SIM_STAT_FEMPTY)
-			break;
-		(void) SIMREGS.drx;
-		if (++count >= 32) {
-			printf("ERROR: Rx FIFO flush does not end\n");
-			return;
-		}
-	}
+	rc = flush_rx_fifo();
+	if (rc < 0)
+		return;
 	/* lift the card out of reset! */
 	SIMREGS.conf1 = conf1_reg |= SIM_CONF1_SRSTLEV;