Prusa MINI Firmware overview
USBD_CORE_Exported_FunctionsPrototype
Collaboration diagram for USBD_CORE_Exported_FunctionsPrototype:

Functions

USBD_StatusTypeDef USBD_Init (USBD_HandleTypeDef *pdev, USBD_DescriptorsTypeDef *pdesc, uint8_t id)
 USBD_Init Initializes the device stack and load the class driver. More...
 
USBD_StatusTypeDef USBD_DeInit (USBD_HandleTypeDef *pdev)
 USBD_DeInit Re-Initialize th device library. More...
 
USBD_StatusTypeDef USBD_Start (USBD_HandleTypeDef *pdev)
 USBD_Start Start the USB Device Core. More...
 
USBD_StatusTypeDef USBD_Stop (USBD_HandleTypeDef *pdev)
 USBD_Stop Stop the USB Device Core. More...
 
USBD_StatusTypeDef USBD_RegisterClass (USBD_HandleTypeDef *pdev, USBD_ClassTypeDef *pclass)
 USBD_RegisterClass Link class driver to Device Core. More...
 
USBD_StatusTypeDef USBD_RunTestMode (USBD_HandleTypeDef *pdev)
 USBD_RunTestMode Launch test mode process. More...
 
USBD_StatusTypeDef USBD_SetClassConfig (USBD_HandleTypeDef *pdev, uint8_t cfgidx)
 USBD_SetClassConfig Configure device and start the interface. More...
 
USBD_StatusTypeDef USBD_ClrClassConfig (USBD_HandleTypeDef *pdev, uint8_t cfgidx)
 USBD_ClrClassConfig Clear current configuration. More...
 
USBD_StatusTypeDef USBD_LL_SetupStage (USBD_HandleTypeDef *pdev, uint8_t *psetup)
 USBD_SetupStage Handle the setup stage. More...
 
USBD_StatusTypeDef USBD_LL_DataOutStage (USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata)
 USBD_DataOutStage Handle data OUT stage. More...
 
USBD_StatusTypeDef USBD_LL_DataInStage (USBD_HandleTypeDef *pdev, uint8_t epnum, uint8_t *pdata)
 USBD_DataInStage Handle data in stage. More...
 
USBD_StatusTypeDef USBD_LL_Reset (USBD_HandleTypeDef *pdev)
 USBD_LL_Reset Handle Reset event. More...
 
USBD_StatusTypeDef USBD_LL_SetSpeed (USBD_HandleTypeDef *pdev, USBD_SpeedTypeDef speed)
 USBD_LL_Reset Handle Reset event. More...
 
USBD_StatusTypeDef USBD_LL_Suspend (USBD_HandleTypeDef *pdev)
 USBD_Suspend Handle Suspend event. More...
 
USBD_StatusTypeDef USBD_LL_Resume (USBD_HandleTypeDef *pdev)
 USBD_Resume Handle Resume event. More...
 
USBD_StatusTypeDef USBD_LL_SOF (USBD_HandleTypeDef *pdev)
 USBD_SOF Handle SOF event. More...
 
USBD_StatusTypeDef USBD_LL_IsoINIncomplete (USBD_HandleTypeDef *pdev, uint8_t epnum)
 USBD_IsoINIncomplete Handle iso in incomplete event. More...
 
USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete (USBD_HandleTypeDef *pdev, uint8_t epnum)
 USBD_IsoOUTIncomplete Handle iso out incomplete event. More...
 
USBD_StatusTypeDef USBD_LL_DevConnected (USBD_HandleTypeDef *pdev)
 USBD_DevConnected Handle device connection event. More...
 
USBD_StatusTypeDef USBD_LL_DevDisconnected (USBD_HandleTypeDef *pdev)
 USBD_DevDisconnected Handle device disconnection event. More...
 
USBD_StatusTypeDef USBD_LL_Init (USBD_HandleTypeDef *pdev)
 Initializes the low level portion of the device driver. More...
 
USBD_StatusTypeDef USBD_LL_DeInit (USBD_HandleTypeDef *pdev)
 De-Initializes the low level portion of the device driver. More...
 
USBD_StatusTypeDef USBD_LL_Start (USBD_HandleTypeDef *pdev)
 Starts the low level portion of the device driver. More...
 
USBD_StatusTypeDef USBD_LL_Stop (USBD_HandleTypeDef *pdev)
 Stops the low level portion of the device driver. More...
 
USBD_StatusTypeDef USBD_LL_OpenEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps)
 Opens an endpoint of the low level driver. More...
 
USBD_StatusTypeDef USBD_LL_CloseEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr)
 Closes an endpoint of the low level driver. More...
 
USBD_StatusTypeDef USBD_LL_FlushEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr)
 Flushes an endpoint of the Low Level Driver. More...
 
USBD_StatusTypeDef USBD_LL_StallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr)
 Sets a Stall condition on an endpoint of the Low Level Driver. More...
 
USBD_StatusTypeDef USBD_LL_ClearStallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr)
 Clears a Stall condition on an endpoint of the Low Level Driver. More...
 
uint8_t USBD_LL_IsStallEP (USBD_HandleTypeDef *pdev, uint8_t ep_addr)
 Returns Stall condition. More...
 
USBD_StatusTypeDef USBD_LL_SetUSBAddress (USBD_HandleTypeDef *pdev, uint8_t dev_addr)
 Assigns a USB address to the device. More...
 
USBD_StatusTypeDef USBD_LL_Transmit (USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size)
 Transmits data over an endpoint. More...
 
