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

📄 usbjoy32.lst

📁 HID规范和一个基于CYPRESS FX2 的例子
💻 LST
📖 第 1 页 / 共 5 页
字号:
                
0094 C0 9A [05]         jc      .DoTheJump
0096 19 00 [04]         mov     A, 00h
0098 31 34 [05]         mov     [task_number], A                        ; user may want to add own error recovery code here
                
009A            .DoTheJump:
009A E0 9C [07]         jacc task_table                                 ; execute the selected task
                
009C            XPAGEOFF
009C            task_table:
009C 80 BE [05]         jmp     Task0
009E 81 0E [05]         jmp     Task1
00A0 81 5C [05]         jmp     Task2
00A2 81 64 [05]         jmp     Task3
00A4 81 B2 [05]         jmp     Task4
00A6 82 02 [05]         jmp     Task5
00A8 82 50 [05]         jmp     Task6
00AA 82 9E [05]         jmp     Task7
00AC 82 B8 [05]         jmp     Task8
00AE 83 08 [05]         jmp     Task9
00B0 84 54 [05]         jmp     Task10
00B2 84 56 [05]         jmp     Task11
00B4 84 A4 [05]         jmp     Task12
00B6 85 F1 [05]         jmp     Task13
00B8 86 40 [05]         jmp     Task14
00BA 87 8C [05]         jmp     Task15
00BC            end_task_table:
00BC            XPAGEON
                
00BC            no_event_task:
                
00BC 80 79 [05]         jmp     TaskLoop
                
                ;=========================================================
                ;       Task 0: Read Resistor Value for x_R1
                ;=========================================================
                
00BE            Task0:
                
00BE 19 30 [04]         mov a, 30h
00C0 2A 20 [05]         iowr Global_Interrupt           ;Enable only Capture interrupts
                
                     ;**********************************************
                     ;P0.0 = CMOS Hi-Z
                     ;P0.1 = TTL Hi-Z
                     ;P0.2 = High Sink
                     ;P0.3/P0.4/P0.5/P0.6/P0.7 = CMOS Hi-Z
                     ;Port0_Mode0 = 00000100
                     ;Port0_Mode1 = 00000100
                     ;Port0       = 00000010
                     ;**********************************************
                
00C2 19 04 [04]         mov a, 04h                      ;Set port and port mode values to discharge capacitor
00C4 2A 0A [05]         iowr Port0_Mode0                ;See table above
00C6 2A 0B [05]         iowr Port0_Mode1
00C8 19 02 [04]         mov a, 02h
00CA 2A 00 [05]         iowr Port0
                
00CC 19 00 [04]         mov a, 00h                      ;wait about 500usec (6000 cycles) for Capture_timer A & B ISRs, then recharge cap and do math below
00CE 31 41 [05]         mov [discharge_cnt], a
00D0                    .discharge_loop:
00D0 23 41 [07]             inc [discharge_cnt]
00D2 19 CC [04]             mov a, CCh
00D4 17 41 [07]             cmp a, [discharge_cnt]
00D6 2A 26 [05]             iowr Watchdog
00D8 B0 D0 [05]             jnz .discharge_loop
                
00DA 19 00 [04]         mov a, 00h
00DC 2A 20 [05]         iowr Global_Interrupt           ;Disable global interrupts
                
00DE 19 00 [04]         mov a, 00h
00E0 31 40 [05]         mov [rollover_bit], a           ;rollover_bit set to 00h, but may need to change to 01h, if TTL value is < CMOS value
                
00E2 29 41 [05]         iord Capture_TimerA_Falling     ;Read CaptureTimerA 8 bits, CMOS captured time value (always earlier and usually the smaller value)
00E4 31 42 [05]         mov [capture_a_temp], a
00E6 29 43 [05]         iord Capture_TimerB_Falling     ;Read CaptureTimerB 8 bits, TTL captured time value (always earlier and usually the larger value)
00E8 31 43 [05]         mov [capture_b_temp], a
                
00EA 08 42 [06]         sub a, [capture_a_temp]         ;Subtract CMOS time from TTL time to see if timer rolled over
00EC D0 F2 [05]         jnc .no_timer_rollover          ;If TTL value is > CMOS value, the timer did not roll over and we keep rollover_bit = 00h
                
00EE 19 01 [04]         mov a, 01h                      ;In the exception that TTL time value is < CMOS time value, we make rollover_bit = 01h
00F0 31 40 [05]         mov [rollover_bit], a   
                        
00F2                    .no_timer_rollover:
00F2 19 FE [04]         mov a, FEh                      ;Recharges the capacitor, P0.0 is Hi-Z CMOS always, others set to Strong Drive CMOS
00F4 2A 0A [05]         iowr Port0_Mode0
00F6 2A 0B [05]         iowr Port0_Mode1
00F8 2A 00 [05]         iowr Port0    
                                
**** MACRO ****         SUB16x16 rollover_bit, capture_b_temp, 00h, capture_a_temp, always_zero, x_R1_diff1_new
00FA 1A 43 [05]     mov a, [capture_b_temp]
00FC 08 42 [06]     sub a, [capture_a_temp]
00FE 20    [04]         NOP
00FF 1F    [04]         XPAGE
0100 31 50 [05]     mov [x_R1_diff1_new], a
0102 1A 40 [05]     mov a, [rollover_bit]
0104 0B 00 [06]     sbb a, [00h]
0106 31 44 [05]     mov [always_zero], a    
***END MACRO*** 
                
0108 19 05 [04]         mov a, 05h                      ;Re-Enable 1ms,USBReset interrupts
010A 2A 20 [05]         iowr Global_Interrupt
                
010C 80 79 [05]         jmp TaskLoop
                
                ;=========================================================
                ;       Task 1: Read Resistor Value for x_R2
                ;=========================================================
                
010E            Task1:
                
010E 19 30 [04]         mov a, 30h
0110 2A 20 [05]         iowr Global_Interrupt           ;Enable only Capture interrupts
                
                     ;**********************************************
                     ;P0.0 = CMOS Hi-Z
                     ;P0.1 = TTL Hi-Z
                     ;P0.2 = CMOS Hi-Z
                     ;P0.3 = High Sink
                     ;P0.4/P0.5/P0.6/P0.7 = CMOS Hi-Z
                     ;Port0_Mode0 = 00001000
                     ;Port0_Mode1 = 00001000
                     ;Port0       = 00000010
                     ;**********************************************
0112 19 08 [04]         mov a, 08h                      ;Set port and port mode values to discharge capacitor
0114 2A 0A [05]         iowr Port0_Mode0                ;See table above
0116 2A 0B [05]         iowr Port0_Mode1
0118 19 02 [04]         mov a, 02h
011A 2A 00 [05]         iowr Port0
                        
011C 19 00 [04]         mov a, 00h                      ;wait about 500usec (6000 cycles) for Capture_timer A & B ISRs, then recharge cap and do math below
011E 31 41 [05]         mov [discharge_cnt], a
0120                    .discharge_loop:
0120 23 41 [07]             inc [discharge_cnt]
0122 19 CC [04]             mov a, CCh
0124 17 41 [07]             cmp a, [discharge_cnt]
0126 2A 26 [05]             iowr Watchdog
0128 B1 20 [05]             jnz .discharge_loop 
                
012A 19 00 [04]         mov a, 00h
012C 2A 20 [05]         iowr Global_Interrupt           ;Disable global interrupts
                
012E 19 00 [04]         mov a, 00h
0130 31 40 [05]         mov [rollover_bit], a           ;rollover_bit set to 00h, but may need to change to 01h, if TTL value is < CMOS value
                
0132 29 41 [05]         iord Capture_TimerA_Falling     ;Read CaptureTimerA 8 bits, CMOS captured time value (always earlier and usually the smaller value)
0134 31 42 [05]         mov [capture_a_temp], a
0136 29 43 [05]         iord Capture_TimerB_Falling     ;Read CaptureTimerB 8 bits, TTL captured time value (always earlier and usually the larger value)
0138 31 43 [05]         mov [capture_b_temp], a
                
013A 08 42 [06]         sub a, [capture_a_temp]         ;Subtract CMOS time from TTL time to see if timer rolled over
013C D1 42 [05]         jnc .no_timer_rollover          ;If TTL value is > CMOS value, the timer did not roll over and we keep rollover_bit = 00h
                
013E 19 01 [04]         mov a, 01h                      ;In the exception that TTL time value is < CMOS time value, we make rollover_bit = 01h
0140 31 40 [05]         mov [rollover_bit], a   
                        
0142                    .no_timer_rollover:
0142 19 FE [04]         mov a, FEh                      ;Recharges the capacitor, P0.0 is Hi-Z CMOS always, others set to Strong Drive CMOS
0144 2A 0A [05]         iowr Port0_Mode0
0146 2A 0B [05]         iowr Port0_Mode1
0148 2A 00 [05]         iowr Port0    
                                
**** MACRO ****         SUB16x16 rollover_bit, capture_b_temp, 00h, capture_a_temp, always_zero, x_R2_diff1_new
014A 1A 43 [05]     mov a, [capture_b_temp]
014C 08 42 [06]     sub a, [capture_a_temp]
014E 31 54 [05]     mov [x_R2_diff1_new], a
0150 1A 40 [05]     mov a, [rollover_bit]
0152 0B 00 [06]     sbb a, [00h]
0154 31 44 [05]     mov [always_zero], a    
***END MACRO*** 
                
0156 19 05 [04]         mov a, 05h                      ;Re-Enable 1ms,USBReset interrupts
0158 2A 20 [05]         iowr Global_Interrupt
                
015A 80 79 [05]         jmp TaskLoop
                
                
                ;========================================================
                ;       Task    2:      read fire buttons
                ;========================================================
                
015C            Task2:
015C 29 01 [05]         iord    Port1
015E 10 FF [04]         and     A, ffh
0160 31 36 [05]         mov     [button_debounce], A
                        
0162 80 79 [05]         jmp     TaskLoop
                
                ;=========================================================
                ;       Task 3: Read Resistor Value for y_R1
                ;=========================================================
                
0164            Task3:
                
0164 19 30 [04]         mov a, 30h
0166 2A 20 [05]         iowr Global_Interrupt           ;Enable only Capture interrupts
                
                     ;**********************************************
                     ;P0.0 = CMOS Hi-Z
                     ;P0.1 = TTL Hi-Z
                     ;P0.4 = High Sink
                     ;P0.2/P0.3/P0.5/P0.6/P0.7 = CMOS Hi-Z
                     ;Port0_Mode0 = 00010000
                     ;Port0_Mode1 = 00010000
                     ;Port0       = 00000010
                     ;**********************************************
                
0168 19 10 [04]         mov a, 10h                      ;Set port and port mode values to discharge capacitor
016A 2A 0A [05]         iowr Port0_Mode0                ;See table above
016C 2A 0B [05]         iowr Port0_Mode1
016E 19 02 [04]         mov a, 02h
0170 2A 00 [05]         iowr Port0
                
0172 19 00 [04]         mov a, 00h                      ;wait about 500usec (6000 cycles) for Capture_timer A & B ISRs, then recharge cap and do math below
0174 31 41 [05]         mov [discharge_cnt], a
0176                    .discharge_loop:
0176 23 41 [07]             inc [discharge_cnt]
0178 19 CC [04]             mov a, CCh
017A 17 41 [07]             cmp a, [discharge_cnt]
017C 2A 26 [05]             iowr Watchdog
017E B1 76 [05]             jnz .discharge_loop 
                
0180 19 00 [04]         mov a, 00h
0182 2A 20 [05]         iowr Global_Interrupt           ;Disable global interrupts
                
0184 19 00 [04]         mov a, 00h
0186 31 40 [05]         mov [rollover_bit], a           ;rollover_bit set to 00h, but may need to change to 01h, if TTL value is < CMOS value
                
0188 29 41 [05]         iord Capture_TimerA_Falling     ;Read CaptureTimerA 8 bits, CMOS captured time value (always earlier and usually the smaller value)
018A 31 42 [05]         mov [capture_a_temp], a
018C 29 43 [05]         iord Capture_TimerB_Falling     ;Read CaptureTimerB 8 bits, TTL captured time value (always earlier and usually the larger value)
018E 31 43 [05]         mov [capture_b_temp], a
                
0190 08 42 [06]         sub a, [capture_a_temp]         ;Subtract CMOS time from TTL time to see if timer rolled over
0192 D1 98 [05]         jnc .no_timer_rollover          ;If TTL value is > CMOS value, the timer did not roll over and we keep rollover_bit = 00h
                
0194 19 01 [04]         mov a, 01h                      ;In the exception that TTL time value is < CMOS time value, we make rollover_bit = 01h
0196 31 40 [05]         mov [rollover_bit], a   
                        
0198                    .no_timer_rollover:
0198 19 FE [04]         mov a, FEh                      ;Recharges the capacitor, P0.0 is Hi-Z CMOS always, others set to Strong Drive CMOS
019A 2A 0A [05]         iowr Port0_Mode0
019C 2A 0B [05]         iowr Port0_Mode1
019E 2A 00 [05]         iowr Port0    
                        
**** MACRO ****         SUB16x16 rollover_bit, capture_b_temp, 00h, capture_a_temp, always_zero, y_R1_diff1_new
01A0 1A 43 [05]     mov a, [capture_b_temp]

⌨️ 快捷键说明

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