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