📄 main.lst
字号:
C51 COMPILER V6.23a MAIN 05/31/2003 10:20:29 PAGE 1
C51 COMPILER V6.23a, COMPILATION OF MODULE MAIN
OBJECT MODULE PLACED IN main.OBJ
COMPILER INVOKED BY: E:\Program Files\keil\C51\BIN\C51.EXE main.c BROWSE DEBUG OBJECTEXTEND
stmt level source
1 #include <REGSND1.H>
2 #include "uart.h"
3 #include "atmelusbci.h"
4 #include "main.h"
5
6 code unsigned char Device_Descriptor[18]={
7 0x12, //0x12
8 0x01, //DEVICE descriptor
9 0x10,0x01, //spec rev level (BCD) 1.0
10 0x0, //device class
11 0x0, //device subclass
12 0x0, //device protocol
13 0x20, //max packet size
14 0x05,0x82, //National's vendor ID
15 0x00,0x11, //National's product ID
16 0x00,0x00, //National's revision ID
17 0, //index of manuf. string
18 0, //index of prod. string
19 0, //index of ser. # string
20 0x01 //number of configs.
21 };
22
23 code unsigned char Configuration_Descriptor_All[32]={
24
25 9,//Size of Descriptor in Bytes
26 2,//Configuration Descriptor (0x02)
27 0x20,//Total length in bytes of data returned LSB
28 0x00,//MSB
29 1,//Number of Interfaces
30 1,//Value to use as an argument to select this configuration
31 0,//Index of String Descriptor describing this configuration
32 0x80,
33 0xfa,//Maximum Power Consumption in 2mA units
34
35 9,
36 4,
37 0,//the index of the interface descriptor Number of Interface
38 0,//Value used to select alternative setting
39 2,//EndPoint Number Used in this Descriptor
40 8,//Class Code (Assigned by USB Org)
41 6, //interface subclass1=RBC,2=SFF,3=QIC,4=UFI,5=SFF,6=SCSI
42 0x50,//bulk 0nly Transport
43 0,//Index of String Descriptor Describing this interface
44
45 //Bulk-in Endpoint
46 0x07, //length of this desc.
47 0x05, //ENDPOINT descriptor TYPE
48 0x81, //address (IN) Endpoint 4 84
49 0x02, //attributes (BULK)
50 0x40,0x00, //max packet size (64)
51 0x0, //Does not apply to Bulk endpoints
52
53 //Bulk-out Endpoint
54 0x07, //length of this desc.
55 0x05, //ENDPOINT descriptor TYPE
C51 COMPILER V6.23a MAIN 05/31/2003 10:20:29 PAGE 2
56 0x02, //address (OUT) Endpoint 5 05
57 0x02, //attributes (BULK)
58 0x40,0x00, //max packet size (64)
59 0x0 //Does not apply to Bulk endpoints
60 };
61
62 unsigned char ReadEp(unsigned char EpNum,unsigned char *Data)
63 {
64 1 unsigned char i=0,nLength;
65 1 UEPNUM=EpNum;
66 1
67 1 nLength=UBYCTX;
68 1 while(nLength--) {Data[i++]=UEPDATX;/*printuf("%x ",Data[i]);*/}
69 1
70 1 UEPSTAX&=~(RXOUTB0|RXOUTB1|RXSETUP);
71 1 return(i);
72 1 }
73
74 void WriteEp(unsigned char EpNum,unsigned char nLength,unsigned char *Data)
75 {
76 1 unsigned char i=0;
77 1 UEPNUM=EpNum;
78 1 UEPSTAX|=DIR;//Set for status of a Control In transaction
79 1 while(nLength--) UEPDATX=Data[i++];
80 1 UEPSTAX|=TXRDY;//Sending the data,this action will switch between bank0 and bank1
81 1 while(!(UEPSTAX&TXCMP)) ;
82 1 UEPSTAX&=(~(TXCMP));//clear TXCMP
83 1 }
84
85
86 void Get_Status()
87 {
88 1 printu("Get_Status\n");
89 1 }
90 void Clear_Feature()
91 {
92 1 printu("Clear_Feature\n");
93 1 }
94 void Set_Feature()
95 {
96 1 printu("Set_Feature\n");
97 1 }
98 void Set_Address(unsigned char EpNum)
99 {
100 1 printu("Set_Address\n");
101 1 // unsigned char Test[]={0};
102 1 WriteEp(0,0,0);//在Status阶段过后才能改变设备地址
103 1
104 1 USBADDR|=EpNum;
105 1 USBADDR|=FEN;
106 1 USBCON|=FADDEN;
107 1
108 1 // printuf("\nSet_Address:%x\n",USBADDR);
109 1 }
110 void Get_Descriptor(unsigned char DesType,unsigned char nLength)
111 {
112 1 printu("Get_Descriptor\n");
113 1 if(DesType==0x01) WriteEp(0,18,Device_Descriptor);
114 1 if((DesType==0x02)&&(nLength==0x09)) WriteEp(0,9,Configuration_Descriptor_All);
115 1 if((DesType==0x02)&&(nLength==0xff)) {WriteEp(0,32,Configuration_Descriptor_All);WriteEp(0,2,&Device_Desc
-riptor[4]);}
116 1 if((DesType==0x02)&&(nLength==0x20)) {WriteEp(0,32,Configuration_Descriptor_All);}
C51 COMPILER V6.23a MAIN 05/31/2003 10:20:29 PAGE 3
117 1
118 1 // printu("Get_Descriptor\n");
119 1 }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -