Prusa MINI Firmware overview
USBH_CORE_Private_Functions
Collaboration diagram for USBH_CORE_Private_Functions:

Functions

static USBH_StatusTypeDef USBH_HandleEnum (USBH_HandleTypeDef *phost)
 USBH_HandleEnum This function includes the complete enumeration process. More...
 
static void USBH_HandleSof (USBH_HandleTypeDef *phost)
 USBH_HandleSof Call SOF process. More...
 
static USBH_StatusTypeDef DeInitStateMachine (USBH_HandleTypeDef *phost)
 DeInitStateMachine De-Initialize the Host state machine. More...
 
USBH_StatusTypeDef USBH_Init (USBH_HandleTypeDef *phost, void(*pUsrFunc)(USBH_HandleTypeDef *phost, uint8_t), uint8_t id)
 HCD_Init Initialize the HOST Core. More...
 
USBH_StatusTypeDef USBH_DeInit (USBH_HandleTypeDef *phost)
 HCD_Init De-Initialize the Host portion of the driver. More...
 
USBH_StatusTypeDef USBH_RegisterClass (USBH_HandleTypeDef *phost, USBH_ClassTypeDef *pclass)
 USBH_RegisterClass Link class driver to Host Core. More...
 
USBH_StatusTypeDef USBH_SelectInterface (USBH_HandleTypeDef *phost, uint8_t interface)
 USBH_SelectInterface Select current interface. More...
 
uint8_t USBH_GetActiveClass (USBH_HandleTypeDef *phost)
 USBH_GetActiveClass Return Device Class. More...
 
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. More...
 
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 number. More...
 
USBH_StatusTypeDef USBH_Start (USBH_HandleTypeDef *phost)
 USBH_Start Start the USB Host Core. More...
 
USBH_StatusTypeDef USBH_Stop (USBH_HandleTypeDef *phost)
 USBH_Stop Stop the USB Host Core. More...
 
USBH_StatusTypeDef USBH_ReEnumerate (USBH_HandleTypeDef *phost)
 HCD_ReEnumerate Perform a new Enumeration phase. More...
 
USBH_StatusTypeDef USBH_Process (USBH_HandleTypeDef *phost)
 USBH_Process Background process of the USB Core. More...
 
void USBH_LL_SetTimer (USBH_HandleTypeDef *phost, uint32_t time)
 USBH_LL_SetTimer Set the initial Host Timer tick. More...
 
void USBH_LL_IncTimer (USBH_HandleTypeDef *phost)
 USBH_LL_IncTimer Increment Host Timer tick. More...
 
USBH_StatusTypeDef USBH_LL_Connect (USBH_HandleTypeDef *phost)
 USBH_LL_Connect Handle USB Host connexion event. More...
 
USBH_StatusTypeDef USBH_LL_Disconnect (USBH_HandleTypeDef *phost)
 USBH_LL_Disconnect Handle USB Host disconnection event. More...
 

Detailed Description

Function Documentation

◆ USBH_HandleEnum()

static USBH_StatusTypeDef USBH_HandleEnum ( USBH_HandleTypeDef phost)
static

USBH_HandleEnum This function includes the complete enumeration process.

Parameters
phostHost Handle
Return values
USBH_Status
610 {
611  USBH_StatusTypeDef Status = USBH_BUSY;
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,
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,
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 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBH_HandleSof()

void USBH_HandleSof ( USBH_HandleTypeDef phost)
static

USBH_HandleSof Call SOF process.

Parameters
phostHost Handle
Return values
None
814 {
815  if((phost->gState == HOST_CLASS)&&(phost->pActiveClass != NULL))
816  {
817  phost->pActiveClass->SOFProcess(phost);
818  }
819 }
Here is the caller graph for this function:

◆ DeInitStateMachine()

static USBH_StatusTypeDef DeInitStateMachine ( USBH_HandleTypeDef phost)
static

DeInitStateMachine De-Initialize the Host state machine.

Parameters
phostHost Handle
Return values
USBHStatus
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 }
Here is the caller graph for this function:

◆ USBH_Init()

USBH_StatusTypeDef USBH_Init ( USBH_HandleTypeDef phost,
void(*)(USBH_HandleTypeDef *phost, uint8_t pUsrFunc,
uint8_t  id 
)

HCD_Init Initialize the HOST Core.

Parameters
phostHost Handle
pUsrFuncUser Callback
Return values
USBHStatus
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 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBH_DeInit()

USBH_StatusTypeDef USBH_DeInit ( USBH_HandleTypeDef phost)

HCD_Init De-Initialize the Host portion of the driver.

Parameters
phostHost Handle
Return values
USBHStatus
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 }
Here is the call graph for this function:

◆ USBH_RegisterClass()

USBH_StatusTypeDef USBH_RegisterClass ( USBH_HandleTypeDef phost,
USBH_ClassTypeDef pclass 
)

USBH_RegisterClass Link class driver to Host Core.

Parameters
phost: Host Handle
pclassClass handle
Return values
USBHStatus
200 {
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 }
Here is the caller graph for this function:

◆ USBH_SelectInterface()

USBH_StatusTypeDef USBH_SelectInterface ( USBH_HandleTypeDef phost,
uint8_t  interface 
)

USBH_SelectInterface Select current interface.

Parameters
phostHost Handle
interfaceInterface number
Return values
USBHStatus
234 {
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 }
Here is the caller graph for this function:

◆ USBH_GetActiveClass()

uint8_t USBH_GetActiveClass ( USBH_HandleTypeDef phost)

USBH_GetActiveClass Return Device Class.

Parameters
phostHost Handle
interfaceInterface index
Return values
ClassCode
261 {
262  return (phost->device.CfgDesc.Itf_Desc[0].bInterfaceClass);
263 }

◆ USBH_FindInterface()

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.

Parameters
phostHost Handle
ClassClass code
SubClassSubClass code
ProtocolProtocol code
Return values
interfaceindex in the configuration structure
Note
: (1)interface index 0xFF means interface index not found
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 }
Here is the caller graph for this function:

◆ USBH_FindInterfaceIndex()

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 number.

Parameters
phostHost Handle
interface_numberinterface number
alt_settings: alternate setting number
Return values
interfaceindex in the configuration structure
Note
: (1)interface index 0xFF means interface index not found
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 }

◆ USBH_Start()

USBH_StatusTypeDef USBH_Start ( USBH_HandleTypeDef phost)

USBH_Start Start the USB Host Core.

Parameters
phostHost Handle
Return values
USBHStatus
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 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBH_Stop()

USBH_StatusTypeDef USBH_Stop ( USBH_HandleTypeDef phost)

USBH_Stop Stop the USB Host Core.

Parameters
phostHost Handle
Return values
USBHStatus
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 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBH_ReEnumerate()

USBH_StatusTypeDef USBH_ReEnumerate ( USBH_HandleTypeDef phost)

HCD_ReEnumerate Perform a new Enumeration phase.

Parameters
phostHost Handle
Return values
USBHStatus
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 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBH_Process()

USBH_StatusTypeDef USBH_Process ( USBH_HandleTypeDef phost)

USBH_Process Background process of the USB Core.

Parameters
phostHost Handle
Return values
USBHStatus
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.");
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 }
Here is the call graph for this function:

◆ USBH_LL_SetTimer()

void USBH_LL_SetTimer ( USBH_HandleTypeDef phost,
uint32_t  time 
)

USBH_LL_SetTimer Set the initial Host Timer tick.

Parameters
phostHost Handle
Return values
None
792 {
793  phost->Timer = time;
794 }
Here is the caller graph for this function:

◆ USBH_LL_IncTimer()

void USBH_LL_IncTimer ( USBH_HandleTypeDef phost)

USBH_LL_IncTimer Increment Host Timer tick.

Parameters
phostHost Handle
Return values
None
802 {
803  phost->Timer ++;
804  USBH_HandleSof(phost);
805 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBH_LL_Connect()

USBH_StatusTypeDef USBH_LL_Connect ( USBH_HandleTypeDef phost)

USBH_LL_Connect Handle USB Host connexion event.

Parameters
phostHost Handle
Return values
USBH_Status
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 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBH_LL_Disconnect()

USBH_StatusTypeDef USBH_LL_Disconnect ( USBH_HandleTypeDef phost)

USBH_LL_Disconnect Handle USB Host disconnection event.

Parameters
phostHost Handle
Return values
USBH_Status
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 }
Here is the call graph for this function:
Here is the caller graph for this function:
_DeviceDescriptor::idVendor
uint16_t idVendor
Definition: usbh_def.h:249
HOST_CHECK_CLASS
Definition: usbh_def.h:337
USBH_LL_GetSpeed
USBH_SpeedTypeDef USBH_LL_GetSpeed(USBH_HandleTypeDef *phost)
Return the USB host speed from the low level driver.
Definition: usbh_conf.c:314
HOST_USER_SELECT_CONFIGURATION
#define HOST_USER_SELECT_CONFIGURATION
Definition: usbh_core.h:64
USBH_SetCfg
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
ENUM_SET_ADDR
Definition: usbh_def.h:348
osThreadDef
#define osThreadDef(name, thread, priority, instances, stacksz)
Definition: cmsis_os.h:468
USBH_DeviceTypeDef::current_interface
uint8_t current_interface
Definition: usbh_def.h:428
USBH_Get_CfgDesc
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
_ConfigurationDescriptor::Itf_Desc
USBH_InterfaceDescTypeDef Itf_Desc[USBH_MAX_NUM_INTERFACES]
Definition: usbh_def.h:296
USBH_HandleEnum
static USBH_StatusTypeDef USBH_HandleEnum(USBH_HandleTypeDef *phost)
USBH_HandleEnum This function includes the complete enumeration process.
Definition: usbh_core.c:609
USBH_Start
USBH_StatusTypeDef USBH_Start(USBH_HandleTypeDef *phost)
USBH_Start Start the USB Host Core.
Definition: usbh_core.c:333
HOST_USER_DISCONNECTION
#define HOST_USER_DISCONNECTION
Definition: usbh_core.h:68
USBH_Delay
void USBH_Delay(uint32_t Delay)
Delay routine for the USB Host Library.
Definition: usbh_conf.c:601
_USBH_HandleTypeDef::RequestState
CMD_StateTypeDef RequestState
Definition: usbh_def.h:454
HOST_INPUT
Definition: usbh_def.h:335
USBH_DeviceTypeDef::Data
uint8_t Data[USBH_MAX_DATA_BUFFER]
Definition: usbh_def.h:424
USBH_SetAddress
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_DeviceTypeDef::DevDesc
USBH_DevDescTypeDef DevDesc
Definition: usbh_def.h:429
_InterfaceDescriptor::bInterfaceNumber
uint8_t bInterfaceNumber
Definition: usbh_def.h:274
USBH_ErrLog
#define USBH_ErrLog(...)
Definition: usbh_conf.h:176
USBH_Get_StringDesc
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
USBH_ClassTypeDef::Requests
USBH_StatusTypeDef(* Requests)(struct _USBH_HandleTypeDef *phost)
Definition: usbh_def.h:443
USBH_LL_DriverVBUS
USBH_StatusTypeDef USBH_LL_DriverVBUS(USBH_HandleTypeDef *phost, uint8_t)
Drive VBUS.
Definition: usbh_conf.c:532
i
uint8_t i
Definition: screen_test_graph.c:72
ENUM_GET_FULL_CFG_DESC
Definition: usbh_def.h:350
USBH_ClassTypeDef::BgndProcess
USBH_StatusTypeDef(* BgndProcess)(struct _USBH_HandleTypeDef *phost)
Definition: usbh_def.h:444
_ConfigurationDescriptor::bConfigurationValue
uint8_t bConfigurationValue
Definition: usbh_def.h:292
HOST_DEV_DISCONNECTED
Definition: usbh_def.h:331
HOST_CLASS_REQUEST
Definition: usbh_def.h:334
USB_CONFIGURATION_DESC_SIZE
#define USB_CONFIGURATION_DESC_SIZE
Definition: usbh_def.h:151
_USBH_HandleTypeDef::Timer
__IO uint32_t Timer
Definition: usbh_def.h:461
HOST_USER_CONNECTION
#define HOST_USER_CONNECTION
Definition: usbh_core.h:67
_DeviceDescriptor::iManufacturer
uint8_t iManufacturer
Definition: usbh_def.h:252
HOST_ENUMERATION
Definition: usbh_def.h:333
NULL
#define NULL
Definition: usbd_def.h:53
USBH_ClassTypeDef::pData
void * pData
Definition: usbh_def.h:446
_USBH_HandleTypeDef::Control
USBH_CtrlTypeDef Control
Definition: usbh_def.h:455
USBH_LL_ResetPort
USBH_StatusTypeDef USBH_LL_ResetPort(USBH_HandleTypeDef *phost)
Reset the Host port of the low level driver.
Definition: usbh_conf.c:342
_InterfaceDescriptor
Definition: usbh_def.h:270
USBH_DeviceTypeDef::address
uint8_t address
Definition: usbh_def.h:425
USBH_LL_Stop
USBH_StatusTypeDef USBH_LL_Stop(USBH_HandleTypeDef *phost)
Stop the low level portion of the host driver.
Definition: usbh_conf.c:283
createSpeedLookupTable.default
default
Definition: createSpeedLookupTable.py:15
USBH_SPEED_FULL
Definition: usbh_def.h:320
_USBH_HandleTypeDef::id
uint8_t id
Definition: usbh_def.h:462
HOST_DEV_ATTACHED
Definition: usbh_def.h:330
HOST_IDLE
Definition: usbh_def.h:328
HOST_DEV_WAIT_FOR_ATTACHMENT
Definition: usbh_def.h:329
USBH_FreePipe
USBH_StatusTypeDef USBH_FreePipe(USBH_HandleTypeDef *phost, uint8_t idx)
USBH_Free_Pipe Free the USB Pipe.
Definition: usbh_pipes.c:158
HOST_ABORT_STATE
Definition: usbh_def.h:340
USBH_ClassTypeDef::SOFProcess
USBH_StatusTypeDef(* SOFProcess)(struct _USBH_HandleTypeDef *phost)
Definition: usbh_def.h:445
USBH_DeviceTypeDef::CfgDesc
USBH_CfgDescTypeDef CfgDesc
Definition: usbh_def.h:430
USBH_ADDRESS_DEFAULT
#define USBH_ADDRESS_DEFAULT
Definition: usbh_core.c:51
_DeviceDescriptor::bNumConfigurations
uint8_t bNumConfigurations
Definition: usbh_def.h:255
USBH_OpenPipe
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
USBH_LL_Start
USBH_StatusTypeDef USBH_LL_Start(USBH_HandleTypeDef *phost)
Start the low level portion of the host driver.
Definition: usbh_conf.c:252
ENUM_IDLE
Definition: usbh_def.h:346
CMD_SEND
Definition: usbh_def.h:380
USBH_PROCESS_STACK_SIZE
#define USBH_PROCESS_STACK_SIZE
Definition: usbh_conf.h:133
USBH_Get_DevDesc
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
ENUM_GET_MFC_STRING_DESC
Definition: usbh_def.h:351
TRUE
#define TRUE
Definition: usbh_def.h:61
ENUM_GET_SERIALNUM_STRING_DESC
Definition: usbh_def.h:353
USBH_ClassTypeDef::ClassCode
uint8_t ClassCode
Definition: usbh_def.h:440
USBH_MPS_DEFAULT
#define USBH_MPS_DEFAULT
Definition: usbh_core.c:53
USBH_MAX_NUM_SUPPORTED_CLASS
#define USBH_MAX_NUM_SUPPORTED_CLASS
Definition: usbh_conf.h:111
USBH_OK
Definition: usbh_def.h:304
configMINIMAL_STACK_SIZE
#define configMINIMAL_STACK_SIZE
Definition: FreeRTOSConfig.h:111
osMessagePut
osStatus osMessagePut(osMessageQId queue_id, uint32_t info, uint32_t millisec)
Put a Message to a Queue.
Definition: cmsis_os.c:1113
USBH_STATE_CHANGED_EVENT
Definition: usbh_def.h:399
_ConfigurationDescriptor
Definition: usbh_def.h:286
USBH_Stop
USBH_StatusTypeDef USBH_Stop(USBH_HandleTypeDef *phost)
USBH_Stop Stop the USB Host Core.
Definition: usbh_core.c:350
ENUM_GET_FULL_DEV_DESC
Definition: usbh_def.h:347
_USBH_HandleTypeDef::device
USBH_DeviceTypeDef device
Definition: usbh_def.h:456
USBH_DeviceTypeDef::speed
uint8_t speed
Definition: usbh_def.h:426
USBH_DEVICE_ADDRESS
#define USBH_DEVICE_ADDRESS
Definition: usbh_def.h:185
USBH_DeviceTypeDef::is_connected
__IO uint8_t is_connected
Definition: usbh_def.h:427
USBH_CtrlTypeDef::state
CTRL_StateTypeDef state
Definition: usbh_def.h:413
USBH_CtrlTypeDef::pipe_size
uint8_t pipe_size
Definition: usbh_def.h:408
_USBH_HandleTypeDef::Pipes
uint32_t Pipes[15]
Definition: usbh_def.h:460
ENUM_GET_PRODUCT_STRING_DESC
Definition: usbh_def.h:352
USBH_ClassTypeDef::DeInit
USBH_StatusTypeDef(* DeInit)(struct _USBH_HandleTypeDef *phost)
Definition: usbh_def.h:442
USBH_PROCESS_PRIO
#define USBH_PROCESS_PRIO
Definition: usbh_conf.h:132
_DeviceDescriptor::iProduct
uint8_t iProduct
Definition: usbh_def.h:253
USBH_ClassTypeDef::Init
USBH_StatusTypeDef(* Init)(struct _USBH_HandleTypeDef *phost)
Definition: usbh_def.h:441
_DeviceDescriptor::bMaxPacketSize
uint8_t bMaxPacketSize
Definition: usbh_def.h:248
USBH_CtrlTypeDef::pipe_in
uint8_t pipe_in
Definition: usbh_def.h:406
HOST_USER_CLASS_SELECTED
#define HOST_USER_CLASS_SELECTED
Definition: usbh_core.h:66
FALSE
#define FALSE
Definition: usbh_def.h:57
uint8_t
const uint8_t[]
Definition: 404_html.c:3
USBH_UsrLog
#define USBH_UsrLog(...)
Definition: usbh_conf.h:166
USBH_LL_Init
USBH_StatusTypeDef USBH_LL_Init(USBH_HandleTypeDef *phost)
Initialize the low level portion of the host driver.
Definition: usbh_conf.c:191
USBH_StatusTypeDef
USBH_StatusTypeDef
Definition: usbh_def.h:302
_DeviceDescriptor::idProduct
uint16_t idProduct
Definition: usbh_def.h:250
CTRL_SETUP
Definition: usbh_def.h:360
_USBH_HandleTypeDef::EnumState
ENUM_StateTypeDef EnumState
Definition: usbh_def.h:453
_InterfaceDescriptor::bInterfaceProtocol
uint8_t bInterfaceProtocol
Definition: usbh_def.h:279
_InterfaceDescriptor::bInterfaceSubClass
uint8_t bInterfaceSubClass
Definition: usbh_def.h:278
DeInitStateMachine
static USBH_StatusTypeDef DeInitStateMachine(USBH_HandleTypeDef *phost)
DeInitStateMachine De-Initialize the Host state machine.
Definition: usbh_core.c:162
_USBH_HandleTypeDef::pClass
USBH_ClassTypeDef * pClass[USBH_MAX_NUM_SUPPORTED_CLASS]
Definition: usbh_def.h:457
USBH_CtrlTypeDef::errorcount
uint8_t errorcount
Definition: usbh_def.h:414
status
static status_t status
Definition: filament_sensor.c:37
_USBH_HandleTypeDef::ClassNumber
uint32_t ClassNumber
Definition: usbh_def.h:459
USBH_CtrlTypeDef::pipe_out
uint8_t pipe_out
Definition: usbh_def.h:407
_USBH_HandleTypeDef::pData
void * pData
Definition: usbh_def.h:463
osMessageCreate
osMessageQId osMessageCreate(const osMessageQDef_t *queue_def, osThreadId thread_id)
Create and Initialize a Message Queue.
Definition: cmsis_os.c:1086
_DeviceDescriptor::iSerialNumber
uint8_t iSerialNumber
Definition: usbh_def.h:254
USBH_MAX_DATA_BUFFER
#define USBH_MAX_DATA_BUFFER
Definition: usbh_conf.h:117
osMessageQ
#define osMessageQ(name)
Access a Message Queue Definition.
Definition: cmsis_os.h:829
USBH_FAIL
Definition: usbh_def.h:306
USBH_BUSY
Definition: usbh_def.h:305
_ConfigurationDescriptor::wTotalLength
uint16_t wTotalLength
Definition: usbh_def.h:290
_USBH_HandleTypeDef::pUser
void(* pUser)(struct _USBH_HandleTypeDef *pHandle, uint8_t id)
Definition: usbh_def.h:464
USBH_ClassTypeDef::Name
const char * Name
Definition: usbh_def.h:439
USBH_MAX_NUM_INTERFACES
#define USBH_MAX_NUM_INTERFACES
Definition: usbh_conf.h:102
_USBH_HandleTypeDef::pActiveClass
USBH_ClassTypeDef * pActiveClass
Definition: usbh_def.h:458
USBH_HandleSof
static void USBH_HandleSof(USBH_HandleTypeDef *phost)
USBH_HandleSof Call SOF process.
Definition: usbh_core.c:813
_USBH_HandleTypeDef::gState
__IO HOST_StateTypeDef gState
Definition: usbh_def.h:452
USBH_EP_CONTROL
#define USBH_EP_CONTROL
Definition: usbh_ioreq.h:61
USBH_PORT_EVENT
Definition: usbh_def.h:395
USB_DEVICE_DESC_SIZE
#define USB_DEVICE_DESC_SIZE
Definition: usbh_def.h:150
USBH_AllocPipe
uint8_t USBH_AllocPipe(USBH_HandleTypeDef *phost, uint8_t ep_addr)
USBH_Alloc_Pipe Allocate a new Pipe.
Definition: usbh_pipes.c:138
_InterfaceDescriptor::bAlternateSetting
uint8_t bAlternateSetting
Definition: usbh_def.h:275
HOST_CLASS
Definition: usbh_def.h:338
ENUM_GET_CFG_DESC
Definition: usbh_def.h:349
osThreadCreate
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:245
HOST_SET_CONFIGURATION
Definition: usbh_def.h:336
USBH_MAX_PIPES_NBR
#define USBH_MAX_PIPES_NBR
Definition: usbh_def.h:180
osThread
#define osThread(name)
Definition: cmsis_os.h:478
_InterfaceDescriptor::bInterfaceClass
uint8_t bInterfaceClass
Definition: usbh_def.h:277
osMessageQDef
#define osMessageQDef(name, queue_sz, type)
Create a Message Queue Definition.
Definition: cmsis_os.h:818