USBD_StatusTypeDef USBD_LL_PrepareReceive (USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size)
 Prepares an endpoint for reception. More...
 
uint32_t USBD_LL_GetRxDataSize (USBD_HandleTypeDef *pdev, uint8_t ep_addr)
 Returns the last transfered packet size. More...
 
void USBD_LL_Delay (uint32_t Delay)
 Delays routine for the USB Device Library. More...
 

Detailed Description

Function Documentation

◆ USBD_Init()

USBD_StatusTypeDef USBD_Init ( USBD_HandleTypeDef pdev,
USBD_DescriptorsTypeDef pdesc,
uint8_t  id 
)

USBD_Init Initializes the device stack and load the class driver.

Parameters
pdevdevice instance
pdescDescriptor structure address
idLow level core index
Return values
None
97 {
98  /* Check whether the USB Host handle is valid */
99  if(pdev == NULL)
100  {
101  USBD_ErrLog("Invalid Device handle");
102  return USBD_FAIL;
103  }
104 
105  /* Unlink previous class*/
106  if(pdev->pClass != NULL)
107  {
108  pdev->pClass = NULL;
109  }
110 
111  /* Assign USBD Descriptors */
112  if(pdesc != NULL)
113  {
114  pdev->pDesc = pdesc;
115  }
116 
117  /* Set Device initial State */
119  pdev->id = id;
120  /* Initialize low level driver */
121  USBD_LL_Init(pdev);
122 
123  return USBD_OK;
124 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBD_DeInit()

USBD_StatusTypeDef USBD_DeInit ( USBD_HandleTypeDef pdev)

USBD_DeInit Re-Initialize th device library.

Parameters
pdevdevice instance
Return values
statusstatus
133 {
134  /* Set Default State */
136 
137  /* Free Class Resources */
138  pdev->pClass->DeInit(pdev, pdev->dev_config);
139 
140  /* Stop the low level driver */
141  USBD_LL_Stop(pdev);
142 
143  /* Initialize low level driver */
144  USBD_LL_DeInit(pdev);
145 
146  return USBD_OK;
147 }
Here is the call graph for this function:

◆ USBD_Start()

USBD_StatusTypeDef USBD_Start ( USBD_HandleTypeDef pdev)

USBD_Start Start the USB Device Core.

Parameters
pdevDevice Handle
Return values
USBDStatus
182 {
183 
184  /* Start the low level driver */
185  USBD_LL_Start(pdev);
186 
187  return USBD_OK;
188 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBD_Stop()

USBD_StatusTypeDef USBD_Stop ( USBD_HandleTypeDef pdev)

USBD_Stop Stop the USB Device Core.

Parameters
pdevDevice Handle
Return values
USBDStatus
197 {
198  /* Free Class Resources */
199  pdev->pClass->DeInit(pdev, pdev->dev_config);
200 
201  /* Stop the low level driver */
202  USBD_LL_Stop(pdev);
203 
204  return USBD_OK;
205 }
Here is the call graph for this function:

◆ USBD_RegisterClass()

USBD_StatusTypeDef USBD_RegisterClass ( USBD_HandleTypeDef pdev,
USBD_ClassTypeDef pclass 
)

USBD_RegisterClass Link class driver to Device Core.

Parameters
pDevice: Device Handle
pclassClass handle
Return values
USBDStatus
158 {
160  if(pclass != 0)
161  {
162  /* link the class to the USB Device handle */
163  pdev->pClass = pclass;
164  status = USBD_OK;
165  }
166  else
167  {
168  USBD_ErrLog("Invalid Class handle");
169  status = USBD_FAIL;
170  }
171 
172  return status;
173 }
Here is the caller graph for this function:

◆ USBD_RunTestMode()

USBD_StatusTypeDef USBD_RunTestMode ( USBD_HandleTypeDef pdev)

USBD_RunTestMode Launch test mode process.

Parameters
pdevdevice instance
Return values
status
214 {
215  return USBD_OK;
216 }
Here is the caller graph for this function:

◆ USBD_SetClassConfig()

USBD_StatusTypeDef USBD_SetClassConfig ( USBD_HandleTypeDef pdev,
uint8_t  cfgidx 
)

USBD_SetClassConfig Configure device and start the interface.

Parameters
pdevdevice instance
cfgidxconfiguration index
Return values
status
228 {
230 
231  if(pdev->pClass != NULL)
232  {
233  /* Set configuration and Start the Class*/
234  if(pdev->pClass->Init(pdev, cfgidx) == 0)
235  {
236  ret = USBD_OK;
237  }
238  }
239  return ret;
240 }
Here is the caller graph for this function:

◆ USBD_ClrClassConfig()

USBD_StatusTypeDef USBD_ClrClassConfig ( USBD_HandleTypeDef pdev,
uint8_t  cfgidx 
)

USBD_ClrClassConfig Clear current configuration.

Parameters
pdevdevice instance
cfgidxconfiguration index
Return values
statusUSBD_StatusTypeDef
250 {
251  /* Clear configuration and De-initialize the Class process*/
252  pdev->pClass->DeInit(pdev, cfgidx);
253  return USBD_OK;
254 }
Here is the caller graph for this function:

◆ USBD_LL_SetupStage()

USBD_StatusTypeDef USBD_LL_SetupStage ( USBD_HandleTypeDef pdev,
uint8_t psetup 
)

USBD_SetupStage Handle the setup stage.

Parameters
pdevdevice instance
Return values
status
264 {
265 
266  USBD_ParseSetupRequest(&pdev->request, psetup);
267 
268  pdev->ep0_state = USBD_EP0_SETUP;
269  pdev->ep0_data_len = pdev->request.wLength;
270 
271  switch (pdev->request.bmRequest & 0x1F)
272  {
274  USBD_StdDevReq (pdev, &pdev->request);
275  break;
276 
278  USBD_StdItfReq(pdev, &pdev->request);
279  break;
280 
282  USBD_StdEPReq(pdev, &pdev->request);
283  break;
284 
285  default:
286  USBD_LL_StallEP(pdev , pdev->request.bmRequest & 0x80);
287  break;
288  }
289  return USBD_OK;
290 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBD_LL_DataOutStage()

USBD_StatusTypeDef USBD_LL_DataOutStage ( USBD_HandleTypeDef pdev,
uint8_t  epnum,
uint8_t pdata 
)

USBD_DataOutStage Handle data OUT stage.

Parameters
pdevdevice instance
epnumendpoint index
Return values
status
300 {
302 
303  if(epnum == 0)
304  {
305  pep = &pdev->ep_out[0];
306 
307  if ( pdev->ep0_state == USBD_EP0_DATA_OUT)
308  {
309  if(pep->rem_length > pep->maxpacket)
310  {
311  pep->rem_length -= pep->maxpacket;
312 
313  USBD_CtlContinueRx (pdev,
314  pdata,
315  MIN(pep->rem_length ,pep->maxpacket));
316  }
317  else
318  {
319  if((pdev->pClass->EP0_RxReady != NULL)&&
320  (pdev->dev_state == USBD_STATE_CONFIGURED))
321  {
322  pdev->pClass->EP0_RxReady(pdev);
323  }
324  USBD_CtlSendStatus(pdev);
325  }
326  }
327  }
328  else if((pdev->pClass->DataOut != NULL)&&
329  (pdev->dev_state == USBD_STATE_CONFIGURED))
330  {
331  pdev->pClass->DataOut(pdev, epnum);
332  }
333  return USBD_OK;
334 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBD_LL_DataInStage()

USBD_StatusTypeDef USBD_LL_DataInStage ( USBD_HandleTypeDef pdev,
uint8_t  epnum,
uint8_t pdata 
)

USBD_DataInStage Handle data in stage.

Parameters
pdevdevice instance
epnumendpoint index
Return values
status
344 {
346 
347  if(epnum == 0)
348  {
349  pep = &pdev->ep_in[0];
350 
351  if ( pdev->ep0_state == USBD_EP0_DATA_IN)
352  {
353  if(pep->rem_length > pep->maxpacket)
354  {
355  pep->rem_length -= pep->maxpacket;
356 
358  pdata,
359  pep->rem_length);
360 
361  /* Prepare endpoint for premature end of transfer */
363  0,
364  NULL,
365  0);
366  }
367  else
368  { /* last packet is MPS multiple, so send ZLP packet */
369  if((pep->total_length % pep->maxpacket == 0) &&
370  (pep->total_length >= pep->maxpacket) &&
371  (pep->total_length < pdev->ep0_data_len ))
372  {
373 
374  USBD_CtlContinueSendData(pdev , NULL, 0);
375  pdev->ep0_data_len = 0;
376 
377  /* Prepare endpoint for premature end of transfer */
379  0,
380  NULL,
381  0);
382  }
383  else
384  {
385  if((pdev->pClass->EP0_TxSent != NULL)&&
386  (pdev->dev_state == USBD_STATE_CONFIGURED))
387  {
388  pdev->pClass->EP0_TxSent(pdev);
389  }
390  USBD_CtlReceiveStatus(pdev);
391  }
392  }
393  }
394  if (pdev->dev_test_mode == 1)
395  {
396  USBD_RunTestMode(pdev);
397  pdev->dev_test_mode = 0;
398  }
399  }
400  else if((pdev->pClass->DataIn != NULL)&&
401  (pdev->dev_state == USBD_STATE_CONFIGURED))
402  {
403  pdev->pClass->DataIn(pdev, epnum);
404  }
405  return USBD_OK;
406 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBD_LL_Reset()

USBD_StatusTypeDef USBD_LL_Reset ( USBD_HandleTypeDef pdev)

USBD_LL_Reset Handle Reset event.

Parameters
pdevdevice instance
Return values
status
416 {
417  /* Open EP0 OUT */
418  USBD_LL_OpenEP(pdev,
419  0x00,
422 
423  pdev->ep_out[0].maxpacket = USB_MAX_EP0_SIZE;
424 
425  /* Open EP0 IN */
426  USBD_LL_OpenEP(pdev,
427  0x80,
430 
431  pdev->ep_in[0].maxpacket = USB_MAX_EP0_SIZE;
432  /* Upon Reset call user call back */
434 
435  if (pdev->pClassData)
436  pdev->pClass->DeInit(pdev, pdev->dev_config);
437 
438 
439  return USBD_OK;
440 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBD_LL_SetSpeed()

USBD_StatusTypeDef USBD_LL_SetSpeed ( USBD_HandleTypeDef pdev,
USBD_SpeedTypeDef  speed 
)

USBD_LL_Reset Handle Reset event.

Parameters
pdevdevice instance
Return values
status
452 {
453  pdev->dev_speed = speed;
454  return USBD_OK;
455 }
Here is the caller graph for this function:

◆ USBD_LL_Suspend()

USBD_StatusTypeDef USBD_LL_Suspend ( USBD_HandleTypeDef pdev)

USBD_Suspend Handle Suspend event.

Parameters
pdevdevice instance
Return values
status
465 {
466  pdev->dev_old_state = pdev->dev_state;
468  return USBD_OK;
469 }
Here is the caller graph for this function:

◆ USBD_LL_Resume()

USBD_StatusTypeDef USBD_LL_Resume ( USBD_HandleTypeDef pdev)

USBD_Resume Handle Resume event.

Parameters
pdevdevice instance
Return values
status
479 {
480  pdev->dev_state = pdev->dev_old_state;
481  return USBD_OK;
482 }
Here is the caller graph for this function:

◆ USBD_LL_SOF()

USBD_StatusTypeDef USBD_LL_SOF ( USBD_HandleTypeDef pdev)

USBD_SOF Handle SOF event.

Parameters
pdevdevice instance
Return values
status
492 {
493  if(pdev->dev_state == USBD_STATE_CONFIGURED)
494  {
495  if(pdev->pClass->SOF != NULL)
496  {
497  pdev->pClass->SOF(pdev);
498  }
499  }
500  return USBD_OK;
501 }
Here is the caller graph for this function:

◆ USBD_LL_IsoINIncomplete()

USBD_StatusTypeDef USBD_LL_IsoINIncomplete ( USBD_HandleTypeDef pdev,
uint8_t  epnum 
)

USBD_IsoINIncomplete Handle iso in incomplete event.

Parameters
pdevdevice instance
Return values
status
510 {
511  return USBD_OK;
512 }
Here is the caller graph for this function:

◆ USBD_LL_IsoOUTIncomplete()

USBD_StatusTypeDef USBD_LL_IsoOUTIncomplete ( USBD_HandleTypeDef pdev,
uint8_t  epnum 
)

USBD_IsoOUTIncomplete Handle iso out incomplete event.

Parameters
pdevdevice instance
Return values
status
521 {
522  return USBD_OK;
523 }
Here is the caller graph for this function:

◆ USBD_LL_DevConnected()

USBD_StatusTypeDef USBD_LL_DevConnected ( USBD_HandleTypeDef pdev)

USBD_DevConnected Handle device connection event.

Parameters
pdevdevice instance
Return values
status
532 {
533  return USBD_OK;
534 }
Here is the caller graph for this function:

◆ USBD_LL_DevDisconnected()

USBD_StatusTypeDef USBD_LL_DevDisconnected ( USBD_HandleTypeDef pdev)

USBD_DevDisconnected Handle device disconnection event.

Parameters
pdevdevice instance
Return values
status
543 {
544  /* Free Class Resources */
546  pdev->pClass->DeInit(pdev, pdev->dev_config);
547 
548  return USBD_OK;
549 }
Here is the caller graph for this function:

◆ USBD_LL_Init()

USBD_StatusTypeDef USBD_LL_Init ( USBD_HandleTypeDef pdev)

Initializes the low level portion of the device driver.

Parameters
pdevDevice handle
Return values
USBDstatus
292  {
293  /* Init USB Ip. */
294  if (pdev->id == DEVICE_FS) {
295  /* Link the driver to the stack. */
296  hpcd_USB_OTG_FS.pData = pdev;
297  pdev->pData = &hpcd_USB_OTG_FS;
298 
299  hpcd_USB_OTG_FS.Instance = USB_OTG_FS;
300  hpcd_USB_OTG_FS.Init.dev_endpoints = 4;
301  hpcd_USB_OTG_FS.Init.speed = PCD_SPEED_FULL;
302  hpcd_USB_OTG_FS.Init.dma_enable = DISABLE;
303  hpcd_USB_OTG_FS.Init.ep0_mps = DEP0CTL_MPS_64;
304  hpcd_USB_OTG_FS.Init.phy_itface = PCD_PHY_EMBEDDED;
305  hpcd_USB_OTG_FS.Init.Sof_enable = DISABLE;
306  hpcd_USB_OTG_FS.Init.low_power_enable = DISABLE;
307  hpcd_USB_OTG_FS.Init.lpm_enable = DISABLE;
308  hpcd_USB_OTG_FS.Init.vbus_sensing_enable = DISABLE;
309  hpcd_USB_OTG_FS.Init.use_dedicated_ep1 = DISABLE;
310  if (HAL_PCD_Init(&hpcd_USB_OTG_FS) != HAL_OK) {
311  Error_Handler();
312  }
313 
314  HAL_PCDEx_SetRxFiFo(&hpcd_USB_OTG_FS, 0x80);
315  HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 0, 0x40);
316  HAL_PCDEx_SetTxFiFo(&hpcd_USB_OTG_FS, 1, 0x80);
317  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBD_LL_DeInit()

USBD_StatusTypeDef USBD_LL_DeInit ( USBD_HandleTypeDef pdev)

De-Initializes the low level portion of the device driver.

Parameters
pdevDevice handle
Return values
USBDstatus
326  {
327  HAL_StatusTypeDef hal_status = HAL_OK;
328  USBD_StatusTypeDef usb_status = USBD_OK;
329 
330  hal_status = HAL_PCD_DeInit(pdev->pData);
331 
332  switch (hal_status) {
333  case HAL_OK:
334  usb_status = USBD_OK;
335  break;
336  case HAL_ERROR:
337  usb_status = USBD_FAIL;
338  break;
339  case HAL_BUSY:
340  usb_status = USBD_BUSY;
341  break;
342  case HAL_TIMEOUT:
343  usb_status = USBD_FAIL;
344  break;
345  default:
346  usb_status = USBD_FAIL;
347  break;
348  }
Here is the caller graph for this function:

◆ USBD_LL_Start()

USBD_StatusTypeDef USBD_LL_Start ( USBD_HandleTypeDef pdev)

Starts the low level portion of the device driver.

Parameters
pdevDevice handle
Return values
USBDstatus
357  {
358  HAL_StatusTypeDef hal_status = HAL_OK;
359  USBD_StatusTypeDef usb_status = USBD_OK;
360 
361  hal_status = HAL_PCD_Start(pdev->pData);
362 
363  switch (hal_status) {
364  case HAL_OK:
365  usb_status = USBD_OK;
366  break;
367  case HAL_ERROR:
368  usb_status = USBD_FAIL;
369  break;
370  case HAL_BUSY:
371  usb_status = USBD_BUSY;
372  break;
373  case HAL_TIMEOUT:
374  usb_status = USBD_FAIL;
375  break;
376  default:
377  usb_status = USBD_FAIL;
378  break;
379  }
Here is the caller graph for this function:

◆ USBD_LL_Stop()

USBD_StatusTypeDef USBD_LL_Stop ( USBD_HandleTypeDef pdev)

Stops the low level portion of the device driver.

Parameters
pdevDevice handle
Return values
USBDstatus
388  {
389  HAL_StatusTypeDef hal_status = HAL_OK;
390  USBD_StatusTypeDef usb_status = USBD_OK;
391 
392  hal_status = HAL_PCD_Stop(pdev->pData);
393 
394  switch (hal_status) {
395  case HAL_OK:
396  usb_status = USBD_OK;
397  break;
398  case HAL_ERROR:
399  usb_status = USBD_FAIL;
400  break;
401  case HAL_BUSY:
402  usb_status = USBD_BUSY;
403  break;
404  case HAL_TIMEOUT:
405  usb_status = USBD_FAIL;
406  break;
407  default:
408  usb_status = USBD_FAIL;
409  break;
410  }
Here is the caller graph for this function:

◆ USBD_LL_OpenEP()

USBD_StatusTypeDef USBD_LL_OpenEP ( USBD_HandleTypeDef pdev,
uint8_t  ep_addr,
uint8_t  ep_type,
uint16_t  ep_mps 
)

Opens an endpoint of the low level driver.

Parameters
pdevDevice handle
ep_addrEndpoint number
ep_typeEndpoint type
ep_mpsEndpoint max packet size
Return values
USBDstatus
422  {
423  HAL_StatusTypeDef hal_status = HAL_OK;
424  USBD_StatusTypeDef usb_status = USBD_OK;
425 
426  hal_status = HAL_PCD_EP_Open(pdev->pData, ep_addr, ep_mps, ep_type);
427 
428  switch (hal_status) {
429  case HAL_OK:
430  usb_status = USBD_OK;
431  break;
432  case HAL_ERROR:
433  usb_status = USBD_FAIL;
434  break;
435  case HAL_BUSY:
436  usb_status = USBD_BUSY;
437  break;
438  case HAL_TIMEOUT:
439  usb_status = USBD_FAIL;
440  break;
441  default:
442  usb_status = USBD_FAIL;
443  break;
444  }
Here is the caller graph for this function:

◆ USBD_LL_CloseEP()

USBD_StatusTypeDef USBD_LL_CloseEP ( USBD_HandleTypeDef pdev,
uint8_t  ep_addr 
)

Closes an endpoint of the low level driver.

Parameters
pdevDevice handle
ep_addrEndpoint number
Return values
USBDstatus
454  {
455  HAL_StatusTypeDef hal_status = HAL_OK;
456  USBD_StatusTypeDef usb_status = USBD_OK;
457 
458  hal_status = HAL_PCD_EP_Close(pdev->pData, ep_addr);
459 
460  switch (hal_status) {
461  case HAL_OK:
462  usb_status = USBD_OK;
463  break;
464  case HAL_ERROR:
465  usb_status = USBD_FAIL;
466  break;
467  case HAL_BUSY:
468  usb_status = USBD_BUSY;
469  break;
470  case HAL_TIMEOUT:
471  usb_status = USBD_FAIL;
472  break;
473  default:
474  usb_status = USBD_FAIL;
475  break;
476  }
Here is the caller graph for this function:

◆ USBD_LL_FlushEP()

USBD_StatusTypeDef USBD_LL_FlushEP ( USBD_HandleTypeDef pdev,
uint8_t  ep_addr 
)

Flushes an endpoint of the Low Level Driver.

Parameters
pdevDevice handle
ep_addrEndpoint number
Return values
USBDstatus
486  {
487  HAL_StatusTypeDef hal_status = HAL_OK;
488  USBD_StatusTypeDef usb_status = USBD_OK;
489 
490  hal_status = HAL_PCD_EP_Flush(pdev->pData, ep_addr);
491 
492  switch (hal_status) {
493  case HAL_OK:
494  usb_status = USBD_OK;
495  break;
496  case HAL_ERROR:
497  usb_status = USBD_FAIL;
498  break;
499  case HAL_BUSY:
500  usb_status = USBD_BUSY;
501  break;
502  case HAL_TIMEOUT:
503  usb_status = USBD_FAIL;
504  break;
505  default:
506  usb_status = USBD_FAIL;
507  break;
508  }

◆ USBD_LL_StallEP()

USBD_StatusTypeDef USBD_LL_StallEP ( USBD_HandleTypeDef pdev,
uint8_t  ep_addr 
)

Sets a Stall condition on an endpoint of the Low Level Driver.

Parameters
pdevDevice handle
ep_addrEndpoint number
Return values
USBDstatus
518  {
519  HAL_StatusTypeDef hal_status = HAL_OK;
520  USBD_StatusTypeDef usb_status = USBD_OK;
521 
522  hal_status = HAL_PCD_EP_SetStall(pdev->pData, ep_addr);
523 
524  switch (hal_status) {
525  case HAL_OK:
526  usb_status = USBD_OK;
527  break;
528  case HAL_ERROR:
529  usb_status = USBD_FAIL;
530  break;
531  case HAL_BUSY:
532  usb_status = USBD_BUSY;
533  break;
534  case HAL_TIMEOUT:
535  usb_status = USBD_FAIL;
536  break;
537  default:
538  usb_status = USBD_FAIL;
539  break;
540  }
Here is the caller graph for this function:

◆ USBD_LL_ClearStallEP()

USBD_StatusTypeDef USBD_LL_ClearStallEP ( USBD_HandleTypeDef pdev,
uint8_t  ep_addr 
)

Clears a Stall condition on an endpoint of the Low Level Driver.

Parameters
pdevDevice handle
ep_addrEndpoint number
Return values
USBDstatus
550  {
551  HAL_StatusTypeDef hal_status = HAL_OK;
552  USBD_StatusTypeDef usb_status = USBD_OK;
553 
554  hal_status = HAL_PCD_EP_ClrStall(pdev->pData, ep_addr);
555 
556  switch (hal_status) {
557  case HAL_OK:
558  usb_status = USBD_OK;
559  break;
560  case HAL_ERROR:
561  usb_status = USBD_FAIL;
562  break;
563  case HAL_BUSY:
564  usb_status = USBD_BUSY;
565  break;
566  case HAL_TIMEOUT:
567  usb_status = USBD_FAIL;
568  break;
569  default:
570  usb_status = USBD_FAIL;
571  break;
572  }
Here is the caller graph for this function:

◆ USBD_LL_IsStallEP()

uint8_t USBD_LL_IsStallEP ( USBD_HandleTypeDef pdev,
uint8_t  ep_addr 
)

Returns Stall condition.

Parameters
pdevDevice handle
ep_addrEndpoint number
Return values
Stall(1: Yes, 0: No)
580  : Yes, 0: No)
581  */
583  PCD_HandleTypeDef *hpcd = (PCD_HandleTypeDef *)pdev->pData;
584 
585  if ((ep_addr & 0x80) == 0x80) {
586  return hpcd->IN_ep[ep_addr & 0x7F].is_stall;
587  } else {
588  return hpcd->OUT_ep[ep_addr & 0x7F].is_stall;
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBD_LL_SetUSBAddress()

USBD_StatusTypeDef USBD_LL_SetUSBAddress ( USBD_HandleTypeDef pdev,
uint8_t  dev_addr 
)

Assigns a USB address to the device.

Parameters
pdevDevice handle
dev_addrDevice address
Return values
USBDstatus
598  {
599  HAL_StatusTypeDef hal_status = HAL_OK;
600  USBD_StatusTypeDef usb_status = USBD_OK;
601 
602  hal_status = HAL_PCD_SetAddress(pdev->pData, dev_addr);
603 
604  switch (hal_status) {
605  case HAL_OK:
606  usb_status = USBD_OK;
607  break;
608  case HAL_ERROR:
609  usb_status = USBD_FAIL;
610  break;
611  case HAL_BUSY:
612  usb_status = USBD_BUSY;
613  break;
614  case HAL_TIMEOUT:
615  usb_status = USBD_FAIL;
616  break;
617  default:
618  usb_status = USBD_FAIL;
619  break;
620  }
Here is the caller graph for this function:

◆ USBD_LL_Transmit()

USBD_StatusTypeDef USBD_LL_Transmit ( USBD_HandleTypeDef pdev,
uint8_t  ep_addr,
uint8_t pbuf,
uint16_t  size 
)

Transmits data over an endpoint.

Parameters
pdevDevice handle
ep_addrEndpoint number
pbufPointer to data to be sent
sizeData size
Return values
USBDstatus
632  {
633  HAL_StatusTypeDef hal_status = HAL_OK;
634  USBD_StatusTypeDef usb_status = USBD_OK;
635 
636  hal_status = HAL_PCD_EP_Transmit(pdev->pData, ep_addr, pbuf, size);
637 
638  switch (hal_status) {
639  case HAL_OK:
640  usb_status = USBD_OK;
641  break;
642  case HAL_ERROR:
643  usb_status = USBD_FAIL;
644  break;
645  case HAL_BUSY:
646  usb_status = USBD_BUSY;
647  break;
648  case HAL_TIMEOUT:
649  usb_status = USBD_FAIL;
650  break;
651  default:
652  usb_status = USBD_FAIL;
653  break;
654  }
Here is the caller graph for this function:

◆ USBD_LL_PrepareReceive()

USBD_StatusTypeDef USBD_LL_PrepareReceive ( USBD_HandleTypeDef pdev,
uint8_t  ep_addr,
uint8_t pbuf,
uint16_t  size 
)

Prepares an endpoint for reception.

Parameters
pdevDevice handle
ep_addrEndpoint number
pbufPointer to data to be received
sizeData size
Return values
USBDstatus
666  {
667  HAL_StatusTypeDef hal_status = HAL_OK;
668  USBD_StatusTypeDef usb_status = USBD_OK;
669 
670  hal_status = HAL_PCD_EP_Receive(pdev->pData, ep_addr, pbuf, size);
671 
672  switch (hal_status) {
673  case HAL_OK:
674  usb_status = USBD_OK;
675  break;
676  case HAL_ERROR:
677  usb_status = USBD_FAIL;
678  break;
679  case HAL_BUSY:
680  usb_status = USBD_BUSY;
681  break;
682  case HAL_TIMEOUT:
683  usb_status = USBD_FAIL;
684  break;
685  default:
686  usb_status = USBD_FAIL;
687  break;
688  }
Here is the caller graph for this function:

◆ USBD_LL_GetRxDataSize()

uint32_t USBD_LL_GetRxDataSize ( USBD_HandleTypeDef pdev,
uint8_t  ep_addr 
)

Returns the last transfered packet size.

Parameters
pdevDevice handle
ep_addrEndpoint number
Return values
RecivedData Size
698  {
Here is the caller graph for this function:

◆ USBD_LL_Delay()

void USBD_LL_Delay ( uint32_t  Delay)

Delays routine for the USB Device Library.

Parameters
DelayDelay in ms
Return values
None
741  {
Here is the call graph for this function:
_Device_cb::DeInit
uint8_t(* DeInit)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx)
Definition: usbd_def.h:163
_USBD_HandleTypeDef::dev_old_state
uint8_t dev_old_state
Definition: usbd_def.h:237
USBD_ErrLog
#define USBD_ErrLog(...)
Definition: usbd_conf.h:157
_Device_cb::SOF
uint8_t(* SOF)(struct _USBD_HandleTypeDef *pdev)
Definition: usbd_def.h:171
USBD_RunTestMode
USBD_StatusTypeDef USBD_RunTestMode(USBD_HandleTypeDef *pdev)
USBD_RunTestMode Launch test mode process.
Definition: usbd_core.c:213
USBD_CtlContinueRx
USBD_StatusTypeDef USBD_CtlContinueRx(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint16_t len)
USBD_CtlContinueRx continue receive data on the ctl pipe.
Definition: usbd_ioreq.c:160
HAL_BUSY
Definition: stm32f4xx_hal_def.h:59
usb_setup_req::wLength
uint16_t wLength
Definition: usbd_def.h:155
HAL_OK
Definition: stm32f4xx_hal_def.h:57
USBD_LL_Start
USBD_StatusTypeDef USBD_LL_Start(USBD_HandleTypeDef *pdev)
Starts the low level portion of the device driver.
Definition: usbd_conf.c:355
_USBD_HandleTypeDef::request
USBD_SetupReqTypedef request
Definition: usbd_def.h:243
USBD_STATE_CONFIGURED
#define USBD_STATE_CONFIGURED
Definition: usbd_def.h:120
_USBD_HandleTypeDef::pClass
USBD_ClassTypeDef * pClass
Definition: usbd_def.h:245
DEVICE_FS
#define DEVICE_FS
Definition: usbd_conf.h:111
MIN
#define MIN(a, b)
Definition: usbd_def.h:265
hpcd_USB_OTG_FS
PCD_HandleTypeDef hpcd_USB_OTG_FS
Definition: usbd_conf.c:69
USBD_FAIL
Definition: usbd_def.h:197
_Device_cb::DataOut
uint8_t(* DataOut)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum)
Definition: usbd_def.h:170
_USBD_HandleTypeDef::dev_state
uint8_t dev_state
Definition: usbd_def.h:236
_USBD_HandleTypeDef::ep0_state
uint32_t ep0_state
Definition: usbd_def.h:234
_USBD_HandleTypeDef::ep_in
USBD_EndpointTypeDef ep_in[15]
Definition: usbd_def.h:232
HAL_TIMEOUT
Definition: stm32f4xx_hal_def.h:60
_USBD_HandleTypeDef::pDesc
USBD_DescriptorsTypeDef * pDesc
Definition: usbd_def.h:244
USBD_EP0_DATA_OUT
#define USBD_EP0_DATA_OUT
Definition: usbd_def.h:128
usb_setup_req::bmRequest
uint8_t bmRequest
Definition: usbd_def.h:151
USBD_EP0_SETUP
#define USBD_EP0_SETUP
Definition: usbd_def.h:126
_USBD_HandleTypeDef::ep0_data_len
uint32_t ep0_data_len
Definition: usbd_def.h:235
_USBD_HandleTypeDef::pClassData
void * pClassData
Definition: usbd_def.h:246
NULL
#define NULL
Definition: usbd_def.h:53
USB_MAX_EP0_SIZE
#define USB_MAX_EP0_SIZE
Definition: usbd_def.h:115
_USBD_HandleTypeDef::dev_config
uint32_t dev_config
Definition: usbd_def.h:228
USB_REQ_RECIPIENT_DEVICE
#define USB_REQ_RECIPIENT_DEVICE
Definition: usbd_def.h:78
USB_REQ_RECIPIENT_INTERFACE
#define USB_REQ_RECIPIENT_INTERFACE
Definition: usbd_def.h:79
USBD_StdEPReq
USBD_StatusTypeDef USBD_StdEPReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
USBD_StdEPReq Handle standard usb endpoint requests.
Definition: usbd_ctlreq.c:207
USBD_LL_OpenEP
USBD_StatusTypeDef USBD_LL_OpenEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t ep_type, uint16_t ep_mps)
Opens an endpoint of the low level driver.
Definition: usbd_conf.c:420
HAL_ERROR
Definition: stm32f4xx_hal_def.h:58
HAL_StatusTypeDef
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32f4xx_hal_def.h:55
USBD_StdDevReq
USBD_StatusTypeDef USBD_StdDevReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
USBD_StdDevReq Handle standard usb device requests.
Definition: usbd_ctlreq.c:119
USBD_LL_Init
USBD_StatusTypeDef USBD_LL_Init(USBD_HandleTypeDef *pdev)
Initializes the low level portion of the device driver.
Definition: usbd_conf.c:290
Error_Handler
void Error_Handler(void)
This function is executed in case of error occurrence.
Definition: main.c:1057
USBD_ParseSetupRequest
void USBD_ParseSetupRequest(USBD_SetupReqTypedef *req, uint8_t *pdata)
USBD_ParseSetupRequest Copy buffer into setup structure.
Definition: usbd_ctlreq.c:698
USBD_LL_Stop
USBD_StatusTypeDef USBD_LL_Stop(USBD_HandleTypeDef *pdev)
Stops the low level portion of the device driver.
Definition: usbd_conf.c:386
_USBD_HandleTypeDef
Definition: usbd_def.h:225
USBD_LL_StallEP
USBD_StatusTypeDef USBD_LL_StallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
Sets a Stall condition on an endpoint of the Low Level Driver.
Definition: usbd_conf.c:516
_USBD_HandleTypeDef::pData
void * pData
Definition: usbd_def.h:248
USBD_EndpointTypeDef
Definition: usbd_def.h:216
_Device_cb::EP0_RxReady
uint8_t(* EP0_RxReady)(struct _USBD_HandleTypeDef *pdev)
Definition: usbd_def.h:167
USBD_EndpointTypeDef::rem_length
uint32_t rem_length
Definition: usbd_def.h:220
_Device_cb::DataIn
uint8_t(* DataIn)(struct _USBD_HandleTypeDef *pdev, uint8_t epnum)
Definition: usbd_def.h:169
if
if(size<=((png_alloc_size_t) -1) - ob)
Definition: pngwrite.c:2176
_Device_cb::Init
uint8_t(* Init)(struct _USBD_HandleTypeDef *pdev, uint8_t cfgidx)
Definition: usbd_def.h:162
USBD_CtlContinueSendData
USBD_StatusTypeDef USBD_CtlContinueSendData(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint16_t len)
USBD_CtlContinueSendData continue sending data on the ctl pipe.
Definition: usbd_ioreq.c:117
USBD_BUSY
Definition: usbd_def.h:196
_USBD_HandleTypeDef::id
uint8_t id
Definition: usbd_def.h:227
uint8_t
const uint8_t[]
Definition: 404_html.c:3
_USBD_HandleTypeDef::dev_speed
USBD_SpeedTypeDef dev_speed
Definition: usbd_def.h:231
USBD_LL_PrepareReceive
USBD_StatusTypeDef USBD_LL_PrepareReceive(USBD_HandleTypeDef *pdev, uint8_t ep_addr, uint8_t *pbuf, uint16_t size)
Prepares an endpoint for reception.
Definition: usbd_conf.c:664
_USBD_HandleTypeDef::ep_out
USBD_EndpointTypeDef ep_out[15]
Definition: usbd_def.h:233
USBD_CtlSendStatus
USBD_StatusTypeDef USBD_CtlSendStatus(USBD_HandleTypeDef *pdev)
USBD_CtlSendStatus send zero lzngth packet on the ctl pipe.
Definition: usbd_ioreq.c:177
USBD_STATE_DEFAULT
#define USBD_STATE_DEFAULT
Definition: usbd_def.h:118
_USBD_HandleTypeDef::dev_test_mode
uint8_t dev_test_mode
Definition: usbd_def.h:240
USBD_CtlReceiveStatus
USBD_StatusTypeDef USBD_CtlReceiveStatus(USBD_HandleTypeDef *pdev)
USBD_CtlReceiveStatus receive zero lzngth packet on the ctl pipe.
Definition: usbd_ioreq.c:195
status
static status_t status
Definition: filament_sensor.c:37
USBD_StatusTypeDef
USBD_StatusTypeDef
Definition: usbd_def.h:194
USBD_StdItfReq
USBD_StatusTypeDef USBD_StdItfReq(USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
USBD_StdItfReq Handle standard usb interface requests.
Definition: usbd_ctlreq.c:170
USBD_LL_IsStallEP
uint8_t USBD_LL_IsStallEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
Returns Stall condition.
Definition: usbd_conf.c:580
USB_REQ_RECIPIENT_ENDPOINT
#define USB_REQ_RECIPIENT_ENDPOINT
Definition: usbd_def.h:80
USBD_EP_TYPE_CTRL
#define USBD_EP_TYPE_CTRL
Definition: usbd_def.h:133
USBD_STATE_SUSPENDED
#define USBD_STATE_SUSPENDED
Definition: usbd_def.h:121
USBD_EP0_DATA_IN
#define USBD_EP0_DATA_IN
Definition: usbd_def.h:127
_Device_cb::EP0_TxSent
uint8_t(* EP0_TxSent)(struct _USBD_HandleTypeDef *pdev)
Definition: usbd_def.h:166
pbuf
Definition: pbuf.h:142
USBD_OK
Definition: usbd_def.h:195
USBD_EndpointTypeDef::maxpacket
uint32_t maxpacket
Definition: usbd_def.h:221
size
static png_bytep size_t size
Definition: pngwrite.c:2170
USBD_EndpointTypeDef::total_length
uint32_t total_length
Definition: usbd_def.h:219
USBD_LL_DeInit
USBD_StatusTypeDef USBD_LL_DeInit(USBD_HandleTypeDef *pdev)
De-Initializes the low level portion of the device driver.
Definition: usbd_conf.c:324