mirror of
https://github.com/polhenarejos/pico-keys-sdk
synced 2026-06-10 11:59:05 +02:00
Fix writting large packets.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
@@ -95,7 +95,7 @@ void hid_write(uint16_t size) {
|
|||||||
uint16_t send_buffer_size = 0;
|
uint16_t send_buffer_size = 0;
|
||||||
|
|
||||||
void tud_hid_report_complete_cb(uint8_t instance, uint8_t const* report, /*uint16_t*/ uint8_t len) {
|
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) {
|
if (send_buffer_size > 0) {
|
||||||
ctap_resp->cid = ctap_req->cid;
|
ctap_resp->cid = ctap_req->cid;
|
||||||
ctap_resp->cont.seq = seq;
|
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 driver_write(const uint8_t *buffer, size_t buffer_size) {
|
||||||
int ret = tud_hid_report(0, buffer, buffer_size);
|
tud_hid_report(0, buffer, buffer_size);
|
||||||
return ret;
|
return MIN(64, buffer_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t driver_read(uint8_t *buffer, size_t buffer_size) {
|
size_t driver_read(uint8_t *buffer, size_t buffer_size) {
|
||||||
|
|||||||
@@ -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 = driver_write(tx_buffer+offset, MIN(len, pkt_max));
|
||||||
w_len -= w;
|
w_len -= w;
|
||||||
tx_r_offset += w;
|
tx_r_offset += w;
|
||||||
return w;
|
return MIN(w_len, pkt_max);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t usb_rx(const uint8_t *buffer, size_t len) {
|
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);
|
// printf("\r\n ------ M = %lu\r\n",m);
|
||||||
if (has_m) {
|
if (has_m) {
|
||||||
if (m == EV_EXEC_FINISHED) {
|
if (m == EV_EXEC_FINISHED) {
|
||||||
|
timeout_stop();
|
||||||
driver_exec_finished(finished_data_size);
|
driver_exec_finished(finished_data_size);
|
||||||
led_set_blink(BLINK_MOUNTED);
|
led_set_blink(BLINK_MOUNTED);
|
||||||
timeout_stop();
|
|
||||||
}
|
}
|
||||||
else if (m == EV_PRESS_BUTTON) {
|
else if (m == EV_PRESS_BUTTON) {
|
||||||
uint32_t flag = wait_button() ? EV_BUTTON_TIMEOUT : EV_BUTTON_PRESSED;
|
uint32_t flag = wait_button() ? EV_BUTTON_TIMEOUT : EV_BUTTON_PRESSED;
|
||||||
|
|||||||
Reference in New Issue
Block a user