📄 usbjoy32.lst
字号:
0000 mov a, [FirstValue]
0000 add a, [SecondValue] ; If carry, then carry bit = 1, else = 0
0000 mov [SumLSByte], a ; Move LSByte of the addition to SumByte
0000 mov [SumLSByteStored], a ; Move LSByte of the addition to SumLSByteStored to be stored until next resistor sampling
0000 mov a, 00h ; Zero out the accumulator
0000 rlc a ; Move the carry bit to the LSbit position
0000 mov [CarryMSByte], a ; If CarryMSByte = 01h, then it means the previous sum > FFh, else CarryMSByte = 00h
0000 mov [SumMSByteStored], a ; Move MSByte of the addition to SumMSByteStored to be stored until next resistor sampling
0000 ENDM
0000 MACRO DIV16x16 LongIX_hi, LongIX_lo, LongAC_hi, LongAC_lo ; executes AC = AC/IX
0000 MOV A,00h ;ACCa._byte.hi=0;
0000 MOV [acc_a_hi],A
0000 MOV A,10h ;temp = 16; // for 16 shifts
0000 MOV [temp_div],A
0000
0000 MOV A,[LongIX_hi] ;ACCa._word = __longIX;
0000 MOV [acc_a_hi],A
0000 MOV A,[LongIX_lo]
0000 MOV [acc_a_lo],A
0000 MOV A,[LongAC_hi] ;ACCb._word = __longAC;
0000 MOV [acc_b_hi],A
0000 MOV A,[LongAC_lo]
0000 MOV [acc_b_lo],A
0000 MOV [acc_d_lo],A ;ACCd._word = ACCb._word = __longAC;
0000 MOV A,[acc_b_hi]
0000 MOV [acc_d_hi],A
0000 MOV A,00h ;ACCb._word = ACCc._word = 0;
0000 MOV [acc_c_lo],A
0000 MOV [acc_c_hi],A
0000 MOV [acc_b_lo],A
0000 MOV [acc_b_hi],A
0000
0000 .routine1: ; {
0000 MOV A,[acc_d_lo] ;AC=ACCd._byte.lo;
0000 ASL A ;ASL();
0000 MOV [acc_d_lo],A ;ACCd._byte.lo=AC;
0000
0000 MOV A,[acc_d_hi] ;AC=ACCd._byte.hi;
0000 RLC A ;RLC();
0000 MOV [acc_d_hi],A ;ACCd._byte.hi=AC;
0000
0000 MOV A,[acc_c_lo] ;AC=ACCc._byte.lo;
0000 RLC A ;RLC();
0000 MOV [acc_c_lo],A ;ACCc._byte.lo=AC;
0000
0000 MOV A,[acc_c_hi] ;AC=ACCc._byte.hi;
0000 RLC A ;RLC();
0000 MOV [acc_c_hi],A ;ACCc._byte.hi=AC;
0000
0000 MOV A,[acc_b_lo] ;AC=ACCb._byte.lo;
0000 ASL A ;ASL();
0000 MOV [acc_b_lo],A ;ACCb._byte.lo=AC;
0000
0000 MOV A,[acc_b_hi] ;AC=ACCb._byte.hi;
0000 RLC A ;RLC();
0000 MOV [acc_b_hi],A ;ACCb._byte.hi=AC;
0000
0000 MOV A,[acc_c_lo] ;if( ACCc._word >= ACCa._word )
0000 SUB A,[acc_a_lo]
0000 MOV [LongAC_lo],A
0000 MOV A,[acc_c_hi]
0000 SBB A,[acc_a_hi]
0000 JC .routine2
0000 ;{
0000 MOV A,[acc_c_lo] ;ACCc._word = ACCc._word - ACCa._word; // c-a into c
0000 SUB A,[acc_a_lo]
0000 MOV [acc_c_lo],A
0000 MOV A,[acc_c_hi]
0000 SBB A,[acc_a_hi]
0000 MOV [acc_c_hi],A
0000 MOV A,01h ;ACCb._byte.lo |=1;
0000 OR [acc_b_lo],A
0000 ; }
0000 .routine2: ; }
0000 DEC [temp_div] ;while (--temp); // loop until all bits checked
0000 JNZ .routine1
0000
0000 MOV A,[acc_c_hi] ;ACCa._word=ACCc._word;
0000 MOV [acc_a_hi],A
0000 MOV A,[acc_c_lo]
0000 MOV [acc_a_lo],A
0000 MOV [LongIX_lo],A ;__longIX = ACCa._word;
0000 MOV A,[acc_a_hi]
0000 MOV [LongIX_hi],A
0000 MOV A,[acc_b_hi] ;__longAC = ACCb._word;
0000 MOV [LongAC_hi],A
0000 MOV A,[acc_b_lo]
0000 MOV [LongAC_lo],A
0000 ENDM
;*************** interrupt vector table ****************
0000 ORG 00h
0000 80 1B [05] jmp Reset ; Reset vector
0002 87 E8 [05] jmp BusResetISR ; bus reset interrupt
0004 88 61 [05] jmp 128usTimerISR ; 128us interrupt
0006 87 F9 [05] jmp 1msTimerISR ; 1.024ms interrupt
0008 88 36 [05] jmp Endpoint0ISR ; endpoint 0 interrupt
000A 88 43 [05] jmp Endpoint1ISR ; endpoint 1 interrupt
000C 88 60 [05] jmp Endpoint2ISR ; endpoint 2 interrupt
000E 88 62 [05] jmp SpiISR ; SPI interrupt
0010 88 63 [05] jmp CaptureTimerAISR ; Capture timer A interrupt
0012 88 64 [05] jmp CaptureTimerBISR ; Capture timer B interrupt
0014 88 69 [05] jmp GpioISR ; GPIO interrupt vector
0016 88 6A [05] jmp WakeUpISR ; Wake-up interrupt vector
;************** program listing ************************
001A ORG 1Ah
001A 00 [07] error: halt
;*******************************************************
;
; Interrupt handler: Reset
; Purpose: The program jumps to this routine when
; the microcontroller has a power on reset or
; a USB Bus Reset
;*******************************************************
001B Reset:
; Use the internal oscillator
001B 19 0E [04] mov A, (LVR_ENABLE | PRECISION_CLK_ENABLE | INTERNAL_CLK ) ;equiv values: 08h | 04h | 02h = 0eh
;mov A, (PRECISION_CLK_ENABLE | INTERNAL_CLK ) ;equiv values: 04h | 02h
001D 2A F8 [05] iowr Clock_Config
; setup data memory stack pointer
001F 19 20 [04] mov A, 20h
0021 30 [05] swap A, dsp
; clear psp
0022 19 00 [04] mov A, 00h
0024 60 [04] mov psp,a
; clear all RAM locations
0025 19 00 [04] mov A, BOTTOM_OF_RAM
0027 1C FF [04] mov X, TOP_OF_RAM
0029 ram_clear_loop: ; clear all ram locations
0029 2A 26 [05] iowr Watchdog
002B 32 00 [06] mov [X+0], A
002D 26 [04] dec X
002E D0 29 [05] jnc ram_clear_loop
0030 19 01 [04] mov A, 01h
0032 31 2A [05] mov [protocol], A
; Set the GPIOs to resistive mode
0034 19 00 [04] mov A, MODE0_RESISTIVE_MODE ; = to 00h
0036 2A 0A [05] iowr Port0_Mode0
0038 2A 0C [05] iowr Port1_Mode0
003A 19 FF [04] mov A, MODE1_RESISTIVE_MODE ; = to FFh
003C 2A 0B [05] iowr Port0_Mode1
003E 2A 0D [05] iowr Port1_Mode1
; Port pins are initially HIGH
0040 19 FF [04] mov A, ffh
0042 2A 00 [05] iowr Port0
0044 2A 01 [05] iowr Port1
; enable USB address for endpoint 0
0046 19 80 [04] mov A, ADDRESS_ENABLE
0048 2A 10 [05] iowr Usb_Address
; enable 3.3V voltage regulator for pulling D- up
004A 19 40 [04] mov A, VREG_ENABLE
004C 2A 1F [05] iowr Usb_Status_Control
; enable 1MS interrupt and Bus Reset interrupt
004E 19 05 [04] mov A, (1MS_INT | USB_RESET_INT) ; same as (04h or 01h) = 05h
0050 2A 20 [05] iowr Global_Interrupt
; enable endpoint 0 interrupt
0052 19 01 [04] mov A, EP0_INT
0054 2A 21 [05] iowr Endpoint_Interrupt
; Upon reset or enterring an ISR, the hardware disables all interrupts by
; clearing the Interrupt Mask/or Interrupt Enable Sense Bit in the Processor
; Status and Control Reg. An "ei" or "reti" instruction sets this bit to 1 to
; enable all interrupts masked by the Global Interrupt Enable Register and
; Endpoint Interrupt Enable Register.
0056 72 [04] ei ;enable interupts command
0057 19 08 [04] mov a, 08h ;Initialize EP1 count reg, must be set to # of words sent to host !!!
0059 2A 13 [05] iowr Ep1_Count ;Initialize EP1 count reg
005B 19 0C [04] mov a, NAK_IN ;USB mode is NAK in, send no words back at this time
005D 2A 14 [05] iowr Ep1_Mode ;USB mode is NAK in, send no words back at this time
005F 19 03 [04] mov a, 03h ;Enables interrupts on EP1,EP0 (EP2 disabled)
0061 2A 21 [05] iowr Endpoint_Interrupt ;Enables interrupts on EP1,EP0 (EP2 disabled)
0063 19 FE [04] mov a, FEh ;Leaves capacitor charged, but puts P0.0 at Hi-Z CMOS
0065 2A 0A [05] iowr Port0_Mode0
0067 2A 0B [05] iowr Port0_Mode1
0069 2A 00 [05] iowr Port0
006B 19 00 [04] mov a, 00h ; Puts all port 1 I/Os into CMOS resistive, allowing for active low push buttons
006D 2A 0C [05] iowr Port1_Mode0
006F 19 FF [04] mov a, FFh
0071 2A 0D [05] iowr Port1_Mode1
0073 2A 01 [05] iowr Port1
0075 19 8A [04] mov a, 8Ah ;Setup Capture Timers -- A & B are falling edge triggered, set 1st edge hold
0077 2A 44 [05] iowr Capture_Timer_Config
;====================================================
;TASK LOOP:
;
; while (forever)
; {
; reset watchdog timer
; check for USB suspend condition
; if (time to do next task)
; {
; if (device is enumerated and not stalled)
; {
; if (task number out of range)
; task number := 0
; jump to task
; }
; }
; }
;
;=====================================================
0079 TaskLoop:
0079 2A 26 [05] iowr Watchdog ; kick the dog
007B 19 FF [04] mov A, ffh ; bug fix by DEF
007D 11 33 [06] and A, [new_task] ; new_task is active if = 0
007F B0 79 [05] jnz TaskLoop ; wait for next time slice
0081 23 33 [07] inc [new_task]
0083 1A 27 [05] mov A, [configuration]
0085 16 01 [05] cmp A, 01h
0087 B0 BC [05] jnz no_event_task
0089 1A 28 [05] mov A, [ep1_stall]
008B 16 FF [05] cmp A, FFh
008D A0 BC [05] jz no_event_task
008F 1A 34 [05] mov A, [task_number] ; jump to current tasklet
0091 3B [04] asl ; x2 because jmp is 2 instructions
0092 16 20 [05] cmp A, (end_task_table - task_table) ; check to ensure not out of range
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -