comparison target-utils/simagent/simup.c @ 782:badc5399d641

simagent: flush_rx_fifo() factored out
author Mychaela Falconia <falcon@freecalypso.org>
date Sat, 13 Mar 2021 21:39:34 +0000
parents 6ec781e61e68
children
comparison
equal deleted inserted replaced
781:289733ff272b 782:badc5399d641
115 SIMREGS.conf1 = conf1_reg |= SIM_CONF1_SCLKEN; 115 SIMREGS.conf1 = conf1_reg |= SIM_CONF1_SCLKEN;
116 SIMREGS.conf1 = conf1_reg &= ~SIM_CONF1_TXRX; //set to receive mode 116 SIMREGS.conf1 = conf1_reg &= ~SIM_CONF1_TXRX; //set to receive mode
117 wait_ARM_cycles(WAIT_ONE_TDMA * 3); 117 wait_ARM_cycles(WAIT_ONE_TDMA * 3);
118 118
119 /* flush any garbage in the Rx FIFO */ 119 /* flush any garbage in the Rx FIFO */
120 for (count = 0; ; ) { 120 rc = flush_rx_fifo();
121 if (SIMREGS.stat & SIM_STAT_FEMPTY) 121 if (rc < 0)
122 break; 122 return;
123 (void) SIMREGS.drx;
124 if (++count >= 32) {
125 printf("ERROR: Rx FIFO flush does not end\n");
126 return;
127 }
128 }
129 /* lift the card out of reset! */ 123 /* lift the card out of reset! */
130 SIMREGS.conf1 = conf1_reg |= SIM_CONF1_SRSTLEV; 124 SIMREGS.conf1 = conf1_reg |= SIM_CONF1_SRSTLEV;
131 125
132 /* first byte of ATR */ 126 /* first byte of ATR */
133 rc = rx_sim_byte(SIM_WAIT_TIMEOUT); 127 rc = rx_sim_byte(SIM_WAIT_TIMEOUT);