/************************************************************************usb_descriptors.cWFF USB Generic HID Demonstration 3usbGenericHidCommunication reference firmware 3_0_0_0Copyright (C) 2011 Simon InnsThis program is free software: you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation, either version 3 of the License, or(at your option) any later version.This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program. If not, see <http://www.gnu.org/licenses/>.Email: simon.inns@gmail.com************************************************************************/#ifndef USB_DESCRIPTORS_C#define USB_DESCRIPTORS_C// Local includes#include "HardwareProfile.h"// Microchip Application Library includes#include "./USB/usb.h"#include "./USB/usb_function_hid.h"// Device DescriptorROM USB_DEVICE_DESCRIPTOR device_dsc={0x12, // Size of this descriptor in bytesUSB_DESCRIPTOR_DEVICE, // DEVICE descriptor type0x0200, // USB Spec Release Number in BCD format0x00, // Class Code0x00, // Subclass code0x00, // Protocol codeUSB_EP0_BUFF_SIZE, // Max packet size for EP0, see usb_config.hUSB_VID, // Vendor IDUSB_PID, // Product ID0x0002, // Device release number in BCD format0x01, // Manufacturer string index0x02, // Product string index0x03, // Device serial number string index0x01 // Number of possible configurations};// Configuration 1 DescriptorROM BYTE configDescriptor1[]={// Configuration Descriptor0x09, // Size of this descriptor in bytes (sizeof(USB_CFG_DSC))USB_DESCRIPTOR_CONFIGURATION, // CONFIGURATION descriptor type0x29,0x00, // Total length of data for this cfg1, // Number of interfaces in this cfg1, // Index value of this configuration0, // Configuration string index_DEFAULT | _SELF, // Attributes, see usb_device.h50, // Max power consumption (2X mA)// Interface Descriptor0x09, // Size of this descriptor in bytes (sizeof(USB_INTF_DSC))USB_DESCRIPTOR_INTERFACE, // INTERFACE descriptor type0, // Interface Number0, // Alternate Setting Number2, // Number of endpoints in this intfHID_INTF, // Class code0, // Subclass code0, // Protocol code0, // Interface string index// HID Class-Specific Descriptor0x09, // Size of this descriptor in bytes (sizeof(USB_HID_DSC)+3)DSC_HID, // HID descriptor type0x11,0x01, // HID Spec Release Number in BCD format (1.11)0x00, // Country Code (0x00 for Not supported)HID_NUM_OF_DSC, // Number of class descriptors, see usbcfg.hDSC_RPT, // Report descriptor typeHID_RPT01_SIZE,0x00, // Size of the report descriptor (sizeof(hid_rpt01))// Endpoint Descriptor0x07, // sizeof(USB_EP_DSC)USB_DESCRIPTOR_ENDPOINT, // Endpoint DescriptorHID_EP | _EP_IN, // Endpoint Address_INTERRUPT, // Attributes0x40,0x00, // size0x01, // Interval// Endpoint Descriptor0x07, // sizeof(USB_EP_DSC)USB_DESCRIPTOR_ENDPOINT, // Endpoint DescriptorHID_EP | _EP_OUT, // EndpointAddress_INTERRUPT, // Attributes0x40,0x00, // size0x01 // Interval};// Language code string descriptorROM struct{BYTE bLength;BYTE bDscType;WORD string[1];}sd000={sizeof(sd000),USB_DESCRIPTOR_STRING,{0x0409}};// Manufacturer string descriptor (set in HardwareProfile.h)ROM struct{BYTE bLength;BYTE bDscType;WORD string[MSDLENGTH];}sd001={sizeof(sd001),USB_DESCRIPTOR_STRING,{MSD}};// Product string descriptor (set in HardwareProfile.h)ROM struct{BYTE bLength;BYTE bDscType;WORD string[PSDLENGTH];}sd002={sizeof(sd002),USB_DESCRIPTOR_STRING,{PSD}};// Device serial number string descriptorROM struct{BYTE bLength;BYTE bDscType;WORD string[DSNLENGTH];}sd003={sizeof(sd003),USB_DESCRIPTOR_STRING,{DSN}};// Class specific descriptor - HIDROM struct{BYTE report[HID_RPT01_SIZE];}hid_rpt01={{0x06, 0x00, 0xFF, // Usage Page = 0xFF00 (Vendor Defined Page 1)0x09, 0x01, // Usage (Vendor Usage 1)0xA1, 0x01, // Collection (Application)0x19, 0x01, // Usage Minimum0x29, 0x40, // Usage Maximum //64 input usages total (0x01 to 0x40)0x15, 0x01, // Logical Minimum (data bytes in the report may have minimum value = 0x00)0x25, 0x40, // Logical Maximum (data bytes in the report may have maximum value = 0x00FF = unsigned 255)0x75, 0x08, // Report Size: 8-bit field size0x95, 0x40, // Report Count: Make sixty-four 8-bit fields (the next time the parser hits an "Input", "Output", or "Feature" item)0x81, 0x00, // Input (Data, Array, Abs): Instantiates input packet fields based on the above report size, count, logical min/max, and usage.0x19, 0x01, // Usage Minimum0x29, 0x40, // Usage Maximum //64 output usages total (0x01 to 0x40)0x91, 0x00, // Output (Data, Array, Abs): Instantiates output packet fields. Uses same report size and count as "Input" fields, since nothing new/different was specified to the parser since the "Input" item.0xC0} // End Collection};// Array of configuration descriptorsROM BYTE *ROM USB_CD_Ptr[]={(ROM BYTE *ROM)&configDescriptor1};// Array of string descriptorsROM BYTE *ROM USB_SD_Ptr[]={(ROM BYTE *ROM)&sd000,(ROM BYTE *ROM)&sd001,(ROM BYTE *ROM)&sd002,(ROM BYTE *ROM)&sd003};#endif