usb_device_descriptor.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482
  1. /*
  2. * The Clear BSD License
  3. * Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
  4. * Copyright 2016-2017 NXP
  5. * All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without modification,
  8. * are permitted (subject to the limitations in the disclaimer below) provided
  9. * that the following conditions are met:
  10. *
  11. * o Redistributions of source code must retain the above copyright notice, this list
  12. * of conditions and the following disclaimer.
  13. *
  14. * o Redistributions in binary form must reproduce the above copyright notice, this
  15. * list of conditions and the following disclaimer in the documentation and/or
  16. * other materials provided with the distribution.
  17. *
  18. * o Neither the name of the copyright holder nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
  23. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  24. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  25. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  26. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
  27. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  28. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  29. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  30. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  32. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. */
  34. #include "usb_device_config.h"
  35. #include "usb.h"
  36. #include "usb_device.h"
  37. #include "usb_device_cdc_acm.h"
  38. #include "usb_device_descriptor.h"
  39. /*******************************************************************************
  40. * Variables
  41. ******************************************************************************/
  42. uint8_t g_currentConfigure = 0;
  43. uint8_t g_interface[USB_CDC_VCOM_INTERFACE_COUNT];
  44. /* Define device descriptor */
  45. uint8_t g_UsbDeviceDescriptor[USB_DESCRIPTOR_LENGTH_DEVICE] = {
  46. /* Size of this descriptor in bytes */
  47. USB_DESCRIPTOR_LENGTH_DEVICE,
  48. /* DEVICE Descriptor Type */
  49. USB_DESCRIPTOR_TYPE_DEVICE,
  50. /* USB Specification Release Number in Binary-Coded Decimal (i.e., 2.10 is 210H). */
  51. USB_SHORT_GET_LOW(USB_DEVICE_SPECIFIC_BCD_VERSION), USB_SHORT_GET_HIGH(USB_DEVICE_SPECIFIC_BCD_VERSION),
  52. /* Class code (assigned by the USB-IF). */
  53. USB_DEVICE_CLASS,
  54. /* Subclass code (assigned by the USB-IF). */
  55. USB_DEVICE_SUBCLASS,
  56. /* Protocol code (assigned by the USB-IF). */
  57. USB_DEVICE_PROTOCOL,
  58. /* Maximum packet size for endpoint zero (only 8, 16, 32, or 64 are valid) */
  59. USB_CONTROL_MAX_PACKET_SIZE,
  60. /* Vendor ID (assigned by the USB-IF) */
  61. 0xC9U, 0x1FU,
  62. /* Product ID (assigned by the manufacturer) */
  63. 0x94, 0x00,
  64. /* Device release number in binary-coded decimal */
  65. USB_SHORT_GET_LOW(USB_DEVICE_DEMO_BCD_VERSION), USB_SHORT_GET_HIGH(USB_DEVICE_DEMO_BCD_VERSION),
  66. /* Index of string descriptor describing manufacturer */
  67. 0x01,
  68. /* Index of string descriptor describing product */
  69. 0x02,
  70. /* Index of string descriptor describing the device's serial number */
  71. 0x00,
  72. /* Number of possible configurations */
  73. USB_DEVICE_CONFIGURATION_COUNT,
  74. };
  75. /* Define configuration descriptor */
  76. uint8_t g_UsbDeviceConfigurationDescriptor[USB_DESCRIPTOR_LENGTH_CONFIGURATION_ALL] = {
  77. /* Size of this descriptor in bytes */
  78. USB_DESCRIPTOR_LENGTH_CONFIGURE,
  79. /* CONFIGURATION Descriptor Type */
  80. USB_DESCRIPTOR_TYPE_CONFIGURE,
  81. /* Total length of data returned for this configuration. */
  82. USB_SHORT_GET_LOW(USB_DESCRIPTOR_LENGTH_CONFIGURATION_ALL),
  83. USB_SHORT_GET_HIGH(USB_DESCRIPTOR_LENGTH_CONFIGURATION_ALL),
  84. /* Number of interfaces supported by this configuration */
  85. USB_CDC_VCOM_INTERFACE_COUNT,
  86. /* Value to use as an argument to the SetConfiguration() request to select this configuration */
  87. USB_CDC_VCOM_CONFIGURE_INDEX,
  88. /* Index of string descriptor describing this configuration */
  89. 0,
  90. /* Configuration characteristics D7: Reserved (set to one) D6: Self-powered D5: Remote Wakeup D4...0: Reserved
  91. (reset to zero) */
  92. (USB_DESCRIPTOR_CONFIGURE_ATTRIBUTE_D7_MASK) |
  93. (USB_DEVICE_CONFIG_SELF_POWER << USB_DESCRIPTOR_CONFIGURE_ATTRIBUTE_SELF_POWERED_SHIFT) |
  94. (USB_DEVICE_CONFIG_REMOTE_WAKEUP << USB_DESCRIPTOR_CONFIGURE_ATTRIBUTE_REMOTE_WAKEUP_SHIFT),
  95. /* Maximum power consumption of the USB * device from the bus in this specific * configuration when the device is
  96. fully * operational. Expressed in 2 mA units * (i.e., 50 = 100 mA). */
  97. USB_DEVICE_MAX_POWER,
  98. /* Communication Interface Descriptor */
  99. USB_DESCRIPTOR_LENGTH_INTERFACE, USB_DESCRIPTOR_TYPE_INTERFACE, USB_CDC_VCOM_COMM_INTERFACE_INDEX, 0x00,
  100. USB_CDC_VCOM_ENDPOINT_CIC_COUNT, USB_CDC_VCOM_CIC_CLASS, USB_CDC_VCOM_CIC_SUBCLASS, USB_CDC_VCOM_CIC_PROTOCOL,
  101. 0x00, /* Interface Description String Index*/
  102. /* CDC Class-Specific descriptor */
  103. USB_DESCRIPTOR_LENGTH_CDC_HEADER_FUNC, /* Size of this descriptor in bytes */
  104. USB_DESCRIPTOR_TYPE_CDC_CS_INTERFACE, /* CS_INTERFACE Descriptor Type */
  105. USB_CDC_HEADER_FUNC_DESC, 0x10,
  106. 0x01, /* USB Class Definitions for Communications the Communication specification version 1.10 */
  107. USB_DESCRIPTOR_LENGTH_CDC_CALL_MANAG, /* Size of this descriptor in bytes */
  108. USB_DESCRIPTOR_TYPE_CDC_CS_INTERFACE, /* CS_INTERFACE Descriptor Type */
  109. USB_CDC_CALL_MANAGEMENT_FUNC_DESC,
  110. 0x01, /*Bit 0: Whether device handle call management itself 1, Bit 1: Whether device can send/receive call
  111. management information over a Data Class Interface 0 */
  112. 0x01, /* Indicates multiplexed commands are handled via data interface */
  113. USB_DESCRIPTOR_LENGTH_CDC_ABSTRACT, /* Size of this descriptor in bytes */
  114. USB_DESCRIPTOR_TYPE_CDC_CS_INTERFACE, /* CS_INTERFACE Descriptor Type */
  115. USB_CDC_ABSTRACT_CONTROL_FUNC_DESC,
  116. 0x06, /* Bit 0: Whether device supports the request combination of Set_Comm_Feature, Clear_Comm_Feature, and
  117. Get_Comm_Feature 0, Bit 1: Whether device supports the request combination of Set_Line_Coding,
  118. Set_Control_Line_State, Get_Line_Coding, and the notification Serial_State 1, Bit ... */
  119. USB_DESCRIPTOR_LENGTH_CDC_UNION_FUNC, /* Size of this descriptor in bytes */
  120. USB_DESCRIPTOR_TYPE_CDC_CS_INTERFACE, /* CS_INTERFACE Descriptor Type */
  121. USB_CDC_UNION_FUNC_DESC, 0x00, /* The interface number of the Communications or Data Class interface */
  122. 0x01, /* Interface number of subordinate interface in the Union */
  123. /*Notification Endpoint descriptor */
  124. USB_DESCRIPTOR_LENGTH_ENDPOINT, USB_DESCRIPTOR_TYPE_ENDPOINT, USB_CDC_VCOM_INTERRUPT_IN_ENDPOINT | (USB_IN << 7U),
  125. USB_ENDPOINT_INTERRUPT, USB_SHORT_GET_LOW(FS_CDC_VCOM_INTERRUPT_IN_PACKET_SIZE),
  126. USB_SHORT_GET_HIGH(FS_CDC_VCOM_INTERRUPT_IN_PACKET_SIZE), FS_CDC_VCOM_INTERRUPT_IN_INTERVAL,
  127. /* Data Interface Descriptor */
  128. USB_DESCRIPTOR_LENGTH_INTERFACE, USB_DESCRIPTOR_TYPE_INTERFACE, USB_CDC_VCOM_DATA_INTERFACE_INDEX, 0x00,
  129. USB_CDC_VCOM_ENDPOINT_DIC_COUNT, USB_CDC_VCOM_DIC_CLASS, USB_CDC_VCOM_DIC_SUBCLASS, USB_CDC_VCOM_DIC_PROTOCOL,
  130. 0x00, /* Interface Description String Index*/
  131. /*Bulk IN Endpoint descriptor */
  132. USB_DESCRIPTOR_LENGTH_ENDPOINT, USB_DESCRIPTOR_TYPE_ENDPOINT, USB_CDC_VCOM_BULK_IN_ENDPOINT | (USB_IN << 7U),
  133. USB_ENDPOINT_BULK, USB_SHORT_GET_LOW(FS_CDC_VCOM_BULK_IN_PACKET_SIZE),
  134. USB_SHORT_GET_HIGH(FS_CDC_VCOM_BULK_IN_PACKET_SIZE), 0x00, /* The polling interval value is every 0 Frames */
  135. /*Bulk OUT Endpoint descriptor */
  136. USB_DESCRIPTOR_LENGTH_ENDPOINT, USB_DESCRIPTOR_TYPE_ENDPOINT, USB_CDC_VCOM_BULK_OUT_ENDPOINT | (USB_OUT << 7U),
  137. USB_ENDPOINT_BULK, USB_SHORT_GET_LOW(FS_CDC_VCOM_BULK_OUT_PACKET_SIZE),
  138. USB_SHORT_GET_HIGH(FS_CDC_VCOM_BULK_OUT_PACKET_SIZE), 0x00, /* The polling interval value is every 0 Frames */
  139. };
  140. /* Define string descriptor */
  141. uint8_t g_UsbDeviceString0[USB_DESCRIPTOR_LENGTH_STRING0] = {sizeof(g_UsbDeviceString0), USB_DESCRIPTOR_TYPE_STRING,
  142. 0x09, 0x04};
  143. uint8_t g_UsbDeviceString1[USB_DESCRIPTOR_LENGTH_STRING1] = {
  144. sizeof(g_UsbDeviceString1),
  145. USB_DESCRIPTOR_TYPE_STRING,
  146. 'N',
  147. 0x00U,
  148. 'X',
  149. 0x00U,
  150. 'P',
  151. 0x00U,
  152. ' ',
  153. 0x00U,
  154. 'S',
  155. 0x00U,
  156. 'E',
  157. 0x00U,
  158. 'M',
  159. 0x00U,
  160. 'I',
  161. 0x00U,
  162. 'C',
  163. 0x00U,
  164. 'O',
  165. 0x00U,
  166. 'N',
  167. 0x00U,
  168. 'D',
  169. 0x00U,
  170. 'U',
  171. 0x00U,
  172. 'C',
  173. 0x00U,
  174. 'T',
  175. 0x00U,
  176. 'O',
  177. 0x00U,
  178. 'R',
  179. 0x00U,
  180. 'S',
  181. 0x00U,
  182. };
  183. uint8_t g_UsbDeviceString2[USB_DESCRIPTOR_LENGTH_STRING2] = {sizeof(g_UsbDeviceString2),
  184. USB_DESCRIPTOR_TYPE_STRING,
  185. 'M',
  186. 0,
  187. 'C',
  188. 0,
  189. 'U',
  190. 0,
  191. ' ',
  192. 0,
  193. 'V',
  194. 0,
  195. 'I',
  196. 0,
  197. 'R',
  198. 0,
  199. 'T',
  200. 0,
  201. 'U',
  202. 0,
  203. 'A',
  204. 0,
  205. 'L',
  206. 0,
  207. ' ',
  208. 0,
  209. 'C',
  210. 0,
  211. 'O',
  212. 0,
  213. 'M',
  214. 0,
  215. ' ',
  216. 0,
  217. 'D',
  218. 0,
  219. 'E',
  220. 0,
  221. 'M',
  222. 0,
  223. 'O',
  224. 0};
  225. uint8_t *g_UsbDeviceStringDescriptorArray[USB_DEVICE_STRING_COUNT] = {g_UsbDeviceString0, g_UsbDeviceString1,
  226. g_UsbDeviceString2};
  227. /* Define string descriptor size */
  228. uint32_t g_UsbDeviceStringDescriptorLength[USB_DEVICE_STRING_COUNT] = {
  229. sizeof(g_UsbDeviceString0), sizeof(g_UsbDeviceString1), sizeof(g_UsbDeviceString2)};
  230. usb_language_t g_UsbDeviceLanguage[USB_DEVICE_LANGUAGE_COUNT] = {{
  231. g_UsbDeviceStringDescriptorArray, g_UsbDeviceStringDescriptorLength, (uint16_t)0x0409,
  232. }};
  233. usb_language_list_t g_UsbDeviceLanguageList = {
  234. g_UsbDeviceString0, sizeof(g_UsbDeviceString0), g_UsbDeviceLanguage, USB_DEVICE_LANGUAGE_COUNT,
  235. };
  236. /*******************************************************************************
  237. * Code
  238. ******************************************************************************/
  239. /*!
  240. * @brief Get the descritpor.
  241. *
  242. * The function is used to get the descritpor, including the device descritpor, configuration descriptor, and string
  243. * descriptor, etc.
  244. *
  245. * @param handle The device handle.
  246. * @param setup The setup packet buffer address.
  247. * @param length It is an OUT parameter, return the data length need to be sent to host.
  248. * @param buffer It is an OUT parameter, return the data buffer address.
  249. *
  250. * @return A USB error code or kStatus_USB_Success.
  251. */
  252. usb_status_t USB_DeviceGetDescriptor(usb_device_handle handle,
  253. usb_setup_struct_t *setup,
  254. uint32_t *length,
  255. uint8_t **buffer)
  256. {
  257. uint8_t descriptorType = (uint8_t)((setup->wValue & 0xFF00U) >> 8U);
  258. uint8_t descriptorIndex = (uint8_t)((setup->wValue & 0x00FFU));
  259. usb_status_t ret = kStatus_USB_Success;
  260. if (USB_REQUEST_STANDARD_GET_DESCRIPTOR != setup->bRequest)
  261. {
  262. return kStatus_USB_InvalidRequest;
  263. }
  264. switch (descriptorType)
  265. {
  266. case USB_DESCRIPTOR_TYPE_STRING:
  267. {
  268. if (descriptorIndex == 0)
  269. {
  270. *buffer = (uint8_t *)g_UsbDeviceLanguageList.languageString;
  271. *length = g_UsbDeviceLanguageList.stringLength;
  272. }
  273. else
  274. {
  275. uint8_t langId = 0;
  276. uint8_t langIndex = USB_DEVICE_STRING_COUNT;
  277. for (; langId < USB_DEVICE_LANGUAGE_COUNT; langId++)
  278. {
  279. if (setup->wIndex == g_UsbDeviceLanguageList.languageList[langId].languageId)
  280. {
  281. if (descriptorIndex < USB_DEVICE_STRING_COUNT)
  282. {
  283. langIndex = descriptorIndex;
  284. }
  285. break;
  286. }
  287. }
  288. if (USB_DEVICE_STRING_COUNT == langIndex)
  289. {
  290. langId = 0;
  291. }
  292. *buffer = (uint8_t *)g_UsbDeviceLanguageList.languageList[langId].string[langIndex];
  293. *length = g_UsbDeviceLanguageList.languageList[langId].length[langIndex];
  294. }
  295. }
  296. break;
  297. case USB_DESCRIPTOR_TYPE_DEVICE:
  298. {
  299. *buffer = g_UsbDeviceDescriptor;
  300. *length = USB_DESCRIPTOR_LENGTH_DEVICE;
  301. }
  302. break;
  303. case USB_DESCRIPTOR_TYPE_CONFIGURE:
  304. {
  305. *buffer = g_UsbDeviceConfigurationDescriptor;
  306. *length = USB_DESCRIPTOR_LENGTH_CONFIGURATION_ALL;
  307. }
  308. break;
  309. default:
  310. ret = kStatus_USB_InvalidRequest;
  311. break;
  312. } /* End Switch */
  313. return ret;
  314. }
  315. /*!
  316. * @brief Set the device configuration.
  317. *
  318. * The function is used to set the device configuration.
  319. *
  320. * @param handle The device handle.
  321. * @param configure The configuration value.
  322. *
  323. * @return A USB error code or kStatus_USB_Success.
  324. */
  325. usb_status_t USB_DeviceSetConfigure(usb_device_handle handle, uint8_t configure)
  326. {
  327. if (!configure)
  328. {
  329. return kStatus_USB_Error;
  330. }
  331. g_currentConfigure = configure;
  332. return USB_DeviceCallback(handle, kUSB_DeviceEventSetConfiguration, &configure);
  333. }
  334. /*!
  335. * @brief Get the device configuration.
  336. *
  337. * The function is used to get the device configuration.
  338. *
  339. * @param handle The device handle.
  340. * @param configure It is an OUT parameter, save the current configuration value.
  341. *
  342. * @return A USB error code or kStatus_USB_Success.
  343. */
  344. usb_status_t USB_DeviceGetConfigure(usb_device_handle handle, uint8_t *configure)
  345. {
  346. *configure = g_currentConfigure;
  347. return kStatus_USB_Success;
  348. }
  349. /*!
  350. * @brief Set an interface alternate setting.
  351. *
  352. * The function is used to set an interface alternate setting.
  353. *
  354. * @param handle The device handle.
  355. * @param interface The interface index.
  356. * @param alternateSetting The new alternate setting value.
  357. *
  358. * @return A USB error code or kStatus_USB_Success.
  359. */
  360. usb_status_t USB_DeviceSetInterface(usb_device_handle handle, uint8_t interface, uint8_t alternateSetting)
  361. {
  362. g_interface[interface] = alternateSetting;
  363. return USB_DeviceCallback(handle, kUSB_DeviceEventSetInterface, &interface);
  364. }
  365. /*!
  366. * @brief Get an interface alternate setting.
  367. *
  368. * The function is used to get an interface alternate setting.
  369. *
  370. * @param handle The device handle.
  371. * @param interface The interface index.
  372. * @param alternateSetting It is an OUT parameter, save the new alternate setting value of the interface.
  373. *
  374. * @return A USB error code or kStatus_USB_Success.
  375. */
  376. usb_status_t USB_DeviceGetInterface(usb_device_handle handle, uint8_t interface, uint8_t *alternateSetting)
  377. {
  378. *alternateSetting = g_interface[interface];
  379. return kStatus_USB_Success;
  380. }
  381. /*!
  382. * @brief USB device set speed function.
  383. *
  384. * This function sets the speed of the USB device.
  385. *
  386. * Due to the difference of HS and FS descriptors, the device descriptors and configurations need to be updated to match
  387. * current speed.
  388. * As the default, the device descriptors and configurations are configured by using FS parameters for both EHCI and
  389. * KHCI.
  390. * When the EHCI is enabled, the application needs to call this fucntion to update device by using current speed.
  391. * The updated information includes endpoint max packet size, endpoint interval, etc.
  392. *
  393. * @param handle The USB device handle.
  394. * @param speed Speed type. USB_SPEED_HIGH/USB_SPEED_FULL/USB_SPEED_LOW.
  395. *
  396. * @return A USB error code or kStatus_USB_Success.
  397. */
  398. usb_status_t USB_DeviceSetSpeed(usb_device_handle handle, uint8_t speed)
  399. {
  400. usb_descriptor_union_t *ptr1;
  401. usb_descriptor_union_t *ptr2;
  402. ptr1 = (usb_descriptor_union_t *)(&g_UsbDeviceConfigurationDescriptor[0]);
  403. ptr2 = (usb_descriptor_union_t *)(&g_UsbDeviceConfigurationDescriptor[USB_DESCRIPTOR_LENGTH_CONFIGURATION_ALL - 1]);
  404. while (ptr1 < ptr2)
  405. {
  406. if (ptr1->common.bDescriptorType == USB_DESCRIPTOR_TYPE_ENDPOINT)
  407. {
  408. if (USB_CDC_VCOM_INTERRUPT_IN_ENDPOINT == (ptr1->endpoint.bEndpointAddress & 0x0FU))
  409. {
  410. if (USB_SPEED_HIGH == speed)
  411. {
  412. ptr1->endpoint.bInterval = HS_CDC_VCOM_INTERRUPT_IN_INTERVAL;
  413. USB_SHORT_TO_LITTLE_ENDIAN_ADDRESS(HS_CDC_VCOM_INTERRUPT_IN_PACKET_SIZE,
  414. ptr1->endpoint.wMaxPacketSize);
  415. }
  416. else
  417. {
  418. ptr1->endpoint.bInterval = FS_CDC_VCOM_INTERRUPT_IN_INTERVAL;
  419. USB_SHORT_TO_LITTLE_ENDIAN_ADDRESS(FS_CDC_VCOM_INTERRUPT_IN_PACKET_SIZE,
  420. ptr1->endpoint.wMaxPacketSize);
  421. }
  422. }
  423. else if (USB_CDC_VCOM_BULK_IN_ENDPOINT == (ptr1->endpoint.bEndpointAddress & 0x0FU))
  424. {
  425. if (USB_SPEED_HIGH == speed)
  426. {
  427. USB_SHORT_TO_LITTLE_ENDIAN_ADDRESS(HS_CDC_VCOM_BULK_IN_PACKET_SIZE, ptr1->endpoint.wMaxPacketSize);
  428. }
  429. else
  430. {
  431. USB_SHORT_TO_LITTLE_ENDIAN_ADDRESS(FS_CDC_VCOM_BULK_IN_PACKET_SIZE, ptr1->endpoint.wMaxPacketSize);
  432. }
  433. }
  434. else if (USB_CDC_VCOM_BULK_OUT_ENDPOINT == (ptr1->endpoint.bEndpointAddress & 0x0FU))
  435. {
  436. if (USB_SPEED_HIGH == speed)
  437. {
  438. USB_SHORT_TO_LITTLE_ENDIAN_ADDRESS(HS_CDC_VCOM_BULK_OUT_PACKET_SIZE, ptr1->endpoint.wMaxPacketSize);
  439. }
  440. else
  441. {
  442. USB_SHORT_TO_LITTLE_ENDIAN_ADDRESS(FS_CDC_VCOM_BULK_OUT_PACKET_SIZE, ptr1->endpoint.wMaxPacketSize);
  443. }
  444. }
  445. else
  446. {
  447. }
  448. }
  449. ptr1 = (usb_descriptor_union_t *)((uint8_t *)ptr1 + ptr1->common.bLength);
  450. }
  451. return kStatus_USB_Success;
  452. }