/*
 USB descriptors
 
 Copyright (c) 2008-2012 Dimtel, Inc., All Rights Reserved

 $Id: usb_descriptors.c,v 1.2 2013/06/06 04:35:11 dim Exp $
 $Date: 2013/06/06 04:35:11 $
 $Author: dim $
 $Revision: 1.2 $
 $Log: usb_descriptors.c,v $
 Revision 1.2  2013/06/06 04:35:11  dim
 Added EP8 OUT to interface 0 for fast JTAG block loading

 Revision 1.1  2012/11/11 01:24:32  dim
 Moved from BxB, adapted to compile for both LLRF4 and IGP12

 Revision 1.1  2011/12/27 19:31:47  dim
 Updated to remove deprecated constructs (at, sfr, xdata, sbit)


*/

#include "usb_descriptors.h"
#include "hwdef.h"
#include "../include/board_ids.h"
#include "../include/usb_defs.h"

#pragma constseg USBDESC

const usb_device descr_device = {
    sizeof(usb_device),		/* Descriptor length, bytes */
    USB_DT_DEVICE,		/* Descriptor type */
    0x0200,			/* USB specification version */
    0xff,			/* Device class (0xff - vendor specific) */
    0xff,			/* Device sub-class */
    0xff,			/* Device protocol */
    64,				/* Max packet size for EP0 */
    VENDID,			/* VID */
    PRODID,			/* PID */
    DEVID,			/* Device ID */
    1,				/* Manufacturer string index */
    2,				/* Product string index */
    3,				/* Serial number string index */
    1				/* Number of configurations */
};

const usb_qualifier descr_qualifier = {
    sizeof(usb_qualifier),	/* Descriptor length, bytes */
    USB_DT_DEVICE_QUALIFIER,	/* Descriptor type */
    0x0200,			/* USB specification version */
    0xff,			/* Device class (0xff - vendor specific) */
    0xff,			/* Device sub-class */
    0xff,			/* Device protocol */
    64,				/* Max packet size for EP0 */
    1,				/* Number of configurations */
    0				/* Reserved, set to 0 */
};

const usb_config_full hs_descr_config = {
  { /* usb_config descriptor (config) */
    sizeof(usb_config),		/* Descriptor length, bytes */
    USB_DT_CONFIG,		/* Descriptor type */
    sizeof(usb_config_full),	/* Total length */
    1,				/* Number of interfaces */
    1,				/* Configuration value */
    0,				/* String index */
    USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,	/* Attributes */
    0				/* Max. power */
  },
  { /* usb_interface descriptor (iface_alt0) */
    sizeof(usb_interface),	/* Descriptor length, bytes */
    USB_DT_INTERFACE,		/* Descriptor type */
    0,				/* Zero-based index */
    0,				/* Alternate setting */
    1,				/* Endpoints */
    0xff,			/* Device class (0xff - vendor specific) */
    0xff,			/* Device sub-class */
    0xff,			/* Device protocol */
    4				/* Interface description string index */
  },
  { /* usb_endpoint descriptor (EP8) */
    sizeof(usb_endpoint),	/* Descriptor length, bytes */
    USB_DT_ENDPOINT,		/* Descriptor type */
    8,				/* EP8 OUT */
    USB_ENDPOINT_XFER_BULK,	/* Bulk */
    512,			/* Max. packet size */
    1
  },
  { /* usb_interface descriptor (iface_alt1) */
    sizeof(usb_interface),	/* Descriptor length, bytes */
    USB_DT_INTERFACE,		/* Descriptor type */
    0,				/* Zero-based index */
    1,				/* Alternate setting */
    2,				/* Endpoints */
    0xff,			/* Device class (0xff - vendor specific) */
    0xff,			/* Device sub-class */
    0xff,			/* Device protocol */
    5				/* Interface description string index */
  },
  { /* usb_endpoint descriptor (EP2) */
    sizeof(usb_endpoint),	/* Descriptor length, bytes */
    USB_DT_ENDPOINT,		/* Descriptor type */
    2,				/* EP2 OUT */
    USB_ENDPOINT_XFER_BULK,	/* Bulk */
    512,			/* Max. packet size */
    1
  },
  { /* usb_endpoint descriptor (EP6) */
    sizeof(usb_endpoint),	/* Descriptor length, bytes */
    USB_DT_ENDPOINT,		/* Descriptor type */
    USB_ENDPOINT_DIR_MASK | 6,	/* EP6 IN */
    USB_ENDPOINT_XFER_BULK,	/* Bulk */
    512,			/* Max. packet size */
    1
  }
};

const uchar padding0 = 0x55;

const usb_config_full fs_descr_config = {
  { /* usb_config descriptor (config) */
    sizeof(usb_config),		/* Descriptor length, bytes */
    USB_DT_CONFIG,		/* Descriptor type */
    sizeof(usb_config_full),	/* Total length */
    1,				/* Number of interfaces */
    1,				/* Configuration value */
    0,				/* String index */
    USB_CONFIG_ATT_ONE | USB_CONFIG_ATT_SELFPOWER,	/* Attributes */
    0				/* Max. power */
  },
  { /* usb_interface descriptor (iface_alt0) */
    sizeof(usb_interface),	/* Descriptor length, bytes */
    USB_DT_INTERFACE,		/* Descriptor type */
    0,				/* Zero-based index */
    0,				/* Alternate setting */
    1,				/* Endpoints */
    0xff,			/* Device class (0xff - vendor specific) */
    0xff,			/* Device sub-class */
    0xff,			/* Device protocol */
    6				/* Interface description string index */
  },
  { /* usb_endpoint descriptor (EP8) */
    sizeof(usb_endpoint),	/* Descriptor length, bytes */
    USB_DT_ENDPOINT,		/* Descriptor type */
    8,				/* EP8 OUT */
    USB_ENDPOINT_XFER_BULK,	/* Bulk */
    64,				/* Max. packet size */
    1
  },
  { /* usb_interface descriptor (iface_alt1) */
    sizeof(usb_interface),	/* Descriptor length, bytes */
    USB_DT_INTERFACE,		/* Descriptor type */
    0,				/* Zero-based index */
    1,				/* Alternate setting */
    2,				/* Endpoints */
    0xff,			/* Device class (0xff - vendor specific) */
    0xff,			/* Device sub-class */
    0xff,			/* Device protocol */
    7				/* Interface description string index */
  },
  { /* usb_endpoint descriptor (EP2) */
    sizeof(usb_endpoint),	/* Descriptor length, bytes */
    USB_DT_ENDPOINT,		/* Descriptor type */
    2,				/* EP2 OUT */
    USB_ENDPOINT_XFER_BULK,	/* Bulk */
    64,				/* Max. packet size */
    0
  },
  { /* usb_endpoint descriptor (EP6) */
    sizeof(usb_endpoint),	/* Descriptor length, bytes */
    USB_DT_ENDPOINT,		/* Descriptor type */
    USB_ENDPOINT_DIR_MASK | 6,	/* EP6 IN */
    USB_ENDPOINT_XFER_BULK,	/* Bulk */
    64,				/* Max. packet size */
    0
  }
};

const uchar padding1 = 0xaa;