From ac7e73a579547e2443d680e91e5c0dab4b915e5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Redon?= Date: Thu, 14 Nov 2019 20:11:42 +0100 Subject: [PATCH] check RST/VCC/CLK line at every step of the activation ISO-7816 specifies a card activation sequence: VCC on, CLK active, then RST release. we now check for the end state at every state of the activation in case the reader does not strictly follows the sequence. change has been tested on OWHW slot 1. Change-Id: Ie55505ab3a70cbd64281af40af53d5e120313228 --- firmware/libcommon/source/card_emu.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/firmware/libcommon/source/card_emu.c b/firmware/libcommon/source/card_emu.c index 087867fe..5298ffcf 100644 --- a/firmware/libcommon/source/card_emu.c +++ b/firmware/libcommon/source/card_emu.c @@ -380,6 +380,13 @@ 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 */