Guest User

Untitled

a guest
Dec 14th, 2012
54
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/firmware/target/arm/rk27xx/usb-drv-rk27xx.c b/firmware/target/arm/rk27xx/usb-drv-rk27xx.c
  2. index 810c793..d12187c 100644
  3. --- a/firmware/target/arm/rk27xx/usb-drv-rk27xx.c
  4. +++ b/firmware/target/arm/rk27xx/usb-drv-rk27xx.c
  5. @@ -203,15 +203,30 @@ static void blk_read(int ep)
  6. {
  7. int ep_num = EP_NUM(ep);
  8. int xfer_size = BOUT_RXSTAT(ep_num) & 0xffff;
  9. + int max = usb_drv_port_speed() ? 512 : 64;
  10. + struct endpoint_t *endp = &endpoints[ep_num];
  11.  
  12. /* clear NAK bit */
  13. BOUT_RXCON(ep_num) &= ~RXNAK;
  14.  
  15. - endpoints[ep_num].cnt -= xfer_size;
  16. - endpoints[ep_num].buf += xfer_size;
  17. -
  18. - BOUT_DMAOUTLMADDR(ep_num) = (uint32_t)endpoints[ep_num].buf;
  19. - BOUT_DMAOUTCTL(ep_num) = DMA_START;
  20. + endp->cnt -= xfer_size;
  21. + endp->buf += xfer_size;
  22. +
  23. + /* if the transfer was short or if the total count is zero, transfer is complete */
  24. + if (endp->cnt == 0 || xfer_size < max)
  25. + {
  26. + logf("udc_intr: usb_core_transfer_complete(0x%x, USB_DIR_OUT, 0, 0x%x), %ld", ep_num, endp->len, current_tick);
  27. + usb_core_transfer_complete(ep_num, /* ep */
  28. + USB_DIR_OUT, /* dir */
  29. + 0, /* status */
  30. + endp->len - endp->cnt); /* length */
  31. + endp->cnt = 0;
  32. + }
  33. + else
  34. + {
  35. + BOUT_DMAOUTLMADDR(ep_num) = (uint32_t)endp->buf;
  36. + BOUT_DMAOUTCTL(ep_num) = DMA_START;
  37. + }
  38. }
  39.  
  40. static void int_write(int ep)
  41. @@ -419,21 +434,10 @@ void INT_UDC(void)
  42. rxstat = BOUT_RXSTAT(ep_num);
  43.  
  44. /* TODO handle errors */
  45. - if (rxstat & RXACK) /* RxACK */
  46. + if (rxstat & RXACK && ep->cnt > 0) /* RxACK */
  47. {
  48. - if (ep->cnt > 0)
  49. - {
  50. - logf("udc_intr: blk_read(0x%x), %ld", ep_num, current_tick);
  51. - blk_read(ep_num);
  52. - }
  53. - else
  54. - {
  55. - logf("udc_intr: usb_core_transfer_complete(0x%x, USB_DIR_OUT, 0, 0x%x), %ld", ep_num, ep->len, current_tick);
  56. - usb_core_transfer_complete(ep_num, /* ep */
  57. - USB_DIR_OUT, /* dir */
  58. - 0, /* status */
  59. - ep->len); /* length */
  60. - }
  61. + logf("udc_intr: blk_read(0x%x), %ld", ep_num, current_tick);
  62. + blk_read(ep_num);
  63. }
  64. }
  65. else
  66. @@ -534,15 +538,15 @@ int usb_drv_request_endpoint(int type, int dir)
  67.  
  68. if (ep_num%3 == 0) /* IIN 3, 6, 9, 12, 15 */
  69. {
  70. - IIN_TXCON(ep_num) = (ep_num<<8)|TXEPEN|TXNAK; /* ep_num, enable, NAK */
  71. + IIN_TXCON(ep_num) = (ep_num<<8)|TXEPEN|TXNAK|TXACKINTEN; /* ep_num, enable, NAK */
  72. }
  73. else if (ep_num%3 == 1) /* BOUT 1, 4, 7, 10, 13 */
  74. {
  75. - BOUT_RXCON(ep_num) = (ep_num<<8)|RXEPEN|RXNAK; /* ep_num, NAK, enable */
  76. + BOUT_RXCON(ep_num) = (ep_num<<8)|RXEPEN|RXNAK|RXACKINTEN; /* ep_num, NAK, enable */
  77. }
  78. else if (ep_num%3 == 2) /* BIN 2, 5, 8, 11, 14 */
  79. {
  80. - BIN_TXCON(ep_num) = (ep_num<<8)|TXEPEN|TXNAK; /* ep_num, enable, NAK */
  81. + BIN_TXCON(ep_num) = (ep_num<<8)|TXEPEN|TXNAK|TXACKINTEN; /* ep_num, enable, NAK */
  82. }
  83.  
  84. /* enable interrupt from this endpoint */
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×