//=============================================================================
// src/descriptors.c: generated by Hardware Configurator
//
// This file is only generated if it does not exist. Modifications in this file
// will persist even if Configurator generates code. To refresh this file,
// you must first delete it and then regenerate code.
//=============================================================================
//-----------------------------------------------------------------------------
// Includes
//-----------------------------------------------------------------------------
#include <si_toolchain.h>
#include <endian.h>
#include <stdlib.h>
#include <string.h>
#include <efm8_usb.h>
#include "descriptors.h"
#include "app.h"

#ifdef __cplusplus
extern "C" {
#endif

// HID Report Descriptor for Interface 0
SI_SEGMENT_VARIABLE(ReportDescriptor0[34],
		const uint8_t,
		SI_SEG_CODE) =
{

	0x06, 0xd0, 0xf1,// USAGE_PAGE (FIDO Alliance)
	0x09, 0x01,// USAGE (Keyboard)
	0xa1, 0x01,// COLLECTION (Application)

        0x09, 0x20,                   //   USAGE (Input Report Data)
        0x15, 0x00,                   //   LOGICAL_MINIMUM (0)
        0x26, 0xff, 0x00,             //   LOGICAL_MAXIMUM (255)
        0x75, 0x08,                   //   REPORT_SIZE (8)
        0x95, HID_PACKET_SIZE,                   //   REPORT_COUNT (64)
        0x81, 0x02,                   //   INPUT (Data,Var,Abs)
        0x09, 0x21,                   //   USAGE(Output Report Data)
        0x15, 0x00,                   //   LOGICAL_MINIMUM (0)
        0x26, 0xff, 0x00,             //   LOGICAL_MAXIMUM (255)
        0x75, 0x08,                   //   REPORT_SIZE (8)
        0x95, HID_PACKET_SIZE,                   //   REPORT_COUNT (64)
        0x91, 0x02,                   //   OUTPUT (Data,Var,Abs)


	0xc0,// END_COLLECTION

};
SI_SEGMENT_VARIABLE(deviceDesc[],
		const USB_DeviceDescriptor_TypeDef,
		SI_SEG_CODE) =
{
	USB_DEVICE_DESCSIZE,             // bLength
	USB_DEVICE_DESCRIPTOR,// bLength
	htole16(0x0200),// bcdUSB
	0,// bDeviceClass
	0,// bDeviceSubClass
	0,// bDeviceProtocol
	64,// bMaxPacketSize
	USB_VENDOR_ID,// idVendor
	USB_PRODUCT_ID,// idProduct
	htole16(0x0100),// bcdDevice
	1,// iManufacturer
	2,// iProduct
	3,// iSerialNumber
	1,// bNumConfigurations
};

SI_SEGMENT_VARIABLE(configDesc[],
		const uint8_t,
		SI_SEG_CODE) =
{
	USB_CONFIG_DESCSIZE,             // bLength
	USB_CONFIG_DESCRIPTOR,// bLength
	0x29,// wTotalLength(LSB)
	0x00,// wTotalLength(MSB)
	1,// bNumInterfaces
	1,// bConfigurationValue
	0,// iConfiguration

	CONFIG_DESC_BM_RESERVED_D7,// bmAttrib: Bus powered

	CONFIG_DESC_MAXPOWER_mA(100),// bMaxPower: 100 mA

	//Interface 0 Descriptor
	USB_INTERFACE_DESCSIZE,// bLength
	USB_INTERFACE_DESCRIPTOR,// bDescriptorType
	0,// bInterfaceNumber
	0,// bAlternateSetting
	2,// bNumEndpoints
	3,// bInterfaceClass: HID (Human Interface Device)
	0,// bInterfaceSubClass
	0,// bInterfaceProtocol
	4,// iInterface

	//HID Descriptor
	USB_HID_DESCSIZE,// bLength
	USB_HID_DESCRIPTOR,// bLength
	0x11,// bcdHID (LSB)
	0x01,// bcdHID (MSB)
	0,// bCountryCode
	1,// bNumDescriptors
	USB_HID_REPORT_DESCRIPTOR,// bDescriptorType
	sizeof( ReportDescriptor0 ),// wDescriptorLength(LSB)
	sizeof( ReportDescriptor0 )>>8,// wDescriptorLength(MSB)

	//Endpoint 2 IN Descriptor
	USB_ENDPOINT_DESCSIZE,// bLength
	USB_ENDPOINT_DESCRIPTOR,// bDescriptorType
	OUTPUT_ENDPOINT_NUM,// bEndpointAddress
	USB_EPTYPE_INTR,// bAttrib
	HID_PACKET_SIZE,// wMaxPacketSize (LSB)
	0x00,// wMaxPacketSize (MSB)
	5,// bInterval

	//Endpoint 3 OUT Descriptor
	USB_ENDPOINT_DESCSIZE,// bLength
	USB_ENDPOINT_DESCRIPTOR,// bDescriptorType
	INPUT_ENDPOINT_NUM,// bEndpointAddress
	USB_EPTYPE_INTR,// bAttrib
	HID_PACKET_SIZE,// wMaxPacketSize (LSB)
	0x00,// wMaxPacketSize (MSB)
	5,// bInterval
};

#define LANG_STRING   htole16( SLAB_USB_LANGUAGE )
#define MFR_STRING                                'S','i','l','i','c','o','n',' ','L','a','b','s','\0'
#define MFR_SIZE                                  13

#define SER_STRING                                '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F','\0'
#define SER_SIZE                                  17
#define CFG_STRING                                'C','o','n','f','i','g',' ','#','1','\0'
#define CFG_SIZE                                  10
#ifdef BRIDGE_TO_WALLET
#define INT0_STRING                               'E','O','S',' ','W','a','l','l','e','t','\0'
#define INT0_SIZE                                 11
#define PROD_STRING                               'E','O','S',' ','W','a','l','l','e','t','\0'
#define PROD_SIZE                                 11
#else
#define INT0_STRING                               'S','o','l','o',' ','K','e','y','\0'
#define INT0_SIZE                                 9
#define PROD_STRING                               'S','o','l','o',' ','K','e','y','\0'
#define PROD_SIZE                                 9
#endif

LANGID_STATIC_CONST_STRING_DESC( langDesc[], LANG_STRING );
UTF16LE_PACKED_STATIC_CONST_STRING_DESC( mfrDesc[], MFR_STRING, MFR_SIZE);
UTF16LE_PACKED_STATIC_CONST_STRING_DESC( prodDesc[], PROD_STRING, PROD_SIZE);
UTF16LE_PACKED_STATIC_CONST_STRING_DESC( serDesc[], SER_STRING, SER_SIZE);
//UTF16LE_PACKED_STATIC_CONST_STRING_DESC( cfgDesc[], CFG_STRING, CFG_SIZE);
UTF16LE_PACKED_STATIC_CONST_STRING_DESC( int0Desc[], INT0_STRING, INT0_SIZE);



//-----------------------------------------------------------------------------
SI_SEGMENT_POINTER(myUsbStringTable_USEnglish[],
		static const USB_StringDescriptor_TypeDef,
		const SI_SEG_CODE) =
{
	langDesc,
	mfrDesc,
	prodDesc,
	serDesc,
	int0Desc,

};

//-----------------------------------------------------------------------------
SI_SEGMENT_VARIABLE(initstruct,
		const USBD_Init_TypeDef,
		SI_SEG_CODE) =
{
	deviceDesc,                                         // deviceDescriptor
	configDesc,// configDescriptor
	myUsbStringTable_USEnglish,// stringDescriptors
	5// numberOfStrings
};

#ifdef __cplusplus
}
#endif

