Prusa MINI Firmware overview
USBH_CTLREQ_Exported_FunctionsPrototype
Collaboration diagram for USBH_CTLREQ_Exported_FunctionsPrototype:

Functions

USBH_StatusTypeDef USBH_CtlReq (USBH_HandleTypeDef *phost, uint8_t *buff, uint16_t length)
 USBH_CtlReq USBH_CtlReq sends a control request and provide the status after completion of the request. More...
 
USBH_StatusTypeDef USBH_GetDescriptor (USBH_HandleTypeDef *phost, uint8_t req_type, uint16_t value_idx, uint8_t *buff, uint16_t length)
 USBH_GetDescriptor Issues Descriptor command to the device. Once the response received, it parses the descriptor and updates the status. More...
 
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, it parses the device descriptor and updates the status. More...
 
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, it parses the string descriptor and updates the status. More...
 
USBH_StatusTypeDef USBH_SetCfg (USBH_HandleTypeDef *phost, uint16_t configuration_value)
 USBH_SetCfg The command sets the configuration value to the connected device. More...
 
USBH_StatusTypeDef USBH_Get_CfgDesc (USBH_HandleTypeDef *phost, uint16_t length)
 USBH_Get_CfgDesc Issues Configuration Descriptor to the device. Once the response received, it parses the configuration descriptor and updates the status. More...
 
USBH_StatusTypeDef USBH_SetAddress (USBH_HandleTypeDef *phost, uint8_t DeviceAddress)
 USBH_SetAddress This command sets the address to the connected device. More...
 
USBH_StatusTypeDef USBH_SetInterface (USBH_HandleTypeDef *phost, uint8_t ep_num, uint8_t altSetting)
 USBH_SetInterface The command sets the Interface value to the connected device. More...
 
USBH_StatusTypeDef USBH_ClrFeature (USBH_HandleTypeDef *phost, uint8_t ep_num)
 USBH_ClrFeature This request is used to clear or disable a specific feature. More...
 
USBH_DescHeader_tUSBH_GetNextDesc (uint8_t *pbuf, uint16_t *ptr)
 USBH_GetNextDesc This function return the next descriptor header. More...
 

Detailed Description

Function Documentation

◆ USBH_CtlReq()

USBH_StatusTypeDef USBH_CtlReq ( USBH_HandleTypeDef phost,
uint8_t buff,
uint16_t  length 
)

USBH_CtlReq USBH_CtlReq sends a control request and provide the status after completion of the request.

Parameters
phostHost Handle
reqSetup Request Structure
buffdata buffer address to store the response
lengthlength of the response
Return values
USBHStatus
534 {
536  status = USBH_BUSY;
537 
538  switch (phost->RequestState)
539  {
540  case CMD_SEND:
541  /* Start a SETUP transfer */
542  phost->Control.buff = buff;
543  phost->Control.length = length;
544  phost->Control.state = CTRL_SETUP;
545  phost->RequestState = CMD_WAIT;
546  status = USBH_BUSY;
547 #if (USBH_USE_OS == 1)
548  osMessagePut ( phost->os_event, USBH_CONTROL_EVENT, 0);
549 #endif
550  break;
551 
552  case CMD_WAIT:
553  status = USBH_HandleControl(phost);
554  if (status == USBH_OK)
555  {
556  /* Commands successfully sent and Response Received */
557  phost->RequestState = CMD_SEND;
558  phost->Control.state =CTRL_IDLE;
559  status = USBH_OK;
560  }
561  else if (status == USBH_FAIL)
562  {
563  /* Failure Mode */
564  phost->RequestState = CMD_SEND;
565  status = USBH_FAIL;
566  }
567  break;
568 
569  default:
570  break;
571  }
572  return status;
573 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBH_GetDescriptor()

USBH_StatusTypeDef USBH_GetDescriptor ( USBH_HandleTypeDef phost,
uint8_t  req_type,
uint16_t  value_idx,
uint8_t buff,
uint16_t  length 
)

USBH_GetDescriptor Issues Descriptor command to the device. Once the response received, it parses the descriptor and updates the status.

Parameters
phostHost Handle
req_typeDescriptor type
value_idxValue for the GetDescriptr request
buffBuffer to store the descriptor
lengthLength of the descriptor
Return values
USBHStatus
209 {
210  if(phost->RequestState == CMD_SEND)
211  {
212  phost->Control.setup.b.bmRequestType = USB_D2H | req_type;
214  phost->Control.setup.b.wValue.w = value_idx;
215 
216  if ((value_idx & 0xff00) == USB_DESC_STRING)
217  {
218  phost->Control.setup.b.wIndex.w = 0x0409;
219  }
220  else
221  {
222  phost->Control.setup.b.wIndex.w = 0;
223  }
224  phost->Control.setup.b.wLength.w = length;
225  }
226  return USBH_CtlReq(phost, buff , length );
227 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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, it parses the device descriptor and updates the status.

Parameters
phostHost Handle
lengthLength of the descriptor
Return values
USBHStatus
113 {
115 
116  if((status = USBH_GetDescriptor(phost,
119  phost->device.Data,
120  length)) == USBH_OK)
121  {
122  /* Commands successfully sent and Response Received */
123  USBH_ParseDevDesc(&phost->device.DevDesc, phost->device.Data, length);
124  }
125  return status;
126 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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, it parses the string descriptor and updates the status.

Parameters
phostHost Handle
string_indexString index for the descriptor
buffBuffer address for the descriptor
lengthLength of the descriptor
Return values
USBHStatus
179 {
181  if((status = USBH_GetDescriptor(phost,
183  USB_DESC_STRING | string_index,
184  phost->device.Data,
185  length)) == USBH_OK)
186  {
187  /* Commands successfully sent and Response Received */
188  USBH_ParseStringDesc(phost->device.Data,buff, length);
189  }
190  return status;
191 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBH_SetCfg()

USBH_StatusTypeDef USBH_SetCfg ( USBH_HandleTypeDef phost,
uint16_t  cfg_idx 
)

USBH_SetCfg The command sets the configuration value to the connected device.

Parameters
phostHost Handle
cfg_idxConfiguration value
Return values
USBHStatus
262 {
263  if(phost->RequestState == CMD_SEND)
264  {
266  USB_REQ_TYPE_STANDARD;
268  phost->Control.setup.b.wValue.w = cfg_idx;
269  phost->Control.setup.b.wIndex.w = 0;
270  phost->Control.setup.b.wLength.w = 0;
271  }
272 
273  return USBH_CtlReq(phost, 0 , 0 );
274 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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, it parses the configuration descriptor and updates the status.

Parameters
phostHost Handle
lengthLength of the descriptor
Return values
USBHStatus
140 {
142  uint8_t *pData;
143 #if (USBH_KEEP_CFG_DESCRIPTOR == 1)
144  pData = phost->device.CfgDesc_Raw;
145 #else
146  pData = phost->device.Data;
147 #endif
148  if((status = USBH_GetDescriptor(phost,
151  pData,
152  length)) == USBH_OK)
153  {
154 
155  /* Commands successfully sent and Response Received */
157  pData,
158  length);
159 
160  }
161  return status;
162 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBH_SetAddress()

USBH_StatusTypeDef USBH_SetAddress ( USBH_HandleTypeDef phost,
uint8_t  DeviceAddress 
)

USBH_SetAddress This command sets the address to the connected device.

Parameters
phostHost Handle
DeviceAddressDevice address to assign
Return values
USBHStatus
238 {
239  if(phost->RequestState == CMD_SEND)
240  {
242  USB_REQ_TYPE_STANDARD;
243 
245 
246  phost->Control.setup.b.wValue.w = (uint16_t)DeviceAddress;
247  phost->Control.setup.b.wIndex.w = 0;
248  phost->Control.setup.b.wLength.w = 0;
249  }
250  return USBH_CtlReq(phost, 0 , 0 );
251 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBH_SetInterface()

USBH_StatusTypeDef USBH_SetInterface ( USBH_HandleTypeDef phost,
uint8_t  ep_num,
uint8_t  altSetting 
)

USBH_SetInterface The command sets the Interface value to the connected device.

Parameters
phostHost Handle
altSettingInterface value
Return values
USBHStatus
285 {
286 
287  if(phost->RequestState == CMD_SEND)
288  {
290  USB_REQ_TYPE_STANDARD;
291 
293  phost->Control.setup.b.wValue.w = altSetting;
294  phost->Control.setup.b.wIndex.w = ep_num;
295  phost->Control.setup.b.wLength.w = 0;
296  }
297  return USBH_CtlReq(phost, 0 , 0 );
298 }
Here is the call graph for this function:

◆ USBH_ClrFeature()

USBH_StatusTypeDef USBH_ClrFeature ( USBH_HandleTypeDef phost,
uint8_t  ep_num 
)

USBH_ClrFeature This request is used to clear or disable a specific feature.

Parameters
phostHost Handle
ep_numendpoint number
hc_numHost channel number
Return values
USBHStatus
310 {
311  if(phost->RequestState == CMD_SEND)
312  {
313  phost->Control.setup.b.bmRequestType = USB_H2D |
316 
319  phost->Control.setup.b.wIndex.w = ep_num;
320  phost->Control.setup.b.wLength.w = 0;
321  }
322  return USBH_CtlReq(phost, 0 , 0 );
323 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ USBH_GetNextDesc()

USBH_DescHeader_t* USBH_GetNextDesc ( uint8_t pbuf,
uint16_t *  ptr 
)

USBH_GetNextDesc This function return the next descriptor header.

Parameters
bufBuffer where the cfg descriptor is available
ptrdata pointer inside the cfg descriptor
Return values
nextheader
510 {
511  USBH_DescHeader_t *pnext;
512 
513  *ptr += ((USBH_DescHeader_t *)pbuf)->bLength;
514  pnext = (USBH_DescHeader_t *)((uint8_t *)pbuf + \
515  ((USBH_DescHeader_t *)pbuf)->bLength);
516 
517  return(pnext);
518 }
Here is the caller graph for this function:
CMD_WAIT
Definition: usbh_def.h:381
USB_REQ_SET_ADDRESS
#define USB_REQ_SET_ADDRESS
Definition: usbd_def.h:86
USBH_CtrlTypeDef::setup
USB_Setup_TypeDef setup
Definition: usbh_def.h:412
USB_REQ_SET_CONFIGURATION
#define USB_REQ_SET_CONFIGURATION
Definition: usbd_def.h:90
USBH_CtrlTypeDef::buff
uint8_t * buff
Definition: usbh_def.h:409
_USB_Setup::_SetupPkt_Struc::bRequest
uint8_t bRequest
Definition: usbh_def.h:222
USBH_HandleControl
static USBH_StatusTypeDef USBH_HandleControl(USBH_HandleTypeDef *phost)
USBH_HandleControl Handles the USB control transfer state machine.
Definition: usbh_ctlreq.c:581
_USBH_HandleTypeDef::RequestState
CMD_StateTypeDef RequestState
Definition: usbh_def.h:454
USBH_DeviceTypeDef::Data
uint8_t Data[USBH_MAX_DATA_BUFFER]
Definition: usbh_def.h:424
USB_REQ_CLEAR_FEATURE
#define USB_REQ_CLEAR_FEATURE
Definition: usbd_def.h:84
USBH_DeviceTypeDef::DevDesc
USBH_DevDescTypeDef DevDesc
Definition: usbh_def.h:429
_USB_Setup::_SetupPkt_Struc::wIndex
uint16_t_uint8_t wIndex
Definition: usbh_def.h:224
USBH_CtrlTypeDef::length
uint16_t length
Definition: usbh_def.h:410
USBH_ParseDevDesc
static void USBH_ParseDevDesc(USBH_DevDescTypeDef *, uint8_t *buf, uint16_t length)
USBH_ParseDevDesc This function Parses the device descriptor.
Definition: usbh_ctlreq.c:333
USB_REQ_SET_INTERFACE
#define USB_REQ_SET_INTERFACE
Definition: usbd_def.h:92
_DescHeader
Definition: usbh_def.h:230
_USBH_HandleTypeDef::Control
USBH_CtrlTypeDef Control
Definition: usbh_def.h:455
_USB_Setup::_SetupPkt_Struc::wValue
uint16_t_uint8_t wValue
Definition: usbh_def.h:223
USB_DESC_STRING
#define USB_DESC_STRING
Definition: usbh_def.h:160
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
USB_REQ_GET_DESCRIPTOR
#define USB_REQ_GET_DESCRIPTOR
Definition: usbd_def.h:87
USBH_DeviceTypeDef::CfgDesc
USBH_CfgDescTypeDef CfgDesc
Definition: usbh_def.h:430
FEATURE_SELECTOR_ENDPOINT
#define FEATURE_SELECTOR_ENDPOINT
Definition: usbh_ctlreq.h:57
CMD_SEND
Definition: usbh_def.h:380
_USB_Setup::_SetupPkt_Struc::wLength
uint16_t_uint8_t wLength
Definition: usbh_def.h:225
USBH_OK
Definition: usbh_def.h:304
osMessagePut
osStatus osMessagePut(osMessageQId queue_id, uint32_t info, uint32_t millisec)
Put a Message to a Queue.
Definition: cmsis_os.c:1113
_USBH_HandleTypeDef::device
USBH_DeviceTypeDef device
Definition: usbh_def.h:456
USBH_CONTROL_EVENT
Definition: usbh_def.h:397
USBH_CtrlTypeDef::state
CTRL_StateTypeDef state
Definition: usbh_def.h:413
USBH_ParseStringDesc
static void USBH_ParseStringDesc(uint8_t *psrc, uint8_t *pdest, uint16_t length)
USBH_ParseStringDesc This function Parses the string descriptor.
Definition: usbh_ctlreq.c:472
uint8_t
const uint8_t[]
Definition: 404_html.c:3
USBH_ParseCfgDesc
static void USBH_ParseCfgDesc(USBH_CfgDescTypeDef *cfg_desc, uint8_t *buf, uint16_t length)
USBH_ParseCfgDesc This function Parses the configuration descriptor.
Definition: usbh_ctlreq.c:366
USBH_CtlReq
USBH_StatusTypeDef USBH_CtlReq(USBH_HandleTypeDef *phost, uint8_t *buff, uint16_t length)
USBH_CtlReq USBH_CtlReq sends a control request and provide the status after completion of the reques...
Definition: usbh_ctlreq.c:531
_USB_Setup::b
struct _USB_Setup::_SetupPkt_Struc b
USBH_StatusTypeDef
USBH_StatusTypeDef
Definition: usbh_def.h:302
CTRL_SETUP
Definition: usbh_def.h:360
_DescHeader::bLength
uint8_t bLength
Definition: usbh_def.h:232
status
static status_t status
Definition: filament_sensor.c:37
USB_H2D
#define USB_H2D
Definition: usbh_def.h:108
CTRL_IDLE
Definition: usbh_def.h:359
uint16_t_uint8_t::w
uint16_t w
Definition: usbh_def.h:204
USB_REQ_RECIPIENT_ENDPOINT
#define USB_REQ_RECIPIENT_ENDPOINT
Definition: usbd_def.h:80
USBH_GetDescriptor
USBH_StatusTypeDef USBH_GetDescriptor(USBH_HandleTypeDef *phost, uint8_t req_type, uint16_t value_idx, uint8_t *buff, uint16_t length)
USBH_GetDescriptor Issues Descriptor command to the device. Once the response received,...
Definition: usbh_ctlreq.c:204
USBH_FAIL
Definition: usbh_def.h:306
USB_D2H
#define USB_D2H
Definition: usbh_def.h:109
USBH_BUSY
Definition: usbh_def.h:305
USB_DESC_CONFIGURATION
#define USB_DESC_CONFIGURATION
Definition: usbh_def.h:159
USB_DESC_DEVICE
#define USB_DESC_DEVICE
Definition: usbh_def.h:158
USB_REQ_TYPE_STANDARD
#define USB_REQ_TYPE_STANDARD
Definition: usbd_def.h:73
length
png_uint_32 length
Definition: png.c:2247
_USB_Setup::_SetupPkt_Struc::bmRequestType
uint8_t bmRequestType
Definition: usbh_def.h:221
pbuf
Definition: pbuf.h:142