XBMC USB Controller solderpad

xbmc-usb-controller / Firmware / USBdsc.c

3.7 KB · raw

//******************************************************************************
//  XBMC USB Controller firmware.
//  Copyright � 2011 Dilshan R Jayakody.
//
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the 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 of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
//******************************************************************************

const unsigned int USB_VENDOR_ID = 0x8420;
const unsigned int USB_PRODUCT_ID = 0x0001;
const char USB_SELF_POWER = 0xC0;
const char USB_MAX_POWER = 50;
const char HID_INPUT_REPORT_BYTES = 64;
const char HID_OUTPUT_REPORT_BYTES = 64;
const char USB_TRANSFER_TYPE = 0x03;
const char EP_IN_INTERVAL = 1;
const char EP_OUT_INTERVAL = 1;

const char USB_INTERRUPT = 1;
const char USB_HID_EP = 1;
const char USB_HID_RPT_SIZE = 33;

const struct {
    char bLength;
    char bDescriptorType;
    unsigned int bcdUSB;
    char bDeviceClass;
    char bDeviceSubClass;
    char bDeviceProtocol;
    char bMaxPacketSize0;
    unsigned int idVendor;
    unsigned int idProduct;
    unsigned int bcdDevice;
    char iManufacturer;
    char iProduct;
    char iSerialNumber;
    char bNumConfigurations;
} device_dsc = {
      0x12,
      0x01,
      0x0200,
      0x00,
      0x00,
      0x00,
      8,
      USB_VENDOR_ID,
      USB_PRODUCT_ID,
      0x0001,
      0x01,
      0x02,
      0x00,
      0x01
  };

const char configDescriptor1[]= {
    0x09,
    0x02,
    0x29,0x00,
    1,
    1,
    0,
    USB_SELF_POWER,
    USB_MAX_POWER,
    0x09,
    0x04,
    0,
    0,
    2,
    0x03,
    0,
    0,
    0,
    0x09,
    0x21,
    0x01,0x01,
    0x00,
    1,
    0x22,
    USB_HID_RPT_SIZE,0x00,
    0x07,
    0x05,
    USB_HID_EP | 0x80,
    USB_TRANSFER_TYPE,
    0x40,0x00,
    EP_IN_INTERVAL,
    0x07,
    0x05,
    USB_HID_EP,
    USB_TRANSFER_TYPE,
    0x40,0x00,
    EP_OUT_INTERVAL
};

const struct {
  char report[USB_HID_RPT_SIZE];
}hid_rpt_desc =
  {
     {0x06, 0x00, 0xFF,
      0x09, 0x01,
      0xA1, 0x01,
      0x19, 0x01,
      0x29, 0x40,
      0x15, 0x00,
      0x26, 0xFF, 0x00,
      0x75, 0x08,
      0x95, HID_INPUT_REPORT_BYTES,
      0x81, 0x02,
      0x19, 0x01,
      0x29, 0x40,
      0x75, 0x08,
      0x95, HID_OUTPUT_REPORT_BYTES,
      0x91, 0x02,
      0xC0}
  };

const struct {
  char bLength;
  char bDscType;
  unsigned int string[1];
  } strd1 = {
      4,
      0x03,
      {0x0409}
    };

const struct{
  char bLength;
  char bDscType;
  unsigned int string[18];
  }strd2={
    38,
    0x03,
    {'D','i','l','s','h','a','n',' ','R',' ','J','a','y','a','k','o','d','y'}
  };

const struct{
  char bLength;
  char bDscType;
  unsigned int string[30];
}strd3={
    62,
    0x03,
    {'M','e','d','i','a',' ','C','e','n','t','e','r',' ','C','o','n','t','r','o','l',' ','I','n','t','e','r','f','a','c','e'}
 };

const char* USB_config_dsc_ptr[1];

const char* USB_string_dsc_ptr[3];

void USB_Init_Desc(){
  USB_config_dsc_ptr[0] = &configDescriptor1;
  USB_string_dsc_ptr[0] = (const char*)&strd1;
  USB_string_dsc_ptr[1] = (const char*)&strd2;
  USB_string_dsc_ptr[2] = (const char*)&strd3;
}