APM:Libraries
usbd_req.c
Go to the documentation of this file.
1 
28 /* Includes ------------------------------------------------------------------*/
29 #include "usbd_req.h"
30 #include "usbd_ioreq.h"
31 #include "usbd_desc.h"
32 
33 
73 
74 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
75  #if defined ( __ICCARM__ )
76  #pragma data_alignment=4
77  #endif
78 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
79 __ALIGN_BEGIN uint32_t USBD_ep_status __ALIGN_END = 0;
80 
81 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
82  #if defined ( __ICCARM__ )
83  #pragma data_alignment=4
84  #endif
85 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
86 __ALIGN_BEGIN uint32_t USBD_default_cfg __ALIGN_END = 0;
87 
88 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
89  #if defined ( __ICCARM__ )
90  #pragma data_alignment=4
91  #endif
92 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
93 __ALIGN_BEGIN uint32_t USBD_cfg_status __ALIGN_END = 0;
94 
95 #ifdef USB_OTG_HS_INTERNAL_DMA_ENABLED
96  #if defined ( __ICCARM__ )
97  #pragma data_alignment=4
98  #endif
99 #endif /* USB_OTG_HS_INTERNAL_DMA_ENABLED */
100 
110 static void USBD_GetDescriptor(USB_OTG_CORE_HANDLE *pdev,
111  USB_SETUP_REQ *req);
112 
113 static void USBD_SetAddress(USB_OTG_CORE_HANDLE *pdev,
114  USB_SETUP_REQ *req);
115 
116 static void USBD_SetConfig(USB_OTG_CORE_HANDLE *pdev,
117  USB_SETUP_REQ *req);
118 
119 static void USBD_GetConfig(USB_OTG_CORE_HANDLE *pdev,
120  USB_SETUP_REQ *req);
121 
122 static void USBD_GetStatus(USB_OTG_CORE_HANDLE *pdev,
123  USB_SETUP_REQ *req);
124 
125 static void USBD_SetFeature(USB_OTG_CORE_HANDLE *pdev,
126  USB_SETUP_REQ *req);
127 
128 static void USBD_ClrFeature(USB_OTG_CORE_HANDLE *pdev,
129  USB_SETUP_REQ *req);
130 
131 static uint8_t USBD_GetLen(const uint8_t *buf);
150 {
151  USBD_Status ret = USBD_OK;
152 
153  switch (req->bRequest)
154  {
156 
157  USBD_GetDescriptor (pdev, req) ;
158  break;
159 
160  case USB_REQ_SET_ADDRESS:
161  USBD_SetAddress(pdev, req);
162  break;
163 
165  USBD_SetConfig (pdev , req);
166  break;
167 
169  USBD_GetConfig (pdev , req);
170  break;
171 
172  case USB_REQ_GET_STATUS:
173  USBD_GetStatus (pdev , req);
174  break;
175 
176 
177  case USB_REQ_SET_FEATURE:
178  USBD_SetFeature (pdev , req);
179  break;
180 
181  case USB_REQ_CLEAR_FEATURE:
182  USBD_ClrFeature (pdev , req);
183  break;
184 
185  default:
186  USBD_CtlError(pdev , req);
187  break;
188  }
189 
190  return ret;
191 }
192 
201 {
202  USBD_Status ret = USBD_OK;
203 
204  switch (pdev->dev.device_status)
205  {
206  case USB_OTG_CONFIGURED:
207 
208  if (LOBYTE(req->wIndex) <= USBD_ITF_MAX_NUM)
209  {
210  pdev->dev.class_cb->Setup (pdev, req);
211 
212  if((req->wLength == 0)&& (ret == USBD_OK))
213  {
214  USBD_CtlSendStatus(pdev);
215  }
216  }
217  else
218  {
219  USBD_CtlError(pdev , req);
220  }
221  break;
222 
223  default:
224  USBD_CtlError(pdev , req);
225  break;
226  }
227  return ret;
228 }
229 
238 {
239 
240  uint8_t ep_addr;
241  USBD_Status ret = USBD_OK;
242 
243  ep_addr = LOBYTE(req->wIndex);
244 
245  switch (req->bRequest)
246  {
247 
248  case USB_REQ_SET_FEATURE :
249 
250  switch (pdev->dev.device_status)
251  {
252  case USB_OTG_ADDRESSED:
253  if ((ep_addr != 0x00) && (ep_addr != 0x80))
254  {
255  DCD_EP_Stall(pdev , ep_addr);
256  }
257  break;
258 
259  case USB_OTG_CONFIGURED:
260  if (req->wValue == USB_FEATURE_EP_HALT)
261  {
262  if ((ep_addr != 0x00) && (ep_addr != 0x80))
263  {
264  DCD_EP_Stall(pdev , ep_addr);
265 
266  }
267  }
268  pdev->dev.class_cb->Setup (pdev, req);
269  USBD_CtlSendStatus(pdev);
270 
271  break;
272 
273  default:
274  USBD_CtlError(pdev , req);
275  break;
276  }
277  break;
278 
279  case USB_REQ_CLEAR_FEATURE :
280 
281  switch (pdev->dev.device_status)
282  {
283  case USB_OTG_ADDRESSED:
284  if ((ep_addr != 0x00) && (ep_addr != 0x80))
285  {
286  DCD_EP_Stall(pdev , ep_addr);
287  }
288  break;
289 
290  case USB_OTG_CONFIGURED:
291  if (req->wValue == USB_FEATURE_EP_HALT)
292  {
293  if ((ep_addr != 0x00) && (ep_addr != 0x80))
294  {
295  DCD_EP_ClrStall(pdev , ep_addr);
296  pdev->dev.class_cb->Setup (pdev, req);
297  }
298  USBD_CtlSendStatus(pdev);
299  }
300  break;
301 
302  default:
303  USBD_CtlError(pdev , req);
304  break;
305  }
306  break;
307 
308  case USB_REQ_GET_STATUS:
309  switch (pdev->dev.device_status)
310  {
311  case USB_OTG_ADDRESSED:
312  if ((ep_addr != 0x00) && (ep_addr != 0x80))
313  {
314  DCD_EP_Stall(pdev , ep_addr);
315  }
316  break;
317 
318  case USB_OTG_CONFIGURED:
319 
320 
321  if ((ep_addr & 0x80)== 0x80)
322  {
323  if(pdev->dev.in_ep[ep_addr & 0x7F].is_stall)
324  {
325  USBD_ep_status = 0x0001;
326  }
327  else
328  {
329  USBD_ep_status = 0x0000;
330  }
331  }
332  else if ((ep_addr & 0x80)== 0x00)
333  {
334  if(pdev->dev.out_ep[ep_addr].is_stall)
335  {
336  USBD_ep_status = 0x0001;
337  }
338 
339  else
340  {
341  USBD_ep_status = 0x0000;
342  }
343  }
344  USBD_CtlSendData (pdev,
345  (uint8_t *)&USBD_ep_status,
346  2);
347  break;
348 
349  default:
350  USBD_CtlError(pdev , req);
351  break;
352  }
353  break;
354 
355  default:
356  break;
357  }
358  return ret;
359 }
368  USB_SETUP_REQ *req)
369 {
370  uint16_t len;
371  uint8_t *pbuf;
372 
373 
374  switch (req->wValue >> 8)
375  {
377  pbuf = pdev->dev.usr_device->GetDeviceDescriptor(pdev->cfg.speed, &len);
378  if ((req->wLength == 64) ||( pdev->dev.device_status == USB_OTG_DEFAULT))
379  {
380  len = 8;
381  }
382  break;
383 
385  pbuf = (uint8_t *)pdev->dev.class_cb->GetConfigDescriptor(pdev->cfg.speed, &len);
386 #ifdef USB_OTG_HS_CORE
387  if((pdev->cfg.speed == USB_OTG_SPEED_FULL )&&
388  (pdev->cfg.phy_itface == USB_OTG_ULPI_PHY))
389  {
390  pbuf = (uint8_t *)pdev->dev.class_cb->GetOtherConfigDescriptor(pdev->cfg.speed, &len);
391  }
392 #endif
393  pbuf[1] = USB_DESC_TYPE_CONFIGURATION;
394  pdev->dev.pConfig_descriptor = pbuf;
395  break;
396 
398  switch ((uint8_t)(req->wValue))
399  {
400  case USBD_IDX_LANGID_STR:
401  pbuf = pdev->dev.usr_device->GetLangIDStrDescriptor(pdev->cfg.speed, &len);
402  break;
403 
404  case USBD_IDX_MFC_STR:
405  pbuf = pdev->dev.usr_device->GetManufacturerStrDescriptor(pdev->cfg.speed, &len);
406  break;
407 
409  pbuf = pdev->dev.usr_device->GetProductStrDescriptor(pdev->cfg.speed, &len);
410  break;
411 
412  case USBD_IDX_SERIAL_STR:
413  pbuf = pdev->dev.usr_device->GetSerialStrDescriptor(pdev->cfg.speed, &len);
414  break;
415 
416  case USBD_IDX_CONFIG_STR:
417  pbuf = pdev->dev.usr_device->GetConfigurationStrDescriptor(pdev->cfg.speed, &len);
418  break;
419 
421  pbuf = pdev->dev.usr_device->GetInterfaceStrDescriptor(pdev->cfg.speed, &len);
422  break;
423 
424  default:
425 #ifdef USB_SUPPORT_USER_STRING_DESC
426  pbuf = pdev->dev.class_cb->GetUsrStrDescriptor(pdev->cfg.speed, (req->wValue) , &len);
427  break;
428 #else
429  USBD_CtlError(pdev , req);
430  return;
431 #endif /* USBD_CtlError(pdev , req); */
432  }
433  break;
435 #ifdef USB_OTG_HS_CORE
436  if(pdev->cfg.speed == USB_OTG_SPEED_HIGH )
437  {
438 
439  pbuf = (uint8_t *)pdev->dev.class_cb->GetConfigDescriptor(pdev->cfg.speed, &len);
440 
441  USBD_DeviceQualifierDesc[4]= pbuf[14];
442  USBD_DeviceQualifierDesc[5]= pbuf[15];
443  USBD_DeviceQualifierDesc[6]= pbuf[16];
444 
447  break;
448  }
449  else
450  {
451  USBD_CtlError(pdev , req);
452  return;
453  }
454 #else
455  USBD_CtlError(pdev , req);
456  return;
457 #endif
458 
460 #ifdef USB_OTG_HS_CORE
461 
462  if(pdev->cfg.speed == USB_OTG_SPEED_HIGH )
463  {
464  pbuf = (uint8_t *)pdev->dev.class_cb->GetOtherConfigDescriptor(pdev->cfg.speed, &len);
466  break;
467  }
468  else
469  {
470  USBD_CtlError(pdev , req);
471  return;
472  }
473 #else
474  USBD_CtlError(pdev , req);
475  return;
476 #endif
477 
478 
479  default:
480  USBD_CtlError(pdev , req);
481  return;
482  }
483 
484  if((len != 0)&& (req->wLength != 0))
485  {
486 
487  len = MIN(len , req->wLength);
488 
489  USBD_CtlSendData (pdev,
490  pbuf,
491  len);
492  }
493 
494 }
495 
504  USB_SETUP_REQ *req)
505 {
506  uint8_t dev_addr;
507 
508  if ((req->wIndex == 0) && (req->wLength == 0))
509  {
510  dev_addr = (uint8_t)(req->wValue) & 0x7F;
511 
512  if (pdev->dev.device_status == USB_OTG_CONFIGURED)
513  {
514  USBD_CtlError(pdev , req);
515  }
516  else
517  {
518  pdev->dev.device_address = dev_addr;
519  DCD_EP_SetAddress(pdev, dev_addr);
520  USBD_CtlSendStatus(pdev);
521 
522  if (dev_addr != 0)
523  {
525  }
526  else
527  {
529  }
530  }
531  }
532  else
533  {
534  USBD_CtlError(pdev , req);
535  }
536 }
537 
546  USB_SETUP_REQ *req)
547 {
548 
549  static uint8_t cfgidx;
550 
551  cfgidx = (uint8_t)(req->wValue);
552 
553  if (cfgidx > USBD_CFG_MAX_NUM )
554  {
555  USBD_CtlError(pdev , req);
556  }
557  else
558  {
559  switch (pdev->dev.device_status)
560  {
561  case USB_OTG_ADDRESSED:
562  if (cfgidx)
563  {
564  pdev->dev.device_config = cfgidx;
566  USBD_SetCfg(pdev , cfgidx);
567  USBD_CtlSendStatus(pdev);
568  }
569  else
570  {
571  USBD_CtlSendStatus(pdev);
572  }
573  break;
574 
575  case USB_OTG_CONFIGURED:
576  if (cfgidx == 0)
577  {
579  pdev->dev.device_config = cfgidx;
580  USBD_ClrCfg(pdev , cfgidx);
581  USBD_CtlSendStatus(pdev);
582 
583  }
584  else if (cfgidx != pdev->dev.device_config)
585  {
586  /* Clear old configuration */
587  USBD_ClrCfg(pdev , pdev->dev.device_config);
588 
589  /* set new configuration */
590  pdev->dev.device_config = cfgidx;
591  USBD_SetCfg(pdev , cfgidx);
592  USBD_CtlSendStatus(pdev);
593  }
594  else
595  {
596  USBD_CtlSendStatus(pdev);
597  }
598  break;
599 
600  default:
601  USBD_CtlError(pdev , req);
602  break;
603  }
604  }
605 }
606 
615  USB_SETUP_REQ *req)
616 {
617 
618  if (req->wLength != 1)
619  {
620  USBD_CtlError(pdev , req);
621  }
622  else
623  {
624  switch (pdev->dev.device_status )
625  {
626  case USB_OTG_ADDRESSED:
627 
628  USBD_CtlSendData (pdev,
629  (uint8_t *)&USBD_default_cfg,
630  1);
631  break;
632 
633  case USB_OTG_CONFIGURED:
634 
635  USBD_CtlSendData (pdev,
636  &pdev->dev.device_config,
637  1);
638  break;
639 
640  default:
641  USBD_CtlError(pdev , req);
642  break;
643  }
644  }
645 }
646 
655  USB_SETUP_REQ *req)
656 {
657 
658 
659  switch (pdev->dev.device_status)
660  {
661  case USB_OTG_ADDRESSED:
662  case USB_OTG_CONFIGURED:
663 
664 #ifdef USBD_SELF_POWERED
665  USBD_cfg_status = USB_CONFIG_SELF_POWERED;
666 #else
667  USBD_cfg_status = 0x00;
668 #endif
669 
670  if (pdev->dev.DevRemoteWakeup)
671  {
672  USBD_cfg_status |= USB_CONFIG_REMOTE_WAKEUP;
673  }
674 
675  USBD_CtlSendData (pdev,
676  (uint8_t *)&USBD_cfg_status,
677  2);
678  break;
679 
680  default :
681  USBD_CtlError(pdev , req);
682  break;
683  }
684 }
685 
686 
695  USB_SETUP_REQ *req)
696 {
697 
699  uint8_t test_mode = 0;
700 
701  if (req->wValue == USB_FEATURE_REMOTE_WAKEUP)
702  {
703  pdev->dev.DevRemoteWakeup = 1;
704  pdev->dev.class_cb->Setup (pdev, req);
705  USBD_CtlSendStatus(pdev);
706  }
707 
708  else if ((req->wValue == USB_FEATURE_TEST_MODE) &&
709  ((req->wIndex & 0xFF) == 0))
710  {
711  dctl.d32 = USB_OTG_READ_REG32(&pdev->regs.DREGS->DCTL);
712 
713  test_mode = req->wIndex >> 8;
714  switch (test_mode)
715  {
716  case 1: // TEST_J
717  dctl.b.tstctl = 1;
718  break;
719 
720  case 2: // TEST_K
721  dctl.b.tstctl = 2;
722  break;
723 
724  case 3: // TEST_SE0_NAK
725  dctl.b.tstctl = 3;
726  break;
727 
728  case 4: // TEST_PACKET
729  dctl.b.tstctl = 4;
730  break;
731 
732  case 5: // TEST_FORCE_ENABLE
733  dctl.b.tstctl = 5;
734  break;
735  }
736  SET_TEST_MODE = dctl;
737  pdev->dev.test_mode = 1;
738  USBD_CtlSendStatus(pdev);
739  }
740 
741 }
742 
743 
752  USB_SETUP_REQ *req)
753 {
754  switch (pdev->dev.device_status)
755  {
756  case USB_OTG_ADDRESSED:
757  case USB_OTG_CONFIGURED:
758  if (req->wValue == USB_FEATURE_REMOTE_WAKEUP)
759  {
760  pdev->dev.DevRemoteWakeup = 0;
761  pdev->dev.class_cb->Setup (pdev, req);
762  USBD_CtlSendStatus(pdev);
763  }
764  break;
765 
766  default :
767  USBD_CtlError(pdev , req);
768  break;
769  }
770 }
771 
781  USB_SETUP_REQ *req)
782 {
783  req->bmRequest = *(uint8_t *) (pdev->dev.setup_packet);
784  req->bRequest = *(uint8_t *) (pdev->dev.setup_packet + 1);
785  req->wValue = SWAPBYTE (pdev->dev.setup_packet + 2);
786  req->wIndex = SWAPBYTE (pdev->dev.setup_packet + 4);
787  req->wLength = SWAPBYTE (pdev->dev.setup_packet + 6);
788 
789  pdev->dev.in_ep[0].ctl_data_len = req->wLength ;
791 }
792 
802  USB_SETUP_REQ *req)
803 {
804 
805  DCD_EP_Stall(pdev , 0x80);
806  DCD_EP_Stall(pdev , 0);
807  USB_OTG_EP0_OutStart(pdev);
808 }
809 
810 
819 void USBD_GetString(const uint8_t *desc, uint8_t *unicode, uint16_t *len)
820 {
821  uint8_t idx = 0;
822 
823  if (desc != NULL) {
824  *len = USBD_GetLen(desc) * 2 + 2;
825  unicode[idx++] = *len;
826  unicode[idx++] = USB_DESC_TYPE_STRING;
827 
828  while (*desc != NULL) {
829  unicode[idx++] = *desc++;
830  unicode[idx++] = 0x00;
831  }
832  }
833 }
834 
841 static uint8_t USBD_GetLen(const uint8_t *buf)
842 {
843  uint8_t len = 0;
844 
845  while (*buf != NULL) {
846  len++;
847  buf++;
848  }
849 
850  return len;
851 }
866 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
uint8_t * pConfig_descriptor
Definition: usb_core.h:268
#define USB_OTG_DEFAULT
Definition: usb_dcd.h:56
USBD_Status USBD_StdItfReq(USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req)
USBD_StdItfReq Handle standard usb interface requests.
Definition: usbd_req.c:200
header file for the usbd_req.c file
uint8_t phy_itface
Definition: usb_core.h:170
USBD_Status
Definition: usbd_core.h:51
#define USB_LEN_DEV_QUALIFIER_DESC
Definition: usbd_def.h:53
#define USBD_IDX_CONFIG_STR
Definition: usbd_def.h:64
static void USBD_GetStatus(USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req)
USBD_GetStatus Handle Get Status request.
Definition: usbd_req.c:654
void USB_OTG_EP0_OutStart(USB_OTG_CORE_HANDLE *pdev)
configures EPO to receive SETUP packets
Definition: usb_core.c:1917
#define USB_DESC_TYPE_DEVICE_QUALIFIER
Definition: usbd_def.h:94
#define USB_OTG_EP0_SETUP
Definition: usb_core.h:53
#define USB_REQ_SET_ADDRESS
Definition: usbd_def.h:80
USBD_Status USBD_CtlSendData(USB_OTG_CORE_HANDLE *pdev, const uint8_t *pbuf, uint16_t len)
USBD_CtlSendData send data on the ctl pipe.
Definition: usbd_ioreq.c:95
uint8_t setup_packet[8 *3]
Definition: usb_core.h:264
uint32_t ctl_data_len
Definition: usb_core.h:154
uint32_t DevRemoteWakeup
Definition: usb_core.h:261
#define USB_CONFIG_REMOTE_WAKEUP
Definition: usbd_def.h:98
#define USBD_CFG_MAX_NUM
Definition: usbd_conf.h:38
#define USB_REQ_GET_STATUS
Definition: usbd_def.h:77
__ALIGN_BEGIN uint32_t USBD_ep_status __ALIGN_END
Definition: usbd_req.c:79
static void USBD_GetDescriptor(USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req)
USBD_GetDescriptor Handle Get Descriptor requests.
Definition: usbd_req.c:367
USBD_Status USBD_ClrCfg(USB_OTG_CORE_HANDLE *pdev, uint8_t cfgidx)
USBD_ClrCfg Clear current configuration.
Definition: usbd_core.c:433
#define USB_FEATURE_EP_HALT
Definition: usbd_def.h:101
#define USBD_ITF_MAX_NUM
Definition: usbd_conf.h:39
__IO USB_OTG_DCTL_TypeDef SET_TEST_MODE
Definition: usbd_core.c:97
uint8_t device_state
Definition: usb_core.h:255
#define USBD_IDX_PRODUCT_STR
Definition: usbd_def.h:62
#define USB_REQ_SET_FEATURE
Definition: usbd_def.h:79
#define USB_REQ_SET_CONFIGURATION
Definition: usbd_def.h:84
#define USBD_IDX_SERIAL_STR
Definition: usbd_def.h:63
#define USB_OTG_SPEED_FULL
Definition: usb_defines.h:62
uint8_t test_mode
Definition: usb_core.h:260
#define MIN(a, b)
Definition: usb_conf.h:215
USB_OTG_CORE_CFGS cfg
Definition: usb_core.h:298
uint8_t *(* GetLangIDStrDescriptor)(uint8_t speed, uint16_t *length)
Definition: usb_core.h:192
uint8_t speed
Definition: usb_core.h:166
#define USB_OTG_SPEED_HIGH
Definition: usb_defines.h:61
USB_OTG_EP in_ep[USB_OTG_MAX_TX_FIFOS]
Definition: usb_core.h:262
#define USBD_IDX_LANGID_STR
Definition: usbd_def.h:60
uint8_t *(* GetConfigurationStrDescriptor)(uint8_t speed, uint16_t *length)
Definition: usb_core.h:196
uint16_t wIndex
Definition: usb_core.h:185
uint8_t device_config
Definition: usb_core.h:254
uint8_t USBD_StrDesc[USB_MAX_STR_DESC_SIZ]
Definition: usbd_req.c:101
#define __ALIGN_BEGIN
Definition: usb_conf.h:198
#define USB_MAX_STR_DESC_SIZ
Definition: usbd_conf.h:43
void USBD_ParseSetupRequest(USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req)
USBD_ParseSetupRequest Copy buffer into setup structure.
Definition: usbd_req.c:780
uint8_t *(* GetProductStrDescriptor)(uint8_t speed, uint16_t *length)
Definition: usb_core.h:194
__IO uint32_t DCTL
Definition: usb_regs.h:116
#define USB_OTG_READ_REG32(reg)
Definition: usb_defines.h:221
struct _USB_OTG_DCTL_TypeDef::@66 b
static void USBD_SetAddress(USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req)
USBD_SetAddress Set device address.
Definition: usbd_req.c:503
#define USB_REQ_GET_DESCRIPTOR
Definition: usbd_def.h:81
static uint8_t USBD_GetLen(const uint8_t *buf)
USBD_GetLen return the string length.
Definition: usbd_req.c:841
uint8_t *(* GetConfigDescriptor)(uint8_t speed, uint16_t *length)
Definition: usb_core.h:225
uint8_t bmRequest
Definition: usb_core.h:182
#define USB_FEATURE_REMOTE_WAKEUP
Definition: usbd_def.h:102
#define USB_OTG_ADDRESSED
Definition: usb_dcd.h:57
DCD_DEV dev
Definition: usb_core.h:301
uint8_t *(* GetSerialStrDescriptor)(uint8_t speed, uint16_t *length)
Definition: usb_core.h:195
const USBD_DEVICE * usr_device
Definition: usb_core.h:267
void USBD_CtlError(USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req)
USBD_CtlError Handle USB low level Error.
Definition: usbd_req.c:801
uint32_t DCD_EP_Stall(USB_OTG_CORE_HANDLE *pdev, uint8_t epnum)
Stall an endpoint.
Definition: usb_dcd.c:296
#define NULL
Definition: hal_types.h:59
header file for the usbd_ioreq.c file
uint8_t *(* GetManufacturerStrDescriptor)(uint8_t speed, uint16_t *length)
Definition: usb_core.h:193
uint8_t *(* GetDeviceDescriptor)(uint8_t speed, uint16_t *length)
Definition: usb_core.h:191
#define SWAPBYTE(addr)
Definition: usbd_def.h:122
#define USB_REQ_CLEAR_FEATURE
Definition: usbd_def.h:78
static void USBD_GetConfig(USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req)
USBD_GetConfig Handle Get device configuration request.
Definition: usbd_req.c:614
USB_OTG_EP out_ep[USB_OTG_MAX_TX_FIFOS]
Definition: usb_core.h:263
#define USB_FEATURE_TEST_MODE
Definition: usbd_def.h:103
#define USB_REQ_GET_CONFIGURATION
Definition: usbd_def.h:83
uint16_t wLength
Definition: usb_core.h:186
uint8_t *(* GetInterfaceStrDescriptor)(uint8_t speed, uint16_t *length)
Definition: usb_core.h:197
#define USBD_IDX_INTERFACE_STR
Definition: usbd_def.h:65
const uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC]
Definition: usb.c:152
USBD_Status USBD_CtlSendStatus(USB_OTG_CORE_HANDLE *pdev)
USBD_CtlSendStatus send zero lzngth packet on the ctl pipe.
Definition: usbd_ioreq.c:183
uint8_t bRequest
Definition: usb_core.h:183
uint8_t device_status
Definition: usb_core.h:256
static void USBD_ClrFeature(USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req)
USBD_ClrFeature Handle clear device feature request.
Definition: usbd_req.c:751
uint8_t device_address
Definition: usb_core.h:258
#define LOBYTE(x)
Definition: usbd_def.h:125
const USBD_Class_cb_TypeDef * class_cb
Definition: usb_core.h:265
void USBD_GetString(const uint8_t *desc, uint8_t *unicode, uint16_t *len)
USBD_GetString Convert Ascii string into unicode one.
Definition: usbd_req.c:819
static void USBD_SetFeature(USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req)
USBD_SetFeature Handle Set device feature request.
Definition: usbd_req.c:694
#define USB_OTG_CONFIGURED
Definition: usb_dcd.h:58
#define USB_DESC_TYPE_OTHER_SPEED_CONFIGURATION
Definition: usbd_def.h:95
USBD_Status USBD_SetCfg(USB_OTG_CORE_HANDLE *pdev, uint8_t cfgidx)
USBD_SetCfg Configure device and start the interface.
Definition: usbd_core.c:417
#define USBD_IDX_MFC_STR
Definition: usbd_def.h:61
#define USB_DESC_TYPE_CONFIGURATION
Definition: usbd_def.h:90
uint8_t is_stall
Definition: usb_core.h:140
void DCD_EP_SetAddress(USB_OTG_CORE_HANDLE *pdev, uint8_t address)
This Function set USB device address.
Definition: usb_dcd.c:372
#define USB_DESC_TYPE_DEVICE
Definition: usbd_def.h:89
uint8_t(* Setup)(void *pdev, USB_SETUP_REQ *req)
Definition: usb_core.h:215
USBD_Status USBD_StdEPReq(USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req)
USBD_StdEPReq Handle standard usb endpoint requests.
Definition: usbd_req.c:237
#define USB_DESC_TYPE_STRING
Definition: usbd_def.h:91
#define USB_CONFIG_SELF_POWERED
Definition: usbd_def.h:99
USB_OTG_CORE_REGS regs
Definition: usb_core.h:299
#define USB_OTG_ULPI_PHY
Definition: usb_defines.h:64
uint16_t wValue
Definition: usb_core.h:184
USBD_Status USBD_StdDevReq(USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req)
USBD_StdDevReq Handle standard usb device requests.
Definition: usbd_req.c:149
header file for the usbd_desc.c file
uint32_t DCD_EP_ClrStall(USB_OTG_CORE_HANDLE *pdev, uint8_t epnum)
Clear stall condition on endpoints.
Definition: usb_dcd.c:323
static void USBD_SetConfig(USB_OTG_CORE_HANDLE *pdev, USB_SETUP_REQ *req)
USBD_SetConfig Handle Set device configuration request.
Definition: usbd_req.c:545
USB_OTG_DREGS * DREGS
Definition: usb_regs.h:225