#include "usbd_desc.h"
#include "usbd_ctlreq.h"
+#define MSC_MAX_FS_PACKET 64
+#define MSC_MAX_HS_PACKET 512
+
// Support 2 USB devices.
__ALIGN_BEGIN static USBD_CompositeClassData fsClassData __ALIGN_END;
static uint8_t USBD_Composite_Setup (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req);
-static uint8_t *USBD_Composite_GetCfgDesc (uint16_t *length);
+static uint8_t *USBD_Composite_GetHSCfgDesc (uint16_t *length);
+static uint8_t *USBD_Composite_GetFSCfgDesc (uint16_t *length);
static uint8_t *USBD_Composite_GetDeviceQualifierDesc (uint16_t *length);
NULL, /*SOF */
NULL,
NULL,
- USBD_Composite_GetCfgDesc,
- USBD_Composite_GetCfgDesc,
- USBD_Composite_GetCfgDesc,
+ USBD_Composite_GetHSCfgDesc,
+ USBD_Composite_GetFSCfgDesc,
+ USBD_Composite_GetFSCfgDesc, // "Other" speed
USBD_Composite_GetDeviceQualifierDesc,
};
-__ALIGN_BEGIN static uint8_t USBD_Composite_CfgDesc[USB_COMPOSITE_CONFIG_DESC_SIZ] __ALIGN_END =
+__ALIGN_BEGIN static uint8_t USBD_Composite_CfgHSDesc[USB_COMPOSITE_CONFIG_DESC_SIZ] __ALIGN_END =
+{
+ 0x09, /* bLength: Configuration Descriptor size */
+ USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
+ USB_COMPOSITE_CONFIG_DESC_SIZ,
+ /* wTotalLength: Bytes returned */
+ 0x00,
+ 0x02, /*bNumInterfaces: 1 interface*/
+ 0x01, /*bConfigurationValue: Configuration value*/
+ 0x00, /*iConfiguration: Index of string descriptor describing
+ the configuration*/
+ 0x80, /*bmAttributes: bus powered */
+ 0xFA, /*MaxPower 500 mA: this current is used for detecting Vbus*/
+
+ /************** Descriptor of GENERIC interface ****************/
+ /* 09 */
+ 0x09, /*bLength: Interface Descriptor size*/
+ USB_DESC_TYPE_INTERFACE,/*bDescriptorType: Interface descriptor type*/
+ 0x00, /*bInterfaceNumber: Number of Interface*/
+ 0x00, /*bAlternateSetting: Alternate setting*/
+ 0x02, /*bNumEndpoints*/
+ 0x03, /*bInterfaceClass: HID*/
+ 0x00, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
+ 0x00, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
+ 0, /*iInterface: Index of string descriptor*/
+ /******************** Descriptor of GENERIC HID ********************/
+ /* 18 */
+ 0x09, /*bLength: HID Descriptor size*/
+ HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/
+ 0x11, /*bcdHID: HID Class Spec release number*/
+ 0x01,
+ 0x00, /*bCountryCode: Hardware target country*/
+ 0x01, /*bNumDescriptors: Number of HID class descriptors to follow*/
+ 0x22, /*bDescriptorType*/
+ HID_GENERIC_REPORT_DESC_SIZE,/*wItemLength: Total length of Report descriptor*/
+ 0x00,
+ /******************** Descriptor of Generic HID endpoint ********************/
+ /* 27 */
+ 0x07, /*bLength: Endpoint Descriptor size*/
+ USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/
+
+ HID_EPIN_ADDR, /*bEndpointAddress: Endpoint Address (IN)*/
+ 0x03, /*bmAttributes: Interrupt endpoint*/
+ HID_EPIN_SIZE, /*wMaxPacketSize: 64 Byte max */
+ 0x00,
+ HID_HS_BINTERVAL, /*bInterval*/
+ /* 34 */
+
+ /******************** Descriptor of GENERIC HID endpoint ********************/
+ /* 34 */
+ 0x07, /*bLength: Endpoint Descriptor size*/
+ USB_DESC_TYPE_ENDPOINT, /*bDescriptorType:*/
+
+ HID_EPOUT_ADDR, /*bEndpointAddress: Endpoint Address (OUT)*/
+ 0x03, /*bmAttributes: Interrupt endpoint*/
+ HID_EPOUT_SIZE, /*wMaxPacketSize */
+ 0x00,
+ HID_HS_BINTERVAL, /*bInterval*/
+ /* 41 */
+
+ /******************** Mass Storage interface ********************/
+ 0x09, /* bLength: Interface Descriptor size */
+ USB_DESC_TYPE_INTERFACE, /* bDescriptorType: */
+ 0x01, /* bInterfaceNumber: Number of Interface */
+ 0x00, /* bAlternateSetting: Alternate setting */
+ 0x02, /* bNumEndpoints*/
+ 0x08, /* bInterfaceClass: MSC Class */
+ 0x06, /* bInterfaceSubClass : SCSI transparent*/
+ 0x50, /* nInterfaceProtocol */
+ 0x00, /* iInterface: */
+ /******************** Mass Storage Endpoints ********************/
+ 0x07, /*Endpoint descriptor length = 7*/
+ 0x05, /*Endpoint descriptor type */
+ MSC_EPIN_ADDR, /*Endpoint address */
+ 0x02, /*Bulk endpoint type */
+ LOBYTE(MSC_MAX_HS_PACKET),
+ HIBYTE(MSC_MAX_HS_PACKET),
+ 0x00, /*Polling interval in milliseconds */
+
+ 0x07, /*Endpoint descriptor length = 7 */
+ 0x05, /*Endpoint descriptor type */
+ MSC_EPOUT_ADDR, /*Endpoint address */
+ 0x02, /*Bulk endpoint type */
+ LOBYTE(MSC_MAX_HS_PACKET),
+ HIBYTE(MSC_MAX_HS_PACKET),
+ 0x00 /*Polling interval in milliseconds*/
+
+};
+
+__ALIGN_BEGIN static uint8_t USBD_Composite_CfgFSDesc[USB_COMPOSITE_CONFIG_DESC_SIZ] __ALIGN_END =
{
0x09, /* bLength: Configuration Descriptor size */
USB_DESC_TYPE_CONFIGURATION, /* bDescriptorType: Configuration */
0x00,
0x00,
0x00,
- 0x40,
+ MSC_MAX_FS_PACKET,
0x01,
0x00,
};
USBD_LL_OpenEP(pdev, HID_EPIN_ADDR, USBD_EP_TYPE_INTR, HID_EPIN_SIZE);
USBD_LL_OpenEP(pdev, HID_EPOUT_ADDR, USBD_EP_TYPE_INTR, HID_EPOUT_SIZE);
-
- // MSC Endpoints
- USBD_LL_OpenEP(pdev, MSC_EPOUT_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_FS_PACKET);
- USBD_LL_OpenEP(pdev, MSC_EPIN_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_FS_PACKET);
-
-
USBD_CompositeClassData* classData;
- if (pdev->id == DEVICE_HS)
+ if(pdev->dev_speed == USBD_SPEED_HIGH)
{
classData = &hsClassData;
+
+ // MSC Endpoints
+ USBD_LL_OpenEP(pdev, MSC_EPOUT_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_HS_PACKET);
+ USBD_LL_OpenEP(pdev, MSC_EPIN_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_HS_PACKET);
}
else
{
classData = &fsClassData;
+
+ // MSC Endpoints
+ USBD_LL_OpenEP(pdev, MSC_EPOUT_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_FS_PACKET);
+ USBD_LL_OpenEP(pdev, MSC_EPIN_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_FS_PACKET);
}
classData->hid.state = HID_IDLE;
classData->hid.reportReady = 0;
switch ((uint8_t)req->wIndex)
{
case MSC_EPIN_ADDR:
- USBD_LL_OpenEP(pdev, MSC_EPIN_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_FS_PACKET);
+ USBD_LL_OpenEP(
+ pdev,
+ MSC_EPIN_ADDR,
+ USBD_EP_TYPE_BULK,
+ pdev->dev_speed == USBD_SPEED_HIGH ? MSC_MAX_HS_PACKET : MSC_MAX_FS_PACKET);
break;
case MSC_EPOUT_ADDR:
- USBD_LL_OpenEP(pdev, MSC_EPOUT_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_FS_PACKET);
+ USBD_LL_OpenEP(
+ pdev,
+ MSC_EPOUT_ADDR,
+ USBD_EP_TYPE_BULK,
+ pdev->dev_speed == USBD_SPEED_HIGH ? MSC_MAX_HS_PACKET : MSC_MAX_FS_PACKET);
break;
case HID_EPIN_ADDR:
return USBD_Composite_DeviceQualifierDesc;
}
+uint8_t *USBD_Composite_GetHSCfgDesc (uint16_t *length)
+{
+ *length = sizeof (USBD_Composite_CfgHSDesc);
+ return USBD_Composite_CfgHSDesc;
+}
-static uint8_t *USBD_Composite_GetCfgDesc (uint16_t *length)
+uint8_t *USBD_Composite_GetFSCfgDesc (uint16_t *length)
{
- *length = sizeof (USBD_Composite_CfgDesc);
- return USBD_Composite_CfgDesc;
+ *length = sizeof (USBD_Composite_CfgFSDesc);
+ return USBD_Composite_CfgFSDesc;
}
+
#define USBD_PRODUCT_STRING_FS (uint8_t*)"SCSI2SD 2020"
#define USBD_CONFIGURATION_STRING_FS (uint8_t*)"SCSI2SD Config"
#define USBD_INTERFACE_STRING_FS (uint8_t*)"SCSI2SD Interface"
-
+#define USB_SIZ_BOS_DESC 0x0C
/**
* @}
*/
uint8_t * USBD_FS_SerialStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length);
uint8_t * USBD_FS_ConfigStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length);
uint8_t * USBD_FS_InterfaceStrDescriptor( USBD_SpeedTypeDef speed , uint16_t *length);
+#if (USBD_LPM_ENABLED == 1)
+uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length);
+#endif /* (USBD_LPM_ENABLED == 1) */
-#ifdef USB_SUPPORT_USER_STRING_DESC
-uint8_t * USBD_FS_USRStringDesc (USBD_SpeedTypeDef speed, uint8_t idx , uint16_t *length);
-#endif /* USB_SUPPORT_USER_STRING_DESC */
USBD_DescriptorsTypeDef FS_Desc =
{
USBD_FS_SerialStrDescriptor,
USBD_FS_ConfigStrDescriptor,
USBD_FS_InterfaceStrDescriptor,
+#if (USBD_LPM_ENABLED == 1)
+ USBD_FS_USR_BOSDescriptor
+#endif /* (USBD_LPM_ENABLED == 1) */
+};
+
+USBD_DescriptorsTypeDef HS_Desc =
+{
+ USBD_FS_DeviceDescriptor,
+ USBD_FS_LangIDStrDescriptor,
+ USBD_FS_ManufacturerStrDescriptor,
+ USBD_FS_ProductStrDescriptor,
+ USBD_FS_SerialStrDescriptor,
+ USBD_FS_ConfigStrDescriptor,
+ USBD_FS_InterfaceStrDescriptor,
+#if (USBD_LPM_ENABLED == 1)
+ USBD_FS_USR_BOSDescriptor
+#endif /* (USBD_LPM_ENABLED == 1) */
};
#if defined ( __ICCARM__ ) /*!< IAR Compiler */
{
0x12, /*bLength */
USB_DESC_TYPE_DEVICE, /*bDescriptorType*/
- 0x00, /* bcdUSB */
+#if (USBD_LPM_ENABLED == 1)
+ 0x01, /*bcdUSB */ /* changed to USB version 2.01
+ in order to support LPM L1 suspend
+ resume test of USBCV3.0*/
+#else
+ 0x00, /*bcdUSB */
+#endif /* (USBD_LPM_ENABLED == 1) */
0x02,
0x00, /*bDeviceClass*/
0x00, /*bDeviceSubClass*/
} ;
/* USB_DeviceDescriptor */
-#if defined ( __ICCARM__ ) /*!< IAR Compiler */
- #pragma data_alignment=4
-#endif
+/** BOS descriptor. */
+#if (USBD_LPM_ENABLED == 1)
+__ALIGN_BEGIN uint8_t USBD_FS_BOSDesc[USB_SIZ_BOS_DESC] __ALIGN_END =
+{
+ 0x5,
+ USB_DESC_TYPE_BOS,
+ 0xC,
+ 0x0,
+ 0x1, /* 1 device capability*/
+ /* device capability*/
+ 0x7,
+ USB_DEVICE_CAPABITY_TYPE,
+ 0x2,
+ 0x2, /* LPM capability bit set*/
+ 0x0,
+ 0x0,
+ 0x0
+};
+#endif /* (USBD_LPM_ENABLED == 1) */
/* USB Standard Device Descriptor */
__ALIGN_BEGIN uint8_t USBD_LangIDDesc[USB_LEN_LANGID_STR_DESC] __ALIGN_END =
}
return USBD_StrDesc;
}
+
+#if (USBD_LPM_ENABLED == 1)
+/**
+ * @brief Return the BOS descriptor
+ * @param speed : Current device speed
+ * @param length : Pointer to data length variable
+ * @retval Pointer to descriptor buffer
+ */
+uint8_t * USBD_FS_USR_BOSDescriptor(USBD_SpeedTypeDef speed, uint16_t *length)
+{
+ UNUSED(speed);
+ *length = sizeof(USBD_FS_BOSDesc);
+ return (uint8_t*)USBD_FS_BOSDesc;
+}
+#endif /* (USBD_LPM_ENABLED == 1) */
+
/**
* @}
*/