⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme

📁 该程序为USB HUB程序
💻
字号:
;=========================================================================
;   Copyright : Cypress Semiconductor Corp, 2000.
;-------------------------------------------------------------------------
;   This is the Cypress COMBI KEYBOARD HUB Reference Design. 
;-------------------------------------------------------------------------
;   The combi means it has Y-type cable to connect both USB and PS/2.
;   Hub supports 2 or 4 port. (option)
;   Reference designe is for demonstration only. 
;   Cypress Semiconductor will not assume any responsibilities for its use.
;-------------------------------------------------------------------------
;   Design Notes:
;
;   This design implements a keyboard function and an embedded hub as a USB
;   compound device. The hub is configured as a bus-powered 4-port hub 
;   utilizing CY66113. It has Y-type cable to connect both USB and PS/2.
;   The keyboard use PS/2. if PS/2 is not connected, The USB keyboard is 
;   configured as a "virtual port" on the hub's 5th port. 
;   The keyboard,as a device, reports it's status and change over the hub's 
;   status/change interrupt endpoint along with the other 4 downstream ports 
;   of the hub.
;
;   The number of downstream ports is configurable by setting MAX_PORTS
;   in OPTION.INC. All routines support variable port number assignment 
;   and RAM allocations are made for up to 4 downstream ports. 
;-------------------------------------------------------------------------
;   Design Specifications:
;
;   [1] USB Rev 1.1
;   [2] USB Rev 1.1 Chapter 11 HUB Specification
;   [3] CY7C66113 High-Speed USB Controller with Integrated Hub data sheet
;   [4] Microsoft Keyboard Scan Code specification Rev1.3a
;   [5] HID Ver 1.1
;   [6] Combi Keyboard Hub Functional Specification Rev 1.0
;   [7] USB Language Identifiers (LANGIDs)Rev 1.0
;   [8] USB Rev 2.0
;
;=========================================================================
;   Development Environment
;-------------------------------------------------------------------------
;   Assembler:    CYASM.EXE (DOS) Version 1.94 (2000)
;                 [example:  CYASM MAIN.ASM -b -t4]
;
;   CAUTION:      CANNOT have XPAGE instructions fall within a JMP table.
;                 Code does not jump correctly for obvioius reasons.
;                 ( See JMP_TBL.ASM ). 
;                 However MUST have XPAGEON!
;
;=========================================================================
;   System parameters
;-------------------------------------------------------------------------
;   Device      CY7C66113 (DAC with 8K EPROM)
;
;   Clock Speed: 
;               12MHz internal from 6MHz external crystal (PLL)
;               USB Hub 48MHz
;
;   Instruction Cycle   
;               Most instructions are 4 to 8 cycles
;               CLK/4 => 333ns/instruction
;
;   Instructions/USB Frame Interval (1ms)
;               12000 Clocks/ms
;               Avg: 2000 instructions/ms
;
;=========================================================================
;   Module descriptions:
;   
;   ckhub.asm       ROM allocation
;   option.inc      Hardware configuration / Software option
;
;   equate.inc      Global system EQU's (CPU specific registers and MASKS)
;   malloc.inc      RAM allocation EQU's
;   macro.inc       Generic system macro definitions
;   hub.inc         Hub related definition
;
;   kbhub.asm       Main loop & 1~4 Port hub + PS/2 & USB Keyboard
;
;   kbscan.asm      Key scan, Phantome key, N-key rollover
;   kbmatrix.asm    Scan matrix
;   kb101.inc       Scan matrix definition
;
;   kbusb.asm       USB Keyboard
;
;   ps2main.asm     PS2 keyboard initial and PS2 loop
;   ps2key.asm      PS2 Keycode transmit/receive
;   ps2_io.asm      PS2 I/O Level
;   ps2.inc         PS2 definitions
;
;   ck.asm          Combi keyboard function
;
;   suspend.asm     Suspend & Resume subroutine
;
;   ocp.asm         Overcurrent detect, shutdown and report
;
;=========================================================================
; Revision History ( Please use the template below! )
;-------------------------------------------------------------------------
;   Rev     : 
;   Date    :   
;   By      :   
;-- Notes ----------------------------------------------------------------
; 
;-------------------------------------------------------------------------
;   Rev     : 1.0
;   Date    : Aug 2nd, 2000  
;   By      : JUK  
;-- Notes ----------------------------------------------------------------
;   Debugged to pass USBCheck 3.2 test (Chapter 9 & 11)
;   -. HubBase & KBBase address mixing problem  
;   -. ClearEndpointFeature
;   -. SetPortFeature 
;   -. SetPortSuspend (Port number is fixed.)
;   -. ClearPortChange (Branch is corrected.)
;   -. ClearHubFeature is implemented.
;   -. Descriptor errors are fixed.
;
;   (Etc)
;   New macro file is defined for conditional branch function.
;   Direct numbers are changed with proper label & Equation
;   Added comment to make it easy to understand.
;   Redundancy is removed at several position. 
;   Hub port number is replaced with label. ( 2 Port / 4 Port ) 
;   7 Port part is removed. (Conditional assembler v1.90)
;   Memory allocation is changed from 8 port to 4 port maximum.
;-------------------------------------------------------------------------
;   Rev     : 1.1
;   Date    : Aug 15th, 2000  
;   By      : JUK  
;-- Notes ----------------------------------------------------------------
;   Keyboard routine is added.
;   USB or PS2 option can be seleted in option.inc file.
;   -. Common keyboard routine ( Key Scan, Phantom, Rollover, ...)
;   -. USB keyboard routine ( Key report, LED report, ... )
;   -. PS2 keyboard routine ( PS2 Buffering, I/O, Typematic, ...)
;-------------------------------------------------------------------------
;   Rev     : 1.2
;   Date    : Aug 17th, 2000  
;   By      : JUK  
;-- Notes ----------------------------------------------------------------
;   -PS/2 Boot error fixed.
;   Reason: When PC is booting, it send 0xff(Keyboard reset command) to 
;           the keyboard. if the keyboard really does software reset,
;           ps2_connect input is changed to LOW short time.
;           it makes fail on boot mode rarely.
;   solution: 0xff command initial only keyboard memory.
;-------------------------------------------------------------------------
;   Rev     : 1.3
;   Date    : Aug 25th, 2000  
;   By      : JUK  
;-- Notes ----------------------------------------------------------------
;   -USB Boot protocol error is fixed
;   -SetReport(Keyboard) stall errors in Win2K is fixed.
;   Reason: When PC is booting, GetDescriptor(Keyboard) is stalled.
;           USB Keyboard is not enumerated. software bug.
;   solution: Checking HubControlCount routine is located in Hub, 
;           KBD common routine. it was moved to Hub part and
;           Keyboard ControlCount is generated in Keyboard part newly.
;   -In emulator test, micros are already turned on. 
;    it can cause ps/2 BAT error in boot mode. (if PS/2 only connected)
;   -GetIdle, SetIdle supported. (No more stall) HIDView test PASS!
;   -HubPortBase,PortStatus,PortChange location is modified.(Malloc.inc)
;   -USB keyboard resume after wakeup
;       Upstream port K status ( 1 ~ 14msec ; 5msec for Old PC )
;       PortCounter = 1 to emulate functions below...
;           ClearPortStatus(PORT_SUSPEND)
;           SetPortChange(C_PORT_SUSPEND)
;           Set Hub EP1 AckIn
;   -When the PS/2 is connected, USB per port wakeup.
;-------------------------------------------------------------------------
;   Rev     : 1.4
;   Date    : Aug 28th, 2000  
;   By      : JUK  
;-- Notes ----------------------------------------------------------------
;   -All interrupts are disabled while PS/2 protocol is processing.
;    it reduce the LED data error. 
;   -getbit() timing in ps2_io.asm is modified.
;   (before)
;    ----+       +-----
;        |       |    
;        +R------+      R:Read port
;   (after)
;
;    ----+       +-----
;        |       |    
;        +----R--+      R:Read port
;
;   -Over-current protection is debugged.
;
;   -Vsw Enable is added to SetPortPower() in kbhub.asm
;-------------------------------------------------------------------------
;   Rev     : 1.5
;   Date    : Aug 31st, 2000  
;   By      : JUK  
;-- Notes ----------------------------------------------------------------
;   -Prevent not to write zero value to Bit7 of Port3.
;   -DI added to Power on reset
;   -Keyboard disable is remarked. ( To avoid error )
;-------------------------------------------------------------------------
;   Rev     : 1.6
;   Date    : Sep 6th, 2000  
;   By      : JUK  
;-- Notes ----------------------------------------------------------------
;   -WHQL TEST (USB) 
;       2 & 3 Key Combo test fail
;       if Any other key is pressed, Report Byte 0 (Modifier) is cleared.        
;    Reason : USB_KBD_Reset is done every main loop. (Bug)
;    Solution : USB_RESET_FLAG is defined.
;-------------------------------------------------------------------------
;   Rev     : 1.61
;   Date    : Sep 8th, 2000  
;   By      : JUK  
;-- Notes ----------------------------------------------------------------
;   -Both PS2 and USB cable are connected, Double keys are noticed.           
;   Reason : PS2 disable interrupt, if it is re-enabled, timing is screwed up.
;   Solution : DEBOUNCE_RELEASE_TIME = 3 ( Old 2x4msec --> 3x4msec )
;
;-------------------------------------------------------------------------
;   Rev     : 1.62
;   Date    : Sep 15th, 2000  
;   By      : JUK  
;-- Notes ----------------------------------------------------------------
;   - Cold & Warm boot problem with Win98 ( over 50% )
;   Reason : WDR clear all endpoint mode register. (Disable status)
;   Solution : If the Watchdog reset is occurred, Upplug/plug is simulated.
;              SE0 is output to USB upstream port for 700usec.
;              'ESDTEST' compile option is enabled at option.inc.
;              Simulating routine is modified to determine WDR state.
;-------------------------------------------------------------------------
;   Rev     : 1.63
;   Date    : Sep 18th, 2000  
;   By      : JUK  
;-- Notes ----------------------------------------------------------------
;   - POR bit is cleared ([3] Processor Status and Control Register 0xFF)
;	- WDR detect bit is changed from 0x40 -> 0x10
;	- WDR SE0 Timing is changed from 700usec to 100msec (at least 1msec)
;-------------------------------------------------------------------------
;   Rev     : 1.64
;   Date    : Sep 20th, 2000  
;   By      : JUK  
;-- Notes ----------------------------------------------------------------
;   - Cyasm version 1.94(debug)
;   - 4 port Hub only function checked. (HubOnly compile option)
;     Power port is changed from DAC port to Port0
;
;     Bit7    Bit6    Bit5    Bit4    Bit3    Bit2    Bit1    Bit0
;     OCin#4  OC_in#3 OC_in#2 OC_in#1 Out#4   Out#3   Out#2   Out#1
;
;   - SetProtocol function is added. 
;     Gateway PIII 700MHz model doesn't accept the stall of SetProtocol.
;   - String descriptor(F/W Version) is updated.
;-------------------------------------------------------------------------
;   Rev     : 1.65
;   Date    : Sep 22th, 2000  
;   By      : JUK  
;-- Notes ----------------------------------------------------------------
;   - GetProtocol function is added.
;   - String descriptor is updated.
;   - Warning comment is added to String descriptor area.
;-------------------------------------------------------------------------
;   Rev     : 1.66
;   Date    : Nov 9th, 2000  
;   By      : JUK  
;-- Notes ----------------------------------------------------------------
;   - GetDeviceStatus Mask error fixed (Search index : JUK v1.66-1)
;     It only affect to Self-powered hub.
;   - HubStatus is not cleared to remain initial status 
;     (Search index : JUK v1.66-2) It only affect to Self-powered hub.
;   - Cold rebooting problem with Self-powered device 
;     It only affect to USB Keyboard Hub option.
;     (Search index : JUK v1.66-3)
;     Reason : Keyboard is enumerated improper position.
;   - GetPortStatus() error
;     (Search index : JUK v1.66-4)  
;     Reason : HubCounterRegister is not unlocked.
;	- String descriptor & Firmware version fixed (Search index : JUK v1.66-5)
;-------------------------------------------------------------------------
;   Rev     : 1.67
;   Date    : Dec 19th, 2000  
;   By      : JUK  
;-- Notes ----------------------------------------------------------------
;	- The input of unused port is masked to avoid error as described below. 
;     (search index : JUK v1.67-1)
;     
;     3654-P03 application board that uses two downstream port. and another 
;     two downstream port are just opened. These undecided input caused the 
;	  hub to change the speed of virtual keyboard.
; 
;   - String descriptor is modified with version information "v1.67" 
;     (Search index : JUK v1.67-2)
;-------------------------------------------------------------------------
;   Rev     : 1.68
;   Date    : Mar 1st, 2001  
;   By      : BTH   
;-- Notes ----------------------------------------------------------------
;
;	- 2nd interrupt endpoint on keyboard (EPA2) now used to report power/multimedia keys.
;	  Report and HID Class descriptors for EPA2 endpoint added;
;	  Idle reports implemented for EPA2 endpoint;
;	  GetIdle, SetIdle implemented for EPA2 endpoint;
;	  GetReport implemented for both keyboard endpoints;
;	  Power/MM key functionality added to both USB and PS/2
;	- Keyboard SetEndpointHalt sets EPA[1,2] response to STALL
;	- Keyboard ClearEndpointHalt sets EPA[1,2] response to NAK, resets toggle to DATA0
;	- Keyboard SetConfiguration	resets EPA[1,2] toggle to DATA0 
;	  Search index: BTH v1.68
;-------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -