usbd_composite.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543
  1. /**
  2. ******************************************************************************
  3. * @attention
  4. *
  5. * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
  6. *
  7. * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
  8. * You may not use this file except in compliance with the License.
  9. * You may obtain a copy of the License at:
  10. *
  11. * http://www.st.com/software_license_agreement_liberty_v2
  12. *
  13. * Unless required by applicable law or agreed to in writing, software
  14. * distributed under the License is distributed on an "AS IS" BASIS,
  15. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  16. * See the License for the specific language governing permissions and
  17. * limitations under the License.
  18. *
  19. ******************************************************************************
  20. */
  21. /* Includes ------------------------------------------------------------------*/
  22. #include "usbd_composite.h"
  23. #include "usbd_hid.h"
  24. #include "usbd_msc.h"
  25. #include "usbd_desc.h"
  26. #include "usbd_ctlreq.h"
  27. #define MSC_MAX_FS_PACKET 64
  28. #define MSC_MAX_HS_PACKET 512
  29. // Support 2 USB devices.
  30. #ifdef S2S_USB_FS
  31. __ALIGN_BEGIN static USBD_CompositeClassData fsClassData __ALIGN_END;
  32. #endif
  33. #ifdef S2S_USB_HS
  34. __ALIGN_BEGIN static USBD_CompositeClassData hsClassData __ALIGN_END;
  35. #endif
  36. static uint8_t USBD_Composite_Init (USBD_HandleTypeDef *pdev, uint8_t cfgidx);
  37. static uint8_t USBD_Composite_DeInit (USBD_HandleTypeDef *pdev, uint8_t cfgidx);
  38. static uint8_t USBD_Composite_Setup (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
  39. static uint8_t *USBD_Composite_GetHSCfgDesc (uint16_t *length);
  40. static uint8_t *USBD_Composite_GetFSCfgDesc (uint16_t *length);
  41. static uint8_t *USBD_Composite_GetDeviceQualifierDesc (uint16_t *length);
  42. static uint8_t USBD_Composite_DataIn (USBD_HandleTypeDef *pdev, uint8_t epnum);
  43. static uint8_t USBD_Composite_DataOut (USBD_HandleTypeDef *pdev, uint8_t epnum);
  44. USBD_ClassTypeDef USBD_Composite =
  45. {
  46. USBD_Composite_Init,
  47. USBD_Composite_DeInit,
  48. USBD_Composite_Setup,
  49. NULL, /*EP0_TxSent*/
  50. NULL, /*EP0_RxReady*/
  51. USBD_Composite_DataIn, /*DataIn*/
  52. USBD_Composite_DataOut, /*DataOut*/
  53. NULL, /*SOF */
  54. NULL,
  55. NULL,
  56. USBD_Composite_GetHSCfgDesc,
  57. USBD_Composite_GetFSCfgDesc,
  58. USBD_Composite_GetFSCfgDesc, // "Other" speed
  59. USBD_Composite_GetDeviceQualifierDesc,
  60. };
  61. __ALIGN_BEGIN static uint8_t USBD_Composite_CfgHSDesc[USB_COMPOSITE_CONFIG_DESC_SIZ] __ALIGN_END =
  62. {
  63. 0x09, /* bLength: Configuration Descriptor size */
  64. USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
  65. USB_COMPOSITE_CONFIG_DESC_SIZ,
  66. /* wTotalLength: Bytes returned */
  67. 0x00,
  68. 0x02, /*bNumInterfaces: 1 interface*/
  69. 0x01, /*bConfigurationValue: Configuration value*/
  70. 0x00, /*iConfiguration: Index of string descriptor describing
  71. the configuration*/
  72. 0x80, /*bmAttributes: bus powered */
  73. 0xFA, /*MaxPower 500 mA: this current is used for detecting Vbus*/
  74. /************** Descriptor of GENERIC interface ****************/
  75. /* 09 */
  76. 0x09, /*bLength: Interface Descriptor size*/
  77. USB_DESC_TYPE_INTERFACE,/*bDescriptorType: Interface descriptor type*/
  78. 0x00, /*bInterfaceNumber: Number of Interface*/
  79. 0x00, /*bAlternateSetting: Alternate setting*/
  80. 0x02, /*bNumEndpoints*/
  81. 0x03, /*bInterfaceClass: HID*/
  82. 0x00, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
  83. 0x00, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
  84. 0, /*iInterface: Index of string descriptor*/
  85. /******************** Descriptor of GENERIC HID ********************/
  86. /* 18 */
  87. 0x09, /*bLength: HID Descriptor size*/
  88. HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/
  89. 0x11, /*bcdHID: HID Class Spec release number*/
  90. 0x01,
  91. 0x00, /*bCountryCode: Hardware target country*/
  92. 0x01, /*bNumDescriptors: Number of HID class descriptors to follow*/
  93. 0x22, /*bDescriptorType*/
  94. HID_GENERIC_REPORT_DESC_SIZE,/*wItemLength: Total length of Report descriptor*/
  95. 0x00,
  96. /******************** Descriptor of Generic HID endpoint ********************/
  97. /* 27 */
  98. 0x07, /*bLength: Endpoint Descriptor size*/
  99. USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/
  100. HID_EPIN_ADDR, /*bEndpointAddress: Endpoint Address (IN)*/
  101. 0x03, /*bmAttributes: Interrupt endpoint*/
  102. HID_EPIN_SIZE, /*wMaxPacketSize: 64 Byte max */
  103. 0x00,
  104. HID_HS_BINTERVAL, /*bInterval*/
  105. /* 34 */
  106. /******************** Descriptor of GENERIC HID endpoint ********************/
  107. /* 34 */
  108. 0x07, /*bLength: Endpoint Descriptor size*/
  109. USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/
  110. HID_EPOUT_ADDR, /*bEndpointAddress: Endpoint Address (OUT)*/
  111. 0x03, /*bmAttributes: Interrupt endpoint*/
  112. HID_EPOUT_SIZE, /*wMaxPacketSize */
  113. 0x00,
  114. HID_HS_BINTERVAL, /*bInterval*/
  115. /* 41 */
  116. /******************** Mass Storage interface ********************/
  117. 0x09, /* bLength: Interface Descriptor size */
  118. USB_DESC_TYPE_INTERFACE, /* bDescriptorType: */
  119. 0x01, /* bInterfaceNumber: Number of Interface */
  120. 0x00, /* bAlternateSetting: Alternate setting */
  121. 0x02, /* bNumEndpoints*/
  122. 0x08, /* bInterfaceClass: MSC Class */
  123. 0x06, /* bInterfaceSubClass : SCSI transparent*/
  124. 0x50, /* nInterfaceProtocol */
  125. 0x00, /* iInterface: */
  126. /******************** Mass Storage Endpoints ********************/
  127. 0x07, /*Endpoint descriptor length = 7*/
  128. 0x05, /*Endpoint descriptor type */
  129. MSC_EPIN_ADDR, /*Endpoint address */
  130. 0x02, /*Bulk endpoint type */
  131. LOBYTE(MSC_MAX_HS_PACKET),
  132. HIBYTE(MSC_MAX_HS_PACKET),
  133. 0x00, /*Polling interval in milliseconds */
  134. 0x07, /*Endpoint descriptor length = 7 */
  135. 0x05, /*Endpoint descriptor type */
  136. MSC_EPOUT_ADDR, /*Endpoint address */
  137. 0x02, /*Bulk endpoint type */
  138. LOBYTE(MSC_MAX_HS_PACKET),
  139. HIBYTE(MSC_MAX_HS_PACKET),
  140. 0x00 /*Polling interval in milliseconds*/
  141. };
  142. __ALIGN_BEGIN static uint8_t USBD_Composite_CfgFSDesc[USB_COMPOSITE_CONFIG_DESC_SIZ] __ALIGN_END =
  143. {
  144. 0x09, /* bLength: Configuration Descriptor size */
  145. USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
  146. USB_COMPOSITE_CONFIG_DESC_SIZ,
  147. /* wTotalLength: Bytes returned */
  148. 0x00,
  149. 0x02, /*bNumInterfaces: 1 interface*/
  150. 0x01, /*bConfigurationValue: Configuration value*/
  151. 0x00, /*iConfiguration: Index of string descriptor describing
  152. the configuration*/
  153. 0x80, /*bmAttributes: bus powered */
  154. 0xFA, /*MaxPower 500 mA: this current is used for detecting Vbus*/
  155. /************** Descriptor of GENERIC interface ****************/
  156. /* 09 */
  157. 0x09, /*bLength: Interface Descriptor size*/
  158. USB_DESC_TYPE_INTERFACE,/*bDescriptorType: Interface descriptor type*/
  159. 0x00, /*bInterfaceNumber: Number of Interface*/
  160. 0x00, /*bAlternateSetting: Alternate setting*/
  161. 0x02, /*bNumEndpoints*/
  162. 0x03, /*bInterfaceClass: HID*/
  163. 0x00, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
  164. 0x00, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
  165. 0, /*iInterface: Index of string descriptor*/
  166. /******************** Descriptor of GENERIC HID ********************/
  167. /* 18 */
  168. 0x09, /*bLength: HID Descriptor size*/
  169. HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/
  170. 0x11, /*bcdHID: HID Class Spec release number*/
  171. 0x01,
  172. 0x00, /*bCountryCode: Hardware target country*/
  173. 0x01, /*bNumDescriptors: Number of HID class descriptors to follow*/
  174. 0x22, /*bDescriptorType*/
  175. HID_GENERIC_REPORT_DESC_SIZE,/*wItemLength: Total length of Report descriptor*/
  176. 0x00,
  177. /******************** Descriptor of Generic HID endpoint ********************/
  178. /* 27 */
  179. 0x07, /*bLength: Endpoint Descriptor size*/
  180. USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/
  181. HID_EPIN_ADDR, /*bEndpointAddress: Endpoint Address (IN)*/
  182. 0x03, /*bmAttributes: Interrupt endpoint*/
  183. HID_EPIN_SIZE, /*wMaxPacketSize: 64 Byte max */
  184. 0x00,
  185. HID_FS_BINTERVAL, /*bInterval*/
  186. /* 34 */
  187. /******************** Descriptor of GENERIC HID endpoint ********************/
  188. /* 34 */
  189. 0x07, /*bLength: Endpoint Descriptor size*/
  190. USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/
  191. HID_EPOUT_ADDR, /*bEndpointAddress: Endpoint Address (OUT)*/
  192. 0x03, /*bmAttributes: Interrupt endpoint*/
  193. HID_EPOUT_SIZE, /*wMaxPacketSize */
  194. 0x00,
  195. HID_FS_BINTERVAL, /*bInterval*/
  196. /* 41 */
  197. /******************** Mass Storage interface ********************/
  198. 0x09, /* bLength: Interface Descriptor size */
  199. USB_DESC_TYPE_INTERFACE, /* bDescriptorType: */
  200. 0x01, /* bInterfaceNumber: Number of Interface */
  201. 0x00, /* bAlternateSetting: Alternate setting */
  202. 0x02, /* bNumEndpoints*/
  203. 0x08, /* bInterfaceClass: MSC Class */
  204. 0x06, /* bInterfaceSubClass : SCSI transparent*/
  205. 0x50, /* nInterfaceProtocol */
  206. 0x00, /* iInterface: */
  207. /******************** Mass Storage Endpoints ********************/
  208. 0x07, /*Endpoint descriptor length = 7*/
  209. 0x05, /*Endpoint descriptor type */
  210. MSC_EPIN_ADDR, /*Endpoint address */
  211. 0x02, /*Bulk endpoint type */
  212. LOBYTE(MSC_MAX_FS_PACKET),
  213. HIBYTE(MSC_MAX_FS_PACKET),
  214. 0x00, /*Polling interval in milliseconds */
  215. 0x07, /*Endpoint descriptor length = 7 */
  216. 0x05, /*Endpoint descriptor type */
  217. MSC_EPOUT_ADDR, /*Endpoint address */
  218. 0x02, /*Bulk endpoint type */
  219. LOBYTE(MSC_MAX_FS_PACKET),
  220. HIBYTE(MSC_MAX_FS_PACKET),
  221. 0x00 /*Polling interval in milliseconds*/
  222. } ;
  223. /* USB Standard Device Descriptor */
  224. __ALIGN_BEGIN static uint8_t USBD_Composite_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END =
  225. {
  226. USB_LEN_DEV_QUALIFIER_DESC,
  227. USB_DESC_TYPE_DEVICE_QUALIFIER,
  228. 0x00,
  229. 0x02,
  230. 0x00,
  231. 0x00,
  232. 0x00,
  233. MSC_MAX_FS_PACKET,
  234. 0x01,
  235. 0x00,
  236. };
  237. static uint8_t USBD_Composite_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
  238. {
  239. uint8_t ret = 0;
  240. // HID Endpoints
  241. USBD_LL_OpenEP(pdev, HID_EPIN_ADDR, USBD_EP_TYPE_INTR, HID_EPIN_SIZE);
  242. USBD_LL_OpenEP(pdev, HID_EPOUT_ADDR, USBD_EP_TYPE_INTR, HID_EPOUT_SIZE);
  243. USBD_CompositeClassData* classData;
  244. #ifdef S2S_USB_HS
  245. if(pdev->dev_speed == USBD_SPEED_HIGH)
  246. {
  247. classData = &hsClassData;
  248. // MSC Endpoints
  249. USBD_LL_OpenEP(pdev, MSC_EPOUT_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_HS_PACKET);
  250. USBD_LL_OpenEP(pdev, MSC_EPIN_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_HS_PACKET);
  251. }
  252. #endif
  253. #ifdef S2S_USB_FS
  254. if(pdev->dev_speed != USBD_SPEED_HIGH)
  255. {
  256. classData = &fsClassData;
  257. // MSC Endpoints
  258. USBD_LL_OpenEP(pdev, MSC_EPOUT_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_FS_PACKET);
  259. USBD_LL_OpenEP(pdev, MSC_EPIN_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_FS_PACKET);
  260. }
  261. #endif
  262. classData->hid.state = HID_IDLE;
  263. classData->hid.reportReady = 0;
  264. classData->DataInReady = 0;
  265. classData->DataOutReady = 0;
  266. pdev->pClassData = classData;
  267. MSC_BOT_Init(pdev);
  268. // Prepare Out endpoint to receive next HID packet
  269. USBD_LL_PrepareReceive(
  270. pdev,
  271. HID_EPOUT_ADDR,
  272. classData->hid.rxBuffer,
  273. sizeof(classData->hid.rxBuffer));
  274. return ret;
  275. }
  276. static uint8_t USBD_Composite_DeInit (USBD_HandleTypeDef *pdev, uint8_t cfgidx)
  277. {
  278. USBD_LL_CloseEP(pdev, HID_EPIN_ADDR);
  279. USBD_LL_CloseEP(pdev, HID_EPOUT_ADDR);
  280. USBD_LL_CloseEP(pdev, MSC_EPOUT_ADDR);
  281. USBD_LL_CloseEP(pdev, MSC_EPIN_ADDR);
  282. MSC_BOT_DeInit(pdev);
  283. pdev->pClassData = NULL;
  284. return USBD_OK;
  285. }
  286. static uint8_t USBD_Composite_Setup(
  287. USBD_HandleTypeDef *pdev,
  288. USBD_SetupReqTypedef *req)
  289. {
  290. uint16_t len = 0;
  291. uint8_t *pbuf = NULL;
  292. USBD_CompositeClassData *classData = (USBD_CompositeClassData*) pdev->pClassData;
  293. USBD_HID_HandleTypeDef *hhid = &(classData->hid);
  294. USBD_MSC_BOT_HandleTypeDef *hmsc = &(classData->msc);
  295. switch (req->bmRequest & USB_REQ_TYPE_MASK)
  296. {
  297. case USB_REQ_TYPE_CLASS :
  298. switch (req->bRequest)
  299. {
  300. case HID_REQ_SET_PROTOCOL:
  301. hhid->Protocol = (uint8_t)(req->wValue);
  302. break;
  303. case HID_REQ_GET_PROTOCOL:
  304. USBD_CtlSendData (pdev, (uint8_t *)&hhid->Protocol, 1);
  305. break;
  306. case HID_REQ_SET_IDLE:
  307. hhid->IdleState = (uint8_t)(req->wValue >> 8);
  308. break;
  309. case HID_REQ_GET_IDLE:
  310. USBD_CtlSendData (pdev, (uint8_t *)&hhid->IdleState, 1);
  311. break;
  312. case BOT_GET_MAX_LUN :
  313. if((req->wValue == 0) &&
  314. (req->wLength == 1) &&
  315. ((req->bmRequest & 0x80) == 0x80))
  316. {
  317. hmsc->max_lun = ((USBD_StorageTypeDef *)pdev->pUserData)->GetMaxLun();
  318. USBD_CtlSendData (pdev, (uint8_t *)&hmsc->max_lun, 1);
  319. }
  320. else
  321. {
  322. USBD_CtlError(pdev , req);
  323. return USBD_FAIL;
  324. }
  325. break;
  326. case BOT_RESET :
  327. if((req->wValue == 0) &&
  328. (req->wLength == 0) &&
  329. ((req->bmRequest & 0x80) != 0x80))
  330. {
  331. MSC_BOT_Reset(pdev);
  332. }
  333. else
  334. {
  335. USBD_CtlError(pdev , req);
  336. return USBD_FAIL;
  337. }
  338. break;
  339. default:
  340. USBD_CtlError (pdev, req);
  341. return USBD_FAIL;
  342. } break;
  343. case USB_REQ_TYPE_STANDARD:
  344. switch (req->bRequest)
  345. {
  346. case USB_REQ_GET_DESCRIPTOR:
  347. if( req->wValue >> 8 == HID_REPORT_DESC)
  348. {
  349. len = MIN(HID_GENERIC_REPORT_DESC_SIZE , req->wLength);
  350. pbuf = (uint8_t*) USBD_HID_GetReportDesc();
  351. }
  352. else if( req->wValue >> 8 == HID_DESCRIPTOR_TYPE)
  353. {
  354. pbuf = (uint8_t*) USBD_HID_GetDesc();
  355. len = MIN(USB_HID_DESC_SIZ , req->wLength);
  356. }
  357. USBD_CtlSendData (pdev, pbuf, len);
  358. break;
  359. case USB_REQ_GET_INTERFACE :
  360. if (req->wIndex == 0)
  361. {
  362. USBD_CtlSendData (pdev, (uint8_t *)&hhid->AltSetting, 1);
  363. }
  364. else
  365. {
  366. USBD_CtlSendData (pdev, (uint8_t *)&hmsc->interface, 1);
  367. }
  368. break;
  369. case USB_REQ_SET_INTERFACE :
  370. if (req->wIndex == 0)
  371. {
  372. hhid->AltSetting = (uint8_t)(req->wValue);
  373. }
  374. else
  375. {
  376. hmsc->interface = (uint8_t)(req->wValue);
  377. }
  378. break;
  379. case USB_REQ_CLEAR_FEATURE:
  380. /* Flush the FIFO and Clear the stall status */
  381. USBD_LL_FlushEP(pdev, (uint8_t)req->wIndex);
  382. /* Reactivate the EP */
  383. USBD_LL_CloseEP (pdev , (uint8_t)req->wIndex);
  384. switch ((uint8_t)req->wIndex)
  385. {
  386. case MSC_EPIN_ADDR:
  387. USBD_LL_OpenEP(
  388. pdev,
  389. MSC_EPIN_ADDR,
  390. USBD_EP_TYPE_BULK,
  391. pdev->dev_speed == USBD_SPEED_HIGH ? MSC_MAX_HS_PACKET : MSC_MAX_FS_PACKET);
  392. break;
  393. case MSC_EPOUT_ADDR:
  394. USBD_LL_OpenEP(
  395. pdev,
  396. MSC_EPOUT_ADDR,
  397. USBD_EP_TYPE_BULK,
  398. pdev->dev_speed == USBD_SPEED_HIGH ? MSC_MAX_HS_PACKET : MSC_MAX_FS_PACKET);
  399. break;
  400. case HID_EPIN_ADDR:
  401. USBD_LL_OpenEP(pdev, HID_EPIN_ADDR, USBD_EP_TYPE_INTR, HID_EPIN_SIZE);
  402. break;
  403. case HID_EPOUT_ADDR:
  404. USBD_LL_OpenEP(pdev, HID_EPOUT_ADDR, USBD_EP_TYPE_INTR, HID_EPOUT_SIZE);
  405. break;
  406. }
  407. /* Handle BOT error */
  408. MSC_BOT_CplClrFeature(pdev, (uint8_t)req->wIndex);
  409. break;
  410. } break;
  411. }
  412. return USBD_OK;
  413. }
  414. static uint8_t USBD_Composite_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
  415. {
  416. USBD_CompositeClassData *classData = (USBD_CompositeClassData*) pdev->pClassData;
  417. if (epnum == (HID_EPIN_ADDR & 0x7F))
  418. {
  419. USBD_HID_HandleTypeDef *hhid = &(classData->hid);
  420. /* Ensure that the FIFO is empty before a new transfer, this condition could
  421. be caused by a new transfer before the end of the previous transfer */
  422. hhid->state = HID_IDLE;
  423. }
  424. else if (epnum == (MSC_EPIN_ADDR & 0x7F))
  425. {
  426. classData->DataInReady = epnum;
  427. }
  428. return USBD_OK;
  429. }
  430. static uint8_t USBD_Composite_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)
  431. {
  432. USBD_CompositeClassData *classData = (USBD_CompositeClassData*) pdev->pClassData;
  433. if (epnum == (HID_EPOUT_ADDR & 0x7F))
  434. {
  435. USBD_HID_HandleTypeDef *hhid = &(classData->hid);
  436. hhid->reportReady = 1;
  437. }
  438. else if (epnum == (MSC_EPOUT_ADDR & 0x7F))
  439. {
  440. classData->DataOutReady = epnum;
  441. }
  442. return USBD_OK;
  443. }
  444. void s2s_usbDevicePoll(USBD_HandleTypeDef *pdev) {
  445. USBD_CompositeClassData *classData = (USBD_CompositeClassData*) pdev->pClassData;
  446. if (classData->DataInReady)
  447. {
  448. classData->DataInReady = 0;
  449. MSC_BOT_DataIn(pdev);
  450. }
  451. if (classData->DataOutReady)
  452. {
  453. classData->DataOutReady = 0;
  454. MSC_BOT_DataOut(pdev);
  455. }
  456. }
  457. static uint8_t *USBD_Composite_GetDeviceQualifierDesc (uint16_t *length)
  458. {
  459. *length = sizeof (USBD_Composite_DeviceQualifierDesc);
  460. return USBD_Composite_DeviceQualifierDesc;
  461. }
  462. uint8_t *USBD_Composite_GetHSCfgDesc (uint16_t *length)
  463. {
  464. *length = sizeof (USBD_Composite_CfgHSDesc);
  465. return USBD_Composite_CfgHSDesc;
  466. }
  467. uint8_t *USBD_Composite_GetFSCfgDesc (uint16_t *length)
  468. {
  469. *length = sizeof (USBD_Composite_CfgFSDesc);
  470. return USBD_Composite_CfgFSDesc;
  471. }