Fix writting large packets.

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos 2022-09-27 12:23:16 +02:00
parent b70a7474f2
commit 3912775ccb
No known key found for this signature in database
GPG key ID: C0095B7870A4CCD3
2 changed files with 5 additions and 5 deletions

View file

@ -95,7 +95,7 @@ void hid_write(uint16_t size) {
uint16_t send_buffer_size = 0;
void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, /*uint16_t*/ uint8_t len) {
uint8_t seq = report[4] & TYPE_MASK ? 0 : report[4]+1;
uint8_t seq = report[4] & TYPE_MASK ? 0 : report[4] + 1;
if (send_buffer_size > 0) {
ctap_resp->cid = ctap_req->cid;
ctap_resp->cont.seq = seq;
@ -106,8 +106,8 @@ void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, /*uint1
}
int driver_write(const uint8_t *buffer, size_t buffer_size) {
int ret = tud_hid_report(0, buffer, buffer_size);
return ret;
tud_hid_report(0, buffer, buffer_size);
return MIN(64, buffer_size);
}
size_t driver_read(uint8_t *buffer, size_t buffer_size) {

View file

@ -54,7 +54,7 @@ uint32_t usb_write_offset(uint16_t len, uint16_t offset) {
w = driver_write(tx_buffer+offset, MIN(len, pkt_max));
w_len -= w;
tx_r_offset += w;
return w;
return MIN(w_len, pkt_max);
}
size_t usb_rx(const uint8_t *buffer, size_t len) {
@ -182,9 +182,9 @@ void usb_task() {
// printf("\r\n ------ M = %lu\r\n",m);
if (has_m) {
if (m == EV_EXEC_FINISHED) {
timeout_stop();
driver_exec_finished(finished_data_size);
led_set_blink(BLINK_MOUNTED);
timeout_stop();
}
else if (m == EV_PRESS_BUTTON) {
uint32_t flag = wait_button() ? EV_BUTTON_TIMEOUT : EV_BUTTON_PRESSED;