mirror of
https://github.com/polhenarejos/pico-hsm.git
synced 2024-09-20 03:10:09 +00:00
Fix a bug where multiple incoming APDU may come
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
parent
08d56af6f3
commit
90ee12ed96
10
hsm2040.c
10
hsm2040.c
@ -1272,7 +1272,8 @@ static void ccid_rx_ready (uint16_t len)
|
|||||||
|
|
||||||
if (cont == 0)
|
if (cont == 0)
|
||||||
notify_icc (epo);
|
notify_icc (epo);
|
||||||
epo->ready = 0;
|
else
|
||||||
|
epo->ready = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void notify_tx (struct ep_in *epi)
|
static void notify_tx (struct ep_in *epi)
|
||||||
@ -1343,7 +1344,7 @@ static int usb_event_handle(struct ccid *c)
|
|||||||
{
|
{
|
||||||
ccid_tx_done ();
|
ccid_tx_done ();
|
||||||
}
|
}
|
||||||
if (tud_vendor_available() && c->epo->ready)
|
else if (tud_vendor_available() && c->epo->ready)
|
||||||
{
|
{
|
||||||
uint32_t count = tud_vendor_read(endp1_rx_buf, sizeof(endp1_rx_buf));
|
uint32_t count = tud_vendor_read(endp1_rx_buf, sizeof(endp1_rx_buf));
|
||||||
DEBUG_PAYLOAD(endp1_rx_buf, count);
|
DEBUG_PAYLOAD(endp1_rx_buf, count);
|
||||||
@ -1377,8 +1378,8 @@ void ccid_task(void)
|
|||||||
// connected and there are data available
|
// connected and there are data available
|
||||||
if ((c->epo->ready && tud_vendor_available()) || (tud_vendor_n_write_available(0) == CFG_TUD_VENDOR_TX_BUFSIZE && c->tx_busy == 1))
|
if ((c->epo->ready && tud_vendor_available()) || (tud_vendor_n_write_available(0) == CFG_TUD_VENDOR_TX_BUFSIZE && c->tx_busy == 1))
|
||||||
{
|
{
|
||||||
if (usb_event_handle (c) == 0)
|
if (usb_event_handle (c) != 0)
|
||||||
return;
|
{
|
||||||
if (c->application)
|
if (c->application)
|
||||||
{
|
{
|
||||||
uint32_t flag = EV_EXIT;
|
uint32_t flag = EV_EXIT;
|
||||||
@ -1388,6 +1389,7 @@ void ccid_task(void)
|
|||||||
prepare_ccid();
|
prepare_ccid();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (timeout == 0)
|
if (timeout == 0)
|
||||||
{
|
{
|
||||||
timeout = USB_CCID_TIMEOUT;
|
timeout = USB_CCID_TIMEOUT;
|
||||||
|
Loading…
Reference in New Issue
Block a user