📄 usb.lst
字号:
003D EP0_Next_Mode: equ (usbmain_ram_base+27)
003D EP0_FLAG: equ (usbmain_ram_base+28)
003D USBMAIN_RAM_SIZE: equ 29
003D
003D SUSPEND_FLAG: equ 1
003D SCAN_FLAG: equ 2
003D ;========================================================================
003D ; program listing
003D ;========================================================================
003D
003D
003D ;========================================================================
003D ; The 128 uSec interrupt is not used by the keyboard code. The keyboard
003D ; only does not require the DAC or GPIO port in this version of
003D ; firmware. It may be necessary to enable GPIO interrupts when the
003D ; keyboard enters a power down suspend mode.
003D DoNothing_ISR:
003D 73 [08] reti ; return from interrupt
003E
003E ;========================================================================
003E ; Suspend
003E ;
003E ; This routine is invoked from the main loop when bus activity has ceased for
003E ; 3 msec or more. This routine prepares the keyboard for suspension, suspends
003E ; the part, and restores the keyboard upon a subsequent resume.
003E ;========================================================================
003E ; Suspend
003E ;
003E ; This routine is invoked from the main loop when bus activity has ceased for
003E ; 3 msec or more. This routine prepares the keyboard for suspension, suspends
003E ; the part, and restores the keyboard upon a subsequent resume.
003E
003E Suspend:
003E
003E 2D [05] push A
003F ; (since all pins are guaranteed to not float)
003F
003F 9E 40 [10] call mouse_suspend ; put PS/2 mouse in stream mode
0041 70 [08] di ; disable interrupts
0042 19 FF [04] mov A, RESISTIVE_NEG ; all ports resistive neg so that
0044 2A 08 [05] iowr GPIO_Config ; we stay within suspend current budget (500uA)
0046 19 00 [04] mov A, 0 ; pull down the column lines
0048 2A 00 [05] iowr Port0_Data
004A 2A 01 [05] iowr Port1_Data
004C 1A 88 [06] mov A, [ksc_p3out]
004E 0D 07 [04] or A, P3_LED_MASK ; turn LEDs off
0050 10 3F [04] and A, ~P3_KEY_MASK ; don't touch bit 6 & 7 (PS/2 mouse interface)
0052 2A 03 [05] iowr Port3_Data
0054 19 FF [04] mov A, FFh
0056 2A 06 [05] iowr Port2_Interrupt ; enable port 2 GPIO interrupt for keyboard
0058 19 20 [04] mov A, GPIO_ONLY_MASK ; enable GPIO interrupt only
005A 2A 20 [05] iowr Global_Interrupt
005C 1A 32 [06] mov A, [remote_wakeup_status] ; is remote wakeup feature enabled?
005E 16 02 [04] cmp A, ENABLE_REMOTE_WAKEUP
0060 B0 63 [05] jnz Suspend_controller
0062 72 [08] ei
0063 Suspend_controller:
0063
0063 29 FF [05] iord Status_Control ; set the suspend bit causing suspend
0065 0D 08 [04] or A, 08h
0067 2A FF [05] iowr Status_Control ; we are suspended here
0069
0069 ; resume !!!!!!
0069 20 [04] nop ; execute a nop after resuming
006A
006A 70 [08] di
006B 2A 26 [05] iowr Watchdog
006D 29 1F [05] iord USB_Status_Control ; check if there is no bus activity
006F 10 08 [04] and A, 08h
0071 16 00 [04] cmp A, 00h
0073 B0 A5 [05] jnz GPIO_disable_interrupts ; if there is bus activity,
0075 ; disable interrupts and exit
0075
0075
0075 19 04 [04] mov A, TIMER_ONLY_MASK ; enable 1ms interrupt
0077 2A 20 [05] iowr Global_Interrupt
0079 72 [08] ei
007A 1A 3F [06] mov A, [1ms_counter] ; clear wakeup counter
007C 01 05 [04] add A,5
007E
007E wakeup_delay: ; wait 5ms before we send the wakeup signal
007E 2A 26 [05] iowr Watchdog
0080 17 3F [06] cmp A, [1ms_counter]
0082 B0 7E [05] jnz wakeup_delay
0084
0084 70 [08] di ; disable interrupts
0085
0085 29 1F [05] iord USB_Status_Control ; check again if there is no bus activity
0087 10 08 [04] and A, 08h ; after 5ms
0089 16 00 [04] cmp A, 00h
008B B0 A5 [05] jnz GPIO_disable_interrupts ; if there is bus activity,
008D ; disable interrupts and exit
008D
008D
008D 19 02 [04] mov A, FORCE_J ; force J state to correct cross-over voltage
008F 2A 1F [05] iowr USB_Status_Control ; problem during resume signalling
0091
0091 19 01 [04] mov A, FORCE_K ; start sending resume signal
0093 2A 1F [05] iowr USB_Status_Control
0095
0095 72 [08] ei ; enable 1ms interrupt again
0096 1A 3F [06] mov A, [1ms_counter] ; clear wakeup counter
0098 01 0A [04] add A,0ah
009A
009A wakeup_duration: ; send resume signal for 10ms
009A 2A 26 [05] iowr Watchdog
009C 17 3F [06] cmp A, [1ms_counter]
009E B0 9A [05] jnz wakeup_duration
00A0
00A0 70 [08] di ; disable interrupts
00A1
00A1 19 00 [04] mov A, NOT_FORCING ; let SIE control D+/D-
00A3 2A 1F [05] iowr USB_Status_Control
00A5
00A5
00A5 GPIO_disable_interrupts: ;
00A5 ;interrupts are off when we get here
00A5 29 1F [05] iord USB_Status_Control
00A7 10 F7 [04] and A, F7h ; clear Bus Activity bit
00A9 2A 1F [05] iowr USB_Status_Control
00AB
00AB 19 00 [04] mov A, 0
00AD 2A 06 [05] iowr Port2_Interrupt ; disable GPIO interrupt for keyboard
00AF
00AF 19 25 [04] mov A, GPIO_TIMER_RESET_MASK ; enable GPIO and 1ms interrupts
00B1 2A 20 [05] iowr Global_Interrupt
00B3
00B3
00B3 72 [08] ei
00B4 9E 40 [10] call mouse_resume ; put PS/2 mouse into polling mode
00B6 70 [08] di
00B7 Skip_suspend:
00B7 19 F5 [04] mov A, NORMAL ; restore original GPIO configuration
00B9 2A 08 [05] iowr GPIO_Config
00BB 19 00 [04] mov A,0
00BD 31 44 [05] mov [suspend_counter],A
00BF 9D 8B [10] call ksc_restore_ports ; restore column ports to pre-suspend values
00C1 72 [08] ei
00C2 2B [04] pop A
00C3 3F [08] ret
00C4
00C4
00C4
00C4 check_activity:
00C4
00C4 29 1F [05] iord USB_Status_Control ; check if there is bus activity
00C6 10 08 [04] and A, 08h
00C8 3F [08] ret
00C9
00C9 ;========================================================================
00C9 ; The 1 msec interrupt is used to clear the watchdog timer, to maintain
00C9 ; all timers with a 1msec granularity
00C9 ;========================================================================
00C9
00C9 One_mSec_ISR:
00C9 23 3F [07] inc [1ms_counter] ;increment 1msec timer
00CB 1A 3F [06] mov A,[1ms_counter]
00CD 10 03 [04] and A,3
00CF
00CF B0 D7 [05] jnz check_bus_activity_status ;every 4 msec, do the following:
00D1
00D1 1A 48 [06] mov A,[background_flags] ; set the flag to scan the keyboard
00D3 0D 02 [04] or A,SCAN_FLAG
00D5 31 48 [05] mov [background_flags],A
00D7
00D7 check_bus_activity_status:
00D7 29 1F [05] iord USB_Status_Control ; check if there is no bus activity
00D9 10 08 [04] and A, 08h
00DB 16 00 [04] cmp A,0h
00DD A0 EB [05] jz Inc_counter ; if there was bus activity
00DF 29 1F [05] iord USB_Status_Control ; clear the bus activity bit
00E1 10 F7 [04] and A, 0F7h
00E3 2A 1F [05] iowr USB_Status_Control
00E5 19 00 [04] mov A, 0h ; clear the suspend counter
00E7 31 44 [05] mov [suspend_counter], A ;
00E9 80 F9 [05] jmp Exit_1ms
00EB
00EB Inc_counter: ;there was no bus activity,
00EB 23 44 [07] inc [suspend_counter] ;so increment the bus activity counter
00ED 1A 44 [06] mov A,[suspend_counter]
00EF 16 03 [04] cmp A, 03h ;if 3msecs of bus inactivity passed
00F1 C0 F9 [05] jc Exit_1ms
00F3 1A 48 [06] mov A,[background_flags] ; set the suspend flag
00F5 0D 01 [04] or A,SUSPEND_FLAG
00F7 31 48 [05] mov [background_flags],A ;
00F9
00F9
00F9 Exit_1ms:
00F9 9E 40 [10] call mouse_1mS_int ; call the mouse 1msec ISR code.
00FB 2B [04] pop A
00FC 73 [08] reti ; return from interrupt
00FD ;========================================================================
00FD ; Endpoint one is used to send keyboard data to the host. This interrupt
00FD ; occurs if the USB serial interface engine has transferred a packet
00FD ; to the host (including NAKs).
00FD ;
00FD ; This routine disables another transfer until valid data has been loaded
00FD ; into the endpoint. This routine is also responsible for toggling the
00FD ; data 0/1 bit for endpoint one after every successful transfer.
00FD USB_EP1_ISR:
00FD 2D [05] push A ; save accumulator on stack
00FE 20 [04] NOP
00FF 1F [04] XPAGE
0100 29 14 [05] iord EP_A1_Mode ; test whether we have an ACK bit
0102 10 10 [04] and A, ACK_BIT
0104 A1 10 [05] jz doneEP1 ; do nothing if we don't have an ACK bit
0106
0106 19 0C [04] mov A, NAKIN ; clear ACK bit
0108 2A 14 [05] iowr EP_A1_Mode
010A
010A 29 13 [05] iord EP_A1_Counter ; flip data 0/1 bit after
010C 13 80 [04] xor A, DATATOGGLE ; a successful data transfer
010E 2A 13 [05] iowr EP_A1_Counter
0110
0110
0110 doneEP1:
0110 2B [04] pop A ; restore accumulator from stack
0111 73 [08] reti ; return from interrupt
0112
0112 ;========================================================================
0112 ; Endpoint two is used to consumer/power key data to the host. This interrupt
0112 ; occurs if the USB serial interface engine has transferred a packet
0112 ; to the host (including NAKs).
0112 ;
0112 ; This routine disables another transfer until valid data has been loaded
0112 ; into the endpoint. This routine is also responsible for toggling the
0112 ; data 0/1 bit for endpoint one after every successful transfer.
0112 USB_EP2_ISR:
0112 2D [05] push A ; save accumulator on stack
0113 29 16 [05] iord EP_A2_Mode ; test whether we have an
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -