mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-05-28 17:11:23 +02:00
Optimitzations to reduce number of interruptions.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -177,20 +177,20 @@ int driver_write_ccid(uint8_t itf, const uint8_t *tx_buffer, uint16_t buffer_siz
|
||||
if (*tx_buffer != 0x81) {
|
||||
DEBUG_PAYLOAD(tx_buffer, buffer_size);
|
||||
}
|
||||
int r = tud_vendor_n_write(itf, tx_buffer, buffer_size);
|
||||
if (r > 0) {
|
||||
uint32_t written = tud_vendor_n_write(itf, tx_buffer, buffer_size);
|
||||
if (written > 0) {
|
||||
tud_vendor_n_flush(itf);
|
||||
|
||||
ccid_tx[itf].r_ptr += (uint16_t)buffer_size;
|
||||
ccid_tx[itf].r_ptr += (uint16_t)written;
|
||||
if (ccid_tx[itf].r_ptr >= ccid_tx[itf].w_ptr) {
|
||||
ccid_tx[itf].r_ptr = ccid_tx[itf].w_ptr = 0;
|
||||
}
|
||||
|
||||
}
|
||||
#ifdef ENABLE_EMULATION
|
||||
tud_vendor_tx_cb(itf, r);
|
||||
tud_vendor_tx_cb(itf, written);
|
||||
#endif
|
||||
return r;
|
||||
return (int)written;
|
||||
}
|
||||
|
||||
int ccid_write_fast(uint8_t itf, const uint8_t *buffer, uint16_t buffer_size) {
|
||||
|
||||
@@ -178,8 +178,10 @@ void usb_send_event(uint32_t flag) {
|
||||
if (flag == EV_CMD_AVAILABLE) {
|
||||
timeout_start();
|
||||
}
|
||||
uint32_t m;
|
||||
queue_remove_blocking(&card_to_usb_q , &m);
|
||||
if (flag != EV_CMD_AVAILABLE) {
|
||||
uint32_t m;
|
||||
queue_remove_blocking(&card_to_usb_q , &m);
|
||||
}
|
||||
#ifndef ENABLE_EMULATION
|
||||
mutex_exit(&mutex);
|
||||
#endif
|
||||
@@ -254,6 +256,9 @@ void usb_task() {
|
||||
|
||||
int card_status(uint8_t itf) {
|
||||
if (card_locked_itf == itf) {
|
||||
if (timeout == 0) {
|
||||
return PICOKEY_ERR_FILE_NOT_FOUND;
|
||||
}
|
||||
uint32_t m = 0x0;
|
||||
#ifndef ENABLE_EMULATION
|
||||
mutex_enter_blocking(&mutex);
|
||||
|
||||
Reference in New Issue
Block a user