Prusa MINI Firmware overview
USBD_CDC_Private_Functions
Collaboration diagram for USBD_CDC_Private_Functions:

Functions

uint8_t USBD_CDC_RegisterInterface (USBD_HandleTypeDef *pdev, USBD_CDC_ItfTypeDef *fops)
 USBD_CDC_RegisterInterface. More...
 
uint8_t USBD_CDC_SetTxBuffer (USBD_HandleTypeDef *pdev, uint8_t *pbuff, uint16_t length)
 USBD_CDC_SetTxBuffer. More...
 
uint8_t USBD_CDC_SetRxBuffer (USBD_HandleTypeDef *pdev, uint8_t *pbuff)
 USBD_CDC_SetRxBuffer. More...
 
uint8_t USBD_CDC_TransmitPacket (USBD_HandleTypeDef *pdev)
 USBD_CDC_DataOut Data received on non-control Out endpoint. More...
 
uint8_t USBD_CDC_ReceivePacket (USBD_HandleTypeDef *pdev)
 USBD_CDC_ReceivePacket prepare OUT Endpoint for reception. More...
 
static uint8_t USBD_CDC_Init (USBD_HandleTypeDef *pdev, uint8_t cfgidx)
 USBD_CDC_Init Initialize the CDC interface. More...
 
static uint8_t USBD_CDC_DeInit (USBD_HandleTypeDef *pdev, uint8_t cfgidx)
 USBD_CDC_Init DeInitialize the CDC layer. More...
 
static uint8_t USBD_CDC_Setup (USBD_HandleTypeDef *pdev, USBD_SetupReqTypedef *req)
 USBD_CDC_Setup Handle the CDC specific requests. More...
 
static uint8_t USBD_CDC_DataIn (USBD_HandleTypeDef *pdev, uint8_t epnum)
 USBD_CDC_DataIn Data sent on non-control IN endpoint. More...
 
static uint8_t USBD_CDC_DataOut (USBD_HandleTypeDef *pdev, uint8_t epnum)
 USBD_CDC_DataOut Data received on non-control Out endpoint. More...
 
static uint8_t USBD_CDC_EP0_RxReady (USBD_HandleTypeDef *pdev)
 USBD_CDC_DataOut Data received on non-control Out endpoint. More...
 
static uint8_tUSBD_CDC_GetFSCfgDesc (uint16_t *length)
 USBD_CDC_GetFSCfgDesc Return configuration descriptor. More...
 
static uint8_tUSBD_CDC_GetHSCfgDesc (uint16_t *length)
 USBD_CDC_GetHSCfgDesc Return configuration descriptor. More...
 
static uint8_tUSBD_CDC_GetOtherSpeedCfgDesc (uint16_t *length)
 USBD_CDC_GetCfgDesc Return configuration descriptor. More...
 
uint8_tUSBD_CDC_GetDeviceQualifierDescriptor (uint16_t *length)
 DeviceQualifierDescriptor return Device Qualifier descriptor. More...
 

Detailed Description

Function Documentation

◆ USBD_CDC_RegisterInterface()

uint8_t USBD_CDC_RegisterInterface ( USBD_HandleTypeDef pdev,
USBD_CDC_ItfTypeDef fops 
)

USBD_CDC_RegisterInterface.

Parameters
pdevdevice instance
fopsCD Interface callback
Return values
status
792 {
793  uint8_t ret = USBD_FAIL;
794 
795  if(fops != NULL)
796  {
797  pdev->pUserData= fops;
798  ret = USBD_OK;
799  }
800 
801  return ret;
802 }
Here is the caller graph for this function:

◆ USBD_CDC_SetTxBuffer()

uint8_t USBD_CDC_SetTxBuffer ( USBD_HandleTypeDef pdev,
uint8_t pbuff,
uint16_t  length 
)

USBD_CDC_SetTxBuffer.

Parameters
pdevdevice instance
pbuffTx Buffer
Return values
status
813 {
815 
816  hcdc->TxBuffer = pbuff;
817  hcdc->TxLength = length;
818 
819  return USBD_OK;
820 }
Here is the caller graph for this function:

◆ USBD_CDC_SetRxBuffer()

uint8_t USBD_CDC_SetRxBuffer ( USBD_HandleTypeDef pdev,
uint8_t pbuff 
)

USBD_CDC_SetRxBuffer.

Parameters
pdevdevice instance
pbuffRx Buffer
Return values
status
831 {
833 
834  hcdc->RxBuffer = pbuff;
835 
836  return USBD_OK;
837 }
Here is the caller graph for this function:

◆ USBD_CDC_TransmitPacket()

uint8_t USBD_CDC_TransmitPacket ( USBD_HandleTypeDef pdev)

USBD_CDC_DataOut Data received on non-control Out endpoint.

Parameters
pdevdevice instance
epnumendpoint number
Return values
status
847 {
849 
850  if(pdev->pClassData != NULL)
851  {
852  if(hcdc->TxState == 0)
853  {
854  /* Tx Transfer in progress */
855  hcdc->TxState = 1;
856 
857  /* Transmit next packet */
858  USBD_LL_Transmit(pdev,
859  CDC_IN_EP,
860  hcdc->TxBuffer,
861  hcdc->TxLength);
862 
863  return USBD_OK;
864  }
865  else
866  {
867  return USBD_BUSY;
868  }
869  }
870  else
871  {
872  return USBD_FAIL;
873  }
874 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBD_CDC_ReceivePacket()

uint8_t USBD_CDC_ReceivePacket ( USBD_HandleTypeDef pdev)

USBD_CDC_ReceivePacket prepare OUT Endpoint for reception.

Parameters
pdevdevice instance
Return values
status
884 {
886 
887  /* Suspend or Resume USB Out process */
888  if(pdev->pClassData != NULL)
889  {
890  if(pdev->dev_speed == USBD_SPEED_HIGH )
891  {
892  /* Prepare Out endpoint to receive next packet */
894  CDC_OUT_EP,
895  hcdc->RxBuffer,
897  }
898  else
899  {
900  /* Prepare Out endpoint to receive next packet */
902  CDC_OUT_EP,
903  hcdc->RxBuffer,
905  }
906  return USBD_OK;
907  }
908  else
909  {
910  return USBD_FAIL;
911  }
912 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBD_CDC_Init()

static uint8_t USBD_CDC_Init ( USBD_HandleTypeDef pdev,
uint8_t  cfgidx 
)
static

USBD_CDC_Init Initialize the CDC interface.

Parameters
pdevdevice instance
cfgidxConfiguration index
Return values
status
477 {
478  uint8_t ret = 0;
480 
481  if(pdev->dev_speed == USBD_SPEED_HIGH )
482  {
483  /* Open EP IN */
484  USBD_LL_OpenEP(pdev,
485  CDC_IN_EP,
488 
489  /* Open EP OUT */
490  USBD_LL_OpenEP(pdev,
491  CDC_OUT_EP,
494 
495  }
496  else
497  {
498  /* Open EP IN */
499  USBD_LL_OpenEP(pdev,
500  CDC_IN_EP,
503 
504  /* Open EP OUT */
505  USBD_LL_OpenEP(pdev,
506  CDC_OUT_EP,
509  }
510  /* Open Command IN EP */
511  USBD_LL_OpenEP(pdev,
512  CDC_CMD_EP,
515 
516 
518 
519  if(pdev->pClassData == NULL)
520  {
521  ret = 1;
522  }
523  else
524  {
525  hcdc = (USBD_CDC_HandleTypeDef*) pdev->pClassData;
526 
527  /* Init physical Interface components */
528  ((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Init();
529 
530  /* Init Xfer states */
531  hcdc->TxState =0;
532  hcdc->RxState =0;
533 
534  if(pdev->dev_speed == USBD_SPEED_HIGH )
535  {
536  /* Prepare Out endpoint to receive next packet */
538  CDC_OUT_EP,
539  hcdc->RxBuffer,
541  }
542  else
543  {
544  /* Prepare Out endpoint to receive next packet */
546  CDC_OUT_EP,
547  hcdc->RxBuffer,
549  }
550 
551 
552  }
553  return ret;
554 }
Here is the call graph for this function:

◆ USBD_CDC_DeInit()

static uint8_t USBD_CDC_DeInit ( USBD_HandleTypeDef pdev,
uint8_t  cfgidx 
)
static

USBD_CDC_Init DeInitialize the CDC layer.

Parameters
pdevdevice instance
cfgidxConfiguration index
Return values
status
565 {
566  uint8_t ret = 0;
567 
568  /* Open EP IN */
569  USBD_LL_CloseEP(pdev,
570  CDC_IN_EP);
571 
572  /* Open EP OUT */
573  USBD_LL_CloseEP(pdev,
574  CDC_OUT_EP);
575 
576  /* Open Command IN EP */
577  USBD_LL_CloseEP(pdev,
578  CDC_CMD_EP);
579 
580 
581  /* DeInit physical Interface components */
582  if(pdev->pClassData != NULL)
583  {
584  ((USBD_CDC_ItfTypeDef *)pdev->pUserData)->DeInit();
585  USBD_free(pdev->pClassData);
586  pdev->pClassData = NULL;
587  }
588 
589  return ret;
590 }
Here is the call graph for this function:

◆ USBD_CDC_Setup()

static uint8_t USBD_CDC_Setup ( USBD_HandleTypeDef pdev,
USBD_SetupReqTypedef req 
)
static

USBD_CDC_Setup Handle the CDC specific requests.

Parameters
pdevinstance
requsb requests
Return values
status
601 {
603  static uint8_t ifalt = 0;
604 
605  switch (req->bmRequest & USB_REQ_TYPE_MASK)
606  {
607  case USB_REQ_TYPE_CLASS :
608  if (req->wLength)
609  {
610  if (req->bmRequest & 0x80)
611  {
612  ((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Control(req->bRequest,
613  (uint8_t *)hcdc->data,
614  req->wLength);
615  USBD_CtlSendData (pdev,
616  (uint8_t *)hcdc->data,
617  req->wLength);
618  }
619  else
620  {
621  hcdc->CmdOpCode = req->bRequest;
622  hcdc->CmdLength = req->wLength;
623 
624  USBD_CtlPrepareRx (pdev,
625  (uint8_t *)hcdc->data,
626  req->wLength);
627  }
628 
629  }
630  else
631  {
632  ((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Control(req->bRequest,
633  (uint8_t*)req,
634  0);
635  }
636  break;
637 
639  switch (req->bRequest)
640  {
641  case USB_REQ_GET_INTERFACE :
642  USBD_CtlSendData (pdev,
643  &ifalt,
644  1);
645  break;
646 
647  case USB_REQ_SET_INTERFACE :
648  break;
649  }
650 
651  default:
652  break;
653  }
654  return USBD_OK;
655 }
Here is the call graph for this function:

◆ USBD_CDC_DataIn()

static uint8_t USBD_CDC_DataIn ( USBD_HandleTypeDef pdev,
uint8_t  epnum 
)
static

USBD_CDC_DataIn Data sent on non-control IN endpoint.

Parameters
pdevdevice instance
epnumendpoint number
Return values
status
665 {
667 
668  if(pdev->pClassData != NULL)
669  {
670 
671  hcdc->TxState = 0;
672 
673  return USBD_OK;
674  }
675  else
676  {
677  return USBD_FAIL;
678  }
679 }

◆ USBD_CDC_DataOut()

static uint8_t USBD_CDC_DataOut ( USBD_HandleTypeDef pdev,
uint8_t  epnum 
)
static

USBD_CDC_DataOut Data received on non-control Out endpoint.

Parameters
pdevdevice instance
epnumendpoint number
Return values
status
689 {
691 
692  /* Get the received data length */
693  hcdc->RxLength = USBD_LL_GetRxDataSize (pdev, epnum);
694 
695  /* USB data will be immediately processed, this allow next USB traffic being
696  NAKed till the end of the application Xfer */
697  if(pdev->pClassData != NULL)
698  {
699  ((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Receive(hcdc->RxBuffer, &hcdc->RxLength);
700 
701  return USBD_OK;
702  }
703  else
704  {
705  return USBD_FAIL;
706  }
707 }
Here is the call graph for this function:

◆ USBD_CDC_EP0_RxReady()

static uint8_t USBD_CDC_EP0_RxReady ( USBD_HandleTypeDef pdev)
static

USBD_CDC_DataOut Data received on non-control Out endpoint.

Parameters
pdevdevice instance
epnumendpoint number
Return values
status
719 {
721 
722  if((pdev->pUserData != NULL) && (hcdc->CmdOpCode != 0xFF))
723  {
724  ((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Control(hcdc->CmdOpCode,
725  (uint8_t *)hcdc->data,
726  hcdc->CmdLength);
727  hcdc->CmdOpCode = 0xFF;
728 
729  }
730  return USBD_OK;
731 }

◆ USBD_CDC_GetFSCfgDesc()

static uint8_t * USBD_CDC_GetFSCfgDesc ( uint16_t *  length)
static

USBD_CDC_GetFSCfgDesc Return configuration descriptor.

Parameters
speed: current device speed
length: pointer data length
Return values
pointerto descriptor buffer
741 {
742  *length = sizeof (USBD_CDC_CfgFSDesc);
743  return USBD_CDC_CfgFSDesc;
744 }

◆ USBD_CDC_GetHSCfgDesc()

static uint8_t * USBD_CDC_GetHSCfgDesc ( uint16_t *  length)
static

USBD_CDC_GetHSCfgDesc Return configuration descriptor.

Parameters
speed: current device speed
length: pointer data length
Return values
pointerto descriptor buffer
754 {
755  *length = sizeof (USBD_CDC_CfgHSDesc);
756  return USBD_CDC_CfgHSDesc;
757 }

◆ USBD_CDC_GetOtherSpeedCfgDesc()

static uint8_t * USBD_CDC_GetOtherSpeedCfgDesc ( uint16_t *  length)
static

USBD_CDC_GetCfgDesc Return configuration descriptor.

Parameters
speed: current device speed
length: pointer data length
Return values
pointerto descriptor buffer
767 {
768  *length = sizeof (USBD_CDC_OtherSpeedCfgDesc);
769  return USBD_CDC_OtherSpeedCfgDesc;
770 }

◆ USBD_CDC_GetDeviceQualifierDescriptor()

uint8_t * USBD_CDC_GetDeviceQualifierDescriptor ( uint16_t *  length)

DeviceQualifierDescriptor return Device Qualifier descriptor.

Parameters
length: pointer data length
Return values
pointerto descriptor buffer
779 {
780  *length = sizeof (USBD_CDC_DeviceQualifierDesc);
781  return USBD_CDC_DeviceQualifierDesc;
782 }
CDC_DATA_HS_IN_PACKET_SIZE
#define CDC_DATA_HS_IN_PACKET_SIZE
Definition: usbd_cdc.h:62
usb_setup_req::wLength
uint16_t wLength
Definition: usbd_def.h:155
USBD_CDC_HandleTypeDef::RxState
__IO uint32_t RxState
Definition: usbd_cdc.h:122
USBD_LL_GetRxDataSize
uint32_t USBD_LL_GetRxDataSize(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
Returns the last transfered packet size.
Definition: usbd_conf.c:696
USBD_EP_TYPE_INTR
#define USBD_EP_TYPE_INTR
Definition: usbd_def.h:136
USBD_CDC_HandleTypeDef::RxBuffer
uint8_t * RxBuffer
Definition: usbd_cdc.h:116
USB_REQ_GET_INTERFACE
#define USB_REQ_GET_INTERFACE
Definition: usbd_def.h:91
USBD_CDC_HandleTypeDef::data
uint32_t data[CDC_DATA_HS_MAX_PACKET_SIZE/4]
Definition: usbd_cdc.h:113
USBD_FAIL
Definition: usbd_def.h:197
usb_setup_req::bmRequest
uint8_t bmRequest
Definition: usbd_def.h:151
USBD_LL_CloseEP
USBD_StatusTypeDef USBD_LL_CloseEP(USBD_HandleTypeDef *pdev, uint8_t ep_addr)
Closes an endpoint of the low level driver.
Definition: usbd_conf.c:452
_USBD_HandleTypeDef::pClassData
void * pClassData
Definition: usbd_def.h:246
USB_REQ_SET_INTERFACE
#define USB_REQ_SET_INTERFACE
Definition: usbd_def.h:92
NULL
#define NULL
Definition: usbd_def.h:53
USBD_CDC_HandleTypeDef::CmdLength
uint8_t CmdLength
Definition: usbd_cdc.h:115
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
USB_REQ_TYPE_MASK
#define USB_REQ_TYPE_MASK
Definition: usbd_def.h:76
USBD_CtlSendData
USBD_StatusTypeDef USBD_CtlSendData(USBD_HandleTypeDef *pdev, uint8_t *buf, uint16_t len)
USBD_CtlSendData send data on the ctl pipe.
Definition: usbd_ioreq.c:95
CDC_IN_EP
#define CDC_IN_EP
Definition: usbd_cdc.h:52
USBD_CDC_HandleTypeDef::TxState
__IO uint32_t TxState
Definition: usbd_cdc.h:121
USBD_CtlPrepareRx
USBD_StatusTypeDef USBD_CtlPrepareRx(USBD_HandleTypeDef *pdev, uint8_t *pbuf, uint16_t len)
USBD_CtlPrepareRx receive data on the ctl pipe.
Definition: usbd_ioreq.c:135
USB_REQ_TYPE_CLASS
#define USB_REQ_TYPE_CLASS
Definition: usbd_def.h:74
USBD_EP_TYPE_BULK
#define USBD_EP_TYPE_BULK
Definition: usbd_def.h:135
_USBD_CDC_Itf
Definition: usbd_cdc.h:101
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.
Definition: usbd_conf.c:630
USBD_BUSY
Definition: usbd_def.h:196
USBD_SPEED_HIGH
Definition: usbd_def.h:188
USBD_CDC_HandleTypeDef
Definition: usbd_cdc.h:111
USBD_malloc
#define USBD_malloc
Definition: usbd_conf.h:126
uint8_t
const uint8_t[]
Definition: 404_html.c:3
CDC_DATA_FS_OUT_PACKET_SIZE
#define CDC_DATA_FS_OUT_PACKET_SIZE
Definition: usbd_cdc.h:66
_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_CDC_HandleTypeDef::TxBuffer
uint8_t * TxBuffer
Definition: usbd_cdc.h:117
USBD_CDC_HandleTypeDef::RxLength
uint32_t RxLength
Definition: usbd_cdc.h:118
usb_setup_req::bRequest
uint8_t bRequest
Definition: usbd_def.h:152
_USBD_HandleTypeDef::pUserData
void * pUserData
Definition: usbd_def.h:247
CDC_DATA_FS_IN_PACKET_SIZE
#define CDC_DATA_FS_IN_PACKET_SIZE
Definition: usbd_cdc.h:65
USBD_CDC_HandleTypeDef::CmdOpCode
uint8_t CmdOpCode
Definition: usbd_cdc.h:114
CDC_OUT_EP
#define CDC_OUT_EP
Definition: usbd_cdc.h:53
USB_REQ_TYPE_STANDARD
#define USB_REQ_TYPE_STANDARD
Definition: usbd_def.h:73
length
png_uint_32 length
Definition: png.c:2247
CDC_CMD_PACKET_SIZE
#define CDC_CMD_PACKET_SIZE
Definition: usbd_cdc.h:59
USBD_CDC_HandleTypeDef::TxLength
uint32_t TxLength
Definition: usbd_cdc.h:119
USBD_OK
Definition: usbd_def.h:195
CDC_CMD_EP
#define CDC_CMD_EP
Definition: usbd_cdc.h:54
CDC_DATA_HS_OUT_PACKET_SIZE
#define CDC_DATA_HS_OUT_PACKET_SIZE
Definition: usbd_cdc.h:63
USBD_free
#define USBD_free
Definition: usbd_conf.h:129