STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
usbh_ctlreq.c
Go to the documentation of this file.
1 
27 /* Includes ------------------------------------------------------------------*/
28 
29 #include "usbh_ctlreq.h"
30 
80 static USBH_StatusTypeDef USBH_HandleControl (USBH_HandleTypeDef *phost);
81 
82 static void USBH_ParseDevDesc (USBH_DevDescTypeDef* , uint8_t *buf, uint16_t length);
83 
84 static void USBH_ParseCfgDesc (USBH_CfgDescTypeDef* cfg_desc,
85  uint8_t *buf,
86  uint16_t length);
87 
88 
89 static void USBH_ParseEPDesc (USBH_EpDescTypeDef *ep_descriptor, uint8_t *buf);
90 static void USBH_ParseStringDesc (uint8_t* psrc, uint8_t* pdest, uint16_t length);
91 static void USBH_ParseInterfaceDesc (USBH_InterfaceDescTypeDef *if_descriptor, uint8_t *buf);
92 
93 
113 {
114  USBH_StatusTypeDef status;
115 
116  if((status = USBH_GetDescriptor(phost,
119  phost->device.Data,
120  length)) == USBH_OK)
121  {
122  /* Commands successfully sent and Response Received */
123  USBH_ParseDevDesc(&phost->device.DevDesc, phost->device.Data, length);
124  }
125  return status;
126 }
127 
138  uint16_t length)
139 
140 {
141  USBH_StatusTypeDef status;
142  uint8_t *pData;
143 #if (USBH_KEEP_CFG_DESCRIPTOR == 1)
144  pData = phost->device.CfgDesc_Raw;
145 #else
146  pData = phost->device.Data;
147 #endif
148  if((status = USBH_GetDescriptor(phost,
151  pData,
152  length)) == USBH_OK)
153  {
154 
155  /* Commands successfully sent and Response Received */
156  USBH_ParseCfgDesc (&phost->device.CfgDesc,
157  pData,
158  length);
159 
160  }
161  return status;
162 }
163 
164 
176  uint8_t string_index,
177  uint8_t *buff,
178  uint16_t length)
179 {
180  USBH_StatusTypeDef status;
181  if((status = USBH_GetDescriptor(phost,
183  USB_DESC_STRING | string_index,
184  phost->device.Data,
185  length)) == USBH_OK)
186  {
187  /* Commands successfully sent and Response Received */
188  USBH_ParseStringDesc(phost->device.Data,buff, length);
189  }
190  return status;
191 }
192 
205  uint8_t req_type,
206  uint16_t value_idx,
207  uint8_t* buff,
208  uint16_t length )
209 {
210  if(phost->RequestState == CMD_SEND)
211  {
212  phost->Control.setup.b.bmRequestType = USB_D2H | req_type;
214  phost->Control.setup.b.wValue.w = value_idx;
215 
216  if ((value_idx & 0xff00) == USB_DESC_STRING)
217  {
218  phost->Control.setup.b.wIndex.w = 0x0409;
219  }
220  else
221  {
222  phost->Control.setup.b.wIndex.w = 0;
223  }
224  phost->Control.setup.b.wLength.w = length;
225  }
226  return USBH_CtlReq(phost, buff , length );
227 }
228 
237  uint8_t DeviceAddress)
238 {
239  if(phost->RequestState == CMD_SEND)
240  {
242  USB_REQ_TYPE_STANDARD;
243 
245 
246  phost->Control.setup.b.wValue.w = (uint16_t)DeviceAddress;
247  phost->Control.setup.b.wIndex.w = 0;
248  phost->Control.setup.b.wLength.w = 0;
249  }
250  return USBH_CtlReq(phost, 0 , 0 );
251 }
252 
261  uint16_t cfg_idx)
262 {
263  if(phost->RequestState == CMD_SEND)
264  {
266  USB_REQ_TYPE_STANDARD;
268  phost->Control.setup.b.wValue.w = cfg_idx;
269  phost->Control.setup.b.wIndex.w = 0;
270  phost->Control.setup.b.wLength.w = 0;
271  }
272 
273  return USBH_CtlReq(phost, 0 , 0 );
274 }
275 
284  uint8_t ep_num, uint8_t altSetting)
285 {
286 
287  if(phost->RequestState == CMD_SEND)
288  {
290  USB_REQ_TYPE_STANDARD;
291 
293  phost->Control.setup.b.wValue.w = altSetting;
294  phost->Control.setup.b.wIndex.w = ep_num;
295  phost->Control.setup.b.wLength.w = 0;
296  }
297  return USBH_CtlReq(phost, 0 , 0 );
298 }
299 
309  uint8_t ep_num)
310 {
311  if(phost->RequestState == CMD_SEND)
312  {
313  phost->Control.setup.b.bmRequestType = USB_H2D |
316 
319  phost->Control.setup.b.wIndex.w = ep_num;
320  phost->Control.setup.b.wLength.w = 0;
321  }
322  return USBH_CtlReq(phost, 0 , 0 );
323 }
324 
333 static void USBH_ParseDevDesc (USBH_DevDescTypeDef* dev_desc,
334  uint8_t *buf,
335  uint16_t length)
336 {
337  dev_desc->bLength = *(uint8_t *) (buf + 0);
338  dev_desc->bDescriptorType = *(uint8_t *) (buf + 1);
339  dev_desc->bcdUSB = LE16 (buf + 2);
340  dev_desc->bDeviceClass = *(uint8_t *) (buf + 4);
341  dev_desc->bDeviceSubClass = *(uint8_t *) (buf + 5);
342  dev_desc->bDeviceProtocol = *(uint8_t *) (buf + 6);
343  dev_desc->bMaxPacketSize = *(uint8_t *) (buf + 7);
344 
345  if (length > 8)
346  { /* For 1st time after device connection, Host may issue only 8 bytes for
347  Device Descriptor Length */
348  dev_desc->idVendor = LE16 (buf + 8);
349  dev_desc->idProduct = LE16 (buf + 10);
350  dev_desc->bcdDevice = LE16 (buf + 12);
351  dev_desc->iManufacturer = *(uint8_t *) (buf + 14);
352  dev_desc->iProduct = *(uint8_t *) (buf + 15);
353  dev_desc->iSerialNumber = *(uint8_t *) (buf + 16);
354  dev_desc->bNumConfigurations = *(uint8_t *) (buf + 17);
355  }
356 }
357 
366 static void USBH_ParseCfgDesc (USBH_CfgDescTypeDef* cfg_desc,
367  uint8_t *buf,
368  uint16_t length)
369 {
371  USBH_EpDescTypeDef *pep;
372  USBH_DescHeader_t *pdesc = (USBH_DescHeader_t *)buf;
373  uint16_t ptr;
374  int8_t if_ix = 0;
375  int8_t ep_ix = 0;
376 
377  pdesc = (USBH_DescHeader_t *)buf;
378 
379  /* Parse configuration descriptor */
380  cfg_desc->bLength = *(uint8_t *) (buf + 0);
381  cfg_desc->bDescriptorType = *(uint8_t *) (buf + 1);
382  cfg_desc->wTotalLength = LE16 (buf + 2);
383  cfg_desc->bNumInterfaces = *(uint8_t *) (buf + 4);
384  cfg_desc->bConfigurationValue = *(uint8_t *) (buf + 5);
385  cfg_desc->iConfiguration = *(uint8_t *) (buf + 6);
386  cfg_desc->bmAttributes = *(uint8_t *) (buf + 7);
387  cfg_desc->bMaxPower = *(uint8_t *) (buf + 8);
388 
389 
390  if (length > USB_CONFIGURATION_DESC_SIZE)
391  {
392  ptr = USB_LEN_CFG_DESC;
393  pif = (USBH_InterfaceDescTypeDef *)0;
394 
395 
396  while ((if_ix < USBH_MAX_NUM_INTERFACES ) && (ptr < cfg_desc->wTotalLength))
397  {
398  pdesc = USBH_GetNextDesc((uint8_t *)pdesc, &ptr);
400  {
401  pif = &cfg_desc->Itf_Desc[if_ix];
402  USBH_ParseInterfaceDesc (pif, (uint8_t *)pdesc);
403 
404  ep_ix = 0;
405  pep = (USBH_EpDescTypeDef *)0;
406  while ((ep_ix < pif->bNumEndpoints) && (ptr < cfg_desc->wTotalLength))
407  {
408  pdesc = USBH_GetNextDesc((uint8_t*) pdesc, &ptr);
410  {
411  pep = &cfg_desc->Itf_Desc[if_ix].Ep_Desc[ep_ix];
412  USBH_ParseEPDesc (pep, (uint8_t *)pdesc);
413  ep_ix++;
414  }
415  }
416  if_ix++;
417  }
418  }
419  }
420 }
421 
422 
423 
431 static void USBH_ParseInterfaceDesc (USBH_InterfaceDescTypeDef *if_descriptor,
432  uint8_t *buf)
433 {
434  if_descriptor->bLength = *(uint8_t *) (buf + 0);
435  if_descriptor->bDescriptorType = *(uint8_t *) (buf + 1);
436  if_descriptor->bInterfaceNumber = *(uint8_t *) (buf + 2);
437  if_descriptor->bAlternateSetting = *(uint8_t *) (buf + 3);
438  if_descriptor->bNumEndpoints = *(uint8_t *) (buf + 4);
439  if_descriptor->bInterfaceClass = *(uint8_t *) (buf + 5);
440  if_descriptor->bInterfaceSubClass = *(uint8_t *) (buf + 6);
441  if_descriptor->bInterfaceProtocol = *(uint8_t *) (buf + 7);
442  if_descriptor->iInterface = *(uint8_t *) (buf + 8);
443 }
444 
452 static void USBH_ParseEPDesc (USBH_EpDescTypeDef *ep_descriptor,
453  uint8_t *buf)
454 {
455 
456  ep_descriptor->bLength = *(uint8_t *) (buf + 0);
457  ep_descriptor->bDescriptorType = *(uint8_t *) (buf + 1);
458  ep_descriptor->bEndpointAddress = *(uint8_t *) (buf + 2);
459  ep_descriptor->bmAttributes = *(uint8_t *) (buf + 3);
460  ep_descriptor->wMaxPacketSize = LE16 (buf + 4);
461  ep_descriptor->bInterval = *(uint8_t *) (buf + 6);
462 }
463 
472 static void USBH_ParseStringDesc (uint8_t* psrc,
473  uint8_t* pdest,
474  uint16_t length)
475 {
476  uint16_t strlength;
477  uint16_t idx;
478 
479  /* The UNICODE string descriptor is not NULL-terminated. The string length is
480  computed by substracting two from the value of the first byte of the descriptor.
481  */
482 
483  /* Check which is lower size, the Size of string or the length of bytes read
484  from the device */
485 
486  if ( psrc[1] == USB_DESC_TYPE_STRING)
487  { /* Make sure the Descriptor is String Type */
488 
489  /* psrc[0] contains Size of Descriptor, subtract 2 to get the length of string */
490  strlength = ( ( (psrc[0]-2) <= length) ? (psrc[0]-2) :length);
491  psrc += 2; /* Adjust the offset ignoring the String Len and Descriptor type */
492 
493  for (idx = 0; idx < strlength; idx+=2 )
494  {/* Copy Only the string and ignore the UNICODE ID, hence add the src */
495  *pdest = psrc[idx];
496  pdest++;
497  }
498  *pdest = 0; /* mark end of string */
499  }
500 }
501 
509 USBH_DescHeader_t *USBH_GetNextDesc (uint8_t *pbuf, uint16_t *ptr)
510 {
511  USBH_DescHeader_t *pnext;
512 
513  *ptr += ((USBH_DescHeader_t *)pbuf)->bLength;
514  pnext = (USBH_DescHeader_t *)((uint8_t *)pbuf + \
515  ((USBH_DescHeader_t *)pbuf)->bLength);
516 
517  return(pnext);
518 }
519 
520 
532  uint8_t *buff,
533  uint16_t length)
534 {
535  USBH_StatusTypeDef status;
536  status = USBH_BUSY;
537 
538  switch (phost->RequestState)
539  {
540  case CMD_SEND:
541  /* Start a SETUP transfer */
542  phost->Control.buff = buff;
543  phost->Control.length = length;
544  phost->Control.state = CTRL_SETUP;
545  phost->RequestState = CMD_WAIT;
546  status = USBH_BUSY;
547 #if (USBH_USE_OS == 1)
548  osMessagePut ( phost->os_event, USBH_CONTROL_EVENT, 0);
549 #endif
550  break;
551 
552  case CMD_WAIT:
553  status = USBH_HandleControl(phost);
554  if (status == USBH_OK)
555  {
556  /* Commands successfully sent and Response Received */
557  phost->RequestState = CMD_SEND;
558  phost->Control.state =CTRL_IDLE;
559  status = USBH_OK;
560  }
561  else if (status == USBH_FAIL)
562  {
563  /* Failure Mode */
564  phost->RequestState = CMD_SEND;
565  status = USBH_FAIL;
566  }
567  break;
568 
569  default:
570  break;
571  }
572  return status;
573 }
574 
581 static USBH_StatusTypeDef USBH_HandleControl (USBH_HandleTypeDef *phost)
582 {
583  uint8_t direction;
584  USBH_StatusTypeDef status = USBH_BUSY;
585  USBH_URBStateTypeDef URB_Status = USBH_URB_IDLE;
586 
587  switch (phost->Control.state)
588  {
589  case CTRL_SETUP:
590  /* send a SETUP packet */
591  USBH_CtlSendSetup (phost,
592  (uint8_t *)phost->Control.setup.d8 ,
593  phost->Control.pipe_out);
594 
595  phost->Control.state = CTRL_SETUP_WAIT;
596  break;
597 
598  case CTRL_SETUP_WAIT:
599 
600  URB_Status = USBH_LL_GetURBState(phost, phost->Control.pipe_out);
601  /* case SETUP packet sent successfully */
602  if(URB_Status == USBH_URB_DONE)
603  {
604  direction = (phost->Control.setup.b.bmRequestType & USB_REQ_DIR_MASK);
605 
606  /* check if there is a data stage */
607  if (phost->Control.setup.b.wLength.w != 0 )
608  {
609  if (direction == USB_D2H)
610  {
611  /* Data Direction is IN */
612  phost->Control.state = CTRL_DATA_IN;
613  }
614  else
615  {
616  /* Data Direction is OUT */
617  phost->Control.state = CTRL_DATA_OUT;
618  }
619  }
620  /* No DATA stage */
621  else
622  {
623  /* If there is No Data Transfer Stage */
624  if (direction == USB_D2H)
625  {
626  /* Data Direction is IN */
627  phost->Control.state = CTRL_STATUS_OUT;
628  }
629  else
630  {
631  /* Data Direction is OUT */
632  phost->Control.state = CTRL_STATUS_IN;
633  }
634  }
635 #if (USBH_USE_OS == 1)
636  osMessagePut ( phost->os_event, USBH_CONTROL_EVENT, 0);
637 #endif
638  }
639  else if(URB_Status == USBH_URB_ERROR)
640  {
641  phost->Control.state = CTRL_ERROR;
642 #if (USBH_USE_OS == 1)
643  osMessagePut ( phost->os_event, USBH_CONTROL_EVENT, 0);
644 #endif
645  }
646  break;
647 
648  case CTRL_DATA_IN:
649  /* Issue an IN token */
650  phost->Control.timer = phost->Timer;
651  USBH_CtlReceiveData(phost,
652  phost->Control.buff,
653  phost->Control.length,
654  phost->Control.pipe_in);
655 
657  break;
658 
659  case CTRL_DATA_IN_WAIT:
660 
661  URB_Status = USBH_LL_GetURBState(phost , phost->Control.pipe_in);
662 
663  /* check is DATA packet transferred successfully */
664  if (URB_Status == USBH_URB_DONE)
665  {
666  phost->Control.state = CTRL_STATUS_OUT;
667 #if (USBH_USE_OS == 1)
668  osMessagePut ( phost->os_event, USBH_CONTROL_EVENT, 0);
669 #endif
670  }
671 
672  /* manage error cases*/
673  if (URB_Status == USBH_URB_STALL)
674  {
675  /* In stall case, return to previous machine state*/
676  status = USBH_NOT_SUPPORTED;
677 #if (USBH_USE_OS == 1)
678  osMessagePut ( phost->os_event, USBH_CONTROL_EVENT, 0);
679 #endif
680  }
681  else if (URB_Status == USBH_URB_ERROR)
682  {
683  /* Device error */
684  phost->Control.state = CTRL_ERROR;
685 #if (USBH_USE_OS == 1)
686  osMessagePut ( phost->os_event, USBH_CONTROL_EVENT, 0);
687 #endif
688  }
689  break;
690 
691  case CTRL_DATA_OUT:
692 
693  USBH_CtlSendData (phost,
694  phost->Control.buff,
695  phost->Control.length ,
696  phost->Control.pipe_out,
697  1);
698  phost->Control.timer = phost->Timer;
700  break;
701 
702  case CTRL_DATA_OUT_WAIT:
703 
704  URB_Status = USBH_LL_GetURBState(phost , phost->Control.pipe_out);
705 
706  if (URB_Status == USBH_URB_DONE)
707  { /* If the Setup Pkt is sent successful, then change the state */
708  phost->Control.state = CTRL_STATUS_IN;
709 #if (USBH_USE_OS == 1)
710  osMessagePut ( phost->os_event, USBH_CONTROL_EVENT, 0);
711 #endif
712  }
713 
714  /* handle error cases */
715  else if (URB_Status == USBH_URB_STALL)
716  {
717  /* In stall case, return to previous machine state*/
718  phost->Control.state = CTRL_STALLED;
719  status = USBH_NOT_SUPPORTED;
720 #if (USBH_USE_OS == 1)
721  osMessagePut ( phost->os_event, USBH_CONTROL_EVENT, 0);
722 #endif
723  }
724  else if (URB_Status == USBH_URB_NOTREADY)
725  {
726  /* Nack received from device */
727  phost->Control.state = CTRL_DATA_OUT;
728 
729 #if (USBH_USE_OS == 1)
730  osMessagePut ( phost->os_event, USBH_CONTROL_EVENT, 0);
731 #endif
732  }
733  else if (URB_Status == USBH_URB_ERROR)
734  {
735  /* device error */
736  phost->Control.state = CTRL_ERROR;
737  status = USBH_FAIL;
738 
739 #if (USBH_USE_OS == 1)
740  osMessagePut ( phost->os_event, USBH_CONTROL_EVENT, 0);
741 #endif
742  }
743  break;
744 
745 
746  case CTRL_STATUS_IN:
747  /* Send 0 bytes out packet */
748  USBH_CtlReceiveData (phost,
749  0,
750  0,
751  phost->Control.pipe_in);
752  phost->Control.timer = phost->Timer;
754 
755  break;
756 
757  case CTRL_STATUS_IN_WAIT:
758 
759  URB_Status = USBH_LL_GetURBState(phost , phost->Control.pipe_in);
760 
761  if ( URB_Status == USBH_URB_DONE)
762  { /* Control transfers completed, Exit the State Machine */
763  phost->Control.state = CTRL_COMPLETE;
764  status = USBH_OK;
765 #if (USBH_USE_OS == 1)
766  osMessagePut ( phost->os_event, USBH_CONTROL_EVENT, 0);
767 #endif
768  }
769 
770  else if (URB_Status == USBH_URB_ERROR)
771  {
772  phost->Control.state = CTRL_ERROR;
773 #if (USBH_USE_OS == 1)
774  osMessagePut ( phost->os_event, USBH_CONTROL_EVENT, 0);
775 #endif
776  }
777  else if(URB_Status == USBH_URB_STALL)
778  {
779  /* Control transfers completed, Exit the State Machine */
780  status = USBH_NOT_SUPPORTED;
781 
782 #if (USBH_USE_OS == 1)
783  osMessagePut ( phost->os_event, USBH_CONTROL_EVENT, 0);
784 #endif
785  }
786  break;
787 
788  case CTRL_STATUS_OUT:
789  USBH_CtlSendData (phost,
790  0,
791  0,
792  phost->Control.pipe_out,
793  1);
794  phost->Control.timer = phost->Timer;
796  break;
797 
798  case CTRL_STATUS_OUT_WAIT:
799 
800  URB_Status = USBH_LL_GetURBState(phost , phost->Control.pipe_out);
801  if (URB_Status == USBH_URB_DONE)
802  {
803  status = USBH_OK;
804  phost->Control.state = CTRL_COMPLETE;
805 
806 #if (USBH_USE_OS == 1)
807  osMessagePut ( phost->os_event, USBH_CONTROL_EVENT, 0);
808 #endif
809  }
810  else if (URB_Status == USBH_URB_NOTREADY)
811  {
812  phost->Control.state = CTRL_STATUS_OUT;
813 
814 #if (USBH_USE_OS == 1)
815  osMessagePut ( phost->os_event, USBH_CONTROL_EVENT, 0);
816 #endif
817  }
818  else if (URB_Status == USBH_URB_ERROR)
819  {
820  phost->Control.state = CTRL_ERROR;
821 
822 #if (USBH_USE_OS == 1)
823  osMessagePut ( phost->os_event, USBH_CONTROL_EVENT, 0);
824 #endif
825  }
826  break;
827 
828  case CTRL_ERROR:
829  /*
830  After a halt condition is encountered or an error is detected by the
831  host, a control endpoint is allowed to recover by accepting the next Setup
832  PID; i.e., recovery actions via some other pipe are not required for control
833  endpoints. For the Default Control Pipe, a device reset will ultimately be
834  required to clear the halt or error condition if the next Setup PID is not
835  accepted.
836  */
837  if (++ phost->Control.errorcount <= USBH_MAX_ERROR_COUNT)
838  {
839  /* try to recover control */
840  USBH_LL_Stop(phost);
841 
842  /* Do the transmission again, starting from SETUP Packet */
843  phost->Control.state = CTRL_SETUP;
844  phost->RequestState = CMD_SEND;
845  }
846  else
847  {
848  phost->pUser(phost, HOST_USER_UNRECOVERED_ERROR);
849  phost->Control.errorcount = 0;
850  USBH_ErrLog("Control error");
851  status = USBH_FAIL;
852  }
853  break;
854 
855  default:
856  break;
857  }
858  return status;
859 }
860 
877 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
878 
879 
880 
881 
USBH_StatusTypeDef USBH_SetInterface(USBH_HandleTypeDef *phost, uint8_t ep_num, uint8_t altSetting)
USBH_SetInterface The command sets the Interface value to the connected device.
Definition: usbh_ctlreq.c:283
#define USBH_ErrLog(...)
CMD_StateTypeDef RequestState
Definition: usbh_def.h:454
USBH_StatusTypeDef USBH_CtlReq(USBH_HandleTypeDef *phost, uint8_t *buff, uint16_t length)
USBH_CtlReq USBH_CtlReq sends a control request and provide the status after completion of the reques...
Definition: usbh_ctlreq.c:531
#define USB_H2D
Definition: usbh_def.h:108
USB_Setup_TypeDef setup
Definition: usbh_def.h:412
USBH_DeviceTypeDef device
Definition: usbh_def.h:456
USBH_DescHeader_t * USBH_GetNextDesc(uint8_t *pbuf, uint16_t *ptr)
USBH_GetNextDesc This function return the next descriptor header.
Definition: usbh_ctlreq.c:509
uint32_t idx
Definition: lcd_log.c:247
#define USB_D2H
Definition: usbh_def.h:109
__IO uint32_t Timer
Definition: usbh_def.h:461
#define HOST_USER_UNRECOVERED_ERROR
Definition: usbh_core.h:69
uint8_t iSerialNumber
Definition: usbh_def.h:254
uint8_t bNumConfigurations
Definition: usbh_def.h:255
uint16_t_uint8_t wValue
Definition: usbh_def.h:223
uint8_t bInterfaceClass
Definition: usbh_def.h:277
#define USB_CONFIGURATION_DESC_SIZE
Definition: usbh_def.h:151
uint8_t bLength
Definition: usbh_def.h:239
#define USB_REQ_RECIPIENT_DEVICE
Definition: usbd_def.h:78
uint8_t iManufacturer
Definition: usbh_def.h:252
#define USB_DESC_CONFIGURATION
Definition: usbh_def.h:159
#define USB_REQ_RECIPIENT_ENDPOINT
Definition: usbd_def.h:80
uint8_t bEndpointAddress
Definition: usbh_def.h:263
#define USB_REQ_GET_DESCRIPTOR
Definition: usbd_def.h:87
uint8_t bMaxPacketSize
Definition: usbh_def.h:248
uint8_t bDeviceSubClass
Definition: usbh_def.h:243
uint8_t bDeviceClass
Definition: usbh_def.h:242
#define USB_REQ_DIR_MASK
Definition: usbh_def.h:107
void(* pUser)(struct _USBH_HandleTypeDef *pHandle, uint8_t id)
Definition: usbh_def.h:464
uint16_t_uint8_t wLength
Definition: usbh_def.h:225
uint16_t idVendor
Definition: usbh_def.h:249
USBH_InterfaceDescTypeDef Itf_Desc[USBH_MAX_NUM_INTERFACES]
Definition: usbh_def.h:296
uint8_t iProduct
Definition: usbh_def.h:253
USBH_StatusTypeDef USBH_CtlSendData(USBH_HandleTypeDef *phost, uint8_t *buff, uint16_t length, uint8_t hc_num, uint8_t do_ping)
USBH_CtlSendData Sends a data Packet to the Device.
Definition: usbh_ioreq.c:126
#define USB_REQ_SET_CONFIGURATION
Definition: usbd_def.h:90
#define USBH_MAX_ERROR_COUNT
Definition: usbh_def.h:184
uint8_t * buff
Definition: usbh_def.h:409
USBH_CfgDescTypeDef CfgDesc
Definition: usbh_def.h:430
#define USB_REQ_RECIPIENT_INTERFACE
Definition: usbd_def.h:79
USBH_StatusTypeDef USBH_LL_Stop(USBH_HandleTypeDef *phost)
USBH_LL_Stop Stop the Low Level portion of the Host driver.
USBH_CtrlTypeDef Control
Definition: usbh_def.h:455
#define USBH_MAX_NUM_INTERFACES
USBH_StatusTypeDef USBH_CtlSendSetup(USBH_HandleTypeDef *phost, uint8_t *buff, uint8_t hc_num)
USBH_CtlSendSetup Sends the Setup Packet to the Device.
Definition: usbh_ioreq.c:100
uint8_t bInterfaceNumber
Definition: usbh_def.h:274
uint16_t bcdUSB
Definition: usbh_def.h:241
#define USB_DESC_STRING
Definition: usbh_def.h:160
Header file for usbh_ctlreq.c.
#define USB_REQ_SET_INTERFACE
Definition: usbd_def.h:92
#define USB_DESC_TYPE_ENDPOINT
Definition: usbd_def.h:99
Definition: pbuf.h:108
#define LE16(addr)
Definition: usbh_def.h:69
#define USB_DESC_TYPE_INTERFACE
Definition: usbd_def.h:98
USBH_EpDescTypeDef Ep_Desc[USBH_MAX_NUM_ENDPOINTS]
Definition: usbh_def.h:281
uint8_t bDescriptorType
Definition: usbh_def.h:240
uint16_t wMaxPacketSize
Definition: usbh_def.h:265
uint8_t bInterfaceSubClass
Definition: usbh_def.h:278
#define USB_REQ_TYPE_STANDARD
Definition: usbd_def.h:73
uint8_t bAlternateSetting
Definition: usbh_def.h:275
USBH_StatusTypeDef USBH_Get_DevDesc(USBH_HandleTypeDef *phost, uint8_t length)
USBH_Get_DevDesc Issue Get Device Descriptor command to the device. Once the response received...
Definition: usbh_ctlreq.c:112
USBH_URBStateTypeDef
Definition: usbh_def.h:384
uint16_t w
Definition: usbh_def.h:204
USBH_URBStateTypeDef USBH_LL_GetURBState(USBH_HandleTypeDef *phost, uint8_t)
USBH_LL_GetURBState Get a URB state from the low level driver.
USBH_StatusTypeDef USBH_Get_StringDesc(USBH_HandleTypeDef *phost, uint8_t string_index, uint8_t *buff, uint16_t length)
USBH_Get_StringDesc Issues string Descriptor command to the device. Once the response received...
Definition: usbh_ctlreq.c:175
#define USB_LEN_CFG_DESC
Definition: usbd_def.h:59
uint8_t pipe_in
Definition: usbh_def.h:406
USBH_StatusTypeDef USBH_CtlReceiveData(USBH_HandleTypeDef *phost, uint8_t *buff, uint16_t length, uint8_t hc_num)
USBH_CtlReceiveData Receives the Device Response to the Setup Packet.
Definition: usbh_ioreq.c:159
USBH_StatusTypeDef USBH_SetAddress(USBH_HandleTypeDef *phost, uint8_t DeviceAddress)
USBH_SetAddress This command sets the address to the connected device.
Definition: usbh_ctlreq.c:236
USBH_StatusTypeDef
Definition: usbh_def.h:302
#define USB_DESC_TYPE_STRING
Definition: usbd_def.h:97
uint16_t idProduct
Definition: usbh_def.h:250
USBH_StatusTypeDef USBH_Get_CfgDesc(USBH_HandleTypeDef *phost, uint16_t length)
USBH_Get_CfgDesc Issues Configuration Descriptor to the device. Once the response received...
Definition: usbh_ctlreq.c:137
CTRL_StateTypeDef state
Definition: usbh_def.h:413
uint8_t pipe_out
Definition: usbh_def.h:407
uint16_t timer
Definition: usbh_def.h:411
uint8_t bNumEndpoints
Definition: usbh_def.h:276
uint8_t bInterfaceProtocol
Definition: usbh_def.h:279
osStatus osMessagePut(osMessageQId queue_id, uint32_t info, uint32_t millisec)
Put a Message to a Queue.
Definition: cmsis_os.c:951
uint8_t Data[USBH_MAX_DATA_BUFFER]
Definition: usbh_def.h:424
USBH_StatusTypeDef USBH_GetDescriptor(USBH_HandleTypeDef *phost, uint8_t req_type, uint16_t value_idx, uint8_t *buff, uint16_t length)
USBH_GetDescriptor Issues Descriptor command to the device. Once the response received, it parses the descriptor and updates the status.
Definition: usbh_ctlreq.c:204
USBH_DevDescTypeDef DevDesc
Definition: usbh_def.h:429
#define USB_REQ_CLEAR_FEATURE
Definition: usbd_def.h:84
uint16_t length
Definition: usbh_def.h:410
#define USB_REQ_SET_ADDRESS
Definition: usbd_def.h:86
uint8_t errorcount
Definition: usbh_def.h:414
USBH_StatusTypeDef USBH_SetCfg(USBH_HandleTypeDef *phost, uint16_t cfg_idx)
USBH_SetCfg The command sets the configuration value to the connected device.
Definition: usbh_ctlreq.c:260
#define FEATURE_SELECTOR_ENDPOINT
Definition: usbh_ctlreq.h:57
USBH_StatusTypeDef USBH_ClrFeature(USBH_HandleTypeDef *phost, uint8_t ep_num)
USBH_ClrFeature This request is used to clear or disable a specific feature.
Definition: usbh_ctlreq.c:308
uint16_t_uint8_t wIndex
Definition: usbh_def.h:224
#define USB_DESC_DEVICE
Definition: usbh_def.h:158
struct _USB_Setup::_SetupPkt_Struc b
uint8_t bDeviceProtocol
Definition: usbh_def.h:244
uint32_t d8[2]
Definition: usbh_def.h:217
uint16_t bcdDevice
Definition: usbh_def.h:251