diff options
Diffstat (limited to 'firmware/usbstack')
-rw-r--r-- | firmware/usbstack/usb_hid.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/firmware/usbstack/usb_hid.c b/firmware/usbstack/usb_hid.c index 4c76ff6db6..213f97180e 100644 --- a/firmware/usbstack/usb_hid.c +++ b/firmware/usbstack/usb_hid.c | |||
@@ -180,6 +180,7 @@ static int cur_buf_prepare; | |||
180 | static int cur_buf_send; | 180 | static int cur_buf_send; |
181 | 181 | ||
182 | static bool active = false; | 182 | static bool active = false; |
183 | static bool currently_sending = false; | ||
183 | static int ep_in; | 184 | static int ep_in; |
184 | static int usb_interface; | 185 | static int usb_interface; |
185 | 186 | ||
@@ -595,6 +596,7 @@ void usb_hid_init_connection(void) | |||
595 | logf("hid: init connection"); | 596 | logf("hid: init connection"); |
596 | 597 | ||
597 | active = true; | 598 | active = true; |
599 | currently_sending = false; | ||
598 | } | 600 | } |
599 | 601 | ||
600 | /* called by usb_core_init() */ | 602 | /* called by usb_core_init() */ |
@@ -611,12 +613,14 @@ void usb_hid_init(void) | |||
611 | cur_buf_send = 0; | 613 | cur_buf_send = 0; |
612 | 614 | ||
613 | active = true; | 615 | active = true; |
616 | currently_sending = false; | ||
614 | } | 617 | } |
615 | 618 | ||
616 | void usb_hid_disconnect(void) | 619 | void usb_hid_disconnect(void) |
617 | { | 620 | { |
618 | logf("hid: disconnect"); | 621 | logf("hid: disconnect"); |
619 | active = false; | 622 | active = false; |
623 | currently_sending = false; | ||
620 | } | 624 | } |
621 | 625 | ||
622 | /* called by usb_core_transfer_complete() */ | 626 | /* called by usb_core_transfer_complete() */ |
@@ -627,6 +631,7 @@ void usb_hid_transfer_complete(int ep, int dir, int status, int length) | |||
627 | (void)status; | 631 | (void)status; |
628 | (void)length; | 632 | (void)length; |
629 | 633 | ||
634 | logf("HID: transfer complete: %d %d %d %d",ep,dir,status,length); | ||
630 | switch (dir) | 635 | switch (dir) |
631 | { | 636 | { |
632 | case USB_DIR_OUT: | 637 | case USB_DIR_OUT: |
@@ -638,6 +643,7 @@ void usb_hid_transfer_complete(int ep, int dir, int status, int length) | |||
638 | 643 | ||
639 | send_buffer_len[cur_buf_send] = 0; | 644 | send_buffer_len[cur_buf_send] = 0; |
640 | HID_BUF_INC(cur_buf_send); | 645 | HID_BUF_INC(cur_buf_send); |
646 | currently_sending = false; | ||
641 | usb_hid_try_send_drv(); | 647 | usb_hid_try_send_drv(); |
642 | break; | 648 | break; |
643 | } | 649 | } |
@@ -787,7 +793,15 @@ static void usb_hid_try_send_drv(void) | |||
787 | if (!length) | 793 | if (!length) |
788 | return; | 794 | return; |
789 | 795 | ||
796 | if (currently_sending) | ||
797 | { | ||
798 | logf("HID: Already sending"); | ||
799 | return; | ||
800 | } | ||
801 | |||
802 | logf("HID: Sending %d bytes",length); | ||
790 | rc = usb_drv_send_nonblocking(ep_in, send_buffer[cur_buf_send], length); | 803 | rc = usb_drv_send_nonblocking(ep_in, send_buffer[cur_buf_send], length); |
804 | currently_sending = true; | ||
791 | if (rc) | 805 | if (rc) |
792 | { | 806 | { |
793 | send_buffer_len[cur_buf_send] = 0; | 807 | send_buffer_len[cur_buf_send] = 0; |