📄 descript.asm
字号:
; Software License Agreement
;
; The software supplied herewith by Microchip Technology Incorporated (the "Company")
; for its PICmicro(r) Microcontroller is intended and supplied to you, the Company's
; customer, for use solely and exclusively on Microchip PICmicro Microcontroller
; products.
;
; The software is owned by the Company and/or its supplier, and is protected under
; applicable copyright laws. All rights are reserved. Any use in violation of the
; foregoing restrictions may subject the user to criminal sanctions under applicable
; laws, as well as to civil liability for the breach of the terms and conditions of
; this license.
;
; THIS SOFTWARE IS PROVIDED IN AN "AS IS" CONDITION. NO WARRANTIES, WHETHER EXPRESS,
; IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
; MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE
; COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
; CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
;
; ###############################################################################
; filename: DESCRIPT.ASM
;
; This file contains a set of descriptors for a standard mouse.
;
; ###############################################################################
;
; Author: Dan Butler and Reston Condit
; Company: Microchip Technology Inc
;
; Revision: 2.00
; Date: 06 November 2002
; Assembled using: MPASM 2.80
;################################################################################
;
; include files:
; P16C745.inc Rev 1.00
; usb_defs.inc Rev 2.00
;
;################################################################################
#include <p16C745.inc>
#include "usb_defs.inc"
USBBANK code
global Config_desc_index
global Report_desc_index
global Descriptions
global DeviceDescriptor
global ReportDescriptor
global ReportDescriptorLen
global String0
global StringDescriptions
global GetStringIndex
global HID_Descriptor
extern EP0_start
extern temp ; temp var used in get config index
extern temp2 ; another temp, in bank2
; ******************************************************************
; Given a configuration descriptor index, returns the beginning address
; of the descriptor within the descriptions table
; ******************************************************************
Config_desc_index
movwf temp
movlw HIGH CDI_start
movwf PCLATH
movlw low CDI_start
addwf temp,w
btfsc STATUS,C
incf PCLATH,f
movwf PCL
CDI_start ; this table calculates the offsets for each
retlw low Config1 ; configuration descriptor from the beginning
retlw high Config1 ; of the table
retlw low Config2
retlw high Config2
; ******************************************************************
; Given a report descriptor index, returns the beginning address
; of the descriptor within the descriptions table
; ******************************************************************
Report_desc_index
movwf temp
movlw HIGH RDI_start
movwf PCLATH
movlw low RDI_start
addwf temp,w
btfsc STATUS,C
incf PCLATH,f
movwf PCL
RDI_start ; this table calculates the offsets for each report
retlw low ReportDescriptorLen ; descriptor from the beginning
retlw high ReportDescriptorLen ; of the table, effectively
; more reports can be added here
; retlw low ReportDescriptorLen2
; retlw high ReportDescriptorLen2
; etc....
; ******************************************************************
; This table is polled by the host immediately after USB Reset has been released.
; This table defines the maximum packet size EP0 can take.
; See section 9.6.1 of the Rev 1.0 USB specification.
; These fields are application DEPENDENT. Modify these to meet
; your specifications.
; the offset is passed in P0 and P1 (P0 is low order byte).
; ******************************************************************
Descriptions
banksel EP0_start
movf EP0_start+1,w
movwf PCLATH
movf EP0_start,w
movwf PCL
DeviceDescriptor
StartDevDescr
retlw 0x12 ; bLengthLength of this descriptor
retlw 0x01 ; bDescType This is a DEVICE descriptor
retlw 0x10 ; bcdUSBUSB revision 1.10 (low byte)
retlw 0x01 ; high byte
retlw 0x00 ; bDeviceClasszero means each interface operates independently
retlw 0x00 ; bDeviceSubClass
retlw 0x00 ; bDeviceProtocol
retlw 0x08 ; bMaxPacketSize0 - inited in UsbInit()
retlw 0xD8 ; idVendor - 0x04D8 is Microchip Vendor ID
retlw 0x04 ; high order byte
retlw 0x32 ; idProduct = 50
retlw 0x00
retlw 0x00 ; bcdDevice
retlw 0x00
retlw 0x01 ; iManufacturer
retlw 0x02 ; iProduct
retlw 0x00 ; iSerialNumber - 3
retlw NUM_CONFIGURATIONS ; bNumConfigurations
; ******************************************************************
; This table is retrieved by the host after the address has been set.
; This table defines the configurations available for the device.
; See section 9.6.2 of the Rev 1.0 USB specification (page 184).
; These fields are application DEPENDENT.
; Modify these to meet your specifications.
; ******************************************************************
Config1
retlw 0x09 ; bLength Length of this descriptor
retlw 0x02 ; bDescType 2=CONFIGURATION
retlw EndConfig1 - Config1
retlw 0x00
retlw 0x01 ; bNumInterfaces Number of interfaces
retlw 0x01 ; bConfigValue Configuration Value
retlw 0x03 ; iConfig String Index for this config = #03
retlw 0x80 ; bmAttributes attributes - bus powered, remote wakeup disabled
retlw 0x32 ; MaxPower 100mA
Interface1
retlw 0x09 ; length of descriptor
retlw INTERFACE;
retlw 0x00 ; number of interface, 0 based array
retlw 0x00 ; alternate setting
retlw 0x02 ; number of endpoints used in this interface
retlw 0x03 ; interface class - assigned by the USB
retlw 0x00 ; Not A boot device
retlw 0x00 ; interface protocol - none
retlw 0x00 ; index to string descriptor that describes this interface
HID_Descriptor
retlw (Endpoint1 - HID_Descriptor) ; descriptor size
retlw 0x21 ; descriptor type (HID)
retlw 0x00
retlw 0x01 ; HID class release number (1.00)
retlw 0x00 ; Localized country code (none)
retlw 0x01 ; # of HID class descriptor to follow (1)
retlw 0x22 ; Report descriptor type (HID)
retlw low (end_ReportDescriptor - ReportDescriptor)
retlw high (end_ReportDescriptor - ReportDescriptor)
Endpoint1
retlw 0x07 ; length of descriptor
retlw ENDPOINT
retlw 0x81 ; EP1, In
retlw 0x03 ; Interrupt
retlw 0x08 ; max packet size (8 bytes) low order byte
retlw 0x00 ; max packet size (8 bytes) high order byte
retlw 0x0A ; polling interval (10ms)
Endpoint2
retlw 0x07 ; length of descriptor
retlw ENDPOINT
retlw 0x01 ; EP1, OUT
retlw 0x03 ; Interrupt
retlw 0x08 ; max packet size (8 bytes) low order byte
retlw 0x00 ; max packet size (8 bytes) high order byte
retlw 0x0a ; polling interval (10ms)
EndConfig1
Config2
retlw 0x09 ; bLength Length of this descriptor
retlw 0x02 ; bDescType 2=CONFIGURATION
retlw EndConfig2 - Config2
retlw 0x00
retlw 0x01 ; bNumInterfaces Number of interfaces
retlw 0x02 ; bConfigValue Configuration Value
retlw 0x04 ; iConfig String Index for this config = #04
retlw 0x80 ; bmAttributes attributes - bus powered, remote wakeup disabled
retlw 0x32 ; MaxPower 100mA
Interface1c2
retlw 0x09 ; length of descriptor
retlw INTERFACE
retlw 0x00 ; number of interface, 0 based array
retlw 0x00 ; alternate setting
retlw 0x02 ; number of endpoints used in this interface
retlw 0xFF ; interface class - assigned by the USB
retlw 0x00 ; not a boot device
retlw 0x00 ; interface protocol - none
retlw 0x00 ; index to string descriptor that describes this interface
Endpoint1c2
retlw 0x07 ; length of descriptor
retlw ENDPOINT
retlw 0x81 ; EP1, In
retlw 0x03 ; Interrupt
retlw 0x08 ; max packet size (8 bytes) low order byte
retlw 0x00 ; max packet size (8 bytes) high order byte
retlw 0x0a ; polling interval (10ms)
Endpoint2c2
retlw 0x07 ; length of descriptor
retlw ENDPOINT
retlw 0x01 ; EP1, OUT
retlw 0x03 ; Interrupt
retlw 0x08 ; max packet size (8 bytes) low order byte
retlw 0x00 ; max packet size (8 bytes) high order byte
retlw 0x0a ; polling interval (10ms)
EndConfig2
ReportDescriptorLen
retlw low (end_ReportDescriptor-ReportDescriptor)
ReportDescriptor
dt 0x06, 0x00, 0xff ; USAGE_PAGE (Vendor Defined Page 1)
dt 0x09, 0x01 ; USAGE (Vendor Usage 1)
dt 0xa1, 0x01 ; COLLECTION (Application)
dt 0x19, 0x01 ; USAGE_MINIMUM (Vendor Usage 1)
dt 0x29, 0x08 ; USAGE_MAXIMUM (Vendor Usage 8)
dt 0x15, 0x00 ; LOGICAL_MINIMUM (0)
dt 0x26, 0xff, 0x00 ; LOGICAL_MAXIMUM (255)
dt 0x75, 0x08 ; REPORT_SIZE (8)
dt 0x95, 0x08 ; REPORT_COUNT (8)
dt 0x81, 0x02 ; INPUT (Data,Var,Abs)
dt 0x19, 0x01 ; USAGE_MINIMUM (Vendor Usage 1)
dt 0x29, 0x08 ; USAGE_MAXIMUM (Vendor Usage 8)
dt 0x91, 0x02 ; OUTPUT (Data,Var,Abs)
dt 0xc0 ; END_COLLECTION
end_ReportDescriptor
; ******************************************************************
; Given a string descriptor index, returns the beginning address
; of the descriptor within the descriptions table
; ******************************************************************
GetStringIndex
movwf temp
movlw HIGH StringIndexTable
movwf PCLATH
movlw LOW StringIndexTable
addwf temp,w
btfsc STATUS,C
incf PCLATH,f
movwf PCL
StringIndexTable
retlw low String0 ; LangIDs
retlw high String0
retlw low String1
retlw high String1
retlw low String2
retlw high String2
retlw low String3
retlw high String3
retlw low String4
retlw high String4
StringDescriptions
banksel EP0_start
movf EP0_start+1,w
movwf PCLATH
movf EP0_start,w
movwf PCL
String0
retlw low (String1 - String0) ; length of string
retlw 0x03 ; descriptor type 3?
retlw 0x09 ; language ID (as defined by MS 0x0409)
retlw 0x04
String1
retlw String2-String1 ; length of string
retlw 0x03 ; string descriptor type 3
retlw 'M'
retlw 0x00
retlw 'i'
retlw 0x00
retlw 'c'
retlw 0x00
retlw 'r'
retlw 0x00
retlw 'o'
retlw 0x00
retlw 'c'
retlw 0x00
retlw 'h'
retlw 0x00
retlw 'i'
retlw 0x00
retlw 'p'
retlw 0x00
retlw ' '
retlw 0x00
retlw 'T'
retlw 0x00
retlw 'e'
retlw 0x00
retlw 'c'
retlw 0x00
retlw 'h'
retlw 0x00
retlw 'n'
retlw 0x00
retlw 'o'
retlw 0x00
retlw 'l'
retlw 0x00
retlw 'o'
retlw 0x00
retlw 'g'
retlw 0x00
retlw 'y'
retlw 0x00
retlw ' '
retlw 0x00
retlw 'I'
retlw 0x00
retlw 'n'
retlw 0x00
retlw 'c'
retlw 0x00
retlw '.'
retlw 0x00
String2
retlw String3-String2
retlw 0x03
retlw 'P'
retlw 0x00
retlw 'I'
retlw 0x00
retlw 'C'
retlw 0x00
retlw 'k'
retlw 0x00
retlw 'i'
retlw 0x00
retlw 't'
retlw 0x00
retlw '('
retlw 0x00
retlw 'T'
retlw 0x00
retlw 'M'
retlw 0x00
retlw ')'
retlw 0x00
retlw ' '
retlw 0x00
retlw '1'
retlw 0x00
retlw ' '
retlw 0x00
retlw 'F'
retlw 0x00
retlw 'L'
retlw 0x00
retlw 'A'
retlw 0x00
retlw 'S'
retlw 0x00
retlw 'H'
retlw 0x00
retlw ' '
retlw 0x00
retlw 'S'
retlw 0x00
retlw 't'
retlw 0x00
retlw 'a'
retlw 0x00
retlw 'r'
retlw 0x00
retlw 't'
retlw 0x00
retlw 'e'
retlw 0x00
retlw 'r'
retlw 0x00
retlw ' '
retlw 0x00
retlw 'K'
retlw 0x00
retlw 'i'
retlw 0x00
retlw 't'
retlw 0x00
String3
retlw String4-String3
retlw 0x03
retlw 'C'
retlw 0x00
retlw 'o'
retlw 0x00
retlw 'n'
retlw 0x00
retlw 'f'
retlw 0x00
retlw 'i'
retlw 0x00
retlw 'g'
retlw 0x00
retlw '.'
retlw 0x00
retlw ' '
retlw 0x00
retlw '1'
retlw 0x00
retlw ':'
retlw 0x00
retlw ' '
retlw 0x00
retlw 'H'
retlw 0x00
retlw 'I'
retlw 0x00
retlw 'D'
retlw 0x00
String4
retlw String5-String4
retlw 0x03
retlw 'C'
retlw 0x00
retlw 'o'
retlw 0x00
retlw 'n'
retlw 0x00
retlw 'f'
retlw 0x00
retlw 'i'
retlw 0x00
retlw 'g'
retlw 0x00
retlw '.'
retlw 0x00
retlw ' '
retlw 0x00
retlw '2'
retlw 0x00
retlw ':'
retlw 0x00
retlw ' '
retlw 0x00
retlw 'n'
retlw 0x00
retlw 'o'
retlw 0x00
retlw 'n'
retlw 0x00
retlw '-'
retlw 0x00
retlw 'H'
retlw 0x00
retlw 'I'
retlw 0x00
retlw 'D'
retlw 0x00
String5
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -