
#include "usb_lib.h"
#include "usb_desc.h"

// USB Standard Device Descriptor
const uint8_t MUSB_DeviceDescriptor[MUSB_SIZE_DEVICE_DESC] =
{
  MUSB_SIZE_DEVICE_DESC,      // bLength
  USB_DEVICE_DESCRIPTOR_TYPE, // bDescriptorType
  0x00,
  0x02,         // bcdUSB = 2.00
  0x00,         // bDeviceClass
  0x00,         // bDeviceSubClass
  0x00,         // bDeviceProtocol
  0x40,         // bMaxPacketSize0
  0x15,
  0x08,         // idVendor = 0x0815
  0x11,
  0x47,         // idProduct = 0x4711
  DEVICE_VER_L,
  DEVICE_VER_H, // bcdDevice = 2.00
  1,            // Index of string descriptor describing manufacturer
  2,            // Index of string descriptor describing product
  0,            // Index of string descriptor describing the device serial number
  0x01          // bNumConfigurations
}; // MUSB_DeviceDescriptor

// USB Configuration Descriptor
//   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor
const uint8_t MUSB_ConfigDescriptor[MUSB_SIZE_CONFIG_DESC] =
{
  //Configuration Descriptor
  0x09,   // bLength: Configuration Descriptor size
  USB_CONFIGURATION_DESCRIPTOR_TYPE, // bDescriptorType: Configuration
  MUSB_SIZE_CONFIG_DESC,             // wTotalLength:no of returned bytes
  0x00,
  0x01,   // bNumInterfaces
  0x01,   // bConfigurationValue: Configuration value
  0x00,   // iConfiguration: Index of string descriptor describing the configuration
  0x80,   // bmAttributes: bus-powered
  0x32,   // MaxPower 100 mA

  // Interface Descriptor
  0x09,   // bLength: Interface Descriptor size
  USB_INTERFACE_DESCRIPTOR_TYPE,  // bDescriptorType: Interface
  0x00,   // bInterfaceNumber: Number of Interface
  0x00,   // bAlternateSetting: Alternate setting
  0x01,   // bNumEndpoints: One endpoints used
  0x00,   // bInterfaceClass
  0x00,   // bInterfaceSubClass
  0x00,   // bInterfaceProtocol
  0x00,   // iInterface:

  // Endpoint 3 Descriptor
  0x07,   // bLength: Endpoint Descriptor size
  USB_ENDPOINT_DESCRIPTOR_TYPE,   // bDescriptorType: Endpoint
  0x83,   // bEndpointAddress: (IN3)
  0x02,   // bmAttributes: Bulk
  wMaxPacketSize,
  0x00,
  0x00,   // bInterval: ignore for Bulk transfer

}; // MUSB_ConfigDescriptor

// USB String Descriptors (optional)
const uint8_t MUSB_StringLangID[MUSB_SIZE_STRING_LANGID] =
{
  MUSB_SIZE_STRING_LANGID,
  USB_STRING_DESCRIPTOR_TYPE,
  0x09,
  0x04
}; // LangID = 0x0409: U.S. English

const uint8_t MUSB_StringVendor[MUSB_SIZE_STRING_VENDOR] =
{
  MUSB_SIZE_STRING_VENDOR,
  USB_STRING_DESCRIPTOR_TYPE,
  // Manufacturer: "Test Device"
  'T', 0, 'e', 0, 's', 0, 't', 0, ' ', 0, 'D', 0, 'e', 0, 'v', 0,
  'i', 0, 'c', 0, 'e', 0
};

const uint8_t MUSB_StringProduct[MUSB_SIZE_STRING_PRODUCT] =
{
  MUSB_SIZE_STRING_PRODUCT,
  USB_STRING_DESCRIPTOR_TYPE,
  // Product name: "STM32 CVBS-Image-Grabber"
  'S', 0, 'T', 0, 'M', 0, '3', 0, '2', 0, ' ', 0, 'C', 0, 'V', 0,
  'B', 0, 'S', 0, '-', 0, 'I', 0, 'm', 0, 'a', 0, 'g', 0, 'e', 0,
  '-', 0, 'G', 0, 'r', 0, 'a', 0, 'b', 0, 'b', 0, 'e', 0, 'r', 0
};
