📄 main.lst
字号:
120 void Get_Configuration()
121 {
122 1 printu("Get_Configuration\n");
123 1 }
124 void Set_Configuration(unsigned char wValue)
125 {
126 1
127 1 printu("Set_Configuration\n");
128 1 if(wValue == 0) {
129 2 /* put device in unconfigured state */
130 2 /* Disable all endpoints but EPP0. *///init_unconfig
131 2
132 2 UEPNUM=0x00;//Ep0 as control Endpoint
133 2 UEPCONX=0x80;
134 2
135 2 UEPNUM=0x01;//Ep1 as Bulk-in Endpoint
136 2 UEPCONX=0x86;
137 2
138 2 UEPNUM=0x02;//Ep2 as Bulk-out Endpoint
139 2 UEPCONX=0x82;
140 2
141 2 // WriteEp(0,&Device_Descriptor[4],2);
142 2 USBCON&=(~CONFG);
143 2 WriteEp(0,0,0);//状态传送阶段之前完成指定操作
144 2
145 2 }
146 1 else if(wValue == 1) {
147 2 /* Configure device */
148 2 /* Enable generic/iso endpoints. init_config*/
149 2
150 2 UEPNUM=0x00;//Ep0 as control Endpoint
151 2 UEPCONX=0x80;
152 2
153 2 UEPNUM=0x01;//Ep1 as Bulk-in Endpoint
154 2 UEPCONX=0x86;
155 2
156 2 UEPNUM=0x02;//Ep2 as Bulk-out Endpoint
157 2 UEPCONX=0x82;
158 2
159 2
160 2 // WriteEp(0,&Device_Descriptor[4],2);
161 2 USBCON|=CONFG;
162 2 WriteEp(0,0,0);//状态传送阶段之前完成指定操作
163 2 // printuf("After Config,USBADDR:%x ",USBADDR);
164 2 // printuf("USBCON:%x \n",USBCON);
165 2
166 2 }
167 1 // printu("Set_Configuration ");
168 1 }
169 void Get_Interface()
170 {
171 1 printu("Get_Interface\n");
172 1 }
173 void Set_Interface()
174 {
175 1 WriteEp(0,0,0);
176 1 printu("Set_Interface\n");
177 1 }
178 void Reserved()
C51 COMPILER V6.23a MAIN 05/31/2003 10:20:29 PAGE 4
179 {}
180
181 void Ep0Int()
182 {
183 1 unsigned char i,j;
184 1 unsigned char ControlData[32]={0,};
185 1 // printu("\nEp0 Interrrupted!");
186 1 i=ReadEp(0,ControlData);//读端点0数据
187 1 for(j=0;j<i;j++) printuf("%x ",ControlData[j]);
188 1 j=ControlData[0]&0x60; //判断是否是USB标准请求
189 1 if((j==0)&&i){ //如果端点0数据长度非零且为标准请求
190 2 switch(ControlData[1]){ //分支处理
191 3 case get_status : Get_Status();break;
192 3 case clear_feature : Clear_Feature();break;
193 3
194 3 case set_feature : Set_Feature();break;
195 3
196 3 case set_address : Set_Address(ControlData[2]);break;
197 3 case get_descriptor : Get_Descriptor(ControlData[3],ControlData[6]);break;
198 3
199 3 case get_configuration : Get_Configuration();break;
200 3 case set_configuration : Set_Configuration(ControlData[2]);break;
201 3 case get_interface : Get_Interface();break;
202 3 case set_interface : Set_Interface();break;
203 3 default : Reserved();break;
204 3 }
205 2 }
206 1 else if(ControlData[0]==0xa1){//非标准USB请求
207 2 WriteEp(0,0,0);
208 2 }
209 1 }
210
211 void main_txdone()
212 {
213 1 printu("Bulk_In Ep Intterupt\n");
214 1 }
215 void main_rxdone()
216 {
217 1 printu("Bulk_Out Ep Intterupt\n");
218 1 }
219 void main()
220 {
221 1 printu("Test Ep0 Intterupt\n");
222 1 AtmelUSBInit(0,2,0);
223 1 EpEnable();
224 1 while(1){
225 2 if(UEPINT&EP0INT) Ep0Int();
226 2 if(UEPINT&EP1INT) main_txdone();
227 2 if(UEPINT&EP2INT) main_rxdone();
228 2 UEPINT=0;
229 2 }
230 1 }
231
232
233
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 600 ----
CONSTANT SIZE = 288 ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
C51 COMPILER V6.23a MAIN 05/31/2003 10:20:29 PAGE 5
DATA SIZE = ---- 44
IDATA SIZE = ---- ----
BIT SIZE = ---- ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -