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

📄 enchid.lst

📁 USB主控器固件程序源码
💻 LST
📖 第 1 页 / 共 5 页
字号:
0012 80 1A [05] jmp     error                           ; Capture timer B interrupt Vector
0014            
0014 80 1A [05] jmp     error                           ; GPIO interrupt vector
0016            
0016 80 1A [05] jmp     error                           ; Wake-up interrupt vector 
0018            
0018            
0018            ;************** program listing ************************
0018            
001A            ORG  1Ah
001A 00    [08] error: halt
001B            
001B            ;*******************************************************
001B            ;
001B            ;       Interrupt handler: reset
001B            ;       Purpose: The program jumps to this routine when
001B            ;                the microcontroller has a power on reset.
001B            ;
001B            ;*******************************************************
001B            
001B            reset:
001B                    ; set for use with external oscillator
001B 19 09 [04]         mov             A, (LVR_ENABLE | EXTERNAL_CLK)  
001D 2A F8 [05]         iowr    clock_config
001F            
001F                    ; setup data memory stack pointer
001F 19 68 [04]         mov             A, 68h
0021 30    [05]         swap    A, dsp          
0022            
0022                    ; 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            
0040 19 01 [04]         mov             A, 01h
0042 31 2B [05]         mov             [protocol], A
0044            
0044                    ; enable global interrupts
0044 19 05 [04]         mov             A, (1MS_INT | USB_RESET_INT)
0046 2A 20 [05]         iowr    global_int
0048            
0048                    ; enable endpoint  0 interrupt
0048 19 01 [04]         mov     A, EP0_INT                      
004A 2A 21 [05]         iowr    endpoint_int
004C            
004C                    ; enable USB address for endpoint 0
004C 19 80 [04]         mov             A, ADDRESS_ENABLE
004E 2A 10 [05]         iowr    usb_address
0050            
0050                    ; enable all interrupts
0050 72    [08]         ei
0051            
0051                    ; enable USB pullup resistor
0051 19 40 [04]         mov             A, VREG_ENABLE  
0053 2A 1F [05]         iowr    usb_status
0055            
0055            task_loop:
0055            
0055 1A 2D [06]         mov             A, [event_machine]
0057 E8 50 [07]         jacc    event_machine_jumptable
0059                            no_event_pending:
0059                                    ; if not configured then skip data transfer
0059 1A 28 [06]                         mov             A, [configuration]
005B 16 01 [04]                         cmp             A, 01h
005D B0 73 [05]                         jnz             no_event_task
005F                                    ; if stalled then skip data transfer
005F 1A 29 [06]                         mov             A, [ep1_stall]
0061 16 FF [04]                         cmp             A, FFh
0063 A0 73 [05]                         jz              no_event_task
0065                                    
0065            
0065 19 02 [04]                         mov             A, 02h          ; set endpoint 1 to send 2 bytes
0067 0E 21 [06]                         or              A, [ep1_data_toggle]
0069 2A 13 [05]                         iowr    ep1_count
006B 19 0D [04]                         mov             A, ACK_IN               ; set to ack on endpoint 1
006D 2A 14 [05]                         iowr    ep1_mode        
006F            
006F 19 02 [04]                         mov             A, EVENT_PENDING        ; clear pending events
0071 31 2D [05]                         mov             [event_machine], A 
0073            
0073                            event_task_done:
0073                    
0073                    no_event_task:
0073            
0073 80 55 [05]         jmp task_loop
0075            
0075            
0075            ;*******************************************************
0075            ;
0075            ;       Interrupt handler: bus_reset
0075            ;       Purpose: The program jumps to this routine when
0075            ;                the microcontroller has a bus reset.
0075            ;
0075            ;*******************************************************
0075            
0075            bus_reset:
0075 19 03 [04]         mov             A, STALL_IN_OUT                 ; set to STALL INs&OUTs
0077 2A 12 [05]         iowr    ep0_mode
0079            
0079 19 80 [04]         mov             A, ADDRESS_ENABLE               ; enable USB address 0
007B 2A 10 [05]         iowr    usb_address
007D 19 00 [04]         mov             A, DISABLE                              ; disable endpoint1
007F 2A 14 [05]         iowr    ep1_mode
0081            
0081 19 00 [04]         mov             A, 00h                                  ; reset program stack pointer
0083 60    [04]         mov             psp,a   
0084            
0084 80 1B [05]         jmp             reset
0086            
0086            
0086            ;*******************************************************
0086            ;
0086            ;       Interrupt: 1ms_clear_control
0086            ;       Purpose: Every 1ms this interrupt handler clears
0086            ;               the watchdog timer.
0086            ;
0086            ;*******************************************************
0086            
0086            1ms_timer:
0086 2D    [05]         push A
0087            
0087                    ; clear watchdog timer
0087 2A 26 [05]         iowr watchdog
0089            
0089                    ; check for no bus activity/usb suspend
0089              1ms_suspend_timer:
0089 29 1F [05]         iord    usb_status                              ; read bus activity bit
008B 10 08 [04]         and             A, BUS_ACTIVITY                 ; mask off activity bit
008D B0 AF [05]         jnz             bus_activity
008F                                    
008F 23 20 [07]         inc             [suspend_count]                 ; increment suspend counter
0091 1A 20 [06]         mov             A, [suspend_count]
0093 16 04 [04]         cmp             A, 04h                                  ; if no bus activity for 3-4ms,
0095 A0 99 [05]         jz              usb_suspend                             ; then go into low power suspend
0097 80 B9 [05]         jmp             ms_timer_done
0099            
0099                    usb_suspend:
0099            
0099                            ; enable wakeup timer
0099            
0099 19 01 [04]                 mov             A, (USB_RESET_INT)
009B 2A 20 [05]                 iowr    global_int
009D            
009D 29 FF [05]                 iord    control
009F 0D 08 [04]                 or              A, SUSPEND                      ; set suspend bit
00A1 72    [08]                 ei
00A2 2A FF [05]                 iowr    control
00A4 20    [04]                 nop
00A5            
00A5                            ; look for bus activity, if none go back into suspend
00A5 29 1F [05]                 iord    usb_status
00A7 10 08 [04]                 and             A, BUS_ACTIVITY
00A9 A0 99 [05]                 jz              usb_suspend             
00AB            
00AB                            ; re-enable interrupts
00AB 19 05 [04]                 mov             A, (1MS_INT | USB_RESET_INT)
00AD 2A 20 [05]                 iowr    global_int
00AF            
00AF            
00AF                    bus_activity:
00AF 19 00 [04]                 mov             A, 00h                          ; reset suspend counter
00B1 31 20 [05]                 mov             [suspend_count], A
00B3 29 1F [05]                 iord    usb_status
00B5 10 F7 [04]                 and             A, ~BUS_ACTIVITY        ; clear bus activity bit
00B7 2A 1F [05]                 iowr    usb_status
00B9            
00B9            
00B9                    ms_timer_done:
00B9 2B    [04]                 pop A
00BA 73    [08]                 reti
00BB            
00BB            ;*******************************************************
00BB            ;
00BB            ;       Interrupt: endpoint0
00BB            ;       Purpose: Usb control endpoint handler.  This interrupt
00BB            ;                       handler formulates responses to SETUP and 
00BB            ;                       CONTROL READ, and NO-DATA CONTROL transactions. 
00BB            ;
00BB            ;       Jump table entry formulation for bmRequestType and bRequest
00BB            ;
00BB            ;       1. Add high and low nibbles of bmRequestType.
00BB            ;       2. Put result into high nibble of A.
00BB            ;       3. Mask off bits [6:4].
00BB            ;       4. Add bRequest to A.
00BB            ;       5. Double value of A (jmp is two bytes).
00BB            ;
00BB            ;*******************************************************
00BB            
00BB            endpoint0:
00BB 2E    [05]         push    X
00BC 2D    [05]         push    A
00BD            
00BD            ;Reading ep0_mode enables writing to the endpoint's buffer.
00BD 29 12 [05]         iord    ep0_mode
00BF            ;If EP0_ACK isn't set, the transaction didn't complete with an Ack,
00BF            ;so exit the ISR.
00BF 10 10 [04]         and             A, EP0_ACK
00C1 A0 CE [05]         jz              ep0_done
00C3            
00C3            ;Bit 5, 6, or 7 is set to indicate whether the transaction is
00C3            ;Setup, In, or Out. Find out which it is and jump to a routine to handle it.
00C3 29 12 [05]         iord    ep0_mode
00C5 3B    [04]         asl             A
00C6 C0 D1 [05]         jc              ep0_setup_received
00C8 3B    [04]         asl             A
00C9 C3 2D [05]         jc              ep0_in_received
00CB 3B    [04]         asl             A

⌨️ 快捷键说明

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