DTables.A51
; This module declares the descriptors
;
; This example has one Device Descriptor with TWO Configurations
ConfigurationCount EQU	2
; Dot Mode: the IO device accepts RAW dots for the display
;	One Interface - there is only one method of accessing the ports
;	One HID Descriptor - to make PC host software simpler
;	One Report Descriptor - 40 byte OUT report
; Text mode: the IO device accepts ASCII characters for display
;	One Interface - there is only one method of accessing the ports
;	One HID Descriptor - to make PC host software simpler
;	One Endpoint Descriptor - for HID Input Reports
;	One Report Descriptor - 40 byte IN and 7 byte OUT reports
;	Multiple Sting Descriptors - to aid the user
;
; PROBLEM: during system testing it was discovered that Windows 98 DOES NOT SUPPORT the
; HidD_GetConfiguration system call - this means that an application program (which is what
; this is) CANNOT send a SetConfiguration packet to an I/O device; the call is supported
; by Windows 2000 and by Windows 98 for kernel level (ie device driver) software.
; The "Reader Board" I/O device was tested independantly for its correct dual-configuration
; operation.
; This example, therefore, uses an ALTERNATE method of implementing "dual-configuration"
; I extended the Report Buffer by one byte and prepend the data with the "mode" byte.
; This works, not as elegant as I would have wanted, but it does implement "dual-modes"
; The "default" configuration (=1) is Text mode so that we have an INPUT Report
	CSEG
DeviceDescriptor:
	DB	18, 1		; Length, Type
	DW	101H		; USB Rev 1.1
	DB	0, 0, 0		; Class, Subclass and Protocol
	DB	64 		; EP0 size
	DW	4242H, 1, 1	; Vendor ID, Product ID and Version
	DB	1, 2, 0		; Manufacturer, Product & Serial# Names
	DB	ConfigurationCount; #Configs

TextConfigurationDescriptor:
	DB	9, 2		; Length, Type
	DB	LOW(TextConfigLength), HIGH(TextConfigLength)
	DB	1, 1, 3		; #Interfaces, Configuration#, Config. Name
	DB	10000000b	; Attributes = Bus Powered
	DB	50		; Max. Power is 50x2 = 100mA
TextInterfaceDescriptor:
	DB	9, 4		; Length, Type
	DB	0, 0, 1		; No alternate setting, HID Input uses EP1
	DB	3		; Class = Human Interface Device
	DB	0, 0		; Subclass and Protocol
	DB	0		; Interface Name
TextHIDDescriptor:
	DB	9, 21H		; Length, Type
	DB	0, 1		; HID Class Specification compliance
	DB	0		; Country localization (=none)
	DB	1		; Number of descriptors to follow
	DB	22H		; And it's a Report descriptor
	DB	LOW(TextReportLength), HIGH(TextReportLength)
TextEndpointDescriptor:
	DB	7, 5		; Length, Type
	DB	10000001b	; Address = IN 1
	DB	00000011b	; Interrupt
	DB	64, 0		; Maximum packet size
	DB	100		; Poll every 0.1 seconds 
TextConfigLength	EQU $ - TextConfigurationDescriptor

TextReportDescriptor:		; Generated with HID Tool, copied to here
	DB	6, 0, 0FFH	; Usage_Page (Vendor Defined)
	DB	9, 1		; Usage (I/O Device)
	DB	0A1H, 1		; Collection (Application)
	DB	19H, 1		;   Usage_Minimum
	DB	29H, 2		;   Usage_Maximum
	DB	15H, 0		;   Logical_Minimum (0)
	DB	26H, 255, 0	;   Logical_Maximum (255)
	DB	75H, 8		;   Report_Size (8)
	DB	95H, 40		;   Report_Count (40) 
	DB	81H, 2		;   Input (Data,Var,Abs) = DOTs
	DB	19H, 1		;   Usage_Minimum
	DB	29H, 2		;   Usage_Maximum
	DB	95H, 41		;   Report_Count (7)
; Report Count Change: See comment re-SetConfiguration
	DB	91H, 2		;   Output (Data,Var,Abs) = Text
	DB	0C0H		; End_Collection
TextReportLength	EQU $-TextReportDescriptor

DotConfigurationDescriptor:
	DB	9, 2		; Length, Type
	DB	LOW(DotConfigLength), HIGH(DotConfigLength)
	DB	1, 2, 4		; #Interfaces, Configuration#, Config. Name
	DB	10000000b	; Attributes = Bus Powered
	DB	50		; Max. Power is 50x2 = 100mA
DotInterfaceDescriptor:
	DB	9, 4		; Length, Type
	DB	0, 0, 0		; No alternate setting, HID Output Report uses EP0
	DB	3		; Class = Human Interface Device
	DB	0, 0		; Subclass and Protocol
	DB	0		; Interface Name
DotHIDDescriptor:
	DB	9, 21H		; Length, Type
	DB	0, 1		; HID Class Specification compliance
	DB	0		; Country localization (=none)
	DB	1		; Number of descriptors to follow
	DB	22H		; And it's a Report descriptor
	DB	LOW(DotReportLength), HIGH(DotReportLength)
DotConfigLength	EQU $ - DotConfigurationDescriptor

DotReportDescriptor:		; Generated with HID Tool, copied to here
	DB	6, 0, 0FFH	; Usage_Page (Vendor Defined)
	DB	9, 1		; Usage (I/O Device)
	DB	0A1H, 1		; Collection (Application)
	DB	19H, 1		;   Usage_Minimum
	DB	29H, 2		;   Usage_Maximum
	DB	15H, 0		;   Logical_Minimum (0)
	DB	26H, 255, 0	;   Logical_Maximum (255)
	DB	75H, 8		;   Report_Size (8)
	DB	95H, 41		;   Report_Count (41) 
; Report Count Change: See comment re-SetConfiguration
	DB	91H, 2		;   Output (Data,Var,Abs) = DOTs
	DB	0C0H		; End_Collection
DotReportLength	EQU $-DotReportDescriptor
	 
String0:			; Declare the UNICODE strings
	DB	4, 3, 9, 4	; Only English language strings supported
String1:			; Manufacturer
	DB	(String2-String1),3 ; Length, Type 
	DB	"U",0,"S",0,"B",0," ",0,"D",0,"e",0,"s",0,"i",0,"g",0,"n",0," ", 0
	DB	"B",0,"y",0," ",0,"E",0,"x",0,"a",0,"m",0,"p",0,"l",0,"e",0
String2:			; Product Name
	DB	(String3-String2),3
	DB	"R",0,"e",0,"a",0,"d",0,"e",0,"r",0
	DB	" ",0,"B",0,"o",0,"a",0,"r",0,"d",0
String3:			; Configuration Name
	DB	(String4-String3),3
	DB	"T",0,"e",0,"x",0,"t",0," ",0,"M",0,"o",0,"d",0,"e",0
String4:			; Configuration Name
	DB	(EndOfDescriptors-String4),3
	DB	"D",0,"o",0,"t",0," ",0,"M",0,"o",0,"d",0,"e",0
EndOfDescriptors:
	DW	0		; Backstop for String Descriptors