aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2021-04-05 18:16:14 +0200
committerlaforge <laforge@osmocom.org>2021-04-08 21:28:37 +0000
commita708ea1d992ecdf84c6747ecef803b2573064e48 (patch)
treefe18d3d0a3c91d198b43faff05425ff401a0a1f6
parentc1ffc8a6039326a0f080b6d25408e8b06acaa73f (diff)
card_emu: improve reset detection conditions
* enter ISO_S_WAIT_RST when RST is asserted * enter ISO_S_WAIT_ATR only when we RST is released while in state ISO_S_WAIT_RST Change-Id: I620333aa8d45561a8028b948955a27f667b58406
-rw-r--r--firmware/libcommon/source/card_emu.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/firmware/libcommon/source/card_emu.c b/firmware/libcommon/source/card_emu.c
index c5e4cfa..216ffe3 100644
--- a/firmware/libcommon/source/card_emu.c
+++ b/firmware/libcommon/source/card_emu.c
@@ -1102,7 +1102,7 @@ void card_emu_io_statechg(struct card_handle *ch, enum card_io io, int active)
case CARD_IO_RST:
if (active == 0 && ch->in_reset) {
TRACE_INFO("%u: RST released\r\n", ch->num);
- if (ch->vcc_active && ch->clocked) {
+ if (ch->vcc_active && ch->clocked && ch->state == ISO_S_WAIT_RST) {
/* enable the TC/ETU counter once reset has been released */
tc_etu_enable(ch->tc_chan);
/* prepare to send the ATR */
@@ -1113,6 +1113,7 @@ void card_emu_io_statechg(struct card_handle *ch, enum card_io io, int active)
TRACE_INFO("%u: RST asserted\r\n", ch->num);
card_handle_reset(ch);
chg_mask |= CEMU_STATUS_F_RESET_ACTIVE;
+ card_set_state(ch, ISO_S_WAIT_RST);
}
ch->in_reset = active;
break;