STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
usbh_core.c
Go to the documentation of this file.
1 
28 /* Includes ------------------------------------------------------------------*/
29 
30 #include "usbh_core.h"
31 
32 
51 #define USBH_ADDRESS_DEFAULT 0
52 #define USBH_ADDRESS_ASSIGNED 1
53 #define USBH_MPS_DEFAULT 0x40
54 
77 static USBH_StatusTypeDef USBH_HandleEnum (USBH_HandleTypeDef *phost);
78 static void USBH_HandleSof (USBH_HandleTypeDef *phost);
79 static USBH_StatusTypeDef DeInitStateMachine(USBH_HandleTypeDef *phost);
80 
81 #if (USBH_USE_OS == 1)
82 static void USBH_Process_OS(void const * argument);
83 #endif
84 
92 USBH_StatusTypeDef USBH_Init(USBH_HandleTypeDef *phost, void (*pUsrFunc)(USBH_HandleTypeDef *phost, uint8_t ), uint8_t id)
93 {
94  /* Check whether the USB Host handle is valid */
95  if(phost == NULL)
96  {
97  USBH_ErrLog("Invalid Host handle");
98  return USBH_FAIL;
99  }
100 
101  /* Set DRiver ID */
102  phost->id = id;
103 
104  /* Unlink class*/
105  phost->pActiveClass = NULL;
106  phost->ClassNumber = 0;
107 
108  /* Restore default states and prepare EP0 */
109  DeInitStateMachine(phost);
110 
111  /* Assign User process */
112  if(pUsrFunc != NULL)
113  {
114  phost->pUser = pUsrFunc;
115  }
116 
117 #if (USBH_USE_OS == 1)
118 
119  /* Create USB Host Queue */
120  osMessageQDef(USBH_Queue, 10, uint16_t);
121  phost->os_event = osMessageCreate (osMessageQ(USBH_Queue), NULL);
122 
123  /*Create USB Host Task */
124 #if defined (USBH_PROCESS_STACK_SIZE)
125  osThreadDef(USBH_Thread, USBH_Process_OS, USBH_PROCESS_PRIO, 0, USBH_PROCESS_STACK_SIZE);
126 #else
127  osThreadDef(USBH_Thread, USBH_Process_OS, USBH_PROCESS_PRIO, 0, 8 * configMINIMAL_STACK_SIZE);
128 #endif
129  phost->thread = osThreadCreate (osThread(USBH_Thread), phost);
130 #endif
131 
132  /* Initialize low level driver */
133  USBH_LL_Init(phost);
134  return USBH_OK;
135 }
136 
144 {
145  DeInitStateMachine(phost);
146 
147  if(phost->pData != NULL)
148  {
149  phost->pActiveClass->pData = NULL;
150  USBH_LL_Stop(phost);
151  }
152 
153  return USBH_OK;
154 }
155 
162 static USBH_StatusTypeDef DeInitStateMachine(USBH_HandleTypeDef *phost)
163 {
164  uint32_t i = 0;
165 
166  /* Clear Pipes flags*/
167  for ( ; i < USBH_MAX_PIPES_NBR; i++)
168  {
169  phost->Pipes[i] = 0;
170  }
171 
172  for(i = 0; i< USBH_MAX_DATA_BUFFER; i++)
173  {
174  phost->device.Data[i] = 0;
175  }
176 
177  phost->gState = HOST_IDLE;
178  phost->EnumState = ENUM_IDLE;
179  phost->RequestState = CMD_SEND;
180  phost->Timer = 0;
181 
182  phost->Control.state = CTRL_SETUP;
184  phost->Control.errorcount = 0;
185 
187  phost->device.speed = USBH_SPEED_FULL;
188 
189  return USBH_OK;
190 }
191 
200 {
201  USBH_StatusTypeDef status = USBH_OK;
202 
203  if(pclass != 0)
204  {
206  {
207  /* link the class to the USB Host handle */
208  phost->pClass[phost->ClassNumber++] = pclass;
209  status = USBH_OK;
210  }
211  else
212  {
213  USBH_ErrLog("Max Class Number reached");
214  status = USBH_FAIL;
215  }
216  }
217  else
218  {
219  USBH_ErrLog("Invalid Class handle");
220  status = USBH_FAIL;
221  }
222 
223  return status;
224 }
225 
234 {
235  USBH_StatusTypeDef status = USBH_OK;
236 
237  if(interface < phost->device.CfgDesc.bNumInterfaces)
238  {
239  phost->device.current_interface = interface;
240  USBH_UsrLog ("Switching to Interface (#%d)", interface);
241  USBH_UsrLog ("Class : %xh", phost->device.CfgDesc.Itf_Desc[interface].bInterfaceClass );
242  USBH_UsrLog ("SubClass : %xh", phost->device.CfgDesc.Itf_Desc[interface].bInterfaceSubClass );
243  USBH_UsrLog ("Protocol : %xh", phost->device.CfgDesc.Itf_Desc[interface].bInterfaceProtocol );
244  }
245  else
246  {
247  USBH_ErrLog ("Cannot Select This Interface.");
248  status = USBH_FAIL;
249  }
250  return status;
251 }
252 
261 {
262  return (phost->device.CfgDesc.Itf_Desc[0].bInterfaceClass);
263 }
274 uint8_t USBH_FindInterface(USBH_HandleTypeDef *phost, uint8_t Class, uint8_t SubClass, uint8_t Protocol)
275 {
277  USBH_CfgDescTypeDef *pcfg ;
278  int8_t if_ix = 0;
279 
280  pif = (USBH_InterfaceDescTypeDef *)0;
281  pcfg = &phost->device.CfgDesc;
282 
283  while (if_ix < USBH_MAX_NUM_INTERFACES)
284  {
285  pif = &pcfg->Itf_Desc[if_ix];
286  if(((pif->bInterfaceClass == Class) || (Class == 0xFF))&&
287  ((pif->bInterfaceSubClass == SubClass) || (SubClass == 0xFF))&&
288  ((pif->bInterfaceProtocol == Protocol) || (Protocol == 0xFF)))
289  {
290  return if_ix;
291  }
292  if_ix++;
293  }
294  return 0xFF;
295 }
296 
306 uint8_t USBH_FindInterfaceIndex(USBH_HandleTypeDef *phost, uint8_t interface_number, uint8_t alt_settings)
307 {
309  USBH_CfgDescTypeDef *pcfg ;
310  int8_t if_ix = 0;
311 
312  pif = (USBH_InterfaceDescTypeDef *)0;
313  pcfg = &phost->device.CfgDesc;
314 
315  while (if_ix < USBH_MAX_NUM_INTERFACES)
316  {
317  pif = &pcfg->Itf_Desc[if_ix];
318  if((pif->bInterfaceNumber == interface_number) && (pif->bAlternateSetting == alt_settings))
319  {
320  return if_ix;
321  }
322  if_ix++;
323  }
324  return 0xFF;
325 }
326 
334 {
335  /* Start the low level driver */
336  USBH_LL_Start(phost);
337 
338  /* Activate VBUS on the port */
339  USBH_LL_DriverVBUS (phost, TRUE);
340 
341  return USBH_OK;
342 }
343 
351 {
352  /* Stop and cleanup the low level driver */
353  USBH_LL_Stop(phost);
354 
355  /* DeActivate VBUS on the port */
356  USBH_LL_DriverVBUS (phost, FALSE);
357 
358  /* FRee Control Pipes */
359  USBH_FreePipe (phost, phost->Control.pipe_in);
360  USBH_FreePipe (phost, phost->Control.pipe_out);
361 
362  return USBH_OK;
363 }
364 
372 {
373  /*Stop Host */
374  USBH_Stop(phost);
375 
376  /*Device has disconnected, so wait for 200 ms */
377  USBH_Delay(200);
378 
379  /* Set State machines in default state */
380  DeInitStateMachine(phost);
381 
382  /* Start again the host */
383  USBH_Start(phost);
384 
385 #if (USBH_USE_OS == 1)
386  osMessagePut ( phost->os_event, USBH_PORT_EVENT, 0);
387 #endif
388  return USBH_OK;
389 }
390 
398 {
400  uint8_t idx = 0;
401 
402  switch (phost->gState)
403  {
404  case HOST_IDLE :
405 
406  if (phost->device.is_connected)
407  {
408  /* Wait for 200 ms after connection */
410  USBH_Delay(200);
411  USBH_LL_ResetPort(phost);
412 #if (USBH_USE_OS == 1)
413  osMessagePut ( phost->os_event, USBH_PORT_EVENT, 0);
414 #endif
415  }
416  break;
417 
419  break;
420 
421  case HOST_DEV_ATTACHED :
422 
423  USBH_UsrLog("USB Device Attached");
424 
425  /* Wait for 100 ms after Reset */
426  USBH_Delay(100);
427 
428  phost->device.speed = USBH_LL_GetSpeed(phost);
429 
430  phost->gState = HOST_ENUMERATION;
431 
432  phost->Control.pipe_out = USBH_AllocPipe (phost, 0x00);
433  phost->Control.pipe_in = USBH_AllocPipe (phost, 0x80);
434 
435 
436  /* Open Control pipes */
437  USBH_OpenPipe (phost,
438  phost->Control.pipe_in,
439  0x80,
440  phost->device.address,
441  phost->device.speed,
443  phost->Control.pipe_size);
444 
445  /* Open Control pipes */
446  USBH_OpenPipe (phost,
447  phost->Control.pipe_out,
448  0x00,
449  phost->device.address,
450  phost->device.speed,
452  phost->Control.pipe_size);
453 
454 #if (USBH_USE_OS == 1)
455  osMessagePut ( phost->os_event, USBH_PORT_EVENT, 0);
456 #endif
457 
458  break;
459 
460  case HOST_ENUMERATION:
461  /* Check for enumeration status */
462  if ( USBH_HandleEnum(phost) == USBH_OK)
463  {
464  /* The function shall return USBH_OK when full enumeration is complete */
465  USBH_UsrLog ("Enumeration done.");
466  phost->device.current_interface = 0;
467  if(phost->device.DevDesc.bNumConfigurations == 1)
468  {
469  USBH_UsrLog ("This device has only 1 configuration.");
470  phost->gState = HOST_SET_CONFIGURATION;
471 
472  }
473  else
474  {
475  phost->gState = HOST_INPUT;
476  }
477 
478  }
479  break;
480 
481  case HOST_INPUT:
482  {
483  /* user callback for end of device basic enumeration */
484  if(phost->pUser != NULL)
485  {
486  phost->pUser(phost, HOST_USER_SELECT_CONFIGURATION);
488 
489 #if (USBH_USE_OS == 1)
490  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
491 #endif
492  }
493  }
494  break;
495 
497  /* set configuration */
498  if (USBH_SetCfg(phost, phost->device.CfgDesc.bConfigurationValue) == USBH_OK)
499  {
500  phost->gState = HOST_CHECK_CLASS;
501  USBH_UsrLog ("Default configuration set.");
502 
503  }
504 
505  break;
506 
507  case HOST_CHECK_CLASS:
508 
509  if(phost->ClassNumber == 0)
510  {
511  USBH_UsrLog ("No Class has been registered.");
512  }
513  else
514  {
515  phost->pActiveClass = NULL;
516 
517  for (idx = 0; idx < USBH_MAX_NUM_SUPPORTED_CLASS ; idx ++)
518  {
519  if(phost->pClass[idx]->ClassCode == phost->device.CfgDesc.Itf_Desc[0].bInterfaceClass)
520  {
521  phost->pActiveClass = phost->pClass[idx];
522  }
523  }
524 
525  if(phost->pActiveClass != NULL)
526  {
527  if(phost->pActiveClass->Init(phost)== USBH_OK)
528  {
529  phost->gState = HOST_CLASS_REQUEST;
530  USBH_UsrLog ("%s class started.", phost->pActiveClass->Name);
531 
532  /* Inform user that a class has been activated */
533  phost->pUser(phost, HOST_USER_CLASS_SELECTED);
534  }
535  else
536  {
537  phost->gState = HOST_ABORT_STATE;
538  USBH_UsrLog ("Device not supporting %s class.", phost->pActiveClass->Name);
539  }
540  }
541  else
542  {
543  phost->gState = HOST_ABORT_STATE;
544  USBH_UsrLog ("No registered class for this device.");
545  }
546  }
547 
548 #if (USBH_USE_OS == 1)
549  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
550 #endif
551  break;
552 
553  case HOST_CLASS_REQUEST:
554  /* process class standard control requests state machine */
555  if(phost->pActiveClass != NULL)
556  {
557  status = phost->pActiveClass->Requests(phost);
558 
559  if(status == USBH_OK)
560  {
561  phost->gState = HOST_CLASS;
562  }
563  }
564  else
565  {
566  phost->gState = HOST_ABORT_STATE;
567  USBH_ErrLog ("Invalid Class Driver.");
568 
569 #if (USBH_USE_OS == 1)
570  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
571 #endif
572  }
573 
574  break;
575  case HOST_CLASS:
576  /* process class state machine */
577  if(phost->pActiveClass != NULL)
578  {
579  phost->pActiveClass->BgndProcess(phost);
580  }
581  break;
582 
583  case HOST_DEV_DISCONNECTED :
584 
585  DeInitStateMachine(phost);
586 
587  /* Re-Initilaize Host for new Enumeration */
588  if(phost->pActiveClass != NULL)
589  {
590  phost->pActiveClass->DeInit(phost);
591  phost->pActiveClass = NULL;
592  }
593  break;
594 
595  case HOST_ABORT_STATE:
596  default :
597  break;
598  }
599  return USBH_OK;
600 }
601 
602 
609 static USBH_StatusTypeDef USBH_HandleEnum (USBH_HandleTypeDef *phost)
610 {
612 
613  switch (phost->EnumState)
614  {
615  case ENUM_IDLE:
616  /* Get Device Desc for only 1st 8 bytes : To get EP0 MaxPacketSize */
617  if ( USBH_Get_DevDesc(phost, 8) == USBH_OK)
618  {
620 
622 
623  /* modify control channels configuration for MaxPacket size */
624  USBH_OpenPipe (phost,
625  phost->Control.pipe_in,
626  0x80,
627  phost->device.address,
628  phost->device.speed,
630  phost->Control.pipe_size);
631 
632  /* Open Control pipes */
633  USBH_OpenPipe (phost,
634  phost->Control.pipe_out,
635  0x00,
636  phost->device.address,
637  phost->device.speed,
639  phost->Control.pipe_size);
640 
641  }
642  break;
643 
645  /* Get FULL Device Desc */
647  {
648  USBH_UsrLog("PID: %xh", phost->device.DevDesc.idProduct );
649  USBH_UsrLog("VID: %xh", phost->device.DevDesc.idVendor );
650 
651  phost->EnumState = ENUM_SET_ADDR;
652 
653  }
654  break;
655 
656  case ENUM_SET_ADDR:
657  /* set address */
659  {
660  USBH_Delay(2);
662 
663  /* user callback for device address assigned */
664  USBH_UsrLog("Address (#%d) assigned.", phost->device.address);
665  phost->EnumState = ENUM_GET_CFG_DESC;
666 
667  /* modify control channels to update device address */
668  USBH_OpenPipe (phost,
669  phost->Control.pipe_in,
670  0x80,
671  phost->device.address,
672  phost->device.speed,
674  phost->Control.pipe_size);
675 
676  /* Open Control pipes */
677  USBH_OpenPipe (phost,
678  phost->Control.pipe_out,
679  0x00,
680  phost->device.address,
681  phost->device.speed,
683  phost->Control.pipe_size);
684  }
685  break;
686 
687  case ENUM_GET_CFG_DESC:
688  /* get standard configuration descriptor */
689  if ( USBH_Get_CfgDesc(phost,
691  {
693  }
694  break;
695 
697  /* get FULL config descriptor (config, interface, endpoints) */
698  if (USBH_Get_CfgDesc(phost,
699  phost->device.CfgDesc.wTotalLength) == USBH_OK)
700  {
702  }
703  break;
704 
706  if (phost->device.DevDesc.iManufacturer != 0)
707  { /* Check that Manufacturer String is available */
708 
709  if ( USBH_Get_StringDesc(phost,
710  phost->device.DevDesc.iManufacturer,
711  phost->device.Data ,
712  0xff) == USBH_OK)
713  {
714  /* User callback for Manufacturing string */
715  USBH_UsrLog("Manufacturer : %s", (char *)phost->device.Data);
717 
718 #if (USBH_USE_OS == 1)
719  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
720 #endif
721  }
722  }
723  else
724  {
725  USBH_UsrLog("Manufacturer : N/A");
727 #if (USBH_USE_OS == 1)
728  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
729 #endif
730  }
731  break;
732 
734  if (phost->device.DevDesc.iProduct != 0)
735  { /* Check that Product string is available */
736  if ( USBH_Get_StringDesc(phost,
737  phost->device.DevDesc.iProduct,
738  phost->device.Data,
739  0xff) == USBH_OK)
740  {
741  /* User callback for Product string */
742  USBH_UsrLog("Product : %s", (char *)phost->device.Data);
744  }
745  }
746  else
747  {
748  USBH_UsrLog("Product : N/A");
750 #if (USBH_USE_OS == 1)
751  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
752 #endif
753  }
754  break;
755 
757  if (phost->device.DevDesc.iSerialNumber != 0)
758  { /* Check that Serial number string is available */
759  if ( USBH_Get_StringDesc(phost,
760  phost->device.DevDesc.iSerialNumber,
761  phost->device.Data,
762  0xff) == USBH_OK)
763  {
764  /* User callback for Serial number string */
765  USBH_UsrLog("Serial Number : %s", (char *)phost->device.Data);
766  Status = USBH_OK;
767  }
768  }
769  else
770  {
771  USBH_UsrLog("Serial Number : N/A");
772  Status = USBH_OK;
773 #if (USBH_USE_OS == 1)
774  osMessagePut ( phost->os_event, USBH_STATE_CHANGED_EVENT, 0);
775 #endif
776  }
777  break;
778 
779  default:
780  break;
781  }
782  return Status;
783 }
784 
791 void USBH_LL_SetTimer (USBH_HandleTypeDef *phost, uint32_t time)
792 {
793  phost->Timer = time;
794 }
802 {
803  phost->Timer ++;
804  USBH_HandleSof(phost);
805 }
806 
813 void USBH_HandleSof (USBH_HandleTypeDef *phost)
814 {
815  if((phost->gState == HOST_CLASS)&&(phost->pActiveClass != NULL))
816  {
817  phost->pActiveClass->SOFProcess(phost);
818  }
819 }
827 {
828  if(phost->gState == HOST_IDLE )
829  {
830  phost->device.is_connected = 1;
831 
832  if(phost->pUser != NULL)
833  {
834  phost->pUser(phost, HOST_USER_CONNECTION);
835  }
836  }
837  else if(phost->gState == HOST_DEV_WAIT_FOR_ATTACHMENT )
838  {
839  phost->gState = HOST_DEV_ATTACHED ;
840  }
841 #if (USBH_USE_OS == 1)
842  osMessagePut ( phost->os_event, USBH_PORT_EVENT, 0);
843 #endif
844 
845  return USBH_OK;
846 }
847 
855 {
856  /*Stop Host */
857  USBH_LL_Stop(phost);
858 
859  /* FRee Control Pipes */
860  USBH_FreePipe (phost, phost->Control.pipe_in);
861  USBH_FreePipe (phost, phost->Control.pipe_out);
862 
863  phost->device.is_connected = 0;
864 
865  if(phost->pUser != NULL)
866  {
867  phost->pUser(phost, HOST_USER_DISCONNECTION);
868  }
869  USBH_UsrLog("USB Device disconnected");
870 
871  /* Start the low level driver */
872  USBH_LL_Start(phost);
873 
874  phost->gState = HOST_DEV_DISCONNECTED;
875 
876 #if (USBH_USE_OS == 1)
877  osMessagePut ( phost->os_event, USBH_PORT_EVENT, 0);
878 #endif
879 
880  return USBH_OK;
881 }
882 
883 
884 #if (USBH_USE_OS == 1)
885 
890 static void USBH_Process_OS(void const * argument)
891 {
892  osEvent event;
893 
894  for(;;)
895  {
896  event = osMessageGet(((USBH_HandleTypeDef *)argument)->os_event, osWaitForever );
897 
898  if( event.status == osEventMessage )
899  {
900  USBH_Process((USBH_HandleTypeDef *)argument);
901  }
902  }
903 }
904 
911 USBH_StatusTypeDef USBH_LL_NotifyURBChange (USBH_HandleTypeDef *phost)
912 {
913  osMessagePut ( phost->os_event, USBH_URB_EVENT, 0);
914  return USBH_OK;
915 }
916 #endif
917 
933 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
#define USBH_ErrLog(...)
CMD_StateTypeDef RequestState
Definition: usbh_def.h:454
USBH_StatusTypeDef(* DeInit)(struct _USBH_HandleTypeDef *phost)
Definition: usbh_def.h:442
Header file for usbh_core.c.
const char * Name
Definition: usbh_def.h:439
#define USBH_MAX_NUM_SUPPORTED_CLASS
void USBH_LL_SetTimer(USBH_HandleTypeDef *phost, uint32_t time)
USBH_LL_SetTimer Set the initial Host Timer tick.
Definition: usbh_core.c:791
#define USBH_MAX_PIPES_NBR
Definition: usbh_def.h:180
USBH_DeviceTypeDef device
Definition: usbh_def.h:456
USBH_StatusTypeDef USBH_ReEnumerate(USBH_HandleTypeDef *phost)
HCD_ReEnumerate Perform a new Enumeration phase.
Definition: usbh_core.c:371
USBH_StatusTypeDef USBH_OpenPipe(USBH_HandleTypeDef *phost, uint8_t ch_num, uint8_t epnum, uint8_t dev_address, uint8_t speed, uint8_t ep_type, uint16_t mps)
USBH_Open_Pipe Open a pipe.
Definition: usbh_pipes.c:93
uint32_t idx
Definition: lcd_log.c:247
__IO uint32_t Timer
Definition: usbh_def.h:461
USBH_StatusTypeDef USBH_SetCfg(USBH_HandleTypeDef *phost, uint16_t configuration_value)
USBH_SetCfg The command sets the configuration value to the connected device.
Definition: usbh_ctlreq.c:260
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
uint8_t iSerialNumber
Definition: usbh_def.h:254
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
uint8_t bNumConfigurations
Definition: usbh_def.h:255
uint8_t USBH_AllocPipe(USBH_HandleTypeDef *phost, uint8_t ep_addr)
USBH_Alloc_Pipe Allocate a new Pipe.
Definition: usbh_pipes.c:138
uint8_t USBH_GetActiveClass(USBH_HandleTypeDef *phost)
USBH_GetActiveClass Return Device Class.
Definition: usbh_core.c:260
function completed; message event occurred.
Definition: cmsis_os.h:255
USBH_StatusTypeDef USBH_LL_DriverVBUS(USBH_HandleTypeDef *phost, uint8_t)
USBH_LL_DriverVBUS Drive VBUS.
uint8_t ClassCode
Definition: usbh_def.h:440
uint8_t bInterfaceClass
Definition: usbh_def.h:277
#define USB_CONFIGURATION_DESC_SIZE
Definition: usbh_def.h:151
uint8_t USBH_FindInterfaceIndex(USBH_HandleTypeDef *phost, uint8_t interface_number, uint8_t alt_settings)
USBH_FindInterfaceIndex Find the interface index for a specific class interface and alternate setting...
Definition: usbh_core.c:306
USBH_StatusTypeDef USBH_RegisterClass(USBH_HandleTypeDef *phost, USBH_ClassTypeDef *pclass)
USBH_RegisterClass Link class driver to Host Core.
Definition: usbh_core.c:199
uint32_t ClassNumber
Definition: usbh_def.h:459
void USBH_Delay(uint32_t Delay)
USBH_Delay Delay routine for the USB Host Library.
USBH_StatusTypeDef(* SOFProcess)(struct _USBH_HandleTypeDef *phost)
Definition: usbh_def.h:445
uint8_t iManufacturer
Definition: usbh_def.h:252
#define osMessageQDef(name, queue_sz, type)
Create a Message Queue Definition.
Definition: cmsis_os.h:753
#define USBH_DEVICE_ADDRESS
Definition: usbh_def.h:185
uint8_t bMaxPacketSize
Definition: usbh_def.h:248
USBH_StatusTypeDef USBH_FreePipe(USBH_HandleTypeDef *phost, uint8_t idx)
USBH_Free_Pipe Free the USB Pipe.
Definition: usbh_pipes.c:158
#define osMessageQ(name)
Access a Message Queue Definition.
Definition: cmsis_os.h:762
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 USBH_LL_Init(USBH_HandleTypeDef *phost)
USBH_LL_Init Initialize the Low Level portion of the Host driver.
void(* pUser)(struct _USBH_HandleTypeDef *pHandle, uint8_t id)
Definition: usbh_def.h:464
uint16_t idVendor
Definition: usbh_def.h:249
#define HOST_USER_CONNECTION
Definition: usbh_core.h:67
USBH_StatusTypeDef(* Init)(struct _USBH_HandleTypeDef *phost)
Definition: usbh_def.h:441
USBH_StatusTypeDef USBH_LL_Connect(USBH_HandleTypeDef *phost)
USBH_LL_Connect Handle USB Host connexion event.
Definition: usbh_core.c:826
USBH_InterfaceDescTypeDef Itf_Desc[USBH_MAX_NUM_INTERFACES]
Definition: usbh_def.h:296
uint8_t iProduct
Definition: usbh_def.h:253
USBH_SpeedTypeDef USBH_LL_GetSpeed(USBH_HandleTypeDef *phost)
USBH_LL_GetSpeed Return the USB Host Speed from the Low Level Driver.
USBH_StatusTypeDef(* Requests)(struct _USBH_HandleTypeDef *phost)
Definition: usbh_def.h:443
#define USBH_EP_CONTROL
Definition: usbh_ioreq.h:61
ENUM_StateTypeDef EnumState
Definition: usbh_def.h:453
#define osThreadDef(name, thread, priority, instances, stacksz)
Definition: cmsis_os.h:445
USBH_CfgDescTypeDef CfgDesc
Definition: usbh_def.h:430
USBH_StatusTypeDef USBH_Stop(USBH_HandleTypeDef *phost)
USBH_Stop Stop the USB Host Core.
Definition: usbh_core.c:350
USBH_StatusTypeDef USBH_LL_Stop(USBH_HandleTypeDef *phost)
USBH_LL_Stop Stop the Low Level portion of the Host driver.
#define NULL
Definition: usbd_def.h:53
USBH_CtrlTypeDef Control
Definition: usbh_def.h:455
#define USBH_MAX_NUM_INTERFACES
osStatus status
status code: event or error information
Definition: cmsis_os.h:384
#define __IO
Definition: core_cm0.h:213
uint8_t bInterfaceNumber
Definition: usbh_def.h:274
#define FALSE
Definition: usbh_def.h:57
osMessageQId osMessageCreate(const osMessageQDef_t *queue_def, osThreadId thread_id)
Create and Initialize a Message Queue.
Definition: cmsis_os.c:936
#define USBH_ADDRESS_DEFAULT
Definition: usbh_core.c:51
#define osWaitForever
wait forever timeout value
Definition: cmsis_os.h:248
#define HOST_USER_DISCONNECTION
Definition: usbh_core.h:68
uint8_t USBH_FindInterface(USBH_HandleTypeDef *phost, uint8_t Class, uint8_t SubClass, uint8_t Protocol)
USBH_FindInterface Find the interface index for a specific class.
Definition: usbh_core.c:274
uint8_t bInterfaceSubClass
Definition: usbh_def.h:278
uint8_t bAlternateSetting
Definition: usbh_def.h:275
USBH_StatusTypeDef USBH_LL_Disconnect(USBH_HandleTypeDef *phost)
USBH_LL_Disconnect Handle USB Host disconnection event.
Definition: usbh_core.c:854
osThreadId osThreadCreate(const osThreadDef_t *thread_def, void *argument)
Create a thread and add it to Active Threads and set it to state READY.
Definition: cmsis_os.c:204
#define TRUE
Definition: usbh_def.h:61
#define USBH_MPS_DEFAULT
Definition: usbh_core.c:53
uint32_t Pipes[15]
Definition: usbh_def.h:460
USBH_StatusTypeDef USBH_Start(USBH_HandleTypeDef *phost)
USBH_Start Start the USB Host Core.
Definition: usbh_core.c:333
#define HOST_USER_CLASS_SELECTED
Definition: usbh_core.h:66
#define USBH_MAX_DATA_BUFFER
uint8_t pipe_in
Definition: usbh_def.h:406
USBH_StatusTypeDef USBH_LL_ResetPort(USBH_HandleTypeDef *phost)
USBH_LL_ResetPort Reset the Host Port of the Low Level Driver.
USBH_StatusTypeDef
Definition: usbh_def.h:302
__IO HOST_StateTypeDef gState
Definition: usbh_def.h:452
uint16_t idProduct
Definition: usbh_def.h:250
uint8_t current_interface
Definition: usbh_def.h:428
CTRL_StateTypeDef state
Definition: usbh_def.h:413
uint8_t pipe_out
Definition: usbh_def.h:407
uint8_t pipe_size
Definition: usbh_def.h:408
#define USBH_UsrLog(...)
USBH_StatusTypeDef(* BgndProcess)(struct _USBH_HandleTypeDef *phost)
Definition: usbh_def.h:444
uint8_t bInterfaceProtocol
Definition: usbh_def.h:279
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
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
#define HOST_USER_SELECT_CONFIGURATION
Definition: usbh_core.h:64
#define USB_DEVICE_DESC_SIZE
Definition: usbh_def.h:150
USBH_StatusTypeDef USBH_DeInit(USBH_HandleTypeDef *phost)
HCD_Init De-Initialize the Host portion of the driver.
Definition: usbh_core.c:143
USBH_ClassTypeDef * pClass[USBH_MAX_NUM_SUPPORTED_CLASS]
Definition: usbh_def.h:457
USBH_DevDescTypeDef DevDesc
Definition: usbh_def.h:429
#define configMINIMAL_STACK_SIZE
USBH_StatusTypeDef USBH_Process(USBH_HandleTypeDef *phost)
USBH_Process Background process of the USB Core.
Definition: usbh_core.c:397
osEvent osMessageGet(osMessageQId queue_id, uint32_t millisec)
Get a Message or Wait for a Message from a Queue.
Definition: cmsis_os.c:983
#define osThread(name)
Definition: cmsis_os.h:454
USBH_ClassTypeDef * pActiveClass
Definition: usbh_def.h:458
uint8_t errorcount
Definition: usbh_def.h:414
USBH_StatusTypeDef USBH_Init(USBH_HandleTypeDef *phost, void(*pUsrFunc)(USBH_HandleTypeDef *phost, uint8_t), uint8_t id)
HCD_Init Initialize the HOST Core.
Definition: usbh_core.c:92
void USBH_LL_IncTimer(USBH_HandleTypeDef *phost)
USBH_LL_IncTimer Increment Host Timer tick.
Definition: usbh_core.c:801
USBH_StatusTypeDef USBH_SelectInterface(USBH_HandleTypeDef *phost, uint8_t interface)
USBH_SelectInterface Select current interface.
Definition: usbh_core.c:233
__IO uint8_t is_connected
Definition: usbh_def.h:427
USBH_StatusTypeDef USBH_LL_Start(USBH_HandleTypeDef *phost)
USBH_LL_Start Start the Low Level portion of the Host driver.