📄 lite_frm.asm
字号:
; mov WR26, #LOW16(OUT_BUFFERS)
; mov R7, RXCNT0 ; Read count of bytes rec'd
; mov @WR26, R7 ; Store the count in the OUT_BUFFERS space.
; add WR26, #01h ; Increment mem pointer
; orl R7, R7 ; Set flags
; je Return
;WriteToOUTBuffer:
; mov R8, RXDAT0
; mov @WR26, R8
; inc WR26, #01h
; djnz R7, WriteToOUTBuffer
;Return:
; Ret
COMMENT *------------------------------------------------------------
Function name : INIT_USB
Brief Description : Initialize USB SFRs
Regs preserved : No reg. is saved
--------------------------------------------------------------------*
SCOPE
INIT_USB:
mov SBI, #00h
mov TXCON0, #84h ; Flush FIFO, sets Empty bit in TXFLG0, enable ATM.
mov RXCON0, #84h ; Flush FIFO, sets Empty bit in RXFLG0, enable ARM.
; Enable endpoint 0 as a control endpoint. We need to set the
; Transmit Endpoint enable, Receive Endpoint enable, and the
; Receive Input enable. We do not set the Transmit Output enable
; until we have determined what type of response we need to send
; back, i.e., NULL packet for status phase or data for a "GET"
; command.
mov EPCON0, #3Dh;
ReturnInitUSB:
Ret
COMMENT *------------------------------------------------------------
Function name : INIT_VARIABLES
Brief Description : Initializes global variables
Regs preserved : No reg. is saved
--------------------------------------------------------------------*
SCOPE
INIT_VARIABLES:
;Init SETUP VARIABLES
mov R0, #00h
mov Heart1, R0
mov Heart1+1, R0
mov gbSetupSeqRX, R0 ; SetupSeq is set to
mov gbSetupSeqTX, R0 ; STATUS_PHASE
ReturnInit:
Ret
;************************************************************************
;************* DEVICE DESCRIPTOR ****************************************
;************************************************************************
;
; NOTE!!!!! '251 is a Big Endian machine. Words and DWords are stored with the
; LSB in the numerically higher address.
;
BEGIN_DEVICE_DESCRIPTOR:
gDevice_bLength: db DEVICE_DESCRIPTOR_LENGTH
gDevice_bDescriptorType: db DEVICE_DESCR
gDevice_bcdUSB: dw 0001h ; Version 1.00 compliant
gDevice_bDeviceClass: db 00h
gDevice_bDeviceSubClass: db 00h
gDevice_bDeviceProtocol: db 00h
gDevice_wMaxPacketSize0: db 08h ;8 byte max for EP0
gDevice_widVendor: dw 8680h ;Intel Vendor ID (8086)
gDevice_widProduct: dw AD0Dh ;product ID 0DADh
gDevice_bcdDevice: dw 0001h ;device version 1.00
gDevice_iManufacturer: db 0h ;These three fields are supposed
gDevice_iProduct: db 0h ;to contain the index of strings
gDevice_iSerialNumber: db 0h ;describing device.
gDevice_bNumConfigurations: db 02h
END_DEVICE_DESCRIPTOR:
;/*--------------- Initialize global Config descriptor ----------------*/
BEGIN_CONFIG_DESCRIPTOR:
gConfig_bLength: db 09h
gConfig_bDescriptorType: db CONFIG_DESCR
gConfig_bTotalLength: db END_CONFIG_DESCRIPTOR - BEGIN_CONFIG_DESCRIPTOR
gConfig_bCorrection: db 0
gConfig_bNumInterfaces: db 01h ;NUM_OF_INTERFACES (2 for kbd & mouse)
gConfig_bConfigurationValue: db 01h
gConfig_iConfiguration: db 0
gConfig_bmAttributes: db 060h
gConfig_MaxPower: db 025h ;50ma
; /*------------- Initialize KBD Interface descriptor ---------------*/
BEGIN_KBD_INTERFACE_DESCRIPTOR:
gInterface_bLength: db END_KBD_INTERFACE_DESCRIPTOR - BEGIN_KBD_INTERFACE_DESCRIPTOR
gInterface_bDescriptorType: db INTERFACE_DESCR
gInterface_bInterfaceNumber: db 00h ;(0=KBD, 1=MOUSE)
gInterface_bAlternateSetting: db 0
gInterface_bNumEndpoints: db 01h
gInterface_bInterfaceClass: db 03h
gInterface_bInterfaceSubClass: db 0 ; Boot device = 01
gInterface_bInterfaceProtocol: db 01h ; 01=KBD, 02=mouse
gInterface_iInterface: db 0
END_KBD_INTERFACE_DESCRIPTOR:
; /*------------- Initialize Endpoint 2 descriptor ---------------*/
BEGIN_ENDPOINT2_DESCRIPTOR:
gEP2_bLength: db END_ENDPOINT2_DESCRIPTOR - BEGIN_ENDPOINT2_DESCRIPTOR
gEP2_bDescriptorType: db ENDPOINT_DESCR
gEP2_bEndpointAddress: db 82h ;EP address 2, IN
gEP2_bmAtrributes: db 03h ;Interrupt
gEP2_wMaxPacketSize: dw 0800h ;Max Packet 8 bytes
gEP2_bInterval: db 08h ;Poll every 8ms
END_ENDPOINT2_DESCRIPTOR:
; /*----------------- Initialize KBD HID descriptor -------------------*/
BEGIN_KBD_HID_DESCRIPTOR:
db END_KBD_HID_DESCRIPTOR - BEGIN_KBD_HID_DESCRIPTOR
db 21h ; Type of HID descriptor
dw 0001h ; HID Spec version
db 0 ; Country code of localized hardware
db 01h ; Number of class descriptors to follow (does this include mouse HID desc???)
db 22h ; Succeeding Desc type: 21=HID, 22=Report, 23=Physical
; Placement of Report descriptors is not clear.
; They are not to be returned in "Get Config Desc"
; request but yet it appears that they must
; "succeed" this HID Desc ?????????
dw END_KBD_REPORT_DESCRIPTOR - BEGIN_KBD_REPORT_DESCRIPTOR
END_KBD_HID_DESCRIPTOR:
END_CONFIG_DESCRIPTOR:
; /*------------- Initialize MOUSE Interface descriptor ---------------*/
;BEGIN_MOUSE_INTERFACE_DESCRIPTOR:
; gInterface_bLength: db END_MOUSE_INTERFACE_DESCRIPTOR - BEGIN_MOUSE_INTERFACE_DESCRIPTOR
; gInterface_bDescriptorType: db INTERFACE_DESCR
; gInterface_bInterfaceNumber: db 0h ;01h
; gInterface_bAlternateSetting: db 0
; gInterface_bNumEndpoints: db 01h
; gInterface_bInterfaceClass: db 03h
; gInterface_bInterfaceSubClass: db 0 ; Boot device = 01
; gInterface_bInterfaceProtocol: db 00h ; 01=KBD, 02=mouse
; gInterface_iInterface: db 0
;END_MOUSE_INTERFACE_DESCRIPTOR:
; /*------------- Initialize Endpoint 3 descriptor ---------------*/
;BEGIN_ENDPOINT3_DESCRIPTOR:
; gEP2_bLength: db END_ENDPOINT3_DESCRIPTOR - BEGIN_ENDPOINT3_DESCRIPTOR
; gEP2_bDescriptorType: db ENDPOINT_DESCR
; gEP2_bEndpointAddress: db 83h ;EP address 3, IN
; gEP2_bmAtrributes: db 03h ;Interrupt
; gEP2_wMaxPacketSize: dw 0400h ;Max Packet 4 bytes
; gEP2_bInterval: db 08h ;Poll every 8ms
;END_ENDPOINT3_DESCRIPTOR:
; /*------------- Initialize MOUSE HID descriptor ----------------*/
;BEGIN_MOUSE_HID_DESCRIPTOR:
; db END_MOUSE_HID_DESCRIPTOR - BEGIN_MOUSE_HID_DESCRIPTOR
; db 21h ; Type of HID descriptor
; dw 0001h ; HID Spec version
; db 0 ; Country code of localized hardware
; db 01h ; Number of class descriptors (1 for mouse report)
; db 22h ; Succeeding Desc type: 01=HID, 02=Report, 03=Physical
; dw END_MOUSE_REPORT_DESCRIPTOR - BEGIN_MOUSE_REPORT_DESCRIPTOR
;END_MOUSE_HID_DESCRIPTOR:
;END_CONFIG_DESCRIPTOR:
; /*--------------- Initialize KBD Report descriptor ------------------*/
BEGIN_KBD_REPORT_DESCRIPTOR: ; Replaces "ENTITY_DESCRIPTOR"
db 005h ; Usage Page = Generic Desktop
db 001h
db 009h ; Usage = KBD
db 006h
db 0A1h ; Collection = Application
db 001h
db 005h ; Usage Page = Key Codes
db 007h
; db 019h ; Usage Min = 00h WHAT IS USAGE MAX/MIN?
; db 000h
; db 029h ; Usage Max = FFh
; db 0FFh
db 015h ; Logical Min = 01h (for ID byte)
db 001h
db 025h ; Logical Max = 02h (for ID byte)
db 002h
;ID byte
db 075h ; Report Size = 08h (# of bits)
db 008h
db 095h ; Report Count = 01h (# of reports)
db 001h
db 081h ; Input = Constant
db 001h
;Modifier byte
db 015h ; Logical Min = 0 (for MOD byte)
db 000h
db 025h ; Logical Max = 1 (for MOD byte)
db 001h
db 075h ; Report Size = 08h (# of bits)
db 008h
db 095h ; Report Count = 01h (# of reports)
db 001h
db 081h ; Input = Data,Variable,Absolute
db 002h
;Reserved byte (should be all 0's)
db 075h ; Report Size = 08h (# of bits)
db 008h
db 095h ; Report Count = 01h (# of reports)
db 001h
db 081h ; Input = Constant
db 001h
;LED Report
db 075h ; Report Size = 05h (# of bits)
db 005h
db 095h ; Report Count = 01h (# of reports)
db 001h
db 005h ; Usage Page = LED's
db 008h
db 019h ; Usage Min = 1
db 001h
db 029h ; Usage Max = 5
db 005h
db 091h ; Output = Data,Variable,Absolute
db 002h
;LED Report Padding
db 075h ; Report Size = 03h (# of bits)
db 003h
db 095h ; Report Count = 01h (# of reports)
db 001h
db 091h ; Output =Constant
db 001h
;Key Array
db 075h ; Report Size = 08h (# of bits)
db 008h
db 095h ; Report Count = 05h (# of reports)
db 005h
db 015h ; Logical Min = 0
db 000h
db 025h ; Logical Max = 0FFh (FF possible values)
db 0FFh
db 005h ; Usage Page = Key Codes
db 007h
db 019h ; Usage Min = 0
db 000h
db 029h ; Usage Max = 0FFh (FF possible values)
db 0FFh
db 081h ; Input = Data,Array,Absolute
db 000h
db 0C0h ; End Collection
END_KBD_REPORT_DESCRIPTOR:
; /*------- Initialize MOUSE Report descriptor ------------------*/
;BEGIN_MOUSE_REPORT_DESCRIPTOR: ; Replaces "ENTITY_DESCRIPTOR"
; db 005h ; Usage Page = Generic Desktop
; db 001h
; db 009h ; Usage = MOUSE
; db 002h
; db 0A1h ; Collection = Application
; db 001h
; db 009h ; Usage = Pointer
; db 001h
; db 0A1h ; Collection = Linked
; db 000h
;
; db 015h ; Logical Min = 01h (for ID byte)
; db 001h
; db 025h ; Logical Max = 02h (for ID byte)
; db 002h
;;ID byte
; db 075h ; Report Size = 08h (# of bits)
; db 008h
; db 095h ; Report Count = 01h (# of reports)
; db 001h
; db 081h ; Input = Constant
; db 001h
;;Button byte
; db 005h ; Usage page = Buttons
; db 009h
; db 019h ; Usage min = 01 ???
; db 001h
; db 029h ; Usage max = 03 ???
; db 002h
; db 015h ; Logical Min = 0 (for button byte)
; db 000h
; db 025h ; Logical Max = 1 (for button byte)
; db 001h
; db 075h ; Report Size = 02h (# of bits)
; db 002h
; db 095h ; Report Count = 01h (# of reports)
; db 001h
; db 081h ; Input = Data,Variable,Absolute
; db 002h
;;6-bit padding
; db 075h ; Report Size = 06h (# of bits)
; db 006h
; db 095h ; Report Count = 01h (# of reports)
; db 001h
; db 081h ; Input = Constant
; db 001h
;;X & Y position bytes
; db 005h ; Usage Page = Generic Desktop
; db 001h
; db 009h ; Usage = X
; db 030h
; db 009h ; Usage = Y
; db 031h
; db 015h ; Logical Min = -127 (for POS byte)
; db 081h
; db 025h ; Logical Max = 127 (for POS byte)
; db 07Fh
; db 075h ; Report Size = 08h (# of bits)
; db 008h
; db 095h ; Report Count = 02h (# of reports)
; db 002h
; db 081h ; Input = Data,Variable,Relative
; db 006h
; db 0C0h ; End Collection (Linked)
; db 0C0h ; End Collection (Application)
;
;END_MOUSE_REPORT_DESCRIPTOR:
;(SPR)
STRING_LOC_TABLE:
STRING_1: db LOW(STRING_2-STRING_1)
db STRING_DESCR
db "KENS FIRMWARE"
STRING_2:
;#############################################################
;####### RAM MEMORY MAP ######################################
;#############################################################
;----------------------------------------------------------------------------
;- Control varaibles need to be placed between 20h & 7fh for the addressing mode
;- If RISM is running, RISM needs 20h-3fH so be careful running RISM.
;----------------------------------------------------------------------------
DEFINE OUR_DATA_SEG, SPACE=DATA
SEGMENT OUR_DATA_SEG
;;
;; Buffer and associated variables for Control Endpoint management
gbSetupSeqTX: ds 1
gbSetupSeqRX: ds 1
COMMAND_BUFFER:
StandardDeviceRequest:
bmRequestType: ds 1
bRequest: ds 1
wValue:
wFeatureSelector:
bDescriptorType: ds 1
bDescriptorIndex: ds 1
wTargetSelector:
wIndex: ds 2
wLength: ds 2
gbDebugMess: ds 1
gbFControlBufferLocation ds 3
gbFControlBufferBytesLeft ds 1
Heart1: ds 2
;org 00:B000h
;----------------------------------------------------------------------------
;- Buffer data can go above the 80 location. we dont need bit addressing
;- on these varaibles.
;----------------------------------------------------------------------------
define BUF_DATA_SEG, SPACE=pdata
segment BUF_DATA_SEG
IN_BUFFERS: ds 256
;org 00:C000h
;OUT_BUFFERS: ds 256
END
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -