diff --git a/firmware/libcommon/source/card_emu.c b/firmware/libcommon/source/card_emu.c index c3299de0..34fac1b0 100644 --- a/firmware/libcommon/source/card_emu.c +++ b/firmware/libcommon/source/card_emu.c @@ -426,13 +426,6 @@ static void card_set_state(struct card_handle *ch, case ISO_S_WAIT_RST: /* disable Rx and Tx of UART */ card_emu_uart_enable(ch->uart_chan, 0); - /* check end activation state (only necessary if the reader to not respect the activation sequence) */ - if (ch->vcc_active && ch->clocked && !ch->in_reset) { - /* enable the TC/ETU counter once reset has been released */ - tc_etu_enable(ch->tc_chan); - /* prepare to send the ATR */ - card_set_state(ch, ISO_S_WAIT_ATR); - } break; case ISO_S_WAIT_ATR: /* Reset to initial Fi / Di ratio */ @@ -1111,6 +1104,23 @@ void card_emu_io_statechg(struct card_handle *ch, enum card_io io, int active) ch->in_reset = active; break; } + + switch (ch->state) { + case ISO_S_WAIT_POWER: + case ISO_S_WAIT_CLK: + case ISO_S_WAIT_RST: + /* check end activation state (even if the reader does + * not respect the activation sequence) */ + if (ch->vcc_active && ch->clocked && !ch->in_reset) { + /* enable the TC/ETU counter once reset has been released */ + tc_etu_enable(ch->tc_chan); + /* prepare to send the ATR */ + card_set_state(ch, ISO_S_WAIT_ATR); + } + break; + default: + break; + } } /* User sets a new ATR to be returned during next card reset */