FreeCalypso > hg > freecalypso-tools
comparison target-utils/simagent/byterx.c @ 783:c136a1a2474b
simagent: initial implementation of APDU exchange
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 13 Mar 2021 22:06:08 +0000 |
parents | badc5399d641 |
children |
comparison
equal
deleted
inserted
replaced
782:badc5399d641 | 783:c136a1a2474b |
---|---|
1 #include <stdlib.h> | 1 #include <stdlib.h> |
2 #include "types.h" | 2 #include "types.h" |
3 #include "simregs.h" | 3 #include "simregs.h" |
4 #include "timeout.h" | |
4 | 5 |
5 rx_sim_byte(count) | 6 rx_sim_byte(count) |
6 unsigned count; | 7 unsigned count; |
7 { | 8 { |
8 for (; count; count--) { | 9 for (; count; count--) { |
9 if (!(SIMREGS.stat & SIM_STAT_FEMPTY)) | 10 if (!(SIMREGS.stat & SIM_STAT_FEMPTY)) |
10 return SIMREGS.drx; | 11 return SIMREGS.drx; |
11 } | 12 } |
13 return(-1); | |
14 } | |
15 | |
16 rx_sim_byte_hl() | |
17 { | |
18 int rc; | |
19 unsigned parcnt; | |
20 | |
21 for (parcnt = 0; parcnt < 3; parcnt++) { | |
22 rc = rx_sim_byte(SIM_WAIT_TIMEOUT); | |
23 if (rc < 0) { | |
24 printf("ERROR: timeout waiting for SIM response\n"); | |
25 return(-1); | |
26 } | |
27 if (rc & 0x100) | |
28 return rc & 0xFF; | |
29 } | |
30 printf("ERROR: received bad parity 3 times in a row\n"); | |
12 return(-1); | 31 return(-1); |
13 } | 32 } |
14 | 33 |
15 flush_rx_fifo() | 34 flush_rx_fifo() |
16 { | 35 { |