PageRenderTime 43ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/BmFW/MCP/USB_Device_Benchmark/Firmware/Benchmark.c

http://usb-travis.googlecode.com/
C | 557 lines | 404 code | 86 blank | 67 comment | 39 complexity | c7c8bacf6188b3551401e07698818436 MD5 | raw file
Possible License(s): GPL-3.0, LGPL-3.0, LGPL-2.0
  1. /// Benchmark.c
  2. /// Single interface ping-pong buffering enabled.
  3. /* USB Benchmark for libusb-win32
  4. Copyright Š 2010 Travis Robinson. <libusbdotnet@gmail.com>
  5. website: http://sourceforge.net/projects/libusb-win32
  6. Software License Agreement:
  7. The software supplied herewith is intended for use solely and
  8. exclusively on Microchip PIC Microcontroller products. This
  9. software is owned by Travis Robinson, and is protected under
  10. applicable copyright laws. All rights are reserved. Any use in
  11. violation of the foregoing restrictions may subject the user to
  12. criminal sanctions under applicable laws, as well as to civil
  13. liability for the breach of the terms and conditions of this
  14. license.
  15. You may redistribute and/or modify this file under the terms
  16. described above.
  17. THIS SOFTWARE IS PROVIDED IN AN &#x201C;AS IS&#x201D; CONDITION. NO WARRANTIES,
  18. WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
  19. TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  20. PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE OWNER SHALL NOT,
  21. IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
  22. CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
  23. */
  24. /** INCLUDES *******************************************************/
  25. #include "USB/usb.h"
  26. #include "USB/usb_function_generic.h"
  27. #include "HardwareProfile.h"
  28. #include "Benchmark.h"
  29. #include "PicFWCommands.h"
  30. #include "BDT_transfer.h"
  31. #if defined(WITH_SERIAL_DEBUG)
  32. #include "usart.h"
  33. #endif
  34. /** VARIABLES ******************************************************/
  35. //NOTE: The below endpoint buffers need to be located in a section of
  36. //system SRAM that is accessible by the USB module. The USB module on all
  37. //currently existing Microchip USB microcontrollers use a dedicated DMA
  38. //interface for reading/writing USB data into/out of main system SRAM.
  39. //On some USB PIC microcontrollers, all of the microcontroller SRAM is dual
  40. //access, and therefore all of it can be accessed by either the USB
  41. //module or the microcontroller core. On other devices, only a certain
  42. //portion of the SRAM is accessible by the USB module. Therefore, on some
  43. //devices, it is important to place USB data buffers in certain sections of
  44. //SRAM, while on other devices, the buffers can be placed anywhere.
  45. //For all PIC18F87J50 family and PIC18F46J50 family devices: all SRAM is USB accessible.
  46. //For PIC18F1xK50 devices: 0x200-0x2FF is USB accessible.
  47. //For PIC18F4450/2450 devices: 0x400-0x4FF is USB accessible.
  48. //For PIC18F4550/4553/4455/4458/2550/2553/2455/2458: 0x400-0x7FF is USB accessible.
  49. #if defined(__18F14K50) || defined(__18F13K50) || defined(__18LF14K50) || defined(__18LF13K50)
  50. #pragma udata USB_VARIABLES=0x240
  51. #elif defined(__18F2455) || defined(__18F2550) || defined(__18F4455) || defined(__18F4550) || defined(__18F2458) || defined(__18F2453) || defined(__18F4558) || defined(__18F4553)
  52. #pragma udata USB_VARIABLES=0x440
  53. #elif defined(__18F4450) || defined(__18F2450)
  54. #pragma udata USB_VARIABLES=0x440
  55. #else
  56. #pragma udata
  57. #endif
  58. // Data buffers
  59. BYTE BenchmarkBuffers_INTF0[2][PP_COUNT][USBGEN_EP_SIZE_INTF0];
  60. #ifdef DUAL_INTERFACE
  61. BYTE BenchmarkBuffers_INTF1[2][PP_COUNT][USBGEN_EP_SIZE_INTF1];
  62. #endif
  63. #if defined(VENDOR_BUFFER_ENABLED)
  64. BYTE VendorBuffer[8];
  65. #endif
  66. // The below variables are only accessed by the CPU and can be placed anywhere in RAM.
  67. #pragma udata
  68. // Temporary variables
  69. WORD counter;
  70. // Internal test variables
  71. volatile BYTE TestType_INTF0;
  72. volatile BYTE PrevTestType_INTF0;
  73. volatile BYTE FillCount_INTF0;
  74. volatile BYTE NextPacketKey_INTF0;
  75. #ifdef DUAL_INTERFACE
  76. volatile BYTE TestType_INTF1;
  77. volatile BYTE PrevTestType_INTF1;
  78. volatile BYTE FillCount_INTF1;
  79. volatile BYTE NextPacketKey_INTF1;
  80. #endif
  81. /** EXTERNS ********************************************************/
  82. extern void BlinkUSBStatus(void);
  83. extern USB_VOLATILE BYTE USBAlternateInterface[USB_MAX_NUM_INT];
  84. extern volatile WORD led_count;
  85. #if defined(DESCRIPTOR_COUNTING_ENABLED)
  86. unsigned char gDeviceDescriptorCount = 0;
  87. unsigned char gConfigDescriptorCount = 0;
  88. #endif
  89. /** BMARK FUNCTIONS ************************************************/
  90. void doBenchmarkLoop_INTF0(void);
  91. void doBenchmarkWrite_INTF0(void);
  92. void doBenchmarkRead_INTF0(void);
  93. #ifdef DUAL_INTERFACE
  94. void doBenchmarkLoop_INTF1(void);
  95. void doBenchmarkWrite_INTF1(void);
  96. void doBenchmarkRead_INTF1(void);
  97. #endif
  98. void fillBuffer(BYTE* pBuffer, WORD size);
  99. /** BMARK MACROS ****************************************************/
  100. #define mBenchMarkInit(IntfSuffix) \
  101. { \
  102. TestType_##IntfSuffix=TEST_LOOP; \
  103. PrevTestType_##IntfSuffix=TEST_LOOP; \
  104. FillCount_##IntfSuffix=0; \
  105. NextPacketKey_##IntfSuffix=0; \
  106. }
  107. #define mSetWritePacketID(BufferPtr, BufferSize, FillCount, NextPacketKey) \
  108. { \
  109. if ((BufferSize)>0) \
  110. { \
  111. if (FillCount < 3) \
  112. { \
  113. FillCount++; \
  114. fillBuffer((BYTE*)BufferPtr,BufferSize); \
  115. } \
  116. BufferPtr[1]=NextPacketKey++; \
  117. } \
  118. }
  119. // If interface #0 is iso, use an iso specific submit macro
  120. #if (INTF0==EP_ISO)
  121. #define mSubmitTransfer_INTF0(BdtPtr, BufferLength) mBDT_SubmitIsoTransfer(BdtPtr, BufferLength)
  122. #else
  123. #define mSubmitTransfer_INTF0(BdtPtr, BufferLength) mBDT_SubmitTransfer(BdtPtr)
  124. #endif
  125. // If interface #1 is iso, use an iso specific submit macro
  126. #if (INTF1==EP_ISO)
  127. #define mSubmitTransfer_INTF1(BdtPtr, BufferLength) mBDT_SubmitIsoTransfer(BdtPtr, BufferLength)
  128. #else
  129. #define mSubmitTransfer_INTF1(BdtPtr, BufferLength) mBDT_SubmitTransfer(BdtPtr)
  130. #endif
  131. #define GetBenchmarkBuffer(IntfSuffix, Direction, IsOdd) BenchmarkBuffers_##IntfSuffix[Direction][IsOdd]
  132. // Swaps byte pointers
  133. #define Swap(r1,r2) { pSwapBufferTemp = r1; r1 = r2; r2 = pSwapBufferTemp; }
  134. /** BMARK DECLARATIONS *********************************************/
  135. #pragma code
  136. #if defined(VENDOR_BUFFER_ENABLED)
  137. void OnSetVendorBufferComplete(void)
  138. {
  139. // set the blink rate to double (for one blink interval).
  140. led_count=20000U;
  141. // clear the callback function pointer.
  142. outPipes[0].pFunc=NULL;
  143. } // EndOf OnSetVendorBufferComplete
  144. void PicFWSetVendorBufferHandler(void)
  145. {
  146. BYTE bLength = SetupPkt.wLength & 0xFF;
  147. // save host data into VendorBuffer
  148. outPipes[0].pDst.bRam = VendorBuffer;
  149. outPipes[0].wCount.v[0] = (bLength < sizeof(VendorBuffer)) ? bLength : sizeof(VendorBuffer);
  150. // Tell the MCP framework to call OnSetVendorBufferComplete() when we have
  151. // all of the host data.
  152. outPipes[0].pFunc = OnSetVendorBufferComplete;
  153. outPipes[0].info.bits.busy = 1; // claim HostToDevice session ownership
  154. inPipes[0].info.bits.busy = 0; // release DeviceToHost session ownership (Necessary?)
  155. }
  156. #endif
  157. // The Benchmark firmware "overrides" the USBCBInitEP to initialize
  158. // the OUT (MCU Rx) endpoint with the first BenchmarkBuffer.
  159. void USBCBInitEP(void)
  160. {
  161. USBEnableEndpoint(USBGEN_EP_NUM_INTF0,USB_OUT_ENABLED|USB_IN_ENABLED|USBGEN_EP_HANDSHAKE_INTF0|USB_DISALLOW_SETUP);
  162. //Prepare the OUT endpoints to receive the first packets from the host.
  163. pBdtRxEp1->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF0, OUT_FROM_HOST, mBDT_IsOdd(pBdtRxEp1)));
  164. #if (PP_COUNT==(2))
  165. mBDT_TogglePP(pBdtRxEp1);
  166. pBdtRxEp1->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF0, OUT_FROM_HOST, mBDT_IsOdd(pBdtRxEp1)));
  167. mBDT_TogglePP(pBdtRxEp1);
  168. #endif
  169. doBenchmarkRead_INTF0();
  170. doBenchmarkRead_INTF0();
  171. pBdtTxEp1->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF0, IN_TO_HOST, mBDT_IsOdd(pBdtTxEp1)));
  172. #if (PP_COUNT==(2))
  173. mBDT_TogglePP(pBdtTxEp1);
  174. pBdtTxEp1->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF0, IN_TO_HOST, mBDT_IsOdd(pBdtTxEp1)));
  175. mBDT_TogglePP(pBdtTxEp1);
  176. #endif
  177. #ifdef DUAL_INTERFACE
  178. USBEnableEndpoint(USBGEN_EP_NUM_INTF1,USB_OUT_ENABLED|USB_IN_ENABLED|USBGEN_EP_HANDSHAKE_INTF1|USB_DISALLOW_SETUP);
  179. //Prepare the OUT endpoints to receive the first packets from the host.
  180. pBdtRxEp2->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF1, OUT_FROM_HOST, mBDT_IsOdd(pBdtRxEp2)));
  181. #if (PP_COUNT==(2))
  182. mBDT_TogglePP(pBdtRxEp2);
  183. pBdtRxEp2->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF1, OUT_FROM_HOST, mBDT_IsOdd(pBdtRxEp2)));
  184. mBDT_TogglePP(pBdtRxEp2);
  185. #endif
  186. doBenchmarkRead_INTF1();
  187. doBenchmarkRead_INTF1();
  188. pBdtTxEp2->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF1, IN_TO_HOST, mBDT_IsOdd(pBdtTxEp2)));
  189. #if (PP_COUNT==(2))
  190. mBDT_TogglePP(pBdtTxEp2);
  191. pBdtTxEp2->ADR = ConvertToPhysicalAddress(GetBenchmarkBuffer(INTF1, IN_TO_HOST, mBDT_IsOdd(pBdtTxEp2)));
  192. mBDT_TogglePP(pBdtTxEp2);
  193. #endif
  194. #endif
  195. }
  196. void USBCBCheckOtherReq(void)
  197. {
  198. if (SetupPkt.RequestType != USB_SETUP_TYPE_VENDOR_BITFIELD) return;
  199. switch (SetupPkt.bRequest)
  200. {
  201. case PICFW_SET_TEST:
  202. #ifdef DUAL_INTERFACE
  203. if ((SetupPkt.wIndex & 0xff) == INTF1_NUMBER)
  204. {
  205. TestType_INTF1=SetupPkt.wValue & 0xff;
  206. inPipes[0].pSrc.bRam = (BYTE*)&TestType_INTF1; // Set Source
  207. inPipes[0].info.bits.ctrl_trf_mem = USB_EP0_RAM; // Set memory type
  208. inPipes[0].wCount.v[0] = 1; // Set data count
  209. inPipes[0].info.bits.busy = 1;
  210. }
  211. else
  212. #endif
  213. {
  214. TestType_INTF0=SetupPkt.wValue & 0xff;
  215. inPipes[0].pSrc.bRam = (BYTE*)&TestType_INTF0; // Set Source
  216. inPipes[0].info.bits.ctrl_trf_mem = USB_EP0_RAM; // Set memory type
  217. inPipes[0].wCount.v[0] = 1; // Set data count
  218. inPipes[0].info.bits.busy = 1;
  219. }
  220. break;
  221. case PICFW_GET_TEST:
  222. #ifdef DUAL_INTERFACE
  223. if ((SetupPkt.wIndex & 0xff) == INTF1_NUMBER)
  224. {
  225. inPipes[0].pSrc.bRam = (BYTE*)&TestType_INTF1; // Set Source
  226. inPipes[0].info.bits.ctrl_trf_mem = USB_EP0_RAM; // Set memory type
  227. inPipes[0].wCount.v[0] = 1; // Set data count
  228. inPipes[0].info.bits.busy = 1;
  229. }
  230. else
  231. #endif
  232. {
  233. inPipes[0].pSrc.bRam = (BYTE*)&TestType_INTF0; // Set Source
  234. inPipes[0].info.bits.ctrl_trf_mem = USB_EP0_RAM; // Set memory type
  235. inPipes[0].wCount.v[0] = 1; // Set data count
  236. inPipes[0].info.bits.busy = 1;
  237. }
  238. break;
  239. #if defined(VENDOR_BUFFER_ENABLED)
  240. case PICFW_SET_VENDOR_BUFFER:
  241. PicFWSetVendorBufferHandler();
  242. break;
  243. case PICFW_GET_VENDOR_BUFFER:
  244. #if defined(DESCRIPTOR_COUNTING_ENABLED)
  245. VendorBuffer[0]=gDeviceDescriptorCount;
  246. VendorBuffer[1]=gConfigDescriptorCount;
  247. #endif
  248. inPipes[0].pSrc.bRam = VendorBuffer; // Set Source
  249. inPipes[0].info.bits.ctrl_trf_mem = USB_EP0_RAM; // Set memory type
  250. // Set data count
  251. inPipes[0].wCount.v[0] = SetupPkt.wLength & 0xFF;
  252. if (inPipes[0].wCount.v[0] > sizeof(VendorBuffer))
  253. inPipes[0].wCount.v[0]=sizeof(VendorBuffer);
  254. inPipes[0].info.bits.busy = 1;
  255. break;
  256. #endif
  257. default:
  258. break;
  259. }//end switch
  260. } // EndOf USBCBCheckOtherReq
  261. void USBCBStdSetDscHandler(void)
  262. {
  263. #if defined(VENDOR_BUFFER_ENABLED)
  264. if(SetupPkt.bDescriptorType == USB_DESCRIPTOR_STRING && SetupPkt.bDscIndex == 0x55)
  265. {
  266. PicFWSetVendorBufferHandler();
  267. }//end if
  268. #endif
  269. } // EndOf USBCBStdSetDscHandler
  270. #if defined(WITH_SERIAL_DEBUG)
  271. void SerialDbg_Init(void)
  272. {
  273. OpenUSART(USART_TX_INT_OFF &
  274. USART_RX_INT_OFF &
  275. USART_ASYNCH_MODE &
  276. USART_EIGHT_BIT &
  277. USART_CONT_RX &
  278. USART_BRGH_HIGH,
  279. CLOCK_FREQ*10/BAUDRATE/64 - 2);
  280. printf("Benchmark Firmware initializing...\r\n");
  281. }
  282. #endif
  283. void Benchmark_Init(void)
  284. {
  285. mBenchMarkInit(INTF0);
  286. #ifdef DUAL_INTERFACE
  287. mBenchMarkInit(INTF1);
  288. #endif
  289. }//end UserInit
  290. void fillBuffer(BYTE* pBuffer, WORD size)
  291. {
  292. BYTE dataByte = 0;
  293. for (counter=0; counter < size; counter++)
  294. {
  295. pBuffer[counter] = dataByte++;
  296. if (dataByte == 0) dataByte++;
  297. }
  298. }
  299. void Benchmark_ProcessIO(void)
  300. {
  301. //Blink the LEDs according to the USB device status, but only do so if the PC application isn't connected and controlling the LEDs.
  302. BlinkUSBStatus();
  303. //Don't attempt to read/write over the USB until after the device has been fully enumerated.
  304. if((USBDeviceState < CONFIGURED_STATE)||(USBSuspendControl==1))
  305. {
  306. Benchmark_Init();
  307. return;
  308. }
  309. if (TestType_INTF0!=PrevTestType_INTF0)
  310. {
  311. FillCount_INTF0=0;
  312. NextPacketKey_INTF0=0;
  313. PrevTestType_INTF0=TestType_INTF0;
  314. }
  315. switch(TestType_INTF0)
  316. {
  317. case TEST_PCREAD:
  318. doBenchmarkWrite_INTF0();
  319. break;
  320. case TEST_PCWRITE:
  321. doBenchmarkRead_INTF0();
  322. break;
  323. case TEST_LOOP:
  324. doBenchmarkLoop_INTF0();
  325. break;
  326. default:
  327. doBenchmarkRead_INTF0();
  328. break;
  329. }
  330. #ifdef DUAL_INTERFACE
  331. if (TestType_INTF1!=PrevTestType_INTF1)
  332. {
  333. FillCount_INTF1=0;
  334. NextPacketKey_INTF1=0;
  335. PrevTestType_INTF1=TestType_INTF1;
  336. }
  337. switch(TestType_INTF1)
  338. {
  339. case TEST_PCREAD:
  340. doBenchmarkWrite_INTF1();
  341. break;
  342. case TEST_PCWRITE:
  343. doBenchmarkRead_INTF1();
  344. break;
  345. case TEST_LOOP:
  346. doBenchmarkLoop_INTF1();
  347. break;
  348. default:
  349. doBenchmarkRead_INTF1();
  350. break;
  351. }
  352. #endif
  353. }//end Benchmark_ProcessIO
  354. void doBenchmarkWrite_INTF0(void)
  355. {
  356. WORD Length;
  357. BYTE* pBufferTx;
  358. if (!USBHandleBusy(pBdtTxEp1))
  359. {
  360. #if defined(SINGLE_INTERFACE_WITH_ALTSETTINGS)
  361. Length=(USBAlternateInterface[INTF0_NUMBER]==1) ? USBGEN_EP_SIZE_INTF0_ALT1 : USBGEN_EP_SIZE_INTF0_ALT0;
  362. #else
  363. Length=USBGEN_EP_SIZE_INTF0;
  364. #endif
  365. pBufferTx = USBHandleGetAddr(pBdtTxEp1);
  366. mSetWritePacketID(pBufferTx, Length, FillCount_INTF0, NextPacketKey_INTF0);
  367. mBDT_FillTransfer(pBdtTxEp1, pBufferTx, Length);
  368. mSubmitTransfer_INTF0(pBdtTxEp1, Length);
  369. mBDT_TogglePP(pBdtTxEp1);
  370. }
  371. }
  372. void doBenchmarkLoop_INTF0(void)
  373. {
  374. WORD Length;
  375. BYTE* pBufferRx;
  376. BYTE* pBufferTx;
  377. if (!USBHandleBusy(pBdtRxEp1) && !USBHandleBusy(pBdtTxEp1))
  378. {
  379. pBufferTx = USBHandleGetAddr(pBdtRxEp1);
  380. pBufferRx = USBHandleGetAddr(pBdtTxEp1);
  381. #if INTF0==EP_ISO
  382. #if defined(SINGLE_INTERFACE_WITH_ALTSETTINGS)
  383. Length=(USBAlternateInterface[INTF0_NUMBER]==1) ? USBGEN_EP_SIZE_INTF0_ALT1 : USBGEN_EP_SIZE_INTF0_ALT0;
  384. #else
  385. Length=USBGEN_EP_SIZE_INTF0;
  386. #endif
  387. #else
  388. Length = mBDT_GetLength(pBdtRxEp1);
  389. #endif
  390. mBDT_FillTransfer(pBdtTxEp1, pBufferTx, Length);
  391. mSubmitTransfer_INTF0(pBdtTxEp1, Length);
  392. mBDT_TogglePP(pBdtTxEp1);
  393. #if defined(SINGLE_INTERFACE_WITH_ALTSETTINGS)
  394. Length=(USBAlternateInterface[INTF0_NUMBER]==1) ? USBGEN_EP_SIZE_INTF0_ALT1 : USBGEN_EP_SIZE_INTF0_ALT0;
  395. #else
  396. Length=USBGEN_EP_SIZE_INTF0;
  397. #endif
  398. mBDT_FillTransfer(pBdtRxEp1, pBufferRx, Length);
  399. mSubmitTransfer_INTF0(pBdtRxEp1, Length);
  400. mBDT_TogglePP(pBdtRxEp1);
  401. }
  402. }
  403. void doBenchmarkRead_INTF0(void)
  404. {
  405. WORD Length;
  406. BYTE* pBufferRx;
  407. if (!USBHandleBusy(pBdtRxEp1))
  408. {
  409. #if defined(SINGLE_INTERFACE_WITH_ALTSETTINGS)
  410. Length=(USBAlternateInterface[INTF0_NUMBER]==1) ? USBGEN_EP_SIZE_INTF0_ALT1 : USBGEN_EP_SIZE_INTF0_ALT0;
  411. #else
  412. Length=USBGEN_EP_SIZE_INTF0;
  413. #endif
  414. pBufferRx = USBHandleGetAddr(pBdtRxEp1);
  415. mBDT_FillTransfer(pBdtRxEp1, pBufferRx, Length);
  416. mSubmitTransfer_INTF0(pBdtRxEp1, Length);
  417. mBDT_TogglePP(pBdtRxEp1);
  418. }
  419. }
  420. #ifdef DUAL_INTERFACE
  421. void doBenchmarkWrite_INTF1(void)
  422. {
  423. BYTE* pBufferTx;
  424. if (!USBHandleBusy(pBdtTxEp2))
  425. {
  426. pBufferTx = USBHandleGetAddr(pBdtTxEp2);
  427. mSetWritePacketID(pBufferTx, USBGEN_EP_SIZE_INTF1, FillCount_INTF1, NextPacketKey_INTF1);
  428. mBDT_FillTransfer(pBdtTxEp2, pBufferTx, USBGEN_EP_SIZE_INTF1);
  429. mSubmitTransfer_INTF1(pBdtTxEp2, USBGEN_EP_SIZE_INTF1);
  430. mBDT_TogglePP(pBdtTxEp2);
  431. }
  432. }
  433. void doBenchmarkLoop_INTF1(void)
  434. {
  435. WORD Length;
  436. BYTE* pBufferRx;
  437. BYTE* pBufferTx;
  438. if (!USBHandleBusy(pBdtRxEp2) && !USBHandleBusy(pBdtTxEp2))
  439. {
  440. pBufferTx = USBHandleGetAddr(pBdtRxEp2);
  441. pBufferRx = USBHandleGetAddr(pBdtTxEp2);
  442. #if INTF1==EP_ISO
  443. Length = USBGEN_EP_SIZE_INTF1;
  444. #else
  445. Length = mBDT_GetLength(pBdtRxEp2);
  446. #endif
  447. mBDT_FillTransfer(pBdtTxEp2, pBufferTx, Length);
  448. mSubmitTransfer_INTF1(pBdtTxEp2, Length);
  449. mBDT_TogglePP(pBdtTxEp2);
  450. mBDT_FillTransfer(pBdtRxEp2, pBufferRx, USBGEN_EP_SIZE_INTF1);
  451. mSubmitTransfer_INTF1(pBdtRxEp2, USBGEN_EP_SIZE_INTF1);
  452. mBDT_TogglePP(pBdtRxEp2);
  453. }
  454. }
  455. void doBenchmarkRead_INTF1(void)
  456. {
  457. BYTE* pBufferRx;
  458. if (!USBHandleBusy(pBdtRxEp2))
  459. {
  460. pBufferRx = USBHandleGetAddr(pBdtRxEp2);
  461. mBDT_FillTransfer(pBdtRxEp2, pBufferRx, USBGEN_EP_SIZE_INTF1);
  462. mSubmitTransfer_INTF1(pBdtRxEp2, USBGEN_EP_SIZE_INTF1);
  463. mBDT_TogglePP(pBdtRxEp2);
  464. }
  465. }
  466. #endif