📄 f32x_usb_standard_requests.lst
字号:
202 2 }
203 1 }
204
205 //-----------------------------------------------------------------------------
206 // Clear_Feature
207 //-----------------------------------------------------------------------------
208 //
209 // Return Value : None
210 // Parameters : None
211 //
212 // This routine can clear Halt Endpoint features on endpoint 1 and 2.
213 //
214 //-----------------------------------------------------------------------------
215
216 void Clear_Feature()
217 {
218 1
219 1 if ((USB_State != DEV_CONFIGURED) ||// Send procedural stall if device isn't configured
220 1 (Setup.bmRequestType == IN_DEVICE) ||// or request is made to host(remote wakeup not supported)
221 1 (Setup.bmRequestType == IN_INTERFACE) ||// or request is made to interface
222 1 Setup.wValue.c[MSB] || Setup.wIndex.c[MSB]||// or msbs of value or index set to non-zero value
223 1 Setup.wLength.c[MSB] || Setup.wLength.c[LSB])// or data length set to non-zero.
224 1 {
225 2 Force_Stall();
226 2 }
227 1
228 1 else
229 1 {
230 2 if ((Setup.bmRequestType == IN_ENDPOINT)&&// Verify that packet was directed at an endpoint
231 2 (Setup.wValue.c[LSB] == ENDPOINT_HALT) &&// the feature selected was HALT_ENDPOINT
232 2 ((Setup.wIndex.c[LSB] == IN_EP1) || // and that the request was directed at EP 1 in
233 2 (Setup.wIndex.c[LSB] == OUT_EP2))) // or EP 2 out
234 2 {
235 3 if (Setup.wIndex.c[LSB] == IN_EP1)
236 3 {
237 4 POLL_WRITE_BYTE (INDEX, 1); // Clear feature endpoint 1 halt
238 4 POLL_WRITE_BYTE (EINCSR1, rbInCLRDT);
239 4 Ep_Status[1] = EP_IDLE; // Set endpoint 1 status back to idle
240 4 }
241 3 else
C51 COMPILER V7.50 F32X_USB_STANDARD_REQUESTS 08/23/2006 15:13:09 PAGE 5
242 3 {
243 4 POLL_WRITE_BYTE (INDEX, 2); // Clear feature endpoint 2 halt
244 4 POLL_WRITE_BYTE (EOUTCSR1, rbOutCLRDT);
245 4 Ep_Status[2] = EP_IDLE; // Set endpoint 2 status back to idle
246 4 }
247 3 }
248 2 else
249 2 {
250 3 Force_Stall(); // Send procedural stall
251 3 }
252 2 }
253 1 POLL_WRITE_BYTE(INDEX, 0); // Reset Index to 0
254 1 if (Ep_Status[0] != EP_STALL)
255 1 {
256 2 POLL_WRITE_BYTE(E0CSR, rbSOPRDY);
257 2 // Set Serviced Out packet ready and data end to
258 2 // indicate transaction is over
259 2 }
260 1 }
261
262 //-----------------------------------------------------------------------------
263 // Set_Feature
264 //-----------------------------------------------------------------------------
265 //
266 // Return Value : None
267 // Parameters : None
268 //
269 // This routine will set the EP Halt feature for endpoints 1 and 2
270 //
271 //-----------------------------------------------------------------------------
272
273 void Set_Feature(void)
274 {
275 1
276 1 if ((USB_State != DEV_CONFIGURED) ||// Make sure device is configured, setup data
277 1 (Setup.bmRequestType == IN_DEVICE) ||// is all valid and that request is directed at
278 1 (Setup.bmRequestType == IN_INTERFACE) ||// an endpoint
279 1 Setup.wValue.c[MSB] || Setup.wIndex.c[MSB]||
280 1 Setup.wLength.c[MSB] || Setup.wLength.c[LSB])
281 1 {
282 2 Force_Stall(); // Otherwise send stall to host
283 2 }
284 1
285 1 else
286 1 {
287 2 if ((Setup.bmRequestType == IN_ENDPOINT)&&// Make sure endpoint exists and that halt
288 2 (Setup.wValue.c[LSB] == ENDPOINT_HALT) &&// endpoint feature is selected
289 2 ((Setup.wIndex.c[LSB] == IN_EP1) ||
290 2 (Setup.wIndex.c[LSB] == OUT_EP2)))
291 2 {
292 3 if (Setup.wIndex.c[LSB] == IN_EP1)
293 3 {
294 4 POLL_WRITE_BYTE (INDEX, 1); // Set feature endpoint 1 halt
295 4 POLL_WRITE_BYTE (EINCSR1, rbInSDSTL);
296 4 Ep_Status[1] = EP_HALT;
297 4 }
298 3 else
299 3 {
300 4 POLL_WRITE_BYTE (INDEX, 2); // Set feature Ep2 halt
301 4 POLL_WRITE_BYTE (EOUTCSR1, rbOutSDSTL);
302 4 Ep_Status[2] = EP_HALT;
303 4 }
C51 COMPILER V7.50 F32X_USB_STANDARD_REQUESTS 08/23/2006 15:13:09 PAGE 6
304 3 }
305 2 else
306 2 {
307 3 Force_Stall(); // Send procedural stall
308 3 }
309 2 }
310 1 POLL_WRITE_BYTE(INDEX, 0);
311 1 if (Ep_Status[0] != EP_STALL)
312 1 {
313 2 POLL_WRITE_BYTE(E0CSR, rbSOPRDY);
314 2 // Indicate setup packet has been serviced
315 2 }
316 1 }
317
318 //-----------------------------------------------------------------------------
319 // Set_Address
320 //-----------------------------------------------------------------------------
321 //
322 // Return Value : None
323 // Parameters : None
324 //
325 // Set new function address
326 //
327 //-----------------------------------------------------------------------------
328
329 void Set_Address(void)
330 {
331 1 if ((Setup.bmRequestType != IN_DEVICE) ||// Request must be directed to device
332 1 Setup.wIndex.c[MSB] || Setup.wIndex.c[LSB]||// with index and length set to zero.
333 1 Setup.wLength.c[MSB] || Setup.wLength.c[LSB]||
334 1 Setup.wValue.c[MSB] || (Setup.wValue.c[LSB] & 0x80))
335 1 {
336 2 Force_Stall(); // Send stall if setup data invalid
337 2 }
338 1
339 1 Ep_Status[0] = EP_ADDRESS; // Set endpoint zero to update address next status phase
340 1 if (Setup.wValue.c[LSB] != 0)
341 1 {
342 2 USB_State = DEV_ADDRESS; // Indicate that device state is now address
343 2 }
344 1 else
345 1 {
346 2 USB_State = DEV_DEFAULT; // If new address was 0x00, return device to default
347 2 } // state
348 1 if (Ep_Status[0] != EP_STALL)
349 1 {
350 2 POLL_WRITE_BYTE(E0CSR, rbSOPRDY);
351 2 // Indicate setup packet has been serviced
352 2 }
353 1 }
354
355 //-----------------------------------------------------------------------------
356 // Get_Descriptor
357 //-----------------------------------------------------------------------------
358 //
359 // Return Value : None
360 // Parameters : None
361 //
362 // This routine sets the data pointer and size to correct
363 // descriptor and sets the endpoint status to transmit
364 //
365 //-----------------------------------------------------------------------------
C51 COMPILER V7.50 F32X_USB_STANDARD_REQUESTS 08/23/2006 15:13:09 PAGE 7
366
367 void Get_Descriptor(void)
368 {
369 1
370 1 switch(Setup.wValue.c[MSB]) // Determine which type of descriptor
371 1 { // was requested, and set data ptr and
372 2 case DSC_DEVICE: // size accordingly
373 2 DataPtr = (BYTE*) &DeviceDesc;
374 2 DataSize = DeviceDesc.bLength;
375 2 break;
376 2
377 2 case DSC_CONFIG:
378 2 DataPtr = (BYTE*) &ConfigDesc;
379 2 // Compiler Specific - The next statement reverses the
380 2 // bytes in the configuration descriptor for the compiler
381 2 DataSize = ConfigDesc.wTotalLength.c[MSB] + 256*ConfigDesc.wTotalLength.c[LSB];
382 2 break;
383 2
384 2 case DSC_STRING:
385 2 DataPtr = StringDescTable[Setup.wValue.c[LSB]];
386 2 // Can have a maximum of 255 strings
387 2 DataSize = *DataPtr;
388 2 break;
389 2
390 2 case DSC_INTERFACE:
391 2 DataPtr = (BYTE*) &InterfaceDesc;
392 2 DataSize = InterfaceDesc.bLength;
393 2 break;
394 2
395 2 case DSC_ENDPOINT:
396 2 if ((Setup.wValue.c[LSB] == IN_EP1) ||
397 2 (Setup.wValue.c[LSB] == OUT_EP2))
398 2 {
399 3 if (Setup.wValue.c[LSB] == IN_EP1)
400 3 {
401 4 DataPtr = (BYTE*) &Endpoint1Desc;
402 4 DataSize = Endpoint1Desc.bLength;
403 4 }
404 3 else
405 3 {
406 4 DataPtr = (BYTE*) &Endpoint2Desc;
407 4 DataSize = Endpoint2Desc.bLength;
408 4 }
409 3 }
410 2 else
411 2 {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -