📄 fw.lst
字号:
203 3 configuration is valid. The config. index is in the low byte of
204 3 wValue, stored in SETUPDAT[2].
205 3
206 3 */
207 3
208 3 if(dscr_ptr = (void *)EZUSB_GetConfigDscr(SETUPDAT[2]))
209 3 {
210 4 SUDPTRH = MSB(dscr_ptr);
211 4 SUDPTRL = LSB(dscr_ptr);
212 4 }
213 3 else
214 3 EZUSB_STALL_EP0(); // Stall End Point 0
215 3 break;
216 3 case GD_STRING: // String
217 3 if(dscr_ptr = (void *)EZUSB_GetStringDscr(SETUPDAT[2]))
218 3 {
219 4 // Workaround for rev D errata number 8
220 4 // If you're certain that you will never run on rev D,
221 4 // you can just do this:
222 4 // SUDPTRH = MSB(dscr_ptr);
223 4 // SUDPTRL = LSB(dscr_ptr);
224 4 STRINGDSCR *sdp;
225 4 BYTE len;
226 4
227 4 sdp = dscr_ptr;
228 4
229 4 len = sdp->length;
230 4 if (len > SETUPDAT[6])
231 4 len = SETUPDAT[6]; //limit to the requested length
232 4
233 4 while (len)
234 4 {
235 5 for(i=0; i<min(len,64); i++)
236 5 *(IN0BUF+i) = *((BYTE xdata *)sdp+i);
237 5
238 5 //set length and arm Endpoint
239 5 EZUSB_SET_EP_BYTES(IN0BUF_ID,min(len,64));
240 5 len -= min(len,64);
241 5
242 5 // Wait for it to go out (Rev C and above)
243 5 while(EP0CS & 0x04)
244 5 ;
245 5 }
246 4
247 4 // Arm a 0 length packet just in case. There was some reflector traffic about
248 4 // Apple hosts asking for too much data. This will keep them happy and will
249 4 // not hurt valid hosts because the next SETUP will clear this.
250 4 EZUSB_SET_EP_BYTES(IN0BUF_ID,0);
251 4 // Clear the HS-nak bit
252 4 EP0CS = bmHS;
253 4 }
254 3 else
255 3 EZUSB_STALL_EP0(); // Stall End Point 0
256 3 break;
C51 COMPILER V5.50, FW 26/07/00 13:53:26 PAGE 5
257 3 //HID code start
258 3 case GD_REPORT:
259 3 //HID Report descriptor
260 3 //Assumes there is one report descriptor.
261 3 //To do: add the ability to return a specific report descriptor.
262 3 //Can't use SUDPTRH and SUDPTRL because the report descriptor doesn't store
263 3 //its length in the first bytes.
264 3 //Instead, adapt code from the String descriptor rev D errata code (above).
265 3 {
266 4 //rdp holds the address of a REPORTDSCR structure.
267 4 REPORTDSCR *rdp;
268 4 //dscr_ptr is the address of the report descriptor
269 4 dscr_ptr = (REPORTDSCR xdata *) pReportDscr;
270 4 rdp = dscr_ptr;
271 4
272 4 //Get the report descriptor's length
273 4 reportlen = sizeof(REPORTDSCR);
274 4 // If the descriptor is longer than the requested amount,
275 4 // limit the data returned to the requested amount.
276 4 if (reportlen > SETUPDAT[6])
277 4 reportlen = SETUPDAT[6];
278 4 // If the host requests more bytes than the descriptor contains,
279 4 // the device will send the descriptor only.
280 4
281 4 while (reportlen)
282 4 {
283 5 //Copy the data to send into Endpoint 0's IN buffer.
284 5 //In each transaction, send the entire descriptor or 64 bytes, whichever is less.
285 5 //The data to send begins at the address pointed to by *rdp.
286 5 for(i=0; i<min(reportlen,64); i++)
287 5 *(IN0BUF+i) = *((BYTE xdata *)rdp+i);
288 5
289 5 //Set the amount of data to send and arm the endpoint
290 5 EZUSB_SET_EP_BYTES(IN0BUF_ID,min(reportlen,64));
291 5 // If reportlen <= 64, all bytes have been copied, so set reportlen =0.
292 5 // Else, set reportlen = number of bytes remaining to send.
293 5 reportlen -= min(reportlen,64);
294 5
295 5 // Wait for the data to go out (Rev C and above)
296 5 while(EP0CS & 0x04);
297 5 }
298 4
299 4 }
300 3 //else
301 3 // EZUSB_STALL_EP0(); // Stall End Point 0
302 3
303 3 break;
304 3 //HID code end
305 3
306 3 default: // Invalid request
307 3 EZUSB_STALL_EP0(); // Stall End Point 0
308 3 }
309 2 break;
310 2 case SC_GET_INTERFACE: // *** Get Interface
311 2 DR_GetInterface();
312 2 break;
313 2 case SC_SET_INTERFACE: // *** Set Interface
314 2 DR_SetInterface();
315 2 break;
316 2 case SC_SET_CONFIGURATION: // *** Set Configuration
317 2 DR_SetConfiguration();
318 2 break;
319 2 case SC_GET_CONFIGURATION: // *** Get Configuration
320 2 DR_GetConfiguration();
321 2 break;
322 2 case SC_GET_STATUS: // *** Get Status
C51 COMPILER V5.50, FW 26/07/00 13:53:26 PAGE 6
323 2 if(DR_GetStatus())
324 2 switch(SETUPDAT[0])
325 2 {
326 3 case GS_DEVICE: // Device
327 3 IN0BUF[0] = ((BYTE)Rwuen << 1) | (BYTE)Selfpwr;
328 3 IN0BUF[1] = 0;
329 3 EZUSB_SET_EP_BYTES(IN0BUF_ID,2);
330 3 break;
331 3 case GS_INTERFACE: // Interface
332 3 IN0BUF[0] = 0;
333 3 IN0BUF[1] = 0;
334 3 EZUSB_SET_EP_BYTES(IN0BUF_ID,2);
335 3 break;
336 3 case GS_ENDPOINT: // End Point
337 3 IN0BUF[0] = EPIO[EPID(SETUPDAT[4])].cntrl & bmEPSTALL;
338 3 IN0BUF[1] = 0;
339 3 EZUSB_SET_EP_BYTES(IN0BUF_ID,2);
340 3 break;
341 3 default: // Invalid Command
342 3 EZUSB_STALL_EP0(); // Stall End Point 0
343 3 }
344 2 break;
345 2 case SC_CLEAR_FEATURE: // *** Clear Feature
346 2 if(DR_ClearFeature())
347 2 switch(SETUPDAT[0])
348 2 {
349 3 case FT_DEVICE: // Device
350 3 if(SETUPDAT[2] == 1)
351 3 Rwuen = FALSE; // Disable Remote Wakeup
352 3 else
353 3 EZUSB_STALL_EP0(); // Stall End Point 0
354 3 break;
355 3 case FT_ENDPOINT: // End Point
356 3 if(SETUPDAT[2] == 0)
357 3 {
358 4 EZUSB_UNSTALL_EP( EPID(SETUPDAT[4]) );
359 4 EZUSB_RESET_DATA_TOGGLE( SETUPDAT[4] );
360 4 }
361 3 else
362 3 EZUSB_STALL_EP0(); // Stall End Point 0
363 3 break;
364 3 }
365 2 break;
366 2 case SC_SET_FEATURE: // *** Set Feature
367 2 if(DR_SetFeature())
368 2 switch(SETUPDAT[0])
369 2 {
370 3 case FT_DEVICE: // Device
371 3 if(SETUPDAT[2] == 1)
372 3 Rwuen = TRUE; // Enable Remote Wakeup
373 3 else
374 3 EZUSB_STALL_EP0(); // Stall End Point 0
375 3 break;
376 3 case FT_ENDPOINT: // End Point
377 3 if(SETUPDAT[2] == 0)
378 3 EZUSB_STALL_EP( EPID(SETUPDAT[4]) );
379 3 else
380 3 EZUSB_STALL_EP0(); // Stall End Point 0
381 3 break;
382 3 }
383 2 break;
384 2 default: // *** Invalid Command
385 2 if(DR_VendorCmnd())
386 2 EZUSB_STALL_EP0(); // Stall End Point 0
387 2 }
388 1
C51 COMPILER V5.50, FW 26/07/00 13:53:26 PAGE 7
389 1 // Acknowledge handshake phase of device request
390 1 // Required for rev C does not effect rev B
391 1 EP0CS |= bmBIT1;
392 1 }
393
394 // Wake-up interrupt handler
395 void resume_isr(void) interrupt WKUP_VECT
396 {
397 1 EZUSB_CLEAR_RSMIRQ();
398 1 }
MODULE INFORMATION: STATIC OVERLAYABLE
CODE SIZE = 1418 ----
CONSTANT SIZE = ---- ----
XDATA SIZE = ---- ----
PDATA SIZE = ---- ----
DATA SIZE = 9 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 + -