📄 fw.lst
字号:
164 1 DWORD i;
165 1
166 1 switch(SETUPDAT[1])
167 1 {
168 2 case SC_GET_DESCRIPTOR: // *** Get Descriptor
169 2 if(DR_GetDescriptor())
170 2 switch(SETUPDAT[3])
171 2 {
172 3 case GD_DEVICE: // Device
173 3 SUDPTRH = MSB(pDeviceDscr);
174 3 SUDPTRL = LSB(pDeviceDscr);
175 3 break;
176 3 case GD_CONFIGURATION: // Configuration
177 3 if(dscr_ptr = (void *)EZUSB_GetConfigDscr(SETUPDAT[2]))
178 3 {
C51 COMPILER V7.06 FW 08/21/2004 11:22:41 PAGE 4
179 4 SUDPTRH = MSB(dscr_ptr);
180 4 SUDPTRL = LSB(dscr_ptr);
181 4 }
182 3 else
183 3 EZUSB_STALL_EP0(); // Stall End Point 0
184 3 break;
185 3 case GD_STRING: // String
186 3 if(dscr_ptr = (void *)EZUSB_GetStringDscr(SETUPDAT[2]))
187 3 {
188 4 // Workaround for rev D errata number 8
189 4 // If you're certain that you will never run on rev D,
190 4 // you can just do this:
191 4 // SUDPTRH = MSB(dscr_ptr);
192 4 // SUDPTRL = LSB(dscr_ptr);
193 4 STRINGDSCR *sdp;
194 4 BYTE len;
195 4
196 4 sdp = dscr_ptr;
197 4
198 4 len = sdp->length;
199 4 if (len > SETUPDAT[6])
200 4 len = SETUPDAT[6]; //limit to the requested length
201 4
202 4 while (len)
203 4 {
204 5 for(i=0; i<min(len,64); i++)
205 5 *(IN0BUF+i) = *((BYTE xdata *)sdp+i);
206 5
207 5 //set length and arm Endpoint
208 5 EZUSB_SET_EP_BYTES(IN0BUF_ID,min(len,64));
209 5 len -= min(len,64);
210 5 (BYTE *)sdp += 64;
211 5
212 5 // Wait for it to go out (Rev C and above)
213 5 while(EP0CS & 0x04)
214 5 ;
215 5 }
216 4
217 4 // Arm a 0 length packet just in case. There was some reflector traffic about
218 4 // Apple hosts asking for too much data. This will keep them happy and will
219 4 // not hurt valid hosts because the next SETUP will clear this.
220 4 EZUSB_SET_EP_BYTES(IN0BUF_ID,0);
221 4 // Clear the HS-nak bit
222 4 EP0CS = bmHS;
223 4 }
224 3 else
225 3 EZUSB_STALL_EP0(); // Stall End Point 0
226 3 break;
227 3 default: // Invalid request
228 3 EZUSB_STALL_EP0(); // Stall End Point 0
229 3 }
230 2 break;
231 2 case SC_GET_INTERFACE: // *** Get Interface
232 2 DR_GetInterface();
233 2 break;
234 2 case SC_SET_INTERFACE: // *** Set Interface
235 2 DR_SetInterface();
236 2 break;
237 2 case SC_SET_CONFIGURATION: // *** Set Configuration
238 2 DR_SetConfiguration();
239 2 break;
240 2 case SC_GET_CONFIGURATION: // *** Get Configuration
C51 COMPILER V7.06 FW 08/21/2004 11:22:41 PAGE 5
241 2 DR_GetConfiguration();
242 2 break;
243 2 case SC_GET_STATUS: // *** Get Status
244 2 if(DR_GetStatus())
245 2 switch(SETUPDAT[0])
246 2 {
247 3 case GS_DEVICE: // Device
248 3 IN0BUF[0] = ((BYTE)Rwuen << 1) | (BYTE)Selfpwr;
249 3 IN0BUF[1] = 0;
250 3 EZUSB_SET_EP_BYTES(IN0BUF_ID,2);
251 3 break;
252 3 case GS_INTERFACE: // Interface
253 3 IN0BUF[0] = 0;
254 3 IN0BUF[1] = 0;
255 3 EZUSB_SET_EP_BYTES(IN0BUF_ID,2);
256 3 break;
257 3 case GS_ENDPOINT: // End Point
258 3 IN0BUF[0] = EPIO[EPID(SETUPDAT[4])].cntrl & bmEPSTALL;
259 3 IN0BUF[1] = 0;
260 3 EZUSB_SET_EP_BYTES(IN0BUF_ID,2);
261 3 break;
262 3 default: // Invalid Command
263 3 EZUSB_STALL_EP0(); // Stall End Point 0
264 3 }
265 2 break;
266 2 case SC_CLEAR_FEATURE: // *** Clear Feature
267 2 if(DR_ClearFeature())
268 2 switch(SETUPDAT[0])
269 2 {
270 3 case FT_DEVICE: // Device
271 3 if(SETUPDAT[2] == 1)
272 3 Rwuen = FALSE; // Disable Remote Wakeup
273 3 else
274 3 EZUSB_STALL_EP0(); // Stall End Point 0
275 3 break;
276 3 case FT_ENDPOINT: // End Point
277 3 if(SETUPDAT[2] == 0)
278 3 {
279 4 EZUSB_UNSTALL_EP( EPID(SETUPDAT[4]) );
280 4 EZUSB_RESET_DATA_TOGGLE( SETUPDAT[4] );
281 4 }
282 3 else
283 3 EZUSB_STALL_EP0(); // Stall End Point 0
284 3 break;
285 3 }
286 2 break;
287 2 case SC_SET_FEATURE: // *** Set Feature
288 2 if(DR_SetFeature())
289 2 switch(SETUPDAT[0])
290 2 {
291 3 case FT_DEVICE: // Device
292 3 if(SETUPDAT[2] == 1)
293 3 Rwuen = TRUE; // Enable Remote Wakeup
294 3 else
295 3 EZUSB_STALL_EP0(); // Stall End Point 0
296 3 break;
297 3 case FT_ENDPOINT: // End Point
298 3 if(SETUPDAT[2] == 0)
299 3 EZUSB_STALL_EP( EPID(SETUPDAT[4]) );
300 3 else
301 3 EZUSB_STALL_EP0(); // Stall End Point 0
302 3 break;
C51 COMPILER V7.06 FW 08/21/2004 11:22:41 PAGE 6
303 3 }
304 2 break;
305 2 default: // *** Invalid Command
306 2 if(DR_VendorCmnd())
307 2 EZUSB_STALL_EP0(); // Stall End Point 0
308 2 }
309 1
310 1 // Acknowledge handshake phase of device request
311 1 // Required for rev C does not effect rev B
312 1 EP0CS |= bmBIT1;
313 1 }
314
315 // Wake-up interrupt handler
316 void resume_isr(void) interrupt WKUP_VECT
317 {
318 1 EZUSB_CLEAR_RSMIRQ();
319 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1035 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 6 27
IDATA SIZE = ---- ----
BIT SIZE = 4 ----
END OF MODULE INFORMATION.
C51 COMPILATION COMPLETE. 0 WARNING(S), 0 ERROR(S)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -