Advertisement
Guest User

RM48 USB patch

a guest
Sep 2nd, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.09 KB | None | 0 0
  1. diff -Burp src/usb.c usbmod/usb.c
  2. --- src/usb.c 2015-09-01 12:33:27.691869900 +0200
  3. +++ usbmod/usb.c 2015-09-02 14:51:54.694726800 +0200
  4. @@ -285,8 +285,10 @@ void USBDevEndpointStall(uint32 ulBase,
  5. (usEndpoint == USB_EP_12) || (usEndpoint == USB_EP_13) ||
  6. (usEndpoint == USB_EP_14) || (usEndpoint == USB_EP_15));
  7.  
  8. + usEndpoint = usEndpoint >> 4;
  9. +
  10. /*SAFETYMCUSW 184 S <INSPECTED> "Reason - LDRA tool issue."*/
  11. - USBD_REG_SET_ONE(usbd0Regs->epnum, (USBD_EP_NUM_EP_SEL | usFlags)); /* Select EP */
  12. + USBD_REG_SET_ONE(usbd0Regs->epnum, (USBD_EP_NUM_EP_SEL | (usEndpoint & USBD_EP_NUM_EP_NUM_MASK) | usFlags)); /* Select EP */
  13.  
  14. /*SAFETYMCUSW 184 S <INSPECTED> "Reason - LDRA tool issue."*/
  15. USBD_REG_SET_ONE(usbd0Regs->ctrl, USBD_CTRL_SET_HALT); /* halt the selected EP */
  16. @@ -296,6 +298,8 @@ void USBDevEndpointStall(uint32 ulBase,
  17. /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Statically defined non-null hardware register address" */
  18. USBD_REG_BIT_CLR(usbd0Regs->epnum, USBD_EP_NUM_EP_SEL); /* Deselct EP */
  19.  
  20. + usEndpoint = usEndpoint << 4;
  21. +
  22. return;
  23. }
  24.  
  25. @@ -333,15 +337,19 @@ void USBDevEndpointStallClear(uint32 ulB
  26. (usEndpoint == USB_EP_14) || (usEndpoint == USB_EP_15));
  27. ASSERT((usFlags & ~(USB_EP_DEV_IN | USB_EP_DEV_OUT)) == 0);
  28.  
  29. + usEndpoint = usEndpoint >> 4;
  30. +
  31. /* Select the specified endpoint and clear the stall */
  32. /*SAFETYMCUSW 184 S <INSPECTED> "Reason - LDRA tool issue."*/
  33. - USBD_REG_SET_ONE(usbd0Regs->epnum, (USBD_EP_NUM_EP_SEL | usFlags));
  34. + USBD_REG_SET_ONE(usbd0Regs->epnum, (USBD_EP_NUM_EP_SEL | (usEndpoint & USBD_EP_NUM_EP_NUM_MASK) | usFlags));
  35. /*SAFETYMCUSW 184 S <INSPECTED> "Reason - LDRA tool issue."*/
  36. USBD_REG_BIT_SET(usbd0Regs->ctrl, USBD_CTRL_CLR_HALT);
  37. /*SAFETYMCUSW 184 S <INSPECTED> "Reason - LDRA tool issue."*/
  38. /*SAFETYMCUSW 185 S <INSPECTED> "Reason - LDRA tool issue."*/
  39. /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Statically defined non-null hardware register address" */
  40. USBD_REG_BIT_CLR(usbd0Regs->epnum, USBD_EP_NUM_EP_SEL);
  41. +
  42. + usEndpoint = usEndpoint << 4;
  43. }
  44.  
  45. /** ***************************************************************************
  46. @@ -454,7 +462,7 @@ uint16 USBEndpointDataAvail(uint32 ulBas
  47.  
  48. /* Setup the epnum register. Note that it's always OUT EP */
  49. /*SAFETYMCUSW 184 S <INSPECTED> "Reason - LDRA tool issue."*/
  50. - USBD_REG_SET_ONE(usbd0Regs->epnum, (USBD_EP_NUM_EP_SEL | usEndpoint | USBD_EP_DIR_OUT));
  51. + USBD_REG_SET_ONE(usbd0Regs->epnum, (USBD_EP_NUM_EP_SEL | (usEndpoint & USBD_EP_NUM_EP_NUM_MASK) | USBD_EP_DIR_OUT));
  52.  
  53. /* Read the count from the RXFstat register */
  54. retVal = usbd0Regs->rxf_stat & USBD_RXFSTAT_RXF_COUNT;
  55. @@ -536,13 +544,9 @@ sint32 USBEndpointDataGet(uint32 ulBase,
  56. pucData[i] = *((volatile uint8 *)(&usbd0Regs->data));
  57. }
  58.  
  59. - /* Restore the epnym register */
  60. + /* Restore the epnum register */
  61. usbd0Regs->epnum = usEpNum;
  62.  
  63. - /* setup to receive data on ep */
  64. - /*SAFETYMCUSW 184 S <INSPECTED> "Reason - LDRA tool issue."*/
  65. - USBD_REG_SET_ONE(usbd0Regs->ctrl, USBD_CTRL_SET_FIFO_EN);
  66. -
  67. usEndpoint = usEndpoint << 4;
  68.  
  69. return(0);
  70. @@ -574,7 +578,7 @@ void USBDevGetSetupPacket (uint32 ulBase
  71. /*SAFETYMCUSW 94 S MR:11.4 <INSPECTED> "Reason - Acceptable deviation."*/
  72. pSetupFifo = (volatile uint8 *)(&usbd0Regs->data);
  73.  
  74. - /* Select the setup IFO. This will clear the event flag */
  75. + /* Select the setup FIFO. This will clear the event flag */
  76. usbd0Regs->epnum = USBD_EP_NUM_SETUP_SEL;
  77.  
  78. /* Extract the setup packet */
  79. @@ -651,11 +655,10 @@ void USBDevEndpointDataAck(uint32 ulBase
  80. /* backup the EP number to restore later */
  81. epNum = usbd0Regs->epnum & USBD_EP_NUM_EP_NUM_MASK;
  82.  
  83. - /* Select the endpoint, (Always read (in) endpoint) */
  84. - usbd0Regs->epnum = USBD_EP_DIR_OUT | USBD_EP_NUM_EP_SEL | (usEndpoint & USBD_EP_NUM_EP_NUM_MASK);
  85. + usEndpoint = usEndpoint >> 4;
  86.  
  87. /*SAFETYMCUSW 184 S <INSPECTED> "Reason - LDRA tool issue."*/
  88. - USBD_REG_SET_ONE(usbd0Regs->epnum, (USBD_EP_NUM_EP_SEL | usEndpoint | USBD_EP_DIR_OUT));
  89. + USBD_REG_SET_ONE(usbd0Regs->epnum, (USBD_EP_NUM_EP_SEL | (usEndpoint & USBD_EP_NUM_EP_NUM_MASK) | USBD_EP_DIR_OUT));
  90. /* Clear endpoint */
  91. /*SAFETYMCUSW 184 S <INSPECTED> "Reason - LDRA tool issue."*/
  92. USBD_REG_SET_ONE(usbd0Regs->ctrl, USBD_CTRL_CLR_EP);
  93. @@ -667,10 +670,12 @@ void USBDevEndpointDataAck(uint32 ulBase
  94. /*SAFETYMCUSW 185 S <INSPECTED> "Reason - LDRA tool issue."*/
  95. USBD_REG_BIT_CLR(usbd0Regs->epnum, USBD_EP_NUM_EP_SEL);
  96.  
  97. - /* Restore the epnym register */
  98. + /* Restore the epnum register */
  99. /*SAFETYMCUSW 45 D MR:21.1 <APPROVED> "Statically defined non-null hardware register address" */
  100. usbd0Regs->epnum = epNum;
  101.  
  102. + usEndpoint = usEndpoint << 4;
  103. +
  104. return;
  105. }
  106.  
  107. diff -Burp src/usbdcdc.c usbmod/usbdcdc.c
  108. --- src/usbdcdc.c 2015-09-01 12:33:27.680868800 +0200
  109. +++ usbmod/usbdcdc.c 2015-09-02 14:32:47.055080400 +0200
  110. @@ -1335,8 +1335,15 @@ ProcessDataToHost(const tUSBDCDCDevice *
  111. */
  112. txSize = (uint32)psInst->usLastTxSize;
  113. psInst->usLastTxSize = 0u;
  114. - psDevice->pfnTxCallback(psDevice->pvTxCBData, USB_EVENT_TX_COMPLETE,
  115. - txSize, (void *)0);
  116. + if (txSize == DATA_OUT_EP_MAX_SIZE)
  117. + {
  118. + USBDCDCPacketWrite((void *)psDevice, 0, 0, TRUE);
  119. + }
  120. + else
  121. + {
  122. + psDevice->pfnTxCallback(psDevice->pvTxCBData, USB_EVENT_TX_COMPLETE,
  123. + txSize, (void *)0);
  124. + }
  125.  
  126. return (TRUE);
  127. }
  128. diff -Burp src/usbdconfig.c usbmod/usbdconfig.c
  129. --- src/usbdconfig.c 2015-09-01 12:33:27.684869200 +0200
  130. +++ usbmod/usbdconfig.c 2015-09-02 14:22:13.702854800 +0200
  131. @@ -545,8 +545,8 @@ USBDeviceConfig(uint32 ulIndex, const tC
  132. USBDevCfgLock(USBD_0_BASE);
  133.  
  134. /* Send a zero packet */
  135. - USBEndpointDataPut(USBD_0_BASE, 0u, 0, 0u);
  136. - USBEndpointDataSend(USBD_0_BASE, 0u, (uint32)USBD_EP_DIR_IN);
  137. + USBEndpointDataPut(USBD_0_BASE, USB_EP_0, 0, 0u);
  138. + USBEndpointDataSend(USBD_0_BASE, USB_EP_0, (uint32)USBD_EP_DIR_IN);
  139.  
  140. /*
  141. * If we get to the end, all is well.
  142. diff -Burp src/usbdenum.c usbmod/usbdenum.c
  143. --- src/usbdenum.c 2015-09-01 12:33:27.687869500 +0200
  144. +++ usbmod/usbdenum.c 2015-09-02 14:24:42.441362100 +0200
  145. @@ -1939,6 +1939,8 @@ USBDGetDescriptor(void * pvInstance, tUS
  146. if(lIndex == -1)
  147. {
  148. USBDCDStallEP0(0u);
  149. + psUSBControl->pEP0Data = 0u;
  150. + psUSBControl->ulEP0DataRemain = 0u;
  151. break;
  152. }
  153.  
  154. @@ -1985,6 +1987,8 @@ USBDGetDescriptor(void * pvInstance, tUS
  155. * just stall the request.
  156. */
  157. USBDCDStallEP0(0u);
  158. + psUSBControl->pEP0Data = 0u;
  159. + psUSBControl->ulEP0DataRemain = 0u;
  160. }
  161. break;
  162. }
  163. @@ -3026,7 +3030,7 @@ USBDeviceIntHandlerInternal(uint32 uInde
  164. USBDIntHandlerSof(USBD_0_BASE);
  165. }
  166.  
  167. - USBIntEnable(USBD_0_BASE, (uint16)0xB9u);
  168. + USBIntEnable(USBD_0_BASE, USBD_INT_EN_ALL);
  169. USBIntStatusClear(uIrqSrc);
  170. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement