📄 subp.lst
字号:
278 6 break;
279 6
280 6 case STRING:
281 6 switch(dReq.wValue>>8) // get string index
282 6 {
283 7 case 0x00: SL811BufWrite(EP0A_Slave_Buf,( unsigned char*)LangString,LangString[0]);
284 7 len_req = (len_req>=LangString[0]) ? LangString[0]:len_req;
285 7
286 7 break;
287 7 case 0x01: SL811BufWrite(EP0A_Slave_Buf,( unsigned char*)MfgString,MfgString[0]);
288 7 len_req = (len_req>=MfgString[0]) ? MfgString[0]:len_req;
289 7 break;
290 7 case 0x02: SL811BufWrite(EP0A_Slave_Buf,( unsigned char*)ProdString,ProdString[0]);
291 7 len_req = (len_req>=ProdString[0]) ? ProdString[0]:len_req;
292 7 break;
293 7 }
294 6 break;
295 6 }
296 5
297 5 if (len_req == WordSwap(dReq.wLength)) // if requested length is equal to the
298 5 IN_EXACT = TRUE; // exact length of descriptor, set IN_EXACT
299 5 // is use during IN-NULL pkt trasnmission
300 5 len_xfr = (len_req>=EP0_LEN) ? EP0_LEN:( unsigned char)len_req; // get current IN transfer length
301 5 EP0A_IN_Arm(EP0A_Slave_Buf,len_xfr,1); // Arm IN response, start with DATA1 seq
302 5 in_buffer_idx += len_xfr; // update to next muliple buffer location
303 5 len_req -= len_xfr; // update data length for current transfer
C51 COMPILER V7.20 SUBP 01/30/2007 16:37:15 PAGE 6
304 5
305 5 break;
306 5
307 5 case GET_CONFIG:
308 5 SL811Write(EP0A_Slave_Buf,Slave_ConfigVal); // load current configuration value
309 5 EP0A_IN_Arm(EP0A_Slave_Buf,1,1); // send 1 unsigned char data back to host
310 5 len_req = 0;
311 5 break;
312 5
313 5 case GET_INTERFACE:
314 5 SL811Write(EP0A_Slave_Buf,Slave_IfcAlt[dReq.wIndex>>8]);// load current alternate setting
315 5 EP0A_IN_Arm(EP0A_Slave_Buf,1,1); // send 1 unsigned char data back to host
316 5 len_req = 0;
317 5 break;
318 5
319 5 case GET_STATUS:
320 5 switch(dReq.bmRequest&0x03) // check for recipients
321 5 {
322 6 case RECIPIENT_DEV: // load current device status
323 6 SL811Write(EP0A_Slave_Buf,(Slave_RemoteWU<<1)|BUS_POWERED);
324 6 break;
325 6 case RECIPIENT_IFC:
326 6 SL811Write(EP0A_Slave_Buf,0); // first unsigned char = 0
327 6 break;
328 6 case RECIPIENT_ENP:
329 6 if((dReq.wIndex>>8) & 0x80) // for IN direction endpoint
330 6 {
331 7 if(Slave_inEPstall & (0x01<<((dReq.wIndex>>8)&0x0F)))
332 7 SL811Write(EP0A_Slave_Buf,1); // first unsigned char = 1 (IN endpoint stall)
333 7 else
334 7 SL811Write(EP0A_Slave_Buf,0); // first unsigned char = 0 (IN endpoint not stall)
335 7 }
336 6 else // for OUT direction endpoint
337 6 {
338 7 if(Slave_outEPstall & (0x01<<((dReq.wIndex>>8)&0x0F)))
339 7 SL811Write(EP0A_Slave_Buf,1); // first unsigned char = 1 (OUT endpoint stall)
340 7 else
341 7 SL811Write(EP0A_Slave_Buf,0); // first unsigned char = 0 (OUT endpoint not stall)
342 7 }
343 6 break;
344 6 }
345 5 SL811Write(EP0A_Slave_Buf+1,0); // second unsigned char = 0
346 5 EP0A_IN_Arm(EP0A_Slave_Buf,2,1); // send 2 unsigned chars data back to host
347 5 len_req = 0; // reset request length to zero
348 5 break;
349 5
350 5 case SET_FEATURE:
351 5 case CLEAR_FEATURE:
352 5 switch(dReq.bmRequest&0x03) // check for recipients
353 5 {
354 6 case RECIPIENT_DEV:
355 6 if((dReq.wValue>>8) == 1) // feature selector = 1 (remote wakeup)
356 6 {
357 7 if(dReq.bRequest==SET_FEATURE) // set remote wake up status
358 7 Slave_RemoteWU = 1;
359 7 if(dReq.bRequest==CLEAR_FEATURE) // clear remote wake up status
360 7 Slave_RemoteWU = 0;
361 7 EP0A_IN_Arm(0,0,1); // IN status stage
362 7 }
363 6 else
364 6 SL811Write(EP0AControl,SEND_STALL); // Stall unsupported requests
365 6 break;
C51 COMPILER V7.20 SUBP 01/30/2007 16:37:15 PAGE 7
366 6
367 6 case RECIPIENT_ENP:
368 6 if((dReq.wValue>>8) == 0) // feature selector = 0 (endpoint stall)
369 6 {
370 7 if((dReq.wIndex>>8) & 0x80) // for IN direction endpoint
371 7 {
372 8 if(dReq.bRequest==SET_FEATURE) // set endpoint stall (limit to 7 IN's data endpoint)
373 8 Slave_inEPstall |= (0x01<<((dReq.wIndex>>8)&0x0F));
374 8 if(dReq.bRequest==CLEAR_FEATURE) // clear endpoint stall (limit to 7 IN's data endpoint)
375 8 Slave_inEPstall &= ~(0x01<<((dReq.wIndex>>8)&0x0F));
376 8 }
377 7 else // for OUT direction endpoint
378 7 {
379 8 if(dReq.bRequest==SET_FEATURE) // set endpoint stall (limit to 7 OUT's data endpoint)
380 8 Slave_outEPstall |= (0x01<<((dReq.wIndex>>8)&0x0F));
381 8 if(dReq.bRequest==CLEAR_FEATURE) // clear endpoint stall (limit to 7 OUT's data endpoint)
382 8 Slave_outEPstall &= ~(0x01<<((dReq.wIndex>>8)&0x0F));
383 8 }
384 7 EP0A_IN_Arm(0,0,1); // IN status stage
385 7 }
386 6 else
387 6 SL811Write(EP0AControl,SEND_STALL); // Stall unsupported requests
388 6 break;
389 6
390 6 default:
391 6 SL811Write(EP0AControl,SEND_STALL); // Stall all unsupported requests
392 6 break;
393 6 }
394 5 break;
395 5
396 5 case SET_ADDRESS:
397 5 Slave_USBaddr = dReq.wValue>>8; // update new USB address assigned by host
398 5 EP0A_IN_Arm(0,0,1); // IN status stage
399 5
400 5 break;
401 5 case SET_CONFIG:
402 5 Slave_ConfigVal = dReq.wValue>>8; // update configuration value
403 5 EP0A_IN_Arm(0,0,1); // IN status stage
404 5 if(Slave_ConfigVal)
405 5 SL811Write(EP1AControl,DATA0_IN_ENABLE); // Enable EP1 (reponse with NAK)
406 5 else
407 5 SL811Write(EP1AControl,DATA0_IN_DISABLE); // Disable EP1
408 5 break;
409 5
410 5 case SET_INTERFACE: // update alternate setting for
411 5 Slave_IfcAlt[dReq.wIndex>>8] = dReq.wValue>>8; // selected interface number
412 5 EP0A_IN_Arm(0,0,1); // IN status stage
413 5 break;
414 5
415 5 default:
416 5 SL811Write(EP0AControl,SEND_STALL); // Stall all unsupported requests
417 5 // EP0A_IN_Arm(0,0,1);
418 5 break;
419 5 }
420 4
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -