chap_9.SRC
资源名称:USB_2.0.rar [点击查看]
上传用户:ids068
上传日期:2013-04-04
资源大小:639k
文件大小:115k
源码类别:
USB编程
开发平台:
C/C++
- ; .chap_9.SRC generated from: chap_9.c
- ; COMPILER INVOKED BY:
- ; C:KEILC51BINC51.EXE chap_9.c OPTIMIZE(2,SPEED) BROWSE DEBUG OBJECTEXTEND SRC(.chap_9.SRC)
- $NOMOD51
- NAME CHAP_9
- P0 DATA 080H
- P1 DATA 090H
- P2 DATA 0A0H
- P3 DATA 0B0H
- T0 BIT 0B0H.4
- AC BIT 0D0H.6
- T1 BIT 0B0H.5
- EA BIT 0A8H.7
- IE DATA 0A8H
- DMA_Wr_Rd BIT 090H.4
- RD BIT 0B0H.7
- ES BIT 0A8H.4
- IP DATA 0B8H
- RI BIT 098H.0
- INT0 BIT 0B0H.2
- CY BIT 0D0H.7
- TI BIT 098H.1
- INT1 BIT 0B0H.3
- ISP1581_RESET BIT 090H.3
- PS BIT 0B8H.4
- SP DATA 081H
- OV BIT 0D0H.2
- WR BIT 0B0H.6
- SBUF DATA 099H
- PCON DATA 087H
- ISP1581_CS BIT 090H.2
- SCON DATA 098H
- TMOD DATA 089H
- TCON DATA 088H
- RESET_IDE BIT 090H.4
- DMA_Reset BIT 090H.4
- IE0 BIT 088H.1
- IE1 BIT 088H.3
- AUXR DATA 08EH
- B DATA 0F0H
- DMA_Start BIT 090H.4
- ACC DATA 0E0H
- ET0 BIT 0A8H.1
- ET1 BIT 0A8H.3
- TF0 BIT 088H.5
- HS_FS_LED BIT 090H.0
- TF1 BIT 088H.7
- RB8 BIT 098H.2
- TH0 DATA 08CH
- EX0 BIT 0A8H.0
- IT0 BIT 088H.0
- TH1 DATA 08DH
- TB8 BIT 098H.3
- EX1 BIT 0A8H.2
- IT1 BIT 088H.2
- P BIT 0D0H.0
- SM0 BIT 098H.7
- TL0 DATA 08AH
- SM1 BIT 098H.6
- TL1 DATA 08BH
- SM2 BIT 098H.5
- PT0 BIT 0B8H.1
- PT1 BIT 0B8H.3
- RS0 BIT 0D0H.3
- TR0 BIT 088H.4
- RS1 BIT 0D0H.4
- TR1 BIT 088H.6
- PX0 BIT 0B8H.0
- PX1 BIT 0B8H.2
- DPH DATA 083H
- DPL DATA 082H
- VBus_Sense BIT 0A0H.4
- REN BIT 098H.4
- RXD BIT 0B0H.0
- CKCON DATA 08FH
- TXD BIT 0B0H.1
- F0 BIT 0D0H.5
- PSW DATA 0D0H
- ?PR?USB_Debug_Mode?CHAP_9 SEGMENT CODE
- ?PR?USB_Setup?CHAP_9 SEGMENT CODE
- ?DT?USB_Setup?CHAP_9 SEGMENT DATA OVERLAYABLE
- ?PR?Vendor_Specific_Command?CHAP_9 SEGMENT CODE
- ?PR?reserved?CHAP_9 SEGMENT CODE
- ?PR?get_descriptor?CHAP_9 SEGMENT CODE
- ?PR?set_address?CHAP_9 SEGMENT CODE
- ?PR?set_config?CHAP_9 SEGMENT CODE
- ?PR?get_config?CHAP_9 SEGMENT CODE
- ?PR?clear_feature?CHAP_9 SEGMENT CODE
- ?DT?clear_feature?CHAP_9 SEGMENT DATA OVERLAYABLE
- ?PR?get_status?CHAP_9 SEGMENT CODE
- ?PR?set_feature?CHAP_9 SEGMENT CODE
- ?DT?set_feature?CHAP_9 SEGMENT DATA OVERLAYABLE
- ?PR?get_interface?CHAP_9 SEGMENT CODE
- ?PR?set_interface?CHAP_9 SEGMENT CODE
- ?PR?ep0in_ack?CHAP_9 SEGMENT CODE
- ?PR?wait_ep0tx?CHAP_9 SEGMENT CODE
- ?PR?ep0out_ack?CHAP_9 SEGMENT CODE
- ?PR?wait_ep0rx?CHAP_9 SEGMENT CODE
- ?PR?_read_endpoint?CHAP_9 SEGMENT CODE
- ?DT?_read_endpoint?CHAP_9 SEGMENT DATA OVERLAYABLE
- ?CO?CHAP_9 SEGMENT CODE
- ?ID?CHAP_9 SEGMENT IDATA
- ?DT?CHAP_9 SEGMENT DATA
- EXTRN CODE (Standard_String_ID)
- EXTRN CODE (HS_Bulk_Interface_Descriptor)
- EXTRN CODE (Bulk_Interface_Descriptor)
- EXTRN XDATA (D14_Cntrl_Reg)
- EXTRN DATA (Temp)
- EXTRN CODE (Other_Speed_Config_Descriptor)
- EXTRN CODE (HS_Bulk_In_Descriptor)
- EXTRN DATA (count)
- EXTRN CODE (HS_Bulk_Out_Descriptor)
- EXTRN CODE (Bulk_In_Descriptor)
- EXTRN CODE (Bulk_Out_Descriptor)
- EXTRN CODE (Init_Endpoint)
- EXTRN DATA (Kernel_Flag)
- EXTRN CODE (HS_Int_In_Descriptor)
- EXTRN CODE (HS_Int_Out_Descriptor)
- EXTRN CODE (Int_In_Descriptor)
- EXTRN CODE (Int_Out_Descriptor)
- EXTRN CODE (HS_Device_Descriptor)
- EXTRN CODE (HS_Device_Qualifier)
- EXTRN DATA (Device_Config_Value)
- EXTRN CODE (Standard_Device_Descriptor)
- EXTRN CODE (Standard_Config_Descriptor)
- EXTRN CODE (?C?ICALL)
- EXTRN CODE (?C?ICASE)
- EXTRN CODE (?C?LSHL)
- EXTRN CODE (?C?LSTXDATA)
- EXTRN CODE (?C?CSTPTR)
- PUBLIC USB_Device_Request
- PUBLIC VID
- PUBLIC bytecount
- PUBLIC PID
- PUBLIC PIO_Count
- PUBLIC USB_Int_Flag
- PUBLIC File_Number
- PUBLIC Current_File
- PUBLIC Descriptor_Ptr
- PUBLIC FileSize
- PUBLIC USB_Device
- PUBLIC FIFO_Count
- PUBLIC Endpt_FIFO
- PUBLIC StandardDeviceRequest
- PUBLIC _read_endpoint
- PUBLIC wait_ep0rx
- PUBLIC ep0out_ack
- PUBLIC wait_ep0tx
- PUBLIC ep0in_ack
- PUBLIC set_interface
- PUBLIC get_interface
- PUBLIC set_feature
- PUBLIC get_status
- PUBLIC clear_feature
- PUBLIC get_config
- PUBLIC set_config
- PUBLIC set_address
- PUBLIC get_descriptor
- PUBLIC reserved
- PUBLIC Vendor_Specific_Command
- PUBLIC USB_Setup
- PUBLIC USB_Debug_Mode
- RSEG ?DT?set_feature?CHAP_9
- ?set_feature?BYTE:
- bRecipient?1043: DS 1
- RSEG ?DT?_read_endpoint?CHAP_9
- ?_read_endpoint?BYTE:
- endp?1744: DS 1
- len?1745: DS 2
- buf?1746: DS 3
- RSEG ?DT?clear_feature?CHAP_9
- ?clear_feature?BYTE:
- bRecipient?842: DS 1
- RSEG ?DT?USB_Setup?CHAP_9
- ?USB_Setup?BYTE:
- type?140: DS 1
- req?141: DS 1
- RSEG ?ID?CHAP_9
- Endpt_FIFO: DS 64
- USB_Device_Request: DS 8
- RSEG ?DT?CHAP_9
- FIFO_Count: DS 2
- USB_Device: DS 4
- FileSize: DS 8
- Descriptor_Ptr: DS 2
- Current_File: DS 1
- File_Number: DS 1
- USB_Int_Flag: DS 4
- PIO_Count: DS 2
- PID: DS 2
- bytecount: DS 4
- VID: DS 2
- RSEG ?CO?CHAP_9
- StandardDeviceRequest:
- DB 0FFH
- DW get_status + 0
- DB 0FFH
- DW clear_feature + 0
- DB 0FFH
- DW reserved + 0
- DB 0FFH
- DW set_feature + 0
- DB 0FFH
- DW reserved + 0
- DB 0FFH
- DW set_address + 0
- DB 0FFH
- DW get_descriptor + 0
- DB 0FFH
- DW reserved + 0
- DB 0FFH
- DW get_config + 0
- DB 0FFH
- DW set_config + 0
- DB 0FFH
- DW get_interface + 0
- DB 0FFH
- DW set_interface + 0
- DB 0FFH
- DW reserved + 0
- DB 0FFH
- DW reserved + 0
- DB 0FFH
- DW reserved + 0
- DB 0FFH
- DW reserved + 0
- ; //***********************************************************************
- ; // *
- ; // P H I L I P S P R O P R I E T A R Y *
- ; // *
- ; // COPYRIGHT (c) 1999 BY PHILIPS SINGAPORE (APIC). *
- ; // -- ALL RIGHTS RESERVED -- *
- ; // *
- ; // File Name : USBDebug.c *
- ; // Author : Albert Goh *
- ; // Created : 3 March 2000 *
- ; // *
- ; //***********************************************************************
- ; //***********************************************************************
- ; // *
- ; // USBDebug has the ability to test the USB core in Bus enumeration or *
- ; // in CBI/bulk mode. *
- ; // *
- ; //***********************************************************************
- ; //***********************************************************************
- ; // *
- ; // Module History *
- ; // ************** *
- ; // *
- ; // Date Version Author Changes *
- ; // ==== ======= ====== ======= *
- ; // 030300 0.1 Albert Created *
- ; // *
- ; //***********************************************************************
- ;
- ; //***********************************************************************
- ; //* *
- ; //* Include Files Definition *
- ; //* *
- ; //***********************************************************************
- ;
- ; #include "standard.h"
- ; #include "Kernel.h"
- ; #include "D14.h"
- ; #include "usb.h"
- ;
- ; extern volatile D14_CNTRL_REG xdata D14_Cntrl_Reg;
- ; extern void Init_D14(void);
- ; extern UC code Standard_Device_Descriptor[];
- ; extern UC code Bulk_Interface_Descriptor[];
- ; extern UC code Iso_Interface_Descriptor[];
- ; extern UC code Standard_Config_Descriptor[];
- ; extern UC code Standard_Manufacturer_String[];
- ; extern UC code Standard_Product_String[];
- ; extern UC code Standard_String_ID[];
- ; extern UC code Bulk_In_Descriptor[];
- ; extern UC code Bulk_Out_Descriptor[];
- ; extern UC code Int_In_Descriptor[];
- ; extern UC code Int_Out_Descriptor[];
- ; extern UC code Iso_In_Descriptor[];
- ; extern UC code Iso_Out_Descriptor[];
- ; extern UC code Iso_In_Zero_Descriptor[];
- ; extern UC code Iso_Out_Zero_Descriptor[];
- ; extern UC code HS_Device_Descriptor[];
- ; extern UC code HS_Device_Qualifier[];
- ; extern UC code HS_Bulk_Interface_Descriptor[];
- ; extern UC code HS_Bulk_In_Descriptor[];
- ; extern UC code HS_Bulk_Out_Descriptor[];
- ; extern UC code HS_Int_In_Descriptor[];
- ; extern UC code HS_Int_Out_Descriptor[];
- ; extern UC code Other_Speed_Config_Descriptor[];
- ; extern UI count;
- ; extern void Start_mSEC_Timer(Data);
- ; extern void Start_SEC_Timer(Data);
- ; extern void Check_Busy(void);
- ; extern void TaskFile_Update(void);
- ; extern UI Temp;
- ; extern UC Device_Config_Value;
- ; extern KERNEL Kernel_Flag;
- ; extern DMA_INT_FLAG DMA_Int_Flag;
- ; extern USB_INT_FLAG USB_Int_Flag;
- ; extern USBCBW USB_CBW;
- ; extern void Init_Device(void);
- ; extern UC code Test_Packet[];
- ; extern void Init_Endpoint(void);
- ; extern void Init_Device(void);
- ; extern void Set_USB(void);
- ;
- ; //***********************************************************************
- ; //* *
- ; //* Prototype Routine Definition *
- ; //* *
- ; //***********************************************************************
- ;
- ; void USB_Setup(void);
- ; void reserved(void);
- ; void Send_Device_Status(void);
- ; void Send_Interface_Status(void);
- ; void Send_Endpoint_Status(void);
- ;
- ; void Vendor_Specific_Command(void);
- ; void Send_Status(unsigned char tran_status);
- ;
- ; void Set_Interface_Value(void);
- ; void Get_Interface_Value(void);
- ; void Process_Synch_Frame(void);
- ;
- ; void get_status(void);
- ; void clear_feature(void);
- ; void set_feature(void);
- ; void set_address(void);
- ; void get_descriptor(void);
- ; void get_config(void);
- ; void set_config(void);
- ; void get_interface(void);
- ; void set_interface(void);
- ;
- ; void Set_Descriptor(void);
- ; void reserved(void);
- ;
- ; void ep0in_ack(void);
- ; void ep0out_ack(void);
- ; void wait_ep0tx(void);
- ; void wait_ep0rx(void);
- ;
- ; //***********************************************************************
- ; //* *
- ; //* Variable Definition *
- ; //* *
- ; //***********************************************************************
- ;
- ; USB_INT_FLAG USB_Int_Flag;
- ; USB_DEVICE_REQ idata USB_Device_Request;
- ; USB_DEVICE USB_Device;
- ;
- ; UC code *Descriptor_Ptr;
- ;
- ; UC idata Endpt_FIFO[MAX_BUF];
- ; UI FIFO_Count;
- ; UC VID[2],PID[2];
- ; FILESIZE FileSize;
- ; UI PIO_Count;
- ; UC File_Number;
- ; UC Current_File;
- ; ULI bytecount;
- ;
- ; //USB标准请求
- ; code void (*StandardDeviceRequest[])(void) =
- ; {
- ; get_status,
- ; clear_feature,
- ; reserved,
- ; set_feature,
- ; reserved,
- ; set_address,
- ; get_descriptor,
- ; reserved,
- ; get_config,
- ; set_config,
- ; get_interface,
- ; set_interface,
- ; reserved,
- ; reserved,
- ; reserved,
- ; reserved
- ; };
- ;
- ;
- ;
- ; //***********************************************************************
- ; //* *
- ; //* Routine Definition *
- ; //* *
- ; //***********************************************************************
- ;
- ; //***********************************************************************
- ; //* *
- ; //* Routine : USB Debug Mode *
- ; //* Input : USB Interrupt Register *
- ; //* Output : None *
- ; //* Function : Branch to respective ISR *
- ; //* *
- ; //***********************************************************************
- ;
- ; void USB_Debug_Mode(void)
- RSEG ?PR?USB_Debug_Mode?CHAP_9
- USB_Debug_Mode:
- USING 0
- ; SOURCE LINE # 179
- ; {
- ; SOURCE LINE # 180
- ; //端点0接收到setup包处理
- ; if(USB_Int_Flag.BITS.EP0SETUP)
- ; SOURCE LINE # 182
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- JNB ACC.0,?C0001
- ; {
- ; SOURCE LINE # 183
- ; EA_DISABLE;
- ; SOURCE LINE # 184
- CLR EA
- ; USB_Setup();
- ; SOURCE LINE # 185
- LCALL USB_Setup
- ; EA_ENABLE;
- ; SOURCE LINE # 186
- SETB EA
- ; }
- ; SOURCE LINE # 187
- ?C0001:
- ;
- ; //挂起处理
- ; if(USB_Int_Flag.BITS.SUSP)
- ; SOURCE LINE # 190
- MOV R7,USB_Int_Flag
- MOV A,R7
- RRC A
- RRC A
- RRC A
- ANL A,#01FH
- MOV R7,A
- MOV A,R7
- JNB ACC.0,?C0002
- ; {
- ; SOURCE LINE # 191
- ; //清除挂起标志
- ; EA_DISABLE;
- ; SOURCE LINE # 193
- CLR EA
- ; USB_Int_Flag.BITS.SUSP = 0;
- ; SOURCE LINE # 194
- MOV R7,USB_Int_Flag
- MOV A,R7
- ANL A,#0F7H
- MOV USB_Int_Flag,A
- ; EA_ENABLE;
- ; SOURCE LINE # 195
- SETB EA
- ; //ISP1581进入挂起状态
- ; D14_Cntrl_Reg.D14_MODE.BITS.GOSUSP = 1;
- ; SOURCE LINE # 197
- MOV DPTR,#D14_Cntrl_Reg+0CH
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ORL A,#020H
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+0CH
- MOV A,R7
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_MODE.BITS.GOSUSP = 0;
- ; SOURCE LINE # 198
- MOV DPTR,#D14_Cntrl_Reg+0CH
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ANL A,#0DFH
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+0CH
- MOV A,R7
- MOVX @DPTR,A
- ; }
- ; SOURCE LINE # 199
- ?C0002:
- ;
- ; //挂起恢复处理
- ; if(USB_Int_Flag.BITS.RESUME)
- ; SOURCE LINE # 202
- MOV R7,USB_Int_Flag
- MOV A,R7
- SWAP A
- ANL A,#0FH
- MOV R7,A
- MOV A,R7
- JNB ACC.0,?C0003
- ; {
- ; SOURCE LINE # 203
- ; //清除恢复标志
- ; EA_DISABLE;
- ; SOURCE LINE # 205
- CLR EA
- ; USB_Int_Flag.BITS.RESUME = 0;
- ; SOURCE LINE # 206
- MOV R7,USB_Int_Flag
- MOV A,R7
- ANL A,#0EFH
- MOV USB_Int_Flag,A
- ; EA_ENABLE;
- ; SOURCE LINE # 207
- SETB EA
- ; //产生一个恢复信号
- ; D14_Cntrl_Reg.D14_MODE.BITS.SNDRSU = 1;
- ; SOURCE LINE # 209
- MOV DPTR,#D14_Cntrl_Reg+0CH
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ORL A,#040H
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+0CH
- MOV A,R7
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_MODE.BITS.SNDRSU = 0;
- ; SOURCE LINE # 210
- MOV DPTR,#D14_Cntrl_Reg+0CH
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ANL A,#0BFH
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+0CH
- MOV A,R7
- MOVX @DPTR,A
- ; }
- ; SOURCE LINE # 211
- ?C0003:
- ;
- ; //高速状态
- ; if(USB_Int_Flag.BITS.HS_STAT)
- ; SOURCE LINE # 214
- MOV R7,USB_Int_Flag
- MOV A,R7
- SWAP A
- RRC A
- ANL A,#07H
- MOV R7,A
- MOV A,R7
- JNB ACC.0,?C0006
- ; {
- ; SOURCE LINE # 215
- ; //清除高速状态标志
- ; EA_DISABLE;
- ; SOURCE LINE # 217
- CLR EA
- ; USB_Int_Flag.BITS.HS_STAT = 0;
- ; SOURCE LINE # 218
- MOV R7,USB_Int_Flag
- MOV A,R7
- ANL A,#0DFH
- MOV USB_Int_Flag,A
- ; EA_ENABLE;
- ; SOURCE LINE # 219
- SETB EA
- ; if(Kernel_Flag.BITS.HS_FS_State == FULL_SPEED)
- ; SOURCE LINE # 220
- MOV R7,Kernel_Flag+03H
- MOV A,R7
- JNB ACC.0,?C0006
- ; {
- ; SOURCE LINE # 221
- ; //切换高速指示
- ; HS_FS_LED = HIGH_SPEED_LED;
- ; SOURCE LINE # 223
- SETB HS_FS_LED
- ; //设置高速模式状态
- ; Kernel_Flag.BITS.HS_FS_State = HIGH_SPEED;
- ; SOURCE LINE # 225
- MOV R7,Kernel_Flag+03H
- MOV A,R7
- ANL A,#0FEH
- MOV Kernel_Flag+03H,A
- ; //重新配置高速端点
- ; Init_Endpoint();
- ; SOURCE LINE # 227
- LCALL Init_Endpoint
- ;
- ; // PIO_Count = 64;
- ; PIO_Count = 512;
- ; SOURCE LINE # 230
- MOV PIO_Count,#02H
- MOV PIO_Count+01H,#00H
- ; }
- ; SOURCE LINE # 231
- ; }
- ; SOURCE LINE # 232
- ; }
- ; SOURCE LINE # 233
- ?C0006:
- RET
- ; END OF USB_Debug_Mode
- ;
- ;
- ; //***********************************************************************
- ; //* *
- ; //* Routine : *
- ; //* Input : None *
- ; //* Output : None *
- ; //* Function : *
- ; //* *
- ; //***********************************************************************
- ; //建立包处理
- ; void USB_Setup(void)
- RSEG ?PR?USB_Setup?CHAP_9
- USB_Setup:
- USING 0
- ; SOURCE LINE # 245
- ; {
- ; SOURCE LINE # 246
- ; unsigned char type, req;
- ;
- ; //清除EP0SETUP中断标志
- ; USB_Int_Flag.BITS.EP0SETUP = 0;
- ; SOURCE LINE # 250
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- ANL A,#0FEH
- MOV USB_Int_Flag+01H,A
- ; //清除总线复位标志
- ; Kernel_Flag.BITS.Bus_Reset = 0;
- ; SOURCE LINE # 252
- MOV R7,Kernel_Flag+01H
- MOV A,R7
- ANL A,#0BFH
- MOV Kernel_Flag+01H,A
- ; //选择端点0SETUP缓冲区
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 0x20;
- ; SOURCE LINE # 254
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#020H
- MOVX @DPTR,A
- ;
- ; //读取USB请求
- ; //读取请求类型
- ; USB_Device_Request.bmRequestType = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
- ; SOURCE LINE # 258
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOVX A,@DPTR
- MOV R7,A
- MOV R0,#LOW (USB_Device_Request)
- MOV @R0,AR7
- ; //读取请求号
- ; USB_Device_Request.bRequest = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
- ; SOURCE LINE # 260
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOVX A,@DPTR
- MOV R7,A
- MOV R0,#LOW (USB_Device_Request+01H)
- MOV @R0,AR7
- ; //读取16bit请求数据
- ; USB_Device_Request.wValue = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
- ; SOURCE LINE # 262
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOVX A,@DPTR
- MOV R7,A
- MOV R6,#00H
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV @R0,AR6
- INC R0
- MOV @R0,AR7
- ; USB_Device_Request.wValue <<= 8;
- ; SOURCE LINE # 263
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- MOV R7,#00H
- MOV R6,A
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV @R0,AR6
- INC R0
- MOV @R0,AR7
- ; USB_Device_Request.wValue |= D14_Cntrl_Reg.D14_DATA_PORT_LSB;
- ; SOURCE LINE # 264
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOVX A,@DPTR
- MOV R5,A
- MOV R4,#00H
- MOV A,R6
- ORL A,R4
- MOV R6,A
- MOV A,R7
- ORL A,R5
- MOV R7,A
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV @R0,AR6
- INC R0
- MOV @R0,AR7
- ; //读取16bit请求索引
- ; USB_Device_Request.wIndex = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
- ; SOURCE LINE # 266
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOVX A,@DPTR
- MOV R7,A
- MOV R6,#00H
- MOV R0,#LOW (USB_Device_Request+04H)
- MOV @R0,AR6
- INC R0
- MOV @R0,AR7
- ; USB_Device_Request.wIndex <<= 8;
- ; SOURCE LINE # 267
- MOV R0,#LOW (USB_Device_Request+04H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- MOV R7,#00H
- MOV R6,A
- MOV R0,#LOW (USB_Device_Request+04H)
- MOV @R0,AR6
- INC R0
- MOV @R0,AR7
- ; USB_Device_Request.wIndex |= D14_Cntrl_Reg.D14_DATA_PORT_LSB;
- ; SOURCE LINE # 268
- MOV R0,#LOW (USB_Device_Request+04H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOVX A,@DPTR
- MOV R5,A
- MOV R4,#00H
- MOV A,R6
- ORL A,R4
- MOV R6,A
- MOV A,R7
- ORL A,R5
- MOV R7,A
- MOV R0,#LOW (USB_Device_Request+04H)
- MOV @R0,AR6
- INC R0
- MOV @R0,AR7
- ; //读取16bit长度
- ; USB_Device_Request.wLength = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
- ; SOURCE LINE # 270
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOVX A,@DPTR
- MOV R7,A
- MOV R6,#00H
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV @R0,AR6
- INC R0
- MOV @R0,AR7
- ; USB_Device_Request.wLength <<= 8;
- ; SOURCE LINE # 271
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- MOV R7,#00H
- MOV R6,A
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV @R0,AR6
- INC R0
- MOV @R0,AR7
- ; USB_Device_Request.wLength |= D14_Cntrl_Reg.D14_DATA_PORT_LSB;
- ; SOURCE LINE # 272
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOVX A,@DPTR
- MOV R5,A
- MOV R4,#00H
- MOV A,R6
- ORL A,R4
- MOV R6,A
- MOV A,R7
- ORL A,R5
- MOV R7,A
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV @R0,AR6
- INC R0
- MOV @R0,AR7
- ;
- ; //长度处理(高低8位对调)
- ; Temp = USB_Device_Request.wLength;
- ; SOURCE LINE # 275
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV Temp,A
- INC R0
- MOV A,@R0
- MOV Temp+01H,A
- ; USB_Device_Request.wLength = 0;
- ; SOURCE LINE # 276
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV @R0,#00H
- INC R0
- MOV @R0,#00H
- ; USB_Device_Request.wLength = (UC) Temp;
- ; SOURCE LINE # 277
- MOV R7,Temp+01H
- MOV R6,#00H
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV @R0,AR6
- INC R0
- MOV @R0,AR7
- ; USB_Device_Request.wLength <<= 8;
- ; SOURCE LINE # 278
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- MOV R7,#00H
- MOV R6,A
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV @R0,AR6
- INC R0
- MOV @R0,AR7
- ; Temp >>= 8;
- ; SOURCE LINE # 279
- MOV A,Temp
- MOV Temp+01H,A
- MOV Temp,#00H
- ; USB_Device_Request.wLength |= Temp;
- ; SOURCE LINE # 280
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R6
- ORL A,Temp
- MOV R6,A
- MOV A,R7
- ORL A,Temp+01H
- MOV R7,A
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV @R0,AR6
- INC R0
- MOV @R0,AR7
- ;
- ; type = USB_Device_Request.bmRequestType & 0x60;
- ; SOURCE LINE # 282
- MOV R0,#LOW (USB_Device_Request)
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- ANL A,#060H
- MOV type?140,A
- ; req = USB_Device_Request.bRequest & 0x0f;
- ; SOURCE LINE # 283
- MOV R0,#LOW (USB_Device_Request+01H)
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- ANL A,#0FH
- MOV req?141,A
- ;
- ; //厂商请求
- ; if (type == 0x40)
- ; SOURCE LINE # 286
- MOV A,type?140
- CJNE A,#040H,?C0007
- ; {
- ; SOURCE LINE # 287
- ; Vendor_Specific_Command();//厂商请求处理
- ; SOURCE LINE # 288
- LCALL Vendor_Specific_Command
- ; }
- ; SOURCE LINE # 289
- RET
- ?C0007:
- ; else if (type == 0x00)
- ; SOURCE LINE # 290
- MOV A,type?140
- JNZ ?C0010
- ; (*StandardDeviceRequest[req])();//调用标准请求
- ; SOURCE LINE # 291
- MOV R7,req?141
- MOV A,R7
- MOV B,#03H
- MUL AB
- ADD A,#LOW (StandardDeviceRequest)
- MOV DPL,A
- CLR A
- ADDC A,#HIGH (StandardDeviceRequest)
- MOV DPH,A
- CLR A
- MOVC A,@A+DPTR
- MOV R3,A
- MOV A,#01H
- MOVC A,@A+DPTR
- MOV R2,A
- MOV A,#02H
- MOVC A,@A+DPTR
- MOV R1,A
- LCALL ?C?ICALL
- ; }
- ; SOURCE LINE # 292
- ?C0010:
- RET
- ; END OF USB_Setup
- ;
- ; //***********************************************************************
- ; //* *
- ; //* Routine : *
- ; //* Input : None *
- ; //* Output : None *
- ; //* Function : *
- ; //* *
- ; //***********************************************************************
- ; //厂商请求处理
- ; void Vendor_Specific_Command(void)
- RSEG ?PR?Vendor_Specific_Command?CHAP_9
- Vendor_Specific_Command:
- USING 0
- ; SOURCE LINE # 303
- ; {
- ; SOURCE LINE # 304
- ; if(USB_Device_Request.bRequest == 0x0C)
- ; SOURCE LINE # 305
- MOV R0,#LOW (USB_Device_Request+01H)
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- XRL A,#0CH
- JZ $ + 5H
- LJMP ?C0023
- ; {
- ; SOURCE LINE # 306
- ; switch (USB_Device_Request.wIndex)
- ; SOURCE LINE # 307
- MOV R0,#LOW (USB_Device_Request+04H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- MOV B,R6
- LCALL ?C?ICASE
- DW ?C0015
- DW 07104H
- DW ?C0013
- DW 07204H
- DW 00H
- DW ?C0016
- ; {
- ; SOURCE LINE # 308
- ; case GET_FIRMWARE_VERSION ://获取固件版本
- ; SOURCE LINE # 309
- ?C0013:
- ; if(USB_Device_Request.wLength == 1)
- ; SOURCE LINE # 310
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- XRL A,#01H
- ORL A,R6
- JNZ ?C0015
- ; {
- ; SOURCE LINE # 311
- ; //select endpoint
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 313
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; //set the data length to 1 byte
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = 1;
- ; SOURCE LINE # 315
- MOV DPTR,#D14_Cntrl_Reg+01CH
- MOV A,#01H
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
- ; SOURCE LINE # 316
- MOV DPTR,#D14_Cntrl_Reg+01DH
- CLR A
- MOVX @DPTR,A
- ; //sent 0x21 as data
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = 0x21;//版本号
- ; SOURCE LINE # 318
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,#021H
- MOVX @DPTR,A
- ; wait_ep0tx();
- ; SOURCE LINE # 319
- LCALL wait_ep0tx
- ; ep0out_ack();
- ; SOURCE LINE # 320
- LCALL ep0out_ack
- ; // ep0in_ack();
- ; break;
- ; SOURCE LINE # 322
- RET
- ; }
- ; SOURCE LINE # 323
- ;
- ; case SETUP_DMA_REQUEST :
- ; SOURCE LINE # 325
- ?C0015:
- ; //Out Token Ack detected
- ; wait_ep0rx();
- ; SOURCE LINE # 327
- LCALL wait_ep0rx
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 0;
- ; SOURCE LINE # 328
- MOV DPTR,#D14_Cntrl_Reg+02CH
- CLR A
- MOVX @DPTR,A
- ; //
- ; FileSize.Size.Address[0] = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
- ; SOURCE LINE # 330
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOVX A,@DPTR
- MOV R7,A
- MOV FileSize,R7
- ; FileSize.Size.Address[1] = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
- ; SOURCE LINE # 331
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOVX A,@DPTR
- MOV R7,A
- MOV FileSize+01H,R7
- ; FileSize.Size.Address[2] = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
- ; SOURCE LINE # 332
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOVX A,@DPTR
- MOV R7,A
- MOV FileSize+02H,R7
- ; //读取传输字节数
- ; Temp = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
- ; SOURCE LINE # 334
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOVX A,@DPTR
- MOV R7,A
- MOV R6,#00H
- MOV Temp,R6
- MOV Temp+01H,R7
- ; bytecount = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
- ; SOURCE LINE # 335
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOVX A,@DPTR
- MOV R7,A
- CLR A
- MOV R4,A
- MOV R5,A
- MOV R6,A
- MOV bytecount+03H,R7
- MOV bytecount+02H,R6
- MOV bytecount+01H,R5
- MOV bytecount,R4
- ; bytecount <<= 8;
- ; SOURCE LINE # 336
- MOV R7,bytecount+03H
- MOV R6,bytecount+02H
- MOV R5,bytecount+01H
- MOV R4,bytecount
- MOV R0,#08H
- LCALL ?C?LSHL
- MOV bytecount+03H,R7
- MOV bytecount+02H,R6
- MOV bytecount+01H,R5
- MOV bytecount,R4
- ; bytecount |= Temp;
- ; SOURCE LINE # 337
- MOV R6,Temp
- MOV R7,Temp+01H
- CLR A
- MOV R4,A
- MOV R5,A
- MOV A,bytecount+03H
- ORL A,R7
- MOV bytecount+03H,A
- MOV A,bytecount+02H
- ORL A,R6
- MOV bytecount+02H,A
- MOV A,bytecount+01H
- ORL A,R5
- MOV bytecount+01H,A
- MOV A,bytecount
- ORL A,R4
- MOV bytecount,A
- ; //读取传输方式
- ; FileSize.Size.DIR = D14_Cntrl_Reg.D14_DATA_PORT_LSB;
- ; SOURCE LINE # 339
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOVX A,@DPTR
- MOV R7,A
- MOV FileSize+07H,R7
- ; ep0in_ack();
- ; SOURCE LINE # 340
- LCALL ep0in_ack
- ; Kernel_Flag.BITS.Transfer_Start = 1;//标志传输数据开始
- ; SOURCE LINE # 341
- MOV R7,Kernel_Flag+03H
- MOV A,R7
- ORL A,#020H
- MOV Kernel_Flag+03H,A
- ; break;
- ; SOURCE LINE # 342
- RET
- ;
- ; default :
- ; SOURCE LINE # 344
- ?C0016:
- ; if(USB_Device_Request.bmRequestType == 0xC0)
- ; SOURCE LINE # 345
- MOV R0,#LOW (USB_Device_Request)
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- CJNE A,#0C0H,?C0017
- ; {
- ; SOURCE LINE # 346
- ; ep0in_ack();
- ; SOURCE LINE # 347
- LCALL ep0in_ack
- ; break;
- ; SOURCE LINE # 348
- RET
- ; }
- ; SOURCE LINE # 349
- ?C0017:
- ; if(USB_Device_Request.bmRequestType == 0x40)
- ; SOURCE LINE # 350
- MOV R0,#LOW (USB_Device_Request)
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- XRL A,#040H
- JNZ ?C0023
- ; {
- ; SOURCE LINE # 351
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 0;
- ; SOURCE LINE # 352
- MOV DPTR,#D14_Cntrl_Reg+02CH
- CLR A
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 1;
- ; SOURCE LINE # 353
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ORL A,#01H
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOV A,R7
- MOVX @DPTR,A
- ?C0019:
- ; while(!USB_Int_Flag.BITS.EP0SETUP)
- ; SOURCE LINE # 354
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- JB ACC.0,?C0020
- ; {
- ; SOURCE LINE # 355
- ; //读取ISP1581中断寄存器
- ; USB_Int_Flag.VALUE |= D14_Cntrl_Reg.D14_INT.VALUE;
- ; SOURCE LINE # 357
- MOV DPTR,#D14_Cntrl_Reg+018H
- MOVX A,@DPTR
- MOV R4,A
- INC DPTR
- MOVX A,@DPTR
- MOV R5,A
- INC DPTR
- MOVX A,@DPTR
- MOV R6,A
- INC DPTR
- MOVX A,@DPTR
- MOV R7,A
- MOV A,USB_Int_Flag+03H
- ORL A,R7
- MOV USB_Int_Flag+03H,A
- MOV A,USB_Int_Flag+02H
- ORL A,R6
- MOV USB_Int_Flag+02H,A
- MOV A,USB_Int_Flag+01H
- ORL A,R5
- MOV USB_Int_Flag+01H,A
- MOV A,USB_Int_Flag
- ORL A,R4
- MOV USB_Int_Flag,A
- ; //回写ISP1581中断寄存器
- ; D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;
- ; SOURCE LINE # 359
- MOV R7,USB_Int_Flag+03H
- MOV R6,USB_Int_Flag+02H
- MOV R5,USB_Int_Flag+01H
- MOV R4,USB_Int_Flag
- MOV DPTR,#D14_Cntrl_Reg+018H
- LCALL ?C?LSTXDATA
- ; if(USB_Int_Flag.BITS.SUSP || USB_Int_Flag.BITS.RESET)
- ; SOURCE LINE # 360
- MOV R7,USB_Int_Flag
- MOV A,R7
- RRC A
- RRC A
- RRC A
- ANL A,#01FH
- MOV R7,A
- MOV A,R7
- JB ACC.0,?C0023
- MOV R7,USB_Int_Flag
- MOV A,R7
- JNB ACC.0,?C0019
- RET
- ; return;
- ; }
- ; SOURCE LINE # 362
- ?C0020:
- ; USB_Int_Flag.BITS.EP0TX = 0;
- ; SOURCE LINE # 363
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- ANL A,#0F7H
- MOV USB_Int_Flag+01H,A
- ; break;
- ; SOURCE LINE # 364
- ; }
- ; SOURCE LINE # 365
- ; }
- ; SOURCE LINE # 366
- ; }
- ; SOURCE LINE # 367
- ; }
- ; SOURCE LINE # 368
- ?C0023:
- RET
- ; END OF Vendor_Specific_Command
- ;
- ; //***********************************************************************
- ; //* *
- ; //* Routine : *
- ; //* Input : None *
- ; //* Output : None *
- ; //* Function : *
- ; //* *
- ; //***********************************************************************
- ;
- ; void reserved(void)
- RSEG ?PR?reserved?CHAP_9
- reserved:
- ; SOURCE LINE # 379
- ; {
- ; SOURCE LINE # 380
- ; }
- ; SOURCE LINE # 381
- RET
- ; END OF reserved
- ;
- ;
- ; //Get_Descriptor()获取描述符
- ; void get_descriptor(void)
- RSEG ?PR?get_descriptor?CHAP_9
- get_descriptor:
- USING 0
- ; SOURCE LINE # 385
- ; {
- ; SOURCE LINE # 386
- ;
- ; switch(USB_Device_Request.wValue)
- ; SOURCE LINE # 388
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- MOV B,R6
- LCALL ?C?ICASE
- DW ?C0026
- DW 01H
- DW ?C0031
- DW 02H
- DW ?C0060
- DW 03H
- DW ?C0064
- DW 04H
- DW ?C0065
- DW 05H
- DW ?C0087
- DW 06H
- DW ?C0092
- DW 07H
- DW ?C0071
- DW 08H
- DW 00H
- DW ?C0112
- ; {
- ; SOURCE LINE # 389
- ; case 1://设备描述符
- ; SOURCE LINE # 390
- ?C0026:
- ; //选择描述符
- ; if(Kernel_Flag.BITS.HS_FS_State == FULL_SPEED)
- ; SOURCE LINE # 392
- MOV R7,Kernel_Flag+03H
- MOV A,R7
- JNB ACC.0,?C0027
- ; Descriptor_Ptr = &Standard_Device_Descriptor[0]; //set pointer to device descriptor
- ; SOURCE LINE # 393
- MOV R6,#HIGH (Standard_Device_Descriptor)
- MOV R7,#LOW (Standard_Device_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ?C0027:
- ; if(Kernel_Flag.BITS.HS_FS_State == HIGH_SPEED)
- ; SOURCE LINE # 394
- MOV R7,Kernel_Flag+03H
- MOV A,R7
- JB ACC.0,?C0028
- ; Descriptor_Ptr = &HS_Device_Descriptor[0]; //set pointer to device descriptor
- ; SOURCE LINE # 395
- MOV R6,#HIGH (HS_Device_Descriptor)
- MOV R7,#LOW (HS_Device_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ?C0028:
- ; count = *Descriptor_Ptr; //read in descriptor length
- ; SOURCE LINE # 396
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV R6,#00H
- MOV count,R6
- MOV count+01H,R7
- ; //选择端点号
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 398
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; //写下发送字节数
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = 0x12;
- ; SOURCE LINE # 400
- MOV DPTR,#D14_Cntrl_Reg+01CH
- MOV A,#012H
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
- ; SOURCE LINE # 401
- MOV DPTR,#D14_Cntrl_Reg+01DH
- CLR A
- MOVX @DPTR,A
- ?C0029:
- ; //send descriptor
- ; //发送描述符
- ; while(count != 0)
- ; SOURCE LINE # 404
- MOV A,count+01H
- ORL A,count
- JZ ?C0030
- ; {
- ; SOURCE LINE # 405
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 406
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; count--;
- ; SOURCE LINE # 407
- MOV A,count+01H
- DEC count+01H
- JNZ ?C0214
- DEC count
- ?C0214:
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 408
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0215
- INC Descriptor_Ptr
- ?C0215:
- ; }
- ; SOURCE LINE # 409
- SJMP ?C0029
- ?C0030:
- ; wait_ep0tx();
- ; SOURCE LINE # 410
- LCALL wait_ep0tx
- ; ep0out_ack();
- ; SOURCE LINE # 411
- LCALL ep0out_ack
- ; break;
- ; SOURCE LINE # 412
- RET
- ;
- ; case 2 : //获取配置描述符
- ; SOURCE LINE # 414
- ?C0031:
- ; USB_Int_Flag.BITS.EP0RX = 0;
- ; SOURCE LINE # 415
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- ANL A,#0FBH
- MOV USB_Int_Flag+01H,A
- ; Temp = 64;
- ; SOURCE LINE # 416
- MOV Temp,#00H
- MOV Temp+01H,#040H
- ; Descriptor_Ptr = &Standard_Config_Descriptor[0]; //set pointer to configuration descriptor
- ; SOURCE LINE # 417
- MOV R6,#HIGH (Standard_Config_Descriptor)
- MOV R7,#LOW (Standard_Config_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ; count = *Descriptor_Ptr; //get configuration Descriptor length
- ; SOURCE LINE # 418
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV R6,#00H
- MOV count,R6
- MOV count+01H,R7
- ; //选择端点号1
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 420
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; //check if only configuration descriptor required
- ; //检查描述符长度,决定是只发送配置描述符还是描述符集合
- ; if(count >= USB_Device_Request.wLength) //Send only Configuration descriptor
- ; SOURCE LINE # 423
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- CLR C
- MOV A,count+01H
- SUBB A,R7
- MOV A,count
- SUBB A,R6
- JC ?C0032
- ; {
- ; SOURCE LINE # 424
- ; //写入发送字节数
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = (UC) USB_Device_Request.wLength;
- ; SOURCE LINE # 426
- MOV R0,#LOW (USB_Device_Request+07H)
- MOV A,@R0
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+01CH
- MOV A,R7
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = (UC) (USB_Device_Request.wLength >> 8);
- ; SOURCE LINE # 427
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R6
- MOV R7,A
- MOV R6,#00H
- MOV DPTR,#D14_Cntrl_Reg+01DH
- MOV A,R7
- MOVX @DPTR,A
- ; //send descriptor
- ; //发送描述符
- ; for(count = 0 ; count < USB_Device_Request.wLength ; count++)
- ; SOURCE LINE # 430
- MOV count,#00H
- MOV count+01H,#00H
- ?C0033:
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- CLR C
- MOV A,count+01H
- SUBB A,R7
- MOV A,count
- SUBB A,R6
- JNC ?C0034
- ; {
- ; SOURCE LINE # 431
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 432
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 433
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0216
- INC Descriptor_Ptr
- ?C0216:
- ; }
- ; SOURCE LINE # 434
- INC count+01H
- MOV A,count+01H
- JNZ ?C0217
- INC count
- ?C0217:
- SJMP ?C0033
- ?C0034:
- ; wait_ep0tx();
- ; SOURCE LINE # 435
- LCALL wait_ep0tx
- ; ep0out_ack();
- ; SOURCE LINE # 436
- LCALL ep0out_ack
- ; }
- ; SOURCE LINE # 437
- RET
- ?C0032:
- ; else //send Configuration,Interface and Endpoint descriptor
- ; {
- ; SOURCE LINE # 439
- ; //发送描述符集合(配置+接口+端点)
- ; if(USB_Device_Request.wLength >= 32)
- ; SOURCE LINE # 441
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- CLR C
- MOV A,R7
- SUBB A,#020H
- MOV A,R6
- SUBB A,#00H
- JNC $ + 5H
- LJMP ?C0037
- ; {
- ; SOURCE LINE # 442
- ?C0038:
- ; //写入配置描述符
- ; while(count != 0)
- ; SOURCE LINE # 444
- MOV A,count+01H
- ORL A,count
- JZ ?C0039
- ; {
- ; SOURCE LINE # 445
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 446
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; count--;
- ; SOURCE LINE # 447
- MOV A,count+01H
- DEC count+01H
- JNZ ?C0218
- DEC count
- ?C0218:
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 448
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0219
- INC Descriptor_Ptr
- ?C0219:
- ; }
- ; SOURCE LINE # 449
- SJMP ?C0038
- ?C0039:
- ; //选择高速还是全速接口描述符
- ; if(Kernel_Flag.BITS.HS_FS_State == FULL_SPEED)
- ; SOURCE LINE # 451
- MOV R7,Kernel_Flag+03H
- MOV A,R7
- JNB ACC.0,?C0040
- ; Descriptor_Ptr = &Bulk_Interface_Descriptor[0]; //set pointer to interface descriptor
- ; SOURCE LINE # 452
- MOV R6,#HIGH (Bulk_Interface_Descriptor)
- MOV R7,#LOW (Bulk_Interface_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ?C0040:
- ; if(Kernel_Flag.BITS.HS_FS_State == HIGH_SPEED)
- ; SOURCE LINE # 453
- MOV R7,Kernel_Flag+03H
- MOV A,R7
- JB ACC.0,?C0041
- ; Descriptor_Ptr = &HS_Bulk_Interface_Descriptor[0]; //set pointer to interface descriptor
- ; SOURCE LINE # 454
- MOV R6,#HIGH (HS_Bulk_Interface_Descriptor)
- MOV R7,#LOW (HS_Bulk_Interface_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ?C0041:
- ; count = *Descriptor_Ptr; //get the descriptor count
- ; SOURCE LINE # 455
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV R6,#00H
- MOV count,R6
- MOV count+01H,R7
- ?C0042:
- ; //写入接口描述符
- ; while(count != 0)
- ; SOURCE LINE # 457
- MOV A,count+01H
- ORL A,count
- JZ ?C0043
- ; {
- ; SOURCE LINE # 458
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 459
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; count--;
- ; SOURCE LINE # 460
- MOV A,count+01H
- DEC count+01H
- JNZ ?C0220
- DEC count
- ?C0220:
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 461
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0221
- INC Descriptor_Ptr
- ?C0221:
- ; }
- ; SOURCE LINE # 462
- SJMP ?C0042
- ?C0043:
- ; //选择高速还是全速端点1IN描述符
- ; if(Kernel_Flag.BITS.HS_FS_State == FULL_SPEED)
- ; SOURCE LINE # 464
- MOV R7,Kernel_Flag+03H
- MOV A,R7
- JNB ACC.0,?C0044
- ; Descriptor_Ptr = &Int_In_Descriptor[0]; //set pointer to interface descriptor
- ; SOURCE LINE # 465
- MOV R6,#HIGH (Int_In_Descriptor)
- MOV R7,#LOW (Int_In_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ?C0044:
- ; if(Kernel_Flag.BITS.HS_FS_State == HIGH_SPEED)
- ; SOURCE LINE # 466
- MOV R7,Kernel_Flag+03H
- MOV A,R7
- JB ACC.0,?C0045
- ; Descriptor_Ptr = &HS_Int_In_Descriptor[0]; //set pointer to interface descriptor
- ; SOURCE LINE # 467
- MOV R6,#HIGH (HS_Int_In_Descriptor)
- MOV R7,#LOW (HS_Int_In_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ?C0045:
- ; count = *Descriptor_Ptr; //read in descriptor length
- ; SOURCE LINE # 468
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV R6,#00H
- MOV count,R6
- MOV count+01H,R7
- ?C0046:
- ; //写入端点1IN描述符
- ; while(count != 0)
- ; SOURCE LINE # 470
- MOV A,count+01H
- ORL A,count
- JZ ?C0047
- ; {
- ; SOURCE LINE # 471
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 472
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; count--;
- ; SOURCE LINE # 473
- MOV A,count+01H
- DEC count+01H
- JNZ ?C0222
- DEC count
- ?C0222:
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 474
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0223
- INC Descriptor_Ptr
- ?C0223:
- ; }
- ; SOURCE LINE # 475
- SJMP ?C0046
- ?C0047:
- ; //选择高速还是全速端点1OUT描述符
- ; if(Kernel_Flag.BITS.HS_FS_State == FULL_SPEED)
- ; SOURCE LINE # 477
- MOV R7,Kernel_Flag+03H
- MOV A,R7
- JNB ACC.0,?C0048
- ; Descriptor_Ptr = &Int_Out_Descriptor[0]; //set pointer to interface descriptor
- ; SOURCE LINE # 478
- MOV R6,#HIGH (Int_Out_Descriptor)
- MOV R7,#LOW (Int_Out_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ?C0048:
- ; if(Kernel_Flag.BITS.HS_FS_State == HIGH_SPEED)
- ; SOURCE LINE # 479
- MOV R7,Kernel_Flag+03H
- MOV A,R7
- JB ACC.0,?C0049
- ; Descriptor_Ptr = &HS_Int_Out_Descriptor[0]; //set pointer to interface descriptor
- ; SOURCE LINE # 480
- MOV R6,#HIGH (HS_Int_Out_Descriptor)
- MOV R7,#LOW (HS_Int_Out_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ?C0049:
- ; count = *Descriptor_Ptr; //read in descriptor length
- ; SOURCE LINE # 481
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV R6,#00H
- MOV count,R6
- MOV count+01H,R7
- ?C0050:
- ; //写入端点1OUT描述符
- ; while(count != 0)
- ; SOURCE LINE # 483
- MOV A,count+01H
- ORL A,count
- JZ ?C0051
- ; {
- ; SOURCE LINE # 484
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 485
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; count--;
- ; SOURCE LINE # 486
- MOV A,count+01H
- DEC count+01H
- JNZ ?C0224
- DEC count
- ?C0224:
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 487
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0225
- INC Descriptor_Ptr
- ?C0225:
- ; }
- ; SOURCE LINE # 488
- SJMP ?C0050
- ?C0051:
- ; //选择高速还是全速端点2IN描述符
- ; if(Kernel_Flag.BITS.HS_FS_State == FULL_SPEED)
- ; SOURCE LINE # 490
- MOV R7,Kernel_Flag+03H
- MOV A,R7
- JNB ACC.0,?C0052
- ; Descriptor_Ptr = &Bulk_In_Descriptor[0]; //set pointer to interface descriptor
- ; SOURCE LINE # 491
- MOV R6,#HIGH (Bulk_In_Descriptor)
- MOV R7,#LOW (Bulk_In_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ?C0052:
- ; if(Kernel_Flag.BITS.HS_FS_State == HIGH_SPEED)
- ; SOURCE LINE # 492
- MOV R7,Kernel_Flag+03H
- MOV A,R7
- JB ACC.0,?C0053
- ; Descriptor_Ptr = &HS_Bulk_In_Descriptor[0]; //set pointer to interface descriptor
- ; SOURCE LINE # 493
- MOV R6,#HIGH (HS_Bulk_In_Descriptor)
- MOV R7,#LOW (HS_Bulk_In_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ?C0053:
- ; count = *Descriptor_Ptr; //read in descriptor length
- ; SOURCE LINE # 494
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV R6,#00H
- MOV count,R6
- MOV count+01H,R7
- ?C0054:
- ; //写入端点2IN描述符
- ; while(count != 0)
- ; SOURCE LINE # 496
- MOV A,count+01H
- ORL A,count
- JZ ?C0055
- ; {
- ; SOURCE LINE # 497
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 498
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; count--;
- ; SOURCE LINE # 499
- MOV A,count+01H
- DEC count+01H
- JNZ ?C0226
- DEC count
- ?C0226:
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 500
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0227
- INC Descriptor_Ptr
- ?C0227:
- ; }
- ; SOURCE LINE # 501
- SJMP ?C0054
- ?C0055:
- ; //选择高速还是全速端点2OUT描述符
- ; if(Kernel_Flag.BITS.HS_FS_State == FULL_SPEED)
- ; SOURCE LINE # 503
- MOV R7,Kernel_Flag+03H
- MOV A,R7
- JNB ACC.0,?C0056
- ; Descriptor_Ptr = &Bulk_Out_Descriptor[0]; //set pointer to interface descriptor
- ; SOURCE LINE # 504
- MOV R6,#HIGH (Bulk_Out_Descriptor)
- MOV R7,#LOW (Bulk_Out_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ?C0056:
- ; if(Kernel_Flag.BITS.HS_FS_State == HIGH_SPEED)
- ; SOURCE LINE # 505
- MOV R7,Kernel_Flag+03H
- MOV A,R7
- JB ACC.0,?C0057
- ; Descriptor_Ptr = &HS_Bulk_Out_Descriptor[0]; //set pointer to interface descriptor
- ; SOURCE LINE # 506
- MOV R6,#HIGH (HS_Bulk_Out_Descriptor)
- MOV R7,#LOW (HS_Bulk_Out_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ?C0057:
- ; count = *Descriptor_Ptr; //read in descriptor length
- ; SOURCE LINE # 507
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV R6,#00H
- MOV count,R6
- MOV count+01H,R7
- ?C0058:
- ; //写入端点2OUT描述符
- ; while(count != 0)
- ; SOURCE LINE # 509
- MOV A,count+01H
- ORL A,count
- JZ ?C0037
- ; {
- ; SOURCE LINE # 510
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 511
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; count--;
- ; SOURCE LINE # 512
- MOV A,count+01H
- DEC count+01H
- JNZ ?C0228
- DEC count
- ?C0228:
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 513
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0229
- INC Descriptor_Ptr
- ?C0229:
- ; }
- ; SOURCE LINE # 514
- SJMP ?C0058
- ; }
- ; SOURCE LINE # 515
- ?C0037:
- ; //使端点有效
- ; D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.VENDP = 1; //validate FIFO
- ; SOURCE LINE # 517
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ORL A,#08H
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOV A,R7
- MOVX @DPTR,A
- ; wait_ep0tx();
- ; SOURCE LINE # 518
- LCALL wait_ep0tx
- ; ep0out_ack();
- ; SOURCE LINE # 519
- LCALL ep0out_ack
- ; }
- ; SOURCE LINE # 520
- ; break;
- ; SOURCE LINE # 521
- RET
- ;
- ; case 3: //获取字符串描述符
- ; SOURCE LINE # 523
- ?C0060:
- ; Descriptor_Ptr = &Standard_String_ID[0]; //set pointer to interface descriptor
- ; SOURCE LINE # 524
- MOV R6,#HIGH (Standard_String_ID)
- MOV R7,#LOW (Standard_String_ID)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ; count = *Descriptor_Ptr; //get length
- ; SOURCE LINE # 525
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV R6,#00H
- MOV count,R6
- MOV count+01H,R7
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 526
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; if(USB_Device_Request.wLength < count)
- ; SOURCE LINE # 527
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- CLR C
- MOV A,R7
- SUBB A,count+01H
- MOV A,R6
- SUBB A,count
- JNC ?C0061
- ; count = USB_Device_Request.wLength; //get the remaining length
- ; SOURCE LINE # 528
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV count,A
- INC R0
- MOV A,@R0
- MOV count+01H,A
- ?C0061:
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = count;
- ; SOURCE LINE # 529
- MOV R7,count+01H
- MOV DPTR,#D14_Cntrl_Reg+01CH
- MOV A,R7
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
- ; SOURCE LINE # 530
- MOV DPTR,#D14_Cntrl_Reg+01DH
- CLR A
- MOVX @DPTR,A
- ?C0062:
- ; //send string ID
- ; while(count != 0)
- ; SOURCE LINE # 532
- MOV A,count+01H
- ORL A,count
- JZ ?C0063
- ; {
- ; SOURCE LINE # 533
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr; //fill up FIFO
- ; SOURCE LINE # 534
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 535
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0230
- INC Descriptor_Ptr
- ?C0230:
- ; count--;
- ; SOURCE LINE # 536
- MOV A,count+01H
- DEC count+01H
- JNZ ?C0231
- DEC count
- ?C0231:
- ; }
- ; SOURCE LINE # 537
- SJMP ?C0062
- ?C0063:
- ; wait_ep0tx();
- ; SOURCE LINE # 538
- LCALL wait_ep0tx
- ; ep0out_ack();
- ; SOURCE LINE # 539
- LCALL ep0out_ack
- ; break;
- ; SOURCE LINE # 540
- RET
- ;
- ;
- ; case 4:
- ; SOURCE LINE # 543
- ?C0064:
- ; reserved();
- ; SOURCE LINE # 544
- LCALL reserved
- ; break;
- ; SOURCE LINE # 545
- RET
- ;
- ; case 5: //获取端点描述符
- ; SOURCE LINE # 547
- ?C0065:
- ; Temp = 0;
- ; SOURCE LINE # 548
- MOV Temp,#00H
- MOV Temp+01H,#00H
- ; if((USB_Device_Request.wValue & 0x00ff) > 0x0001)
- ; SOURCE LINE # 549
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV R6,#00H
- SETB C
- MOV A,R7
- SUBB A,#01H
- MOV A,R6
- SUBB A,#00H
- JC ?C0066
- ; {
- ; SOURCE LINE # 550
- ; D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 1;
- ; SOURCE LINE # 551
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ORL A,#01H
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOV A,R7
- MOVX @DPTR,A
- ?C0067:
- ; while(!USB_Int_Flag.BITS.EP0SETUP)
- ; SOURCE LINE # 552
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- JB ACC.0,?C0068
- ; {
- ; SOURCE LINE # 553
- ; //读取ISP1581中断寄存器
- ; USB_Int_Flag.VALUE |= D14_Cntrl_Reg.D14_INT.VALUE;
- ; SOURCE LINE # 555
- MOV DPTR,#D14_Cntrl_Reg+018H
- MOVX A,@DPTR
- MOV R4,A
- INC DPTR
- MOVX A,@DPTR
- MOV R5,A
- INC DPTR
- MOVX A,@DPTR
- MOV R6,A
- INC DPTR
- MOVX A,@DPTR
- MOV R7,A
- MOV A,USB_Int_Flag+03H
- ORL A,R7
- MOV USB_Int_Flag+03H,A
- MOV A,USB_Int_Flag+02H
- ORL A,R6
- MOV USB_Int_Flag+02H,A
- MOV A,USB_Int_Flag+01H
- ORL A,R5
- MOV USB_Int_Flag+01H,A
- MOV A,USB_Int_Flag
- ORL A,R4
- MOV USB_Int_Flag,A
- ; //回写ISP1581中断寄存器
- ; D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;
- ; SOURCE LINE # 557
- MOV R7,USB_Int_Flag+03H
- MOV R6,USB_Int_Flag+02H
- MOV R5,USB_Int_Flag+01H
- MOV R4,USB_Int_Flag
- MOV DPTR,#D14_Cntrl_Reg+018H
- LCALL ?C?LSTXDATA
- ; if(USB_Int_Flag.BITS.SUSP || USB_Int_Flag.BITS.RESET)
- ; SOURCE LINE # 558
- MOV R7,USB_Int_Flag
- MOV A,R7
- RRC A
- RRC A
- RRC A
- ANL A,#01FH
- MOV R7,A
- MOV A,R7
- JNB ACC.0,$ + 6H
- LJMP ?C0071
- MOV R7,USB_Int_Flag
- MOV A,R7
- JNB ACC.0,?C0067
- RET
- ; return;
- ; }
- ; SOURCE LINE # 560
- ?C0068:
- ; USB_Int_Flag.BITS.EP0TX = 0;
- ; SOURCE LINE # 561
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- ANL A,#0F7H
- MOV USB_Int_Flag+01H,A
- ; }
- ; SOURCE LINE # 562
- RET
- ?C0066:
- ; else
- ; {
- ; SOURCE LINE # 564
- ; Descriptor_Ptr = &Bulk_Out_Descriptor[0]; //set pointer to Bulk Out endpoint descriptor
- ; SOURCE LINE # 565
- MOV R6,#HIGH (Bulk_Out_Descriptor)
- MOV R7,#LOW (Bulk_Out_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ; count = *Descriptor_Ptr; //read in descriptor length
- ; SOURCE LINE # 566
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV R6,#00H
- MOV count,R6
- MOV count+01H,R7
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 567
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; if(count >= USB_Device_Request.wLength)
- ; SOURCE LINE # 568
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- CLR C
- MOV A,count+01H
- SUBB A,R7
- MOV A,count
- SUBB A,R6
- JC ?C0073
- ; {
- ; SOURCE LINE # 569
- ; Temp = USB_Device_Request.wLength;
- ; SOURCE LINE # 570
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV Temp,A
- INC R0
- MOV A,@R0
- MOV Temp+01H,A
- ; //send endpoint descriptor
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = (UC) Temp;
- ; SOURCE LINE # 572
- MOV R7,Temp+01H
- MOV DPTR,#D14_Cntrl_Reg+01CH
- MOV A,R7
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = (UC) (Temp >> 8);
- ; SOURCE LINE # 573
- MOV A,Temp
- MOV R7,A
- MOV R6,#00H
- MOV DPTR,#D14_Cntrl_Reg+01DH
- MOV A,R7
- MOVX @DPTR,A
- ; for(count = 0 ; count < USB_Device_Request.wLength ; count++)
- ; SOURCE LINE # 574
- MOV count,#00H
- MOV count+01H,#00H
- ?C0074:
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- CLR C
- MOV A,count+01H
- SUBB A,R7
- MOV A,count
- SUBB A,R6
- JNC ?C0075
- ; {
- ; SOURCE LINE # 575
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 576
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 577
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0232
- INC Descriptor_Ptr
- ?C0232:
- ; }
- ; SOURCE LINE # 578
- INC count+01H
- MOV A,count+01H
- JNZ ?C0233
- INC count
- ?C0233:
- SJMP ?C0074
- ?C0075:
- ; wait_ep0tx();
- ; SOURCE LINE # 579
- LCALL wait_ep0tx
- ; ep0out_ack();
- ; SOURCE LINE # 580
- LCALL ep0out_ack
- ; }
- ; SOURCE LINE # 581
- RET
- ?C0073:
- ; else
- ; {
- ; SOURCE LINE # 583
- ; USB_Device_Request.wLength -= count; //send Endpoint descriptor
- ; SOURCE LINE # 584
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- CLR C
- MOV A,R7
- SUBB A,count+01H
- MOV R7,A
- MOV A,R6
- SUBB A,count
- MOV R6,A
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV @R0,AR6
- INC R0
- MOV @R0,AR7
- ; Temp += count;
- ; SOURCE LINE # 585
- MOV A,count+01H
- ADD A,Temp+01H
- MOV Temp+01H,A
- MOV A,count
- ADDC A,Temp
- MOV Temp,A
- ?C0078:
- ; while(count != 0)
- ; SOURCE LINE # 586
- MOV A,count+01H
- ORL A,count
- JZ ?C0079
- ; {
- ; SOURCE LINE # 587
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 588
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; count--;
- ; SOURCE LINE # 589
- MOV A,count+01H
- DEC count+01H
- JNZ ?C0234
- DEC count
- ?C0234:
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 590
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0235
- INC Descriptor_Ptr
- ?C0235:
- ; }
- ; SOURCE LINE # 591
- SJMP ?C0078
- ?C0079:
- ; Descriptor_Ptr = &Bulk_In_Descriptor[0]; //set pointer to Bulk In endpoint descriptor
- ; SOURCE LINE # 592
- MOV R6,#HIGH (Bulk_In_Descriptor)
- MOV R7,#LOW (Bulk_In_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ; count = *Descriptor_Ptr; //read in descriptor length
- ; SOURCE LINE # 593
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV R6,#00H
- MOV count,R6
- MOV count+01H,R7
- ; if(count >= USB_Device_Request.wLength)
- ; SOURCE LINE # 594
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- CLR C
- MOV A,count+01H
- SUBB A,R7
- MOV A,count
- SUBB A,R6
- JC ?C0080
- ; {
- ; SOURCE LINE # 595
- ; Temp += USB_Device_Request.wLength;
- ; SOURCE LINE # 596
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- ADD A,Temp+01H
- MOV Temp+01H,A
- MOV A,R6
- ADDC A,Temp
- MOV Temp,A
- ; //send endpoint descriptor
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = (UC) Temp;
- ; SOURCE LINE # 598
- MOV R7,Temp+01H
- MOV DPTR,#D14_Cntrl_Reg+01CH
- MOV A,R7
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = (UC) (Temp >> 8);
- ; SOURCE LINE # 599
- MOV A,Temp
- MOV R7,A
- MOV R6,#00H
- MOV DPTR,#D14_Cntrl_Reg+01DH
- MOV A,R7
- MOVX @DPTR,A
- ; for(count = 0 ; count < USB_Device_Request.wLength ; count++)
- ; SOURCE LINE # 600
- MOV count,#00H
- MOV count+01H,#00H
- ?C0081:
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- CLR C
- MOV A,count+01H
- SUBB A,R7
- MOV A,count
- SUBB A,R6
- JNC ?C0082
- ; {
- ; SOURCE LINE # 601
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 602
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 603
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0236
- INC Descriptor_Ptr
- ?C0236:
- ; }
- ; SOURCE LINE # 604
- INC count+01H
- MOV A,count+01H
- JNZ ?C0237
- INC count
- ?C0237:
- SJMP ?C0081
- ?C0082:
- ; wait_ep0tx();
- ; SOURCE LINE # 605
- LCALL wait_ep0tx
- ; ep0out_ack();
- ; SOURCE LINE # 606
- LCALL ep0out_ack
- ; }
- ; SOURCE LINE # 607
- RET
- ?C0080:
- ; else
- ; {
- ; SOURCE LINE # 609
- ; USB_Device_Request.wLength -= count; //send Endpoint descriptor
- ; SOURCE LINE # 610
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- CLR C
- MOV A,R7
- SUBB A,count+01H
- MOV R7,A
- MOV A,R6
- SUBB A,count
- MOV R6,A
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV @R0,AR6
- INC R0
- MOV @R0,AR7
- ; Temp += count;
- ; SOURCE LINE # 611
- MOV A,count+01H
- ADD A,Temp+01H
- MOV Temp+01H,A
- MOV A,count
- ADDC A,Temp
- MOV Temp,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = (UC) Temp;
- ; SOURCE LINE # 612
- MOV R7,Temp+01H
- MOV DPTR,#D14_Cntrl_Reg+01CH
- MOV A,R7
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = (UC) (Temp >> 8);
- ; SOURCE LINE # 613
- MOV A,Temp
- MOV R7,A
- MOV R6,#00H
- MOV DPTR,#D14_Cntrl_Reg+01DH
- MOV A,R7
- MOVX @DPTR,A
- ?C0085:
- ; while(count != 0)
- ; SOURCE LINE # 614
- MOV A,count+01H
- ORL A,count
- JZ ?C0086
- ; {
- ; SOURCE LINE # 615
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 616
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; count--;
- ; SOURCE LINE # 617
- MOV A,count+01H
- DEC count+01H
- JNZ ?C0238
- DEC count
- ?C0238:
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 618
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0239
- INC Descriptor_Ptr
- ?C0239:
- ; }
- ; SOURCE LINE # 619
- SJMP ?C0085
- ?C0086:
- ; wait_ep0tx();
- ; SOURCE LINE # 620
- LCALL wait_ep0tx
- ; ep0out_ack();
- ; SOURCE LINE # 621
- LCALL ep0out_ack
- ; }
- ; SOURCE LINE # 622
- ; }
- ; SOURCE LINE # 623
- ; }
- ; SOURCE LINE # 624
- ; break;
- ; SOURCE LINE # 625
- RET
- ;
- ; case 6: //获取设备限制描述符
- ; SOURCE LINE # 627
- ?C0087:
- ; Descriptor_Ptr = &HS_Device_Qualifier[0]; //set pointer to High Speed device descriptor
- ; SOURCE LINE # 628
- MOV R6,#HIGH (HS_Device_Qualifier)
- MOV R7,#LOW (HS_Device_Qualifier)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ; count = *Descriptor_Ptr; //read in descriptor length
- ; SOURCE LINE # 629
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV R6,#00H
- MOV count,R6
- MOV count+01H,R7
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 630
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; if(USB_Device_Request.wLength < count)
- ; SOURCE LINE # 631
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- CLR C
- MOV A,R7
- SUBB A,count+01H
- MOV A,R6
- SUBB A,count
- JNC ?C0088
- ; {
- ; SOURCE LINE # 632
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = (UC) USB_Device_Request.wLength;
- ; SOURCE LINE # 633
- MOV R0,#LOW (USB_Device_Request+07H)
- MOV A,@R0
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+01CH
- MOV A,R7
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
- ; SOURCE LINE # 634
- MOV DPTR,#D14_Cntrl_Reg+01DH
- CLR A
- MOVX @DPTR,A
- ; count = USB_Device_Request.wLength;
- ; SOURCE LINE # 635
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV count,A
- INC R0
- MOV A,@R0
- MOV count+01H,A
- ; }
- ; SOURCE LINE # 636
- SJMP ?C0090
- ?C0088:
- ; else
- ; {
- ; SOURCE LINE # 638
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = count;
- ; SOURCE LINE # 639
- MOV R7,count+01H
- MOV DPTR,#D14_Cntrl_Reg+01CH
- MOV A,R7
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
- ; SOURCE LINE # 640
- MOV DPTR,#D14_Cntrl_Reg+01DH
- CLR A
- MOVX @DPTR,A
- ; }
- ; SOURCE LINE # 641
- ?C0090:
- ; while(count != 0)
- ; SOURCE LINE # 642
- MOV A,count+01H
- ORL A,count
- JZ ?C0091
- ; {
- ; SOURCE LINE # 643
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr; //fill up FIFO
- ; SOURCE LINE # 644
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 645
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0240
- INC Descriptor_Ptr
- ?C0240:
- ; count--;
- ; SOURCE LINE # 646
- MOV A,count+01H
- DEC count+01H
- JNZ ?C0241
- DEC count
- ?C0241:
- ; };
- ; SOURCE LINE # 647
- SJMP ?C0090
- ?C0091:
- ; wait_ep0tx();
- ; SOURCE LINE # 648
- LCALL wait_ep0tx
- ; ep0out_ack();
- ; SOURCE LINE # 649
- LCALL ep0out_ack
- ; break;
- ; SOURCE LINE # 650
- RET
- ;
- ; case 7 ://获取速度配置描述符
- ; SOURCE LINE # 652
- ?C0092:
- ; Temp = 64;
- ; SOURCE LINE # 653
- MOV Temp,#00H
- MOV Temp+01H,#040H
- ; Descriptor_Ptr = &Other_Speed_Config_Descriptor[0]; //set pointer to configuration descriptor
- ; SOURCE LINE # 654
- MOV R6,#HIGH (Other_Speed_Config_Descriptor)
- MOV R7,#LOW (Other_Speed_Config_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ; count = *Descriptor_Ptr; //get configuration Descriptor length
- ; SOURCE LINE # 655
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV R6,#00H
- MOV count,R6
- MOV count+01H,R7
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 656
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; if(count >= USB_Device_Request.wLength) //Send only Configuration descriptor
- ; SOURCE LINE # 657
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- CLR C
- MOV A,count+01H
- SUBB A,R7
- MOV A,count
- SUBB A,R6
- JC ?C0093
- ; {
- ; SOURCE LINE # 658
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = (UC) USB_Device_Request.wLength;
- ; SOURCE LINE # 659
- MOV R0,#LOW (USB_Device_Request+07H)
- MOV A,@R0
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+01CH
- MOV A,R7
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = (UC) (USB_Device_Request.wLength >> 8);
- ; SOURCE LINE # 660
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R6
- MOV R7,A
- MOV R6,#00H
- MOV DPTR,#D14_Cntrl_Reg+01DH
- MOV A,R7
- MOVX @DPTR,A
- ; for(count = 0 ; count < USB_Device_Request.wLength ; count++)
- ; SOURCE LINE # 661
- MOV count,#00H
- MOV count+01H,#00H
- ?C0094:
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- CLR C
- MOV A,count+01H
- SUBB A,R7
- MOV A,count
- SUBB A,R6
- JNC ?C0095
- ; {
- ; SOURCE LINE # 662
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 663
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 664
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0242
- INC Descriptor_Ptr
- ?C0242:
- ; }
- ; SOURCE LINE # 665
- INC count+01H
- MOV A,count+01H
- JNZ ?C0243
- INC count
- ?C0243:
- SJMP ?C0094
- ?C0095:
- ; wait_ep0tx();
- ; SOURCE LINE # 666
- LCALL wait_ep0tx
- ; ep0out_ack();
- ; SOURCE LINE # 667
- LCALL ep0out_ack
- ; }
- ; SOURCE LINE # 668
- RET
- ?C0093:
- ; else //send Configuration,Interface and Endpoint descriptor
- ; {
- ; SOURCE LINE # 670
- ; if(USB_Device_Request.wLength >= 32)
- ; SOURCE LINE # 671
- MOV R0,#LOW (USB_Device_Request+06H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- CLR C
- MOV A,R7
- SUBB A,#020H
- MOV A,R6
- SUBB A,#00H
- JNC $ + 5H
- LJMP ?C0098
- ; {
- ; SOURCE LINE # 672
- ?C0099:
- ; while(count != 0)
- ; SOURCE LINE # 673
- MOV A,count+01H
- ORL A,count
- JZ ?C0100
- ; {
- ; SOURCE LINE # 674
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 675
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; count--;
- ; SOURCE LINE # 676
- MOV A,count+01H
- DEC count+01H
- JNZ ?C0244
- DEC count
- ?C0244:
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 677
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0245
- INC Descriptor_Ptr
- ?C0245:
- ; }
- ; SOURCE LINE # 678
- SJMP ?C0099
- ?C0100:
- ; Descriptor_Ptr = &Bulk_Interface_Descriptor[0]; //set pointer to interface descriptor
- ; SOURCE LINE # 679
- MOV R6,#HIGH (Bulk_Interface_Descriptor)
- MOV R7,#LOW (Bulk_Interface_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ; count = *Descriptor_Ptr; //get the descriptor count
- ; SOURCE LINE # 680
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV R6,#00H
- MOV count,R6
- MOV count+01H,R7
- ?C0101:
- ; while(count != 0)
- ; SOURCE LINE # 681
- MOV A,count+01H
- ORL A,count
- JZ ?C0102
- ; {
- ; SOURCE LINE # 682
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 683
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; count--;
- ; SOURCE LINE # 684
- MOV A,count+01H
- DEC count+01H
- JNZ ?C0246
- DEC count
- ?C0246:
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 685
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0247
- INC Descriptor_Ptr
- ?C0247:
- ; }
- ; SOURCE LINE # 686
- SJMP ?C0101
- ?C0102:
- ; Descriptor_Ptr = &Int_In_Descriptor[0]; //set pointer to interface descriptor
- ; SOURCE LINE # 687
- MOV R6,#HIGH (Int_In_Descriptor)
- MOV R7,#LOW (Int_In_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ; count = *Descriptor_Ptr; //read in descriptor length
- ; SOURCE LINE # 688
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV R6,#00H
- MOV count,R6
- MOV count+01H,R7
- ?C0103:
- ; while(count != 0)
- ; SOURCE LINE # 689
- MOV A,count+01H
- ORL A,count
- JZ ?C0104
- ; {
- ; SOURCE LINE # 690
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 691
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; count--;
- ; SOURCE LINE # 692
- MOV A,count+01H
- DEC count+01H
- JNZ ?C0248
- DEC count
- ?C0248:
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 693
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0249
- INC Descriptor_Ptr
- ?C0249:
- ; }
- ; SOURCE LINE # 694
- SJMP ?C0103
- ?C0104:
- ; Descriptor_Ptr = &Int_Out_Descriptor[0]; //set pointer to interface descriptor
- ; SOURCE LINE # 695
- MOV R6,#HIGH (Int_Out_Descriptor)
- MOV R7,#LOW (Int_Out_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ; count = *Descriptor_Ptr; //read in descriptor length
- ; SOURCE LINE # 696
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV R6,#00H
- MOV count,R6
- MOV count+01H,R7
- ?C0105:
- ; while(count != 0)
- ; SOURCE LINE # 697
- MOV A,count+01H
- ORL A,count
- JZ ?C0106
- ; {
- ; SOURCE LINE # 698
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 699
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; count--;
- ; SOURCE LINE # 700
- MOV A,count+01H
- DEC count+01H
- JNZ ?C0250
- DEC count
- ?C0250:
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 701
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0251
- INC Descriptor_Ptr
- ?C0251:
- ; }
- ; SOURCE LINE # 702
- SJMP ?C0105
- ?C0106:
- ; Descriptor_Ptr = &Bulk_In_Descriptor[0]; //set pointer to interface descriptor
- ; SOURCE LINE # 703
- MOV R6,#HIGH (Bulk_In_Descriptor)
- MOV R7,#LOW (Bulk_In_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ; count = *Descriptor_Ptr; //read in descriptor length
- ; SOURCE LINE # 704
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV R6,#00H
- MOV count,R6
- MOV count+01H,R7
- ?C0107:
- ; while(count != 0)
- ; SOURCE LINE # 705
- MOV A,count+01H
- ORL A,count
- JZ ?C0108
- ; {
- ; SOURCE LINE # 706
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 707
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; count--;
- ; SOURCE LINE # 708
- MOV A,count+01H
- DEC count+01H
- JNZ ?C0252
- DEC count
- ?C0252:
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 709
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0253
- INC Descriptor_Ptr
- ?C0253:
- ; }
- ; SOURCE LINE # 710
- SJMP ?C0107
- ?C0108:
- ; Descriptor_Ptr = &Bulk_Out_Descriptor[0]; //set pointer to interface descriptor
- ; SOURCE LINE # 711
- MOV R6,#HIGH (Bulk_Out_Descriptor)
- MOV R7,#LOW (Bulk_Out_Descriptor)
- MOV Descriptor_Ptr,R6
- MOV Descriptor_Ptr+01H,R7
- ; count = *Descriptor_Ptr; //read in descriptor length
- ; SOURCE LINE # 712
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV R6,#00H
- MOV count,R6
- MOV count+01H,R7
- ?C0109:
- ; while(count != 0)
- ; SOURCE LINE # 713
- MOV A,count+01H
- ORL A,count
- JZ ?C0098
- ; {
- ; SOURCE LINE # 714
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = *Descriptor_Ptr;
- ; SOURCE LINE # 715
- MOV R6,Descriptor_Ptr
- MOV R7,Descriptor_Ptr+01H
- MOV DPL,R7
- MOV DPH,R6
- CLR A
- MOVC A,@A+DPTR
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; count--;
- ; SOURCE LINE # 716
- MOV A,count+01H
- DEC count+01H
- JNZ ?C0254
- DEC count
- ?C0254:
- ; Descriptor_Ptr++;
- ; SOURCE LINE # 717
- INC Descriptor_Ptr+01H
- MOV A,Descriptor_Ptr+01H
- JNZ ?C0255
- INC Descriptor_Ptr
- ?C0255:
- ; }
- ; SOURCE LINE # 718
- SJMP ?C0109
- ; }
- ; SOURCE LINE # 719
- ?C0098:
- ; D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.VENDP = 1; //validate FIFO
- ; SOURCE LINE # 720
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ORL A,#08H
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOV A,R7
- MOVX @DPTR,A
- ; wait_ep0tx();
- ; SOURCE LINE # 721
- LCALL wait_ep0tx
- ; ep0out_ack();
- ; SOURCE LINE # 722
- LCALL ep0out_ack
- ; }
- ; SOURCE LINE # 723
- ; break;
- ; SOURCE LINE # 724
- RET
- ;
- ; case 8:
- ; SOURCE LINE # 726
- ; break;
- ; SOURCE LINE # 727
- ;
- ; default :
- ; SOURCE LINE # 729
- ?C0112:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 730
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 1;
- ; SOURCE LINE # 731
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ORL A,#01H
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOV A,R7
- MOVX @DPTR,A
- ?C0113:
- ; while(!USB_Int_Flag.BITS.EP0SETUP)
- ; SOURCE LINE # 732
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- JB ACC.0,?C0114
- ; {
- ; SOURCE LINE # 733
- ; //读取ISP1581中断寄存器
- ; USB_Int_Flag.VALUE |= D14_Cntrl_Reg.D14_INT.VALUE;
- ; SOURCE LINE # 735
- MOV DPTR,#D14_Cntrl_Reg+018H
- MOVX A,@DPTR
- MOV R4,A
- INC DPTR
- MOVX A,@DPTR
- MOV R5,A
- INC DPTR
- MOVX A,@DPTR
- MOV R6,A
- INC DPTR
- MOVX A,@DPTR
- MOV R7,A
- MOV A,USB_Int_Flag+03H
- ORL A,R7
- MOV USB_Int_Flag+03H,A
- MOV A,USB_Int_Flag+02H
- ORL A,R6
- MOV USB_Int_Flag+02H,A
- MOV A,USB_Int_Flag+01H
- ORL A,R5
- MOV USB_Int_Flag+01H,A
- MOV A,USB_Int_Flag
- ORL A,R4
- MOV USB_Int_Flag,A
- ; //回写ISP1581中断寄存器
- ; D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;
- ; SOURCE LINE # 737
- MOV R7,USB_Int_Flag+03H
- MOV R6,USB_Int_Flag+02H
- MOV R5,USB_Int_Flag+01H
- MOV R4,USB_Int_Flag
- MOV DPTR,#D14_Cntrl_Reg+018H
- LCALL ?C?LSTXDATA
- ; if(USB_Int_Flag.BITS.SUSP || USB_Int_Flag.BITS.RESET)
- ; SOURCE LINE # 738
- MOV R7,USB_Int_Flag
- MOV A,R7
- RRC A
- RRC A
- RRC A
- ANL A,#01FH
- MOV R7,A
- MOV A,R7
- JB ACC.0,?C0071
- MOV R7,USB_Int_Flag
- MOV A,R7
- JNB ACC.0,?C0113
- RET
- ; return;
- ; }
- ; SOURCE LINE # 740
- ?C0114:
- ; USB_Int_Flag.BITS.EP0TX = 0;
- ; SOURCE LINE # 741
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- ANL A,#0F7H
- MOV USB_Int_Flag+01H,A
- ; break;
- ; SOURCE LINE # 742
- ; }
- ; SOURCE LINE # 743
- ; }
- ; SOURCE LINE # 744
- ?C0071:
- RET
- ; END OF get_descriptor
- ;
- ; //Set_Address设置地址
- ; void set_address(void)
- RSEG ?PR?set_address?CHAP_9
- set_address:
- USING 0
- ; SOURCE LINE # 747
- ; {
- ; SOURCE LINE # 748
- ; USB_Int_Flag.BITS.EP0RX = 0;
- ; SOURCE LINE # 749
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- ANL A,#0FBH
- MOV USB_Int_Flag+01H,A
- ; D14_Cntrl_Reg.D14_ADDRESS.BITS.DEVADDR = (USB_Device_Request.wValue >> 8);//设置地址
- ; SOURCE LINE # 750
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R6
- MOV R7,A
- MOV R6,#00H
- MOV A,R7
- ANL A,#07FH
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg
- MOVX A,@DPTR
- MOV R6,A
- MOV A,R6
- ANL A,#080H
- MOV R6,A
- MOV A,R6
- ORL A,R7
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg
- MOV A,R7
- MOVX @DPTR,A
- ; //状态响应
- ; ep0in_ack();
- ; SOURCE LINE # 752
- LCALL ep0in_ack
- ; }
- ; SOURCE LINE # 753
- RET
- ; END OF set_address
- ;
- ; //Set_Config设置配置
- ; void set_config(void)
- RSEG ?PR?set_config?CHAP_9
- set_config:
- USING 0
- ; SOURCE LINE # 756
- ; {
- ; SOURCE LINE # 757
- ; USB_Int_Flag.BITS.EP0RX = 0;
- ; SOURCE LINE # 758
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- ANL A,#0FBH
- MOV USB_Int_Flag+01H,A
- ;
- ; if(USB_Device_Request.wValue == 0)
- ; SOURCE LINE # 760
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- ORL A,R6
- JNZ ?C0118
- ; {
- ; SOURCE LINE # 761
- ; Device_Config_Value = 0;
- ; SOURCE LINE # 762
- MOV Device_Config_Value,#00H
- ; ep0in_ack();
- ; SOURCE LINE # 763
- LCALL ep0in_ack
- ; }
- ; SOURCE LINE # 764
- RET
- ?C0118:
- ; else if (USB_Device_Request.wValue == 0x0100)
- ; SOURCE LINE # 765
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- CJNE A,#00H,?C0120
- MOV A,R6
- CJNE A,#01H,?C0120
- ; {
- ; SOURCE LINE # 766
- ; //配置设备
- ; Device_Config_Value = (UC) (USB_Device_Request.wValue >> 8);
- ; SOURCE LINE # 768
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R6
- MOV R7,A
- MOV R6,#00H
- MOV Device_Config_Value,R7
- ; // USB_Device.BITS.State = USB_Configured;
- ; ep0in_ack();
- ; SOURCE LINE # 770
- LCALL ep0in_ack
- ; }
- ; SOURCE LINE # 771
- RET
- ?C0120:
- ; else
- ; {
- ; SOURCE LINE # 773
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 774
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 1;
- ; SOURCE LINE # 775
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ORL A,#01H
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOV A,R7
- MOVX @DPTR,A
- ?C0122:
- ; while(!USB_Int_Flag.BITS.EP0SETUP)
- ; SOURCE LINE # 776
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- JB ACC.0,?C0123
- ; {
- ; SOURCE LINE # 777
- ; //读取ISP1581中断寄存器
- ; USB_Int_Flag.VALUE |= D14_Cntrl_Reg.D14_INT.VALUE;
- ; SOURCE LINE # 779
- MOV DPTR,#D14_Cntrl_Reg+018H
- MOVX A,@DPTR
- MOV R4,A
- INC DPTR
- MOVX A,@DPTR
- MOV R5,A
- INC DPTR
- MOVX A,@DPTR
- MOV R6,A
- INC DPTR
- MOVX A,@DPTR
- MOV R7,A
- MOV A,USB_Int_Flag+03H
- ORL A,R7
- MOV USB_Int_Flag+03H,A
- MOV A,USB_Int_Flag+02H
- ORL A,R6
- MOV USB_Int_Flag+02H,A
- MOV A,USB_Int_Flag+01H
- ORL A,R5
- MOV USB_Int_Flag+01H,A
- MOV A,USB_Int_Flag
- ORL A,R4
- MOV USB_Int_Flag,A
- ; //回写ISP1581中断寄存器
- ; D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;
- ; SOURCE LINE # 781
- MOV R7,USB_Int_Flag+03H
- MOV R6,USB_Int_Flag+02H
- MOV R5,USB_Int_Flag+01H
- MOV R4,USB_Int_Flag
- MOV DPTR,#D14_Cntrl_Reg+018H
- LCALL ?C?LSTXDATA
- ; if(USB_Int_Flag.BITS.SUSP || USB_Int_Flag.BITS.RESET)
- ; SOURCE LINE # 782
- MOV R7,USB_Int_Flag
- MOV A,R7
- RRC A
- RRC A
- RRC A
- ANL A,#01FH
- MOV R7,A
- MOV A,R7
- JB ACC.0,?C0126
- MOV R7,USB_Int_Flag
- MOV A,R7
- JNB ACC.0,?C0122
- RET
- ; return;
- ; }
- ; SOURCE LINE # 784
- ?C0123:
- ; USB_Int_Flag.BITS.EP0TX = 0;
- ; SOURCE LINE # 785
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- ANL A,#0F7H
- MOV USB_Int_Flag+01H,A
- ; }
- ; SOURCE LINE # 786
- ; }
- ; SOURCE LINE # 787
- ?C0126:
- RET
- ; END OF set_config
- ;
- ;
- ; //Get_Config获取配置
- ; void get_config(void)
- RSEG ?PR?get_config?CHAP_9
- get_config:
- USING 0
- ; SOURCE LINE # 791
- ; {
- ; SOURCE LINE # 792
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 793
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = Device_Config_Value;
- ; SOURCE LINE # 794
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,Device_Config_Value
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.VENDP = 1;
- ; SOURCE LINE # 795
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ORL A,#08H
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOV A,R7
- MOVX @DPTR,A
- ; wait_ep0tx();
- ; SOURCE LINE # 796
- LCALL wait_ep0tx
- ; ep0out_ack();
- ; SOURCE LINE # 797
- LCALL ep0out_ack
- ; }
- ; SOURCE LINE # 798
- RET
- ; END OF get_config
- ;
- ; //Clear_Feature特性清除
- ; void clear_feature(void)
- RSEG ?PR?clear_feature?CHAP_9
- clear_feature:
- USING 0
- ; SOURCE LINE # 801
- ; {
- ; SOURCE LINE # 802
- ; unsigned char bRecipient = USB_Device_Request.bmRequestType & 0x0f;
- ; SOURCE LINE # 803
- MOV R0,#LOW (USB_Device_Request)
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- ANL A,#0FH
- MOV bRecipient?842,A
- ; //端点
- ; if(bRecipient == 0x02 &&USB_Device_Request.wValue == 0x0000)
- ; SOURCE LINE # 805
- MOV A,bRecipient?842
- XRL A,#02H
- JZ $ + 5H
- LJMP ?C0128
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- ORL A,R6
- JZ $ + 5H
- LJMP ?C0128
- ; {
- ; SOURCE LINE # 806
- ; switch(USB_Device_Request.wIndex)
- ; SOURCE LINE # 807
- MOV R0,#LOW (USB_Device_Request+04H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- MOV B,R6
- LCALL ?C?ICASE
- DW ?C0131
- DW 00H
- DW ?C0133
- DW 0100H
- DW ?C0135
- DW 0200H
- DW ?C0137
- DW 0300H
- DW ?C0139
- DW 0400H
- DW ?C0141
- DW 0500H
- DW ?C0143
- DW 0600H
- DW ?C0145
- DW 0700H
- DW ?C0130
- DW 08000H
- DW ?C0132
- DW 08100H
- DW ?C0134
- DW 08200H
- DW ?C0136
- DW 08300H
- DW ?C0138
- DW 08400H
- DW ?C0140
- DW 08500H
- DW ?C0142
- DW 08600H
- DW ?C0144
- DW 08700H
- DW 00H
- DW ?C0129
- ; {
- ; SOURCE LINE # 808
- ; case 0x8000 :
- ; SOURCE LINE # 809
- ?C0130:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 810
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 811
- SJMP ?C0129
- ; case 0x0000 :
- ; SOURCE LINE # 812
- ?C0131:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 0;
- ; SOURCE LINE # 813
- MOV DPTR,#D14_Cntrl_Reg+02CH
- CLR A
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 814
- SJMP ?C0129
- ; case 0x8100 :
- ; SOURCE LINE # 815
- ?C0132:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 3;
- ; SOURCE LINE # 816
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#03H
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 817
- SJMP ?C0129
- ; case 0x0100 :
- ; SOURCE LINE # 818
- ?C0133:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 2;
- ; SOURCE LINE # 819
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#02H
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 820
- SJMP ?C0129
- ; case 0x8200 :
- ; SOURCE LINE # 821
- ?C0134:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 5;
- ; SOURCE LINE # 822
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#05H
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 823
- SJMP ?C0129
- ; case 0x0200 :
- ; SOURCE LINE # 824
- ?C0135:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 4;
- ; SOURCE LINE # 825
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#04H
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 826
- SJMP ?C0129
- ; case 0x8300 :
- ; SOURCE LINE # 827
- ?C0136:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 7;
- ; SOURCE LINE # 828
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#07H
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 829
- SJMP ?C0129
- ; case 0x0300 :
- ; SOURCE LINE # 830
- ?C0137:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 6;
- ; SOURCE LINE # 831
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#06H
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 832
- SJMP ?C0129
- ; case 0x8400 :
- ; SOURCE LINE # 833
- ?C0138:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 9;
- ; SOURCE LINE # 834
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#09H
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 835
- SJMP ?C0129
- ; case 0x0400 :
- ; SOURCE LINE # 836
- ?C0139:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 8;
- ; SOURCE LINE # 837
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#08H
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 838
- SJMP ?C0129
- ; case 0x8500 :
- ; SOURCE LINE # 839
- ?C0140:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 11;
- ; SOURCE LINE # 840
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#0BH
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 841
- SJMP ?C0129
- ; case 0x0500 :
- ; SOURCE LINE # 842
- ?C0141:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 10;
- ; SOURCE LINE # 843
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#0AH
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 844
- SJMP ?C0129
- ; case 0x8600 :
- ; SOURCE LINE # 845
- ?C0142:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 13;
- ; SOURCE LINE # 846
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#0DH
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 847
- SJMP ?C0129
- ; case 0x0600 :
- ; SOURCE LINE # 848
- ?C0143:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 12;
- ; SOURCE LINE # 849
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#0CH
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 850
- SJMP ?C0129
- ; case 0x8700 :
- ; SOURCE LINE # 851
- ?C0144:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 15;
- ; SOURCE LINE # 852
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#0FH
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 853
- SJMP ?C0129
- ; case 0x0700 :
- ; SOURCE LINE # 854
- ?C0145:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 14;
- ; SOURCE LINE # 855
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#0EH
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 856
- ; default :
- ; SOURCE LINE # 857
- ; break;
- ; SOURCE LINE # 858
- ; }
- ; SOURCE LINE # 859
- ?C0129:
- ; D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 0;
- ; SOURCE LINE # 860
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ANL A,#0FEH
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOV A,R7
- MOVX @DPTR,A
- ; Kernel_Flag.BITS.Endpt_Stall = 0;
- ; SOURCE LINE # 861
- MOV R7,Kernel_Flag+02H
- MOV A,R7
- ANL A,#07FH
- MOV Kernel_Flag+02H,A
- ; D14_Cntrl_Reg.D14_ENDPT_TYPE.BITS.ENABLE = OFF; //disable FIFO
- ; SOURCE LINE # 862
- MOV DPTR,#D14_Cntrl_Reg+08H
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ANL A,#0F7H
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+08H
- MOV A,R7
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_ENDPT_TYPE.BITS.ENABLE = ON; //disable FIFO
- ; SOURCE LINE # 863
- MOV DPTR,#D14_Cntrl_Reg+08H
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ORL A,#08H
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+08H
- MOV A,R7
- MOVX @DPTR,A
- ; ep0in_ack();
- ; SOURCE LINE # 864
- LCALL ep0in_ack
- ; USB_Device.BITS.Halt = 0;
- ; SOURCE LINE # 865
- MOV R7,USB_Device
- MOV A,R7
- ANL A,#0FDH
- MOV USB_Device,A
- ; }
- ; SOURCE LINE # 866
- RET
- ?C0128:
- ; else if(bRecipient == 0x00 && USB_Device_Request.wValue == 0x0100)
- ; SOURCE LINE # 867
- MOV A,bRecipient?842
- JNZ ?C0148
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- CJNE A,#00H,?C0148
- MOV A,R6
- CJNE A,#01H,?C0148
- ; { //远程唤醒
- ; SOURCE LINE # 868
- ; USB_Device.BITS.Remote_Wakeup = 0;
- ; SOURCE LINE # 869
- MOV R7,USB_Device
- MOV A,R7
- ANL A,#0FEH
- MOV USB_Device,A
- ; ep0in_ack();
- ; SOURCE LINE # 870
- LCALL ep0in_ack
- ; }
- ; SOURCE LINE # 871
- RET
- ?C0148:
- ; else
- ; {
- ; SOURCE LINE # 873
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 874
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 1;
- ; SOURCE LINE # 875
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ORL A,#01H
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOV A,R7
- MOVX @DPTR,A
- ?C0150:
- ; while(!USB_Int_Flag.BITS.EP0SETUP)
- ; SOURCE LINE # 876
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- JB ACC.0,?C0151
- ; {
- ; SOURCE LINE # 877
- ; //读取ISP1581中断寄存器
- ; USB_Int_Flag.VALUE |= D14_Cntrl_Reg.D14_INT.VALUE;
- ; SOURCE LINE # 879
- MOV DPTR,#D14_Cntrl_Reg+018H
- MOVX A,@DPTR
- MOV R4,A
- INC DPTR
- MOVX A,@DPTR
- MOV R5,A
- INC DPTR
- MOVX A,@DPTR
- MOV R6,A
- INC DPTR
- MOVX A,@DPTR
- MOV R7,A
- MOV A,USB_Int_Flag+03H
- ORL A,R7
- MOV USB_Int_Flag+03H,A
- MOV A,USB_Int_Flag+02H
- ORL A,R6
- MOV USB_Int_Flag+02H,A
- MOV A,USB_Int_Flag+01H
- ORL A,R5
- MOV USB_Int_Flag+01H,A
- MOV A,USB_Int_Flag
- ORL A,R4
- MOV USB_Int_Flag,A
- ; //回写ISP1581中断寄存器
- ; D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;
- ; SOURCE LINE # 881
- MOV R7,USB_Int_Flag+03H
- MOV R6,USB_Int_Flag+02H
- MOV R5,USB_Int_Flag+01H
- MOV R4,USB_Int_Flag
- MOV DPTR,#D14_Cntrl_Reg+018H
- LCALL ?C?LSTXDATA
- ; if(USB_Int_Flag.BITS.SUSP || USB_Int_Flag.BITS.RESET)
- ; SOURCE LINE # 882
- MOV R7,USB_Int_Flag
- MOV A,R7
- RRC A
- RRC A
- RRC A
- ANL A,#01FH
- MOV R7,A
- MOV A,R7
- JB ACC.0,?C0154
- MOV R7,USB_Int_Flag
- MOV A,R7
- JNB ACC.0,?C0150
- RET
- ; return;
- ; }
- ; SOURCE LINE # 884
- ?C0151:
- ; USB_Int_Flag.BITS.EP0TX = 0;
- ; SOURCE LINE # 885
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- ANL A,#0F7H
- MOV USB_Int_Flag+01H,A
- ; }
- ; SOURCE LINE # 886
- ; }
- ; SOURCE LINE # 887
- ?C0154:
- RET
- ; END OF clear_feature
- ;
- ; //Get_Status获取设备状态
- ; void get_status(void)
- RSEG ?PR?get_status?CHAP_9
- get_status:
- USING 0
- ; SOURCE LINE # 890
- ; {
- ; SOURCE LINE # 891
- ; if(USB_Device_Request.bmRequestType == 0x80)
- ; SOURCE LINE # 892
- MOV R0,#LOW (USB_Device_Request)
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- CJNE A,#080H,?C0155
- ; {
- ; SOURCE LINE # 893
- ; //端点0IN返回0x01,0x00两字节
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 895
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = 2;
- ; SOURCE LINE # 896
- MOV DPTR,#D14_Cntrl_Reg+01CH
- MOV A,#02H
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
- ; SOURCE LINE # 897
- MOV DPTR,#D14_Cntrl_Reg+01DH
- CLR A
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = 1;
- ; SOURCE LINE # 898
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,#01H
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_DATA_PORT_MSB = 0;
- ; SOURCE LINE # 899
- MOV DPTR,#D14_Cntrl_Reg+021H
- CLR A
- MOVX @DPTR,A
- ; //等待发送完毕
- ; wait_ep0tx();
- ; SOURCE LINE # 901
- LCALL wait_ep0tx
- ; ep0out_ack();
- ; SOURCE LINE # 902
- LCALL ep0out_ack
- ; }
- ; SOURCE LINE # 903
- ?C0155:
- ;
- ; if(USB_Device_Request.bmRequestType == 0x81)
- ; SOURCE LINE # 905
- MOV R0,#LOW (USB_Device_Request)
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- CJNE A,#081H,?C0156
- ; {
- ; SOURCE LINE # 906
- ; //端点0IN返回0x00,0x00两字节
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 908
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = 2;
- ; SOURCE LINE # 909
- MOV DPTR,#D14_Cntrl_Reg+01CH
- MOV A,#02H
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
- ; SOURCE LINE # 910
- MOV DPTR,#D14_Cntrl_Reg+01DH
- CLR A
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = 0;
- ; SOURCE LINE # 911
- MOV DPTR,#D14_Cntrl_Reg+020H
- CLR A
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_DATA_PORT_MSB = 0;
- ; SOURCE LINE # 912
- MOV DPTR,#D14_Cntrl_Reg+021H
- CLR A
- MOVX @DPTR,A
- ; wait_ep0tx();
- ; SOURCE LINE # 913
- LCALL wait_ep0tx
- ; ep0out_ack();
- ; SOURCE LINE # 914
- LCALL ep0out_ack
- ; }
- ; SOURCE LINE # 915
- ?C0156:
- ;
- ; if(USB_Device_Request.bmRequestType == 0x82)
- ; SOURCE LINE # 917
- MOV R0,#LOW (USB_Device_Request)
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- XRL A,#082H
- JNZ ?C0158
- ; {
- ; SOURCE LINE # 918
- ; Temp = 0;
- ; SOURCE LINE # 919
- MOV Temp,#00H
- MOV Temp+01H,#00H
- ; Temp = USB_Device.BITS.Halt;
- ; SOURCE LINE # 920
- MOV R7,USB_Device
- MOV A,R7
- CLR C
- RRC A
- MOV R7,A
- MOV A,R7
- ANL A,#01H
- MOV R7,A
- MOV R6,#00H
- MOV Temp,R6
- MOV Temp+01H,R7
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 921
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = 2;
- ; SOURCE LINE # 922
- MOV DPTR,#D14_Cntrl_Reg+01CH
- MOV A,#02H
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
- ; SOURCE LINE # 923
- MOV DPTR,#D14_Cntrl_Reg+01DH
- CLR A
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = (UC) Temp;
- ; SOURCE LINE # 924
- MOV R7,Temp+01H
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,R7
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_DATA_PORT_MSB = (UC) (Temp >> 8);
- ; SOURCE LINE # 925
- MOV A,Temp
- MOV R7,A
- MOV R6,#00H
- MOV DPTR,#D14_Cntrl_Reg+021H
- MOV A,R7
- MOVX @DPTR,A
- ; wait_ep0tx();
- ; SOURCE LINE # 926
- LCALL wait_ep0tx
- ; ep0out_ack();
- ; SOURCE LINE # 927
- LCALL ep0out_ack
- ; }
- ; SOURCE LINE # 928
- ; }
- ; SOURCE LINE # 929
- ?C0158:
- RET
- ; END OF get_status
- ;
- ;
- ;
- ; //Set_Feature特性设置
- ; //不支持测试模式
- ; void set_feature(void)
- RSEG ?PR?set_feature?CHAP_9
- set_feature:
- USING 0
- ; SOURCE LINE # 935
- ; {
- ; SOURCE LINE # 936
- ; unsigned char bRecipient = USB_Device_Request.bmRequestType & 0x0f;
- ; SOURCE LINE # 937
- MOV R0,#LOW (USB_Device_Request)
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- ANL A,#0FH
- MOV bRecipient?1043,A
- ; //端点
- ; if(bRecipient == 0x02 && USB_Device_Request.wValue == 0x0000)
- ; SOURCE LINE # 939
- MOV A,bRecipient?1043
- XRL A,#02H
- JZ $ + 5H
- LJMP ?C0159
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- ORL A,R6
- JZ $ + 5H
- LJMP ?C0159
- ; {
- ; SOURCE LINE # 940
- ; switch(USB_Device_Request.wIndex)
- ; SOURCE LINE # 941
- MOV R0,#LOW (USB_Device_Request+04H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- MOV B,R6
- LCALL ?C?ICASE
- DW ?C0162
- DW 00H
- DW ?C0164
- DW 0100H
- DW ?C0166
- DW 0200H
- DW ?C0168
- DW 0300H
- DW ?C0170
- DW 0400H
- DW ?C0172
- DW 0500H
- DW ?C0174
- DW 0600H
- DW ?C0176
- DW 0700H
- DW ?C0161
- DW 08000H
- DW ?C0163
- DW 08100H
- DW ?C0165
- DW 08200H
- DW ?C0167
- DW 08300H
- DW ?C0169
- DW 08400H
- DW ?C0171
- DW 08500H
- DW ?C0173
- DW 08600H
- DW ?C0175
- DW 08700H
- DW 00H
- DW ?C0160
- ; {
- ; SOURCE LINE # 942
- ; case 0x8000 :
- ; SOURCE LINE # 943
- ?C0161:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 944
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 945
- SJMP ?C0160
- ; case 0x0000 :
- ; SOURCE LINE # 946
- ?C0162:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 0;
- ; SOURCE LINE # 947
- MOV DPTR,#D14_Cntrl_Reg+02CH
- CLR A
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 948
- SJMP ?C0160
- ; case 0x8100 :
- ; SOURCE LINE # 949
- ?C0163:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 3;
- ; SOURCE LINE # 950
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#03H
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 951
- SJMP ?C0160
- ; case 0x0100 :
- ; SOURCE LINE # 952
- ?C0164:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 2;
- ; SOURCE LINE # 953
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#02H
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 954
- SJMP ?C0160
- ; case 0x8200 :
- ; SOURCE LINE # 955
- ?C0165:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 5;
- ; SOURCE LINE # 956
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#05H
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 957
- SJMP ?C0160
- ; case 0x0200 :
- ; SOURCE LINE # 958
- ?C0166:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 4;
- ; SOURCE LINE # 959
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#04H
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 960
- SJMP ?C0160
- ; case 0x8300 :
- ; SOURCE LINE # 961
- ?C0167:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 7;
- ; SOURCE LINE # 962
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#07H
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 963
- SJMP ?C0160
- ; case 0x0300 :
- ; SOURCE LINE # 964
- ?C0168:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 6;
- ; SOURCE LINE # 965
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#06H
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 966
- SJMP ?C0160
- ; case 0x8400 :
- ; SOURCE LINE # 967
- ?C0169:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 9;
- ; SOURCE LINE # 968
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#09H
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 969
- SJMP ?C0160
- ; case 0x0400 :
- ; SOURCE LINE # 970
- ?C0170:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 8;
- ; SOURCE LINE # 971
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#08H
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 972
- SJMP ?C0160
- ; case 0x8500 :
- ; SOURCE LINE # 973
- ?C0171:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 11;
- ; SOURCE LINE # 974
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#0BH
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 975
- SJMP ?C0160
- ; case 0x0500 :
- ; SOURCE LINE # 976
- ?C0172:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 10;
- ; SOURCE LINE # 977
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#0AH
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 978
- SJMP ?C0160
- ; case 0x8600 :
- ; SOURCE LINE # 979
- ?C0173:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 13;
- ; SOURCE LINE # 980
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#0DH
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 981
- SJMP ?C0160
- ; case 0x0600 :
- ; SOURCE LINE # 982
- ?C0174:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 12;
- ; SOURCE LINE # 983
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#0CH
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 984
- SJMP ?C0160
- ; case 0x8700 :
- ; SOURCE LINE # 985
- ?C0175:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 15;
- ; SOURCE LINE # 986
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#0FH
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 987
- SJMP ?C0160
- ; case 0x0700 :
- ; SOURCE LINE # 988
- ?C0176:
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 14;
- ; SOURCE LINE # 989
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#0EH
- MOVX @DPTR,A
- ; break;
- ; SOURCE LINE # 990
- ; default :
- ; SOURCE LINE # 991
- ; break;
- ; SOURCE LINE # 992
- ; }
- ; SOURCE LINE # 993
- ?C0160:
- ; D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 1;
- ; SOURCE LINE # 994
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ORL A,#01H
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOV A,R7
- MOVX @DPTR,A
- ; Kernel_Flag.BITS.Endpt_Stall = 1;
- ; SOURCE LINE # 995
- MOV R7,Kernel_Flag+02H
- MOV A,R7
- ORL A,#080H
- MOV Kernel_Flag+02H,A
- ; D14_Cntrl_Reg.D14_ENDPT_TYPE.BITS.ENABLE = OFF; //disable FIFO
- ; SOURCE LINE # 996
- MOV DPTR,#D14_Cntrl_Reg+08H
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ANL A,#0F7H
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+08H
- MOV A,R7
- MOVX @DPTR,A
- ; //D14_Cntrl_Reg.D14_ENDPT_TYPE.BITS.ENABLE = ON; //disable FIFO
- ; ep0in_ack();
- ; SOURCE LINE # 998
- LCALL ep0in_ack
- ; USB_Device.BITS.Halt = 0;
- ; SOURCE LINE # 999
- MOV R7,USB_Device
- MOV A,R7
- ANL A,#0FDH
- MOV USB_Device,A
- ; }
- ; SOURCE LINE # 1000
- RET
- ?C0159:
- ; else if(bRecipient == 0x00 && USB_Device_Request.wValue == 0x0100)
- ; SOURCE LINE # 1001
- MOV A,bRecipient?1043
- JNZ ?C0179
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- CJNE A,#00H,?C0179
- MOV A,R6
- CJNE A,#01H,?C0179
- ; { //远程唤醒
- ; SOURCE LINE # 1002
- ; USB_Device.BITS.Remote_Wakeup = 1;
- ; SOURCE LINE # 1003
- MOV R7,USB_Device
- MOV A,R7
- ORL A,#01H
- MOV USB_Device,A
- ; ep0in_ack();
- ; SOURCE LINE # 1004
- LCALL ep0in_ack
- ; }
- ; SOURCE LINE # 1005
- RET
- ?C0179:
- ; else
- ; {
- ; SOURCE LINE # 1007
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 1008
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 1;
- ; SOURCE LINE # 1009
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ORL A,#01H
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOV A,R7
- MOVX @DPTR,A
- ?C0181:
- ; while(!USB_Int_Flag.BITS.EP0SETUP)
- ; SOURCE LINE # 1010
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- JB ACC.0,?C0182
- ; {
- ; SOURCE LINE # 1011
- ; //读取ISP1581中断寄存器
- ; USB_Int_Flag.VALUE |= D14_Cntrl_Reg.D14_INT.VALUE;
- ; SOURCE LINE # 1013
- MOV DPTR,#D14_Cntrl_Reg+018H
- MOVX A,@DPTR
- MOV R4,A
- INC DPTR
- MOVX A,@DPTR
- MOV R5,A
- INC DPTR
- MOVX A,@DPTR
- MOV R6,A
- INC DPTR
- MOVX A,@DPTR
- MOV R7,A
- MOV A,USB_Int_Flag+03H
- ORL A,R7
- MOV USB_Int_Flag+03H,A
- MOV A,USB_Int_Flag+02H
- ORL A,R6
- MOV USB_Int_Flag+02H,A
- MOV A,USB_Int_Flag+01H
- ORL A,R5
- MOV USB_Int_Flag+01H,A
- MOV A,USB_Int_Flag
- ORL A,R4
- MOV USB_Int_Flag,A
- ; //回写ISP1581中断寄存器
- ; D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;
- ; SOURCE LINE # 1015
- MOV R7,USB_Int_Flag+03H
- MOV R6,USB_Int_Flag+02H
- MOV R5,USB_Int_Flag+01H
- MOV R4,USB_Int_Flag
- MOV DPTR,#D14_Cntrl_Reg+018H
- LCALL ?C?LSTXDATA
- ; if(USB_Int_Flag.BITS.SUSP || USB_Int_Flag.BITS.RESET)
- ; SOURCE LINE # 1016
- MOV R7,USB_Int_Flag
- MOV A,R7
- RRC A
- RRC A
- RRC A
- ANL A,#01FH
- MOV R7,A
- MOV A,R7
- JB ACC.0,?C0185
- MOV R7,USB_Int_Flag
- MOV A,R7
- JNB ACC.0,?C0181
- RET
- ; return;
- ; }
- ; SOURCE LINE # 1018
- ?C0182:
- ; USB_Int_Flag.BITS.EP0TX = 0;
- ; SOURCE LINE # 1019
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- ANL A,#0F7H
- MOV USB_Int_Flag+01H,A
- ; }
- ; SOURCE LINE # 1020
- ; }
- ; SOURCE LINE # 1021
- ?C0185:
- RET
- ; END OF set_feature
- ;
- ;
- ; //Get_Interface 获取接口状态
- ; void get_interface(void)
- RSEG ?PR?get_interface?CHAP_9
- get_interface:
- USING 0
- ; SOURCE LINE # 1025
- ; {
- ; SOURCE LINE # 1026
- ; if(USB_Device_Request.wValue != 0)
- ; SOURCE LINE # 1027
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- ORL A,R6
- JZ ?C0186
- ; {
- ; SOURCE LINE # 1028
- ; D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STALL = 1;
- ; SOURCE LINE # 1029
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ORL A,#01H
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOV A,R7
- MOVX @DPTR,A
- ?C0187:
- ; while(!USB_Int_Flag.BITS.EP0SETUP)
- ; SOURCE LINE # 1030
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- JB ACC.0,?C0188
- ; {
- ; SOURCE LINE # 1031
- ; //读取ISP1581中断寄存器
- ; USB_Int_Flag.VALUE |= D14_Cntrl_Reg.D14_INT.VALUE;
- ; SOURCE LINE # 1033
- MOV DPTR,#D14_Cntrl_Reg+018H
- MOVX A,@DPTR
- MOV R4,A
- INC DPTR
- MOVX A,@DPTR
- MOV R5,A
- INC DPTR
- MOVX A,@DPTR
- MOV R6,A
- INC DPTR
- MOVX A,@DPTR
- MOV R7,A
- MOV A,USB_Int_Flag+03H
- ORL A,R7
- MOV USB_Int_Flag+03H,A
- MOV A,USB_Int_Flag+02H
- ORL A,R6
- MOV USB_Int_Flag+02H,A
- MOV A,USB_Int_Flag+01H
- ORL A,R5
- MOV USB_Int_Flag+01H,A
- MOV A,USB_Int_Flag
- ORL A,R4
- MOV USB_Int_Flag,A
- ; //回写ISP1581中断寄存器
- ; D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;
- ; SOURCE LINE # 1035
- MOV R7,USB_Int_Flag+03H
- MOV R6,USB_Int_Flag+02H
- MOV R5,USB_Int_Flag+01H
- MOV R4,USB_Int_Flag
- MOV DPTR,#D14_Cntrl_Reg+018H
- LCALL ?C?LSTXDATA
- ; if(USB_Int_Flag.BITS.SUSP || USB_Int_Flag.BITS.RESET)
- ; SOURCE LINE # 1036
- MOV R7,USB_Int_Flag
- MOV A,R7
- RRC A
- RRC A
- RRC A
- ANL A,#01FH
- MOV R7,A
- MOV A,R7
- JB ACC.0,?C0191
- MOV R7,USB_Int_Flag
- MOV A,R7
- JNB ACC.0,?C0187
- RET
- ; return;
- ; }
- ; SOURCE LINE # 1038
- ?C0188:
- ; USB_Int_Flag.BITS.EP0TX = 0;
- ; SOURCE LINE # 1039
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- ANL A,#0F7H
- MOV USB_Int_Flag+01H,A
- ; }
- ; SOURCE LINE # 1040
- RET
- ?C0186:
- ; else
- ; {
- ; SOURCE LINE # 1042
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 1043
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB = 1;
- ; SOURCE LINE # 1044
- MOV DPTR,#D14_Cntrl_Reg+01CH
- MOV A,#01H
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = 0;
- ; SOURCE LINE # 1045
- MOV DPTR,#D14_Cntrl_Reg+01DH
- CLR A
- MOVX @DPTR,A
- ; if(!USB_Device.BITS.Alter_Interface)
- ; SOURCE LINE # 1046
- MOV R7,USB_Device+03H
- MOV A,R7
- JB ACC.0,?C0193
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = 0;
- ; SOURCE LINE # 1047
- MOV DPTR,#D14_Cntrl_Reg+020H
- CLR A
- MOVX @DPTR,A
- SJMP ?C0194
- ?C0193:
- ; else
- ; D14_Cntrl_Reg.D14_DATA_PORT_LSB = 1;
- ; SOURCE LINE # 1049
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOV A,#01H
- MOVX @DPTR,A
- ?C0194:
- ; wait_ep0tx();
- ; SOURCE LINE # 1050
- LCALL wait_ep0tx
- ; ep0in_ack();
- ; SOURCE LINE # 1051
- LCALL ep0in_ack
- ; }
- ; SOURCE LINE # 1052
- ; }
- ; SOURCE LINE # 1053
- ?C0191:
- RET
- ; END OF get_interface
- ;
- ;
- ; //Set_Interface 设置接口状态
- ; void set_interface(void)
- RSEG ?PR?set_interface?CHAP_9
- set_interface:
- USING 0
- ; SOURCE LINE # 1057
- ; {
- ; SOURCE LINE # 1058
- ; if(USB_Device_Request.wIndex == 0 && USB_Device_Request.wValue == 0x0100)
- ; SOURCE LINE # 1059
- MOV R0,#LOW (USB_Device_Request+04H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- ORL A,R6
- JNZ ?C0195
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- CJNE A,#00H,?C0195
- MOV A,R6
- CJNE A,#01H,?C0195
- ; USB_Device.BITS.Alter_Interface = 1;
- ; SOURCE LINE # 1060
- MOV R7,USB_Device+03H
- MOV A,R7
- ORL A,#01H
- MOV USB_Device+03H,A
- ?C0195:
- ;
- ; if(USB_Device_Request.wIndex == 0x0100 && USB_Device_Request.wValue == 0)
- ; SOURCE LINE # 1062
- MOV R0,#LOW (USB_Device_Request+04H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- CJNE A,#00H,?C0196
- MOV A,R6
- CJNE A,#01H,?C0196
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- ORL A,R6
- JNZ ?C0196
- ; USB_Device.BITS.Alter_Interface = 0;
- ; SOURCE LINE # 1063
- MOV R7,USB_Device+03H
- MOV A,R7
- ANL A,#0FEH
- MOV USB_Device+03H,A
- ?C0196:
- ;
- ; if(USB_Device_Request.wIndex == 0 && USB_Device_Request.wValue == 0)
- ; SOURCE LINE # 1065
- MOV R0,#LOW (USB_Device_Request+04H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- ORL A,R6
- JNZ ?C0197
- MOV R0,#LOW (USB_Device_Request+02H)
- MOV A,@R0
- MOV R6,A
- INC R0
- MOV A,@R0
- MOV R7,A
- MOV A,R7
- ORL A,R6
- JNZ ?C0197
- ; USB_Device.BITS.Alter_Interface = 0;
- ; SOURCE LINE # 1066
- MOV R7,USB_Device+03H
- MOV A,R7
- ANL A,#0FEH
- MOV USB_Device+03H,A
- ?C0197:
- ;
- ; ep0in_ack();
- ; SOURCE LINE # 1068
- LCALL ep0in_ack
- ; }
- ; SOURCE LINE # 1069
- RET
- ; END OF set_interface
- ;
- ;
- ;
- ; //端点0IN状态响应
- ; void ep0in_ack(void)
- RSEG ?PR?ep0in_ack?CHAP_9
- ep0in_ack:
- USING 0
- ; SOURCE LINE # 1074
- ; {
- ; SOURCE LINE # 1075
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 1;
- ; SOURCE LINE # 1076
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,#01H
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STATUS = 1;
- ; SOURCE LINE # 1077
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ORL A,#02H
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOV A,R7
- MOVX @DPTR,A
- ; wait_ep0tx();
- ; SOURCE LINE # 1078
- LCALL wait_ep0tx
- ; }
- ; SOURCE LINE # 1079
- RET
- ; END OF ep0in_ack
- ;
- ; //端点0IN状态响应
- ; void wait_ep0tx(void)
- RSEG ?PR?wait_ep0tx?CHAP_9
- wait_ep0tx:
- USING 0
- ; SOURCE LINE # 1082
- ; {
- ; SOURCE LINE # 1083
- ?C0200:
- ; //end of status stage
- ; while(!USB_Int_Flag.BITS.EP0TX)
- ; SOURCE LINE # 1085
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- RRC A
- RRC A
- RRC A
- ANL A,#01FH
- MOV R7,A
- MOV A,R7
- JB ACC.0,?C0201
- ; {
- ; SOURCE LINE # 1086
- ; //读取ISP1581中断寄存器
- ; USB_Int_Flag.VALUE |= D14_Cntrl_Reg.D14_INT.VALUE;
- ; SOURCE LINE # 1088
- MOV DPTR,#D14_Cntrl_Reg+018H
- MOVX A,@DPTR
- MOV R4,A
- INC DPTR
- MOVX A,@DPTR
- MOV R5,A
- INC DPTR
- MOVX A,@DPTR
- MOV R6,A
- INC DPTR
- MOVX A,@DPTR
- MOV R7,A
- MOV A,USB_Int_Flag+03H
- ORL A,R7
- MOV USB_Int_Flag+03H,A
- MOV A,USB_Int_Flag+02H
- ORL A,R6
- MOV USB_Int_Flag+02H,A
- MOV A,USB_Int_Flag+01H
- ORL A,R5
- MOV USB_Int_Flag+01H,A
- MOV A,USB_Int_Flag
- ORL A,R4
- MOV USB_Int_Flag,A
- ; //回写ISP1581中断寄存器
- ; D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;
- ; SOURCE LINE # 1090
- MOV R7,USB_Int_Flag+03H
- MOV R6,USB_Int_Flag+02H
- MOV R5,USB_Int_Flag+01H
- MOV R4,USB_Int_Flag
- MOV DPTR,#D14_Cntrl_Reg+018H
- LCALL ?C?LSTXDATA
- ; if(USB_Int_Flag.BITS.SUSP || USB_Int_Flag.BITS.RESET)
- ; SOURCE LINE # 1091
- MOV R7,USB_Int_Flag
- MOV A,R7
- RRC A
- RRC A
- RRC A
- ANL A,#01FH
- MOV R7,A
- MOV A,R7
- JB ACC.0,?C0204
- MOV R7,USB_Int_Flag
- MOV A,R7
- JNB ACC.0,?C0200
- RET
- ; return;
- ; }
- ; SOURCE LINE # 1093
- ?C0201:
- ; USB_Int_Flag.BITS.EP0TX = 0;
- ; SOURCE LINE # 1094
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- ANL A,#0F7H
- MOV USB_Int_Flag+01H,A
- ; }
- ; SOURCE LINE # 1095
- ?C0204:
- RET
- ; END OF wait_ep0tx
- ;
- ; //端点0OUT状态响应
- ; void ep0out_ack(void)
- RSEG ?PR?ep0out_ack?CHAP_9
- ep0out_ack:
- USING 0
- ; SOURCE LINE # 1098
- ; {
- ; SOURCE LINE # 1099
- ; //设置状态响应
- ; //acknowledge status stage
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = 0;
- ; SOURCE LINE # 1102
- MOV DPTR,#D14_Cntrl_Reg+02CH
- CLR A
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_CONTROL_FUNCTION.BITS.STATUS = 1;
- ; SOURCE LINE # 1103
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOVX A,@DPTR
- MOV R7,A
- MOV A,R7
- ORL A,#02H
- MOV R7,A
- MOV DPTR,#D14_Cntrl_Reg+028H
- MOV A,R7
- MOVX @DPTR,A
- ; // D14_Cntrl_Reg.D14_CONTROL_FUNCTION.VALUE = 2;
- ; wait_ep0rx();
- ; SOURCE LINE # 1105
- LCALL wait_ep0rx
- ; }
- ; SOURCE LINE # 1106
- RET
- ; END OF ep0out_ack
- ;
- ; //端点0OUT状态响应
- ; void wait_ep0rx(void)
- RSEG ?PR?wait_ep0rx?CHAP_9
- wait_ep0rx:
- USING 0
- ; SOURCE LINE # 1109
- ; {
- ; SOURCE LINE # 1110
- ?C0206:
- ; while(!USB_Int_Flag.BITS.EP0RX)
- ; SOURCE LINE # 1111
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- RRC A
- RRC A
- ANL A,#03FH
- MOV R7,A
- MOV A,R7
- JB ACC.0,?C0207
- ; {
- ; SOURCE LINE # 1112
- ; //读取ISP1581中断寄存器
- ; USB_Int_Flag.VALUE |= D14_Cntrl_Reg.D14_INT.VALUE;
- ; SOURCE LINE # 1114
- MOV DPTR,#D14_Cntrl_Reg+018H
- MOVX A,@DPTR
- MOV R4,A
- INC DPTR
- MOVX A,@DPTR
- MOV R5,A
- INC DPTR
- MOVX A,@DPTR
- MOV R6,A
- INC DPTR
- MOVX A,@DPTR
- MOV R7,A
- MOV A,USB_Int_Flag+03H
- ORL A,R7
- MOV USB_Int_Flag+03H,A
- MOV A,USB_Int_Flag+02H
- ORL A,R6
- MOV USB_Int_Flag+02H,A
- MOV A,USB_Int_Flag+01H
- ORL A,R5
- MOV USB_Int_Flag+01H,A
- MOV A,USB_Int_Flag
- ORL A,R4
- MOV USB_Int_Flag,A
- ; //回写ISP1581中断寄存器
- ; D14_Cntrl_Reg.D14_INT.VALUE = USB_Int_Flag.VALUE;
- ; SOURCE LINE # 1116
- MOV R7,USB_Int_Flag+03H
- MOV R6,USB_Int_Flag+02H
- MOV R5,USB_Int_Flag+01H
- MOV R4,USB_Int_Flag
- MOV DPTR,#D14_Cntrl_Reg+018H
- LCALL ?C?LSTXDATA
- ; if(USB_Int_Flag.BITS.SUSP || USB_Int_Flag.BITS.RESET)
- ; SOURCE LINE # 1117
- MOV R7,USB_Int_Flag
- MOV A,R7
- RRC A
- RRC A
- RRC A
- ANL A,#01FH
- MOV R7,A
- MOV A,R7
- JB ACC.0,?C0210
- MOV R7,USB_Int_Flag
- MOV A,R7
- JNB ACC.0,?C0206
- RET
- ; return;
- ; }
- ; SOURCE LINE # 1119
- ?C0207:
- ; USB_Int_Flag.BITS.EP0RX = 0;
- ; SOURCE LINE # 1120
- MOV R7,USB_Int_Flag+01H
- MOV A,R7
- ANL A,#0FBH
- MOV USB_Int_Flag+01H,A
- ; }
- ; SOURCE LINE # 1121
- ?C0210:
- RET
- ; END OF wait_ep0rx
- ;
- ;
- ; unsigned char read_endpoint(unsigned char endp,unsigned int len,unsigned char *buf)
- RSEG ?PR?_read_endpoint?CHAP_9
- _read_endpoint:
- USING 0
- ; SOURCE LINE # 1124
- MOV endp?1744,R7
- MOV len?1745,R4
- MOV len?1745+01H,R5
- MOV buf?1746,R3
- MOV buf?1746+01H,R2
- MOV buf?1746+02H,R1
- ; {
- ; SOURCE LINE # 1125
- ; D14_Cntrl_Reg.D14_ENDPT_INDEX = endp;
- ; SOURCE LINE # 1126
- MOV DPTR,#D14_Cntrl_Reg+02CH
- MOV A,endp?1744
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_LSB =( unsigned char ) len;
- ; SOURCE LINE # 1127
- MOV R7,len?1745+01H
- MOV DPTR,#D14_Cntrl_Reg+01CH
- MOV A,R7
- MOVX @DPTR,A
- ; D14_Cntrl_Reg.D14_BUFFER_LENGTH_MSB = ( unsigned char ) (len>>8);
- ; SOURCE LINE # 1128
- MOV A,len?1745
- MOV R7,A
- MOV R6,#00H
- MOV DPTR,#D14_Cntrl_Reg+01DH
- MOV A,R7
- MOVX @DPTR,A
- ?C0211:
- ; while(len-- != 0)
- ; SOURCE LINE # 1129
- MOV A,len?1745+01H
- DEC len?1745+01H
- MOV R6,len?1745
- JNZ ?C0261
- DEC len?1745
- ?C0261:
- MOV R7,A
- MOV A,R7
- ORL A,R6
- JZ ?C0212
- ; {
- ; SOURCE LINE # 1130
- ; *buf = D14_Cntrl_Reg.D14_DATA_PORT_LSB; //fill up FIFO
- ; SOURCE LINE # 1131
- MOV DPTR,#D14_Cntrl_Reg+020H
- MOVX A,@DPTR
- MOV R7,A
- MOV R3,buf?1746
- MOV R2,buf?1746+01H
- MOV R1,buf?1746+02H
- MOV A,R7
- LCALL ?C?CSTPTR
- ; buf++;
- ; SOURCE LINE # 1132
- MOV A,#01H
- ADD A,buf?1746+02H
- MOV buf?1746+02H,A
- CLR A
- ADDC A,buf?1746+01H
- MOV buf?1746+01H,A
- ; }
- ; SOURCE LINE # 1133
- SJMP ?C0211
- ?C0212:
- ; return len;
- ; SOURCE LINE # 1134
- MOV R7,len?1745+01H
- ; }
- ; SOURCE LINE # 1135
- ?C0213:
- RET
- ; END OF _read_endpoint
- END