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

📄 logo.lst

📁 利用CY单片机CY7C637XX编写的USB鼠标程序
💻 LST
📖 第 1 页 / 共 5 页
字号:
                ;                the microcontroller has a power on reset.
                ;
                ;*******************************************************
                
001B            reset:
                        ; set for use with external oscillator
001B 19 0A [04]         mov             A, (LVR_ENABLE|INTERNAL_CLK)    
001D 2A F8 [05]         iowr    clock_config
                
                        ; setup data memory stack pointer
001F 19 68 [04]         mov             A, 68h
0021 30    [05]         swap    A, dsp          
                
                        ; clear variables
0022 19 00 [04]         mov             A, 00h          
0024 31 26 [05]         mov             [ep0_in_machine], A             ; clear ep0 state machine
0026 31 28 [05]         mov             [configuration], A
0028 31 29 [05]         mov             [ep1_stall], A
002A 31 2A [05]         mov             [idle], A
002C 31 20 [05]         mov             [suspend_count], A
002E 31 F0 [05]         mov             [ep1_dmabuff0], A
0030 31 F1 [05]         mov             [ep1_dmabuff1], A
0032 31 F2 [05]         mov             [ep1_dmabuff2], A
0034 31 2F [05]         mov             [int_temp], A
0036 31 30 [05]         mov             [idle_timer], A
0038 31 31 [05]         mov             [idle_prescaler], A
003A 31 2D [05]         mov             [event_machine], A
003C 31 32 [05]         mov             [logo_index], A
003E 31 33 [05]         mov             [ep0_transtype], A
                
0040 19 01 [04]         mov             A, 01h
0042 31 2B [05]         mov             [protocol], A
                
                                ; enable global interrupts
0044 19 05 [04]         mov             A, (1MS_INT | USB_RESET_INT)
0046 2A 20 [05]         iowr    global_int
                
                        ; enable endpoint  0 interrupt
0048 19 01 [04]         mov     A, EP0_INT                      
004A 2A 21 [05]         iowr    endpoint_int
                
                        ; enable USB address for endpoint 0
004C 19 80 [04]         mov             A, ADDRESS_ENABLE       ;0
004E 2A 10 [05]         iowr    usb_address
                
                        ; enable all interrupts
0050 72    [04]         ei
                
                        ; enable USB pullup resistor
0051 19 40 [04]         mov             A, VREG_ENABLE  
0053 2A 1F [05]         iowr    usb_status
                
0055            task_loop:
                
0055 1A 2D [05]         mov             A, [event_machine]
0057 E8 00 [07]         jacc    event_machine_jumptable
0059                            no_event_pending:      ;event_machine=0
                                        ; if not configured then skip data transfer
0059 1A 28 [05]                         mov             A, [configuration]
005B 16 01 [05]                         cmp             A, 01h
005D B0 8D [05]                         jnz             no_event_task
                                        ; if stalled then skip data transfer
005F 1A 29 [05]                         mov             A, [ep1_stall]
0061 16 FF [05]                         cmp             A, FFh
0063 A0 8D [05]                         jz              no_event_task
                                        
                                        ;read logo data
0065 1A 32 [05]                         mov             A, [logo_index]                 
0067 F8 04 [14]                         index   logo_table                              ; get X offset
0069 31 F1 [05]                         mov             [ep1_dmabuff1], A
006B 23 32 [07]                         inc             [logo_index]
006D 1A 32 [05]                         mov             A, [logo_index]
006F F8 04 [14]                         index   logo_table                              ; get Y offset
0071 31 F2 [05]                         mov             [ep1_dmabuff2], A
0073 23 32 [07]                         inc             [logo_index]
0075 1A 32 [05]                         mov             A, [logo_index]
0077 16 6E [05]                         cmp             A, 6Eh                                  ; check if at end of table
0079 B0 7F [05]                         jnz             no_table_reset
007B 19 00 [04]                         mov             A, 00h
007D 31 32 [05]                         mov             [logo_index], A
007F                                    no_table_reset:
                
007F 19 03 [04]                         mov             A, 03h                          ; set endpoint 1 to send 3 bytes
0081 0E 21 [06]                         or              A, [ep1_data_toggle]
0083 2A 13 [05]                         iowr    ep1_count
0085 19 0D [04]                         mov             A, ACK_IN                       ; set to ack on endpoint 1
0087 2A 14 [05]                         iowr    ep1_mode        
                
0089 19 02 [04]                         mov             A, EVENT_PENDING        ; clear pending events
008B 31 2D [05]                         mov             [event_machine], A 
                
008D                            event_task_done:
                        
008D                    no_event_task:
                
008D 80 55 [05]                 jmp task_loop
                
                
                ;*******************************************************
                ;
                ;       Interrupt handler: bus_reset
                ;       Purpose: The program jumps to this routine when
                ;                the microcontroller has a bus reset.
                ;
                ;*******************************************************
                
008F            bus_reset:
008F 19 03 [04]         mov             A, STALL_IN_OUT                 ; set to STALL INs&OUTs
0091 2A 12 [05]         iowr            ep0_mode
                
0093 19 80 [04]         mov             A, ADDRESS_ENABLE               ; enable USB address 0
0095 2A 10 [05]         iowr            usb_address
0097 19 00 [04]         mov             A, DISABLE                      ; disable endpoint1
0099 2A 14 [05]         iowr            ep1_mode
                
009B 19 00 [04]         mov             A, 00h                          ; reset program stack pointer
009D 60    [04]         mov             psp,a   
                
009E 80 1B [05]         jmp             reset
                
                
                ;*******************************************************
                ;
                ;       Interrupt: 1ms_clear_control
                ;       Purpose: Every 1ms this interrupt handler clears
                ;               the watchdog timer.
                ;
                ;*******************************************************
                
00A0            1ms_timer:
00A0 2D    [05]         push A
                
                        ; clear watchdog timer
00A1 2A 26 [05]         iowr watchdog
                
                        ; check for no bus activity/usb suspend
00A3              1ms_suspend_timer:
00A3 29 1F [05]         iord    usb_status                              ; read bus activity bit
00A5 10 08 [04]         and             A, BUS_ACTIVITY    ;08          ; mask off activity bit
00A7 B0 C9 [05]         jnz             bus_activity    
                                        
00A9 23 20 [07]         inc             [suspend_count]                 ; increment suspend counter
00AB 1A 20 [05]         mov             A, [suspend_count]
00AD 16 04 [05]         cmp             A, 04h                  ; if no bus activity for 3-4ms,
00AF A0 B3 [05]         jz              usb_suspend                             ; then go into low power suspend
00B1 80 D3 [05]         jmp             ms_timer_done
                
00B3                    usb_suspend:
                
                                ; enable wakeup timer
                
00B3 19 01 [04]                 mov             A, (USB_RESET_INT)
00B5 2A 20 [05]                 iowr            global_int
                
00B7 29 FF [05]                 iord            control
00B9 0D 08 [04]                 or              A, SUSPEND                      ; set suspend bit
00BB 72    [04]                 ei
00BC 2A FF [05]                 iowr            control
00BE 20    [04]                 nop
                
                                ; look for bus activity, if none go back into suspend
00BF 29 1F [05]                 iord    usb_status
00C1 10 08 [04]                 and             A, BUS_ACTIVITY
00C3 A0 B3 [05]                 jz              usb_suspend             
                
                                ; re-enable interrupts
00C5 19 05 [04]                 mov             A, (1MS_INT | USB_RESET_INT)
00C7 2A 20 [05]                 iowr    global_int
                
                
00C9                    bus_activity:           ;clear the activity bit
00C9 19 00 [04]                 mov             A, 00h                          ; reset suspend counter
00CB 31 20 [05]                 mov             [suspend_count], A
00CD 29 1F [05]                 iord            usb_status
00CF 10 F7 [04]                 and             A, ~BUS_ACTIVITY        ; clear bus activity bit
00D1 2A 1F [05]                 iowr            usb_status
                
                
00D3                    ms_timer_done:
00D3 2B    [04]                 pop A
00D4 73    [08]                 reti
                
                ;*******************************************************
                ;
                ;       Interrupt: endpoint0
                ;       Purpose: Usb control endpoint handler.  This interrupt
                ;                       handler formulates responses to SETUP and 
                ;                       CONTROL READ, and NO-DATA CONTROL transactions. 
                ;
                ;       Jump table entry formulation for bmRequestType and bRequest
                ;
                ;       1. Add high and low nibbles of bmRequestType.
                ;       2. Put result into high nibble of A.
                ;       3. Mask off bits [6:4].
                ;       4. Add bRequest to A.
                ;       5. Double value of A (jmp is two bytes).
                ;
                ;*******************************************************
                
00D5            endpoint0:
00D5 2E    [05]         push    X
00D6 2D    [05]         push    A
                
00D7 29 12 [05]         iord    ep0_mode
00D9 10 10 [04]         and             A, EP0_ACK
00DB A0 E8 [05]         jz              ep0_done
                
00DD 29 12 [05]         iord    ep0_mode
00DF 3B    [04]         asl             A
00E0 C0 EB [05]         jc              ep0_setup_received
00E2 3B    [04]         asl             A
00E3 C3 49 [05]         jc              ep0_in_received
00E5 3B    [04]         asl             A
00E6 C3 9D [05]         jc              ep0_out_received
00E8              ep0_done:
00E8 2B    [04]         pop             A

⌨️ 快捷键说明

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