Skip to content

Commit

Permalink
FIX: fix usb_send tx_space_available check, closes #52
Browse files Browse the repository at this point in the history
  • Loading branch information
r2axz committed Feb 11, 2022
1 parent 7cea59a commit e7cb9ec
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion usb_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,12 @@ size_t usb_send(uint8_t ep_num, const void *buf, size_t count) {
ep_reg_t *ep_reg = ep_regs(ep_num);
usb_pbuffer_data_t *ep_buf = (usb_pbuffer_data_t *)(USB_PMAADDR + (usb_btable[ep_num].tx_offset<<1));
pb_word_t *buf_p = (pb_word_t*)buf;
pb_word_t words_left = count >> 1;
pb_word_t words_left;
size_t tx_space_available = usb_endpoints[ep_num].tx_size;
if (count > tx_space_available) {
count = tx_space_available;
}
words_left = count >> 1;
while (words_left--) {
(ep_buf++)->data = *buf_p++;
}
Expand All @@ -131,6 +132,7 @@ size_t usb_send(uint8_t ep_num, const void *buf, size_t count) {
return count;
}


/* Circular Buffer Read/Write Operations */

/* NOTE: usb_circ_buf_read assumes enough buffer space is available */
Expand Down

0 comments on commit e7cb9ec

Please sign in to comment.