Implement multi-PID support so that Windows will recognise each device

class as a separate device.
USG_1.0
Robert Fisk 9 years ago
parent a64b89175e
commit 6c96824da8

@ -52,6 +52,9 @@
* @{
*/
#define USBD_PID_LOBYTE_OFFSET 0x0A
#define USBD_PID_HIBYTE_OFFSET 0x0B
/**
* @}
*/
@ -74,6 +77,7 @@
* @{
*/
extern USBD_DescriptorsTypeDef FS_Desc;
extern uint8_t USBD_FS_DeviceDesc[];
extern const int8_t STORAGE_Inquirydata_FS[];
/**
* @}

@ -75,6 +75,9 @@ static uint8_t USBD_HID_SendReport (uint8_t *report,
#define USBD_PID_HID 0x0002
USBD_ClassTypeDef USBD_HID =
{
USBD_HID_Init,
@ -92,6 +95,7 @@ USBD_ClassTypeDef USBD_HID =
USBD_HID_GetCfgDesc,
USBD_HID_GetCfgDesc,
USBD_HID_GetDeviceQualifierDesc,
USBD_PID_HID
};

@ -69,6 +69,7 @@
* @{
*/
/**
* @}
*/
@ -122,6 +123,10 @@ uint8_t USBD_MSC_BufferFreed(USBD_HandleTypeDef *pdev);
*/
#define USBD_PID_MSC 0x0001
USBD_ClassTypeDef USBD_MSC =
{
USBD_MSC_Init,
@ -139,6 +144,7 @@ USBD_ClassTypeDef USBD_MSC =
USBD_MSC_GetFSCfgDesc,
USBD_MSC_GetOtherSpeedCfgDesc,
USBD_MSC_GetDeviceQualifierDescriptor,
USBD_PID_MSC
};
/* USB Mass storage device Configuration Descriptor */

@ -177,6 +177,9 @@ typedef struct _Device_cb
uint8_t *(*GetFSConfigDescriptor)(uint16_t *length);
uint8_t *(*GetOtherSpeedConfigDescriptor)(uint16_t *length);
uint8_t *(*GetDeviceQualifierDescriptor)(uint16_t *length);
uint16_t USBDevPid;
#if (USBD_SUPPORT_USER_STRING == 1)
uint8_t *(*GetUsrStrDescriptor)(struct _USBD_HandleTypeDef *pdev ,uint8_t index, uint16_t *length);
#endif

@ -27,6 +27,8 @@
/* Includes ------------------------------------------------------------------*/
#include "usbd_core.h"
#include "usbd_descriptors.h"
/** @addtogroup STM32_USBD_DEVICE_LIBRARY
* @{
@ -159,6 +161,8 @@ USBD_StatusTypeDef USBD_RegisterClass(USBD_HandleTypeDef *pdev, USBD_ClassTypeD
{
/* link the class to the USB Device handle */
pdev->pClass = pclass;
USBD_FS_DeviceDesc[USBD_PID_LOBYTE_OFFSET] = LOBYTE(pclass->USBDevPid);
USBD_FS_DeviceDesc[USBD_PID_HIBYTE_OFFSET] = HIBYTE(pclass->USBDevPid);
status = USBD_OK;
}
else

@ -169,13 +169,13 @@ void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd)
case PCD_SPEED_HIGH:
speed = USBD_SPEED_HIGH;
break;
case PCD_SPEED_FULL:
speed = USBD_SPEED_FULL;
break;
default:
speed = USBD_SPEED_FULL;
break;
// case PCD_SPEED_FULL:
// speed = USBD_SPEED_FULL;
// break;
//
// default:
// speed = USBD_SPEED_FULL;
// break;
}
USBD_SetSpeed(hpcd->pData, speed);

@ -59,15 +59,15 @@
/** @defgroup USBD_DESC_Private_Defines
* @{
*/
#define USBD_VID 1155
#define USBD_VID 0xF000 //TODO: get a real VID :) We also need a separate PID for each supported device class.
#define USBD_LANGID_STRING 1033
#define USBD_MANUFACTURER_STRING "The USG is Good, not Bad"
#define USBD_PID_FS 22314
#define USBD_PRODUCT_STRING_FS "USG v1.0"
#define USBD_SERIALNUMBER_STRING_FS "00000000001A"
#define USBD_CONFIGURATION_STRING_FS "USG multipurpose configuration"
#define USBD_INTERFACE_STRING_FS "USG multipurpose interface"
/**
* @}
*/
@ -121,8 +121,8 @@ __ALIGN_BEGIN uint8_t USBD_FS_DeviceDesc[USB_LEN_DEV_DESC] __ALIGN_END =
USB_MAX_EP0_SIZE, /*bMaxPacketSize*/
LOBYTE(USBD_VID), /*idVendor*/
HIBYTE(USBD_VID), /*idVendor*/
LOBYTE(USBD_PID_FS), /*idVendor*/
HIBYTE(USBD_PID_FS), /*idVendor*/
0x00, //LOBYTE(USBD_PID_FS), /*idVendor*/
0x00, //HIBYTE(USBD_PID_FS), /*idVendor*/
0x00, /*bcdDevice rel. 2.00*/
0x02,
USBD_IDX_MFC_STR, /*Index of manufacturer string*/

Loading…
Cancel
Save