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