2019-03-09 12:59 AM
My environment is NUCLEO-F446RE and TrueSTUDIO / STM32CubeMX.
On Microchip PIC32MX's framework(MPLAB Harmony), it can make a custom usb device as "Vender".
On the other hand, STM32CubeMX has only options for custom HID and virtual COM devices so I can't define the original device.
This is an example of a simple WinUSB device demo descriptor output by the microchip framework.
/*******************************************
* USB Device Layer Descriptors
*******************************************/
/*******************************************
* USB Device Descriptor
*******************************************/
const USB_DEVICE_DESCRIPTOR deviceDescriptor =
{
0x12, // Size of this descriptor in bytes
USB_DESCRIPTOR_DEVICE, // DEVICE descriptor type
0x0200, // USB Spec Release Number in BCD format
0x00, // Class Code
0x00, // Subclass code
0x00, // Protocol code
USB_DEVICE_EP0_BUFFER_SIZE, // Max packet size for EP0, see system_config.h
0x04D8, // Vendor ID
0x0053, // Product ID
0x0100, // Device release number in BCD format
0x01, // Manufacturer string index
0x02, // Product string index
0x00, // Device serial number string index
0x01 // Number of possible configurations
};
/*******************************************
* USB Full Speed Configuration Descriptor
*******************************************/
const uint8_t fullSpeedConfigurationDescriptor[]=
{
/* Configuration Descriptor */
0x09, // Size of this descriptor in bytes
USB_DESCRIPTOR_CONFIGURATION, // Descriptor Type
32,0, //(32 Bytes)Size of the Config descriptor.e
1, // Number of interfaces in this cfg
0x01, // Index value of this configuration
0x00, // Configuration string index
USB_ATTRIBUTE_DEFAULT | USB_ATTRIBUTE_SELF_POWERED, // Attributes
50, // Max power consumption (2X mA)
/* Descriptor for Function 1 - Vendor */
/* Interface Descriptor */
0x09, // Size of this descriptor in bytes
USB_DESCRIPTOR_INTERFACE, // INTERFACE descriptor type
0, // Interface Number
0, // Alternate Setting Number
2, // Number of endpoints in this intf
0xFF, // Class code
0xFF, // Subclass code
0xFF, // Protocol code
0, // Interface string index
/* Endpoint (OUT) Descriptor */
0x07, // Size of this descriptor in bytes
USB_DESCRIPTOR_ENDPOINT, // Endpoint Descriptor
1 | USB_EP_DIRECTION_OUT, // EndpointAddress ( EP1 OUT )
USB_TRANSFER_TYPE_BULK, // Attributes
0x40,0x00, // Max packet size of this EP
1, // Interval
/* Endpoint (IN) Descriptor */
0x07, // Size of this descriptor in bytes
USB_DESCRIPTOR_ENDPOINT, // Endpoint Descriptor
1 | USB_EP_DIRECTION_IN, // EndpointAddress ( EP1 IN )
USB_TRANSFER_TYPE_BULK, // Attributes
0x40,0x00, // Max packet size of this EP
1, // Interval
};
Is there a way to define my own descriptor with STM32CubeMX? Or does STM32 have a library for creating libusb compatible devices?