本文整理汇总了C++中USBD_CtlSendData函数的典型用法代码示例。如果您正苦于以下问题:C++ USBD_CtlSendData函数的具体用法?C++ USBD_CtlSendData怎么用?C++ USBD_CtlSendData使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了USBD_CtlSendData函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: USBD_CDC_Setup
/**
* @brief USBD_CDC_Setup
* Handle the CDC specific requests
* @param pdev: instance
* @param req: usb requests
* @retval status
*/
static uint8_t USBD_CDC_Setup (USBD_HandleTypeDef *pdev,
USBD_SetupReqTypedef *req)
{
USBD_CDC_HandleTypeDef *hcdc = (USBD_CDC_HandleTypeDef*) pdev->pClassData;
static uint8_t ifalt = 0;
switch (req->bmRequest & USB_REQ_TYPE_MASK)
{
case USB_REQ_TYPE_CLASS :
if (req->wLength)
{
if (req->bmRequest & 0x80)
{
((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Control(req->bRequest,
(uint8_t *)hcdc->data,
req->wLength);
USBD_CtlSendData (pdev,
(uint8_t *)hcdc->data,
req->wLength);
}
else
{
hcdc->CmdOpCode = req->bRequest;
hcdc->CmdLength = req->wLength;
USBD_CtlPrepareRx (pdev,
(uint8_t *)hcdc->data,
req->wLength);
}
}
else
{
((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Control(req->bRequest,
(uint8_t*)req,
0);
}
break;
case USB_REQ_TYPE_STANDARD:
switch (req->bRequest)
{
case USB_REQ_GET_INTERFACE :
USBD_CtlSendData (pdev,
&ifalt,
1);
break;
case USB_REQ_SET_INTERFACE :
break;
}
case USB_REQ_TYPE_VENDOR:
return USBD_WinUSBComm_SetupVendor(pdev, req);
default:
break;
}
return USBD_OK;
}
示例2: USBD_GetConfig
/**
* @brief USBD_GetConfig
* Handle Get device configuration request
* @param pdev: device instance
* @param req: usb request
* @retval status
*/
static void USBD_GetConfig(USB_OTG_CORE_HANDLE *pdev,
USB_SETUP_REQ *req)
{
if (req->wLength != 1)
{
dbg_printf(DBGMODE_ERR, "USBD_GetConfig Stall, bad wLength 0x%04X (should be 1), file " __FILE__ ":%d\r\n", req->wLength, __LINE__);
USBD_CtlError(pdev , req);
}
else
{
switch (pdev->dev.device_status )
{
case USB_OTG_ADDRESSED:
USBD_CtlSendData (pdev,
(uint8_t *)&USBD_default_cfg,
1);
break;
case USB_OTG_CONFIGURED:
USBD_CtlSendData (pdev,
&pdev->dev.device_config,
1);
break;
default:
dbg_printf(DBGMODE_ERR, "USBD_GetConfig Stall, unknown device_status 0x%02X, file " __FILE__ ":%d\r\n", pdev->dev.device_status, __LINE__);
USBD_CtlError(pdev , req);
break;
}
}
}
示例3: USBD_GetConfig
//--------------------------------------------------------------
static void USBD_GetConfig(USB_OTG_CORE_HANDLE *pdev,
USB_SETUP_REQ *req)
{
if (req->wLength != 1)
{
USBD_CtlError(pdev , req);
}
else
{
switch (pdev->dev.device_status )
{
case USB_OTG_ADDRESSED:
USBD_CtlSendData (pdev,
(uint8_t *)&USBD_default_cfg,
1);
break;
case USB_OTG_CONFIGURED:
USBD_CtlSendData (pdev,
&pdev->dev.device_config,
1);
break;
default:
USBD_CtlError(pdev , req);
break;
}
}
}
示例4: USBD_GetConfig
/**
* @brief USBD_GetConfig
* Handle Get device configuration request
* @param pdev: device instance
* @param req: usb request
* @retval status
*/
static void USBD_GetConfig(USBD_HandleTypeDef *pdev ,
USBD_SetupReqTypedef *req)
{
if (req->wLength != 1)
{
USBD_CtlError(pdev , req);
}
else
{
switch (pdev->dev_state )
{
case USBD_STATE_ADDRESSED:
pdev->dev_default_config = 0;
USBD_CtlSendData (pdev,
(uint8_t *)&pdev->dev_default_config,
1);
break;
case USBD_STATE_CONFIGURED:
USBD_CtlSendData (pdev,
(uint8_t *)&pdev->dev_config,
1);
break;
default:
USBD_CtlError(pdev , req);
break;
}
}
}
示例5: USBD_CDC_Setup
static uint8_t USBD_CDC_Setup (USBD_HandleTypeDef *pdev,
USBD_SetupReqTypedef *req)
{
USBD_CDC_HID_HandleTypeDef *handle = (USBD_CDC_HID_HandleTypeDef*) pdev->pClassData;
static uint8_t ifalt = 0;
switch (req->bmRequest & USB_REQ_TYPE_MASK)
{
case USB_REQ_TYPE_CLASS :
if (req->wLength)
{
if (req->bmRequest & 0x80)
{
CDC_Control_FS(req->bRequest, (uint8_t *)handle->data, req->wLength);
USBD_CtlSendData (pdev,
(uint8_t *)handle->data,
req->wLength);
}
else
{
handle->CmdOpCode = req->bRequest;
handle->CmdLength = (uint8_t)req->wLength;
USBD_CtlPrepareRx (pdev,
(uint8_t *)handle->data,
req->wLength);
}
}
else
{
CDC_Control_FS(req->bRequest, (uint8_t*)req, 0);
}
break;
case USB_REQ_TYPE_STANDARD:
switch (req->bRequest)
{
case USB_REQ_GET_INTERFACE :
USBD_CtlSendData (pdev,
&ifalt,
1);
break;
case USB_REQ_SET_INTERFACE :
break;
}
default:
break;
}
return USBD_OK;
}
示例6: USBD_DEV_Setup
static uint8_t USBD_DEV_Setup(void *pdev, USB_SETUP_REQ *req)
{
printf("USB SETUP request: bmRequest: 0x%x, bRequest: 0x%x, wValue: 0x%x, wIndex: 0x%x, wLength: 0x%x\r\n",
req->bmRequest,
req->bRequest,
req->wValue,
req->wIndex,
req->wLength
);
switch (req->bmRequest & USB_REQ_TYPE_MASK)
{
case USB_REQ_TYPE_VENDOR:
switch(req->bRequest)
{
case USB_REQ_SET_VALUE:
value = req->wValue;
break;
case USB_REQ_GET_VALUE:
USBD_CtlSendData(pdev, (uint8_t*)&value, sizeof(value));
break;
default:
USBD_CtlError(pdev, req);
return USBD_FAIL;
}
}
return USBD_OK;
}
示例7: USBD_GetStatus
/**
* @brief USBD_GetStatus
* Handle Get Status request
* @param pdev: device instance
* @param req: usb request
* @retval status
*/
static void USBD_GetStatus(USB_CORE_HANDLE *pdev,
USB_SETUP_REQ *req)
{
uint32_t USBD_cfg_status = 0;
switch (pdev->dev.device_status)
{
case USB_ADDRESSED:
case USB_CONFIGURED:
#ifdef USBD_SELF_POWERED
USBD_cfg_status = USB_CONFIG_SELF_POWERED;
#else
USBD_cfg_status = 0x00;
#endif
if (pdev->dev.DevRemoteWakeup)
{
USBD_cfg_status |= USB_CONFIG_REMOTE_WAKEUP;
}
USBD_CtlSendData (pdev,
(uint8_t *)&USBD_cfg_status,
2);
break;
default :
USBD_CtlError(pdev , req);
break;
}
}
示例8: DFU_Req_GETSTATUS
/**
* @brief DFU_Req_GETSTATUS
* Handles the DFU GETSTATUS request.
* @param pdev: instance
* @retval status
*/
static void DFU_Req_GETSTATUS(void *pdev)
{
switch (DeviceState)
{
case STATE_dfuDNLOAD_SYNC:
if (wlength != 0)
{
DeviceState = STATE_dfuDNBUSY;
DeviceStatus[4] = DeviceState;
if ((wBlockNum == 0) && (MAL_Buffer[0] == CMD_ERASE))
{
MAL_GetStatus(usbd_dfu_AltSet, Pointer, 0, DeviceStatus);
}
else
{
MAL_GetStatus(usbd_dfu_AltSet, Pointer, 1, DeviceStatus);
}
}
else /* (wlength==0)*/
{
DeviceState = STATE_dfuDNLOAD_IDLE;
DeviceStatus[4] = DeviceState;
}
break;
case STATE_dfuMANIFEST_SYNC :
if (Manifest_State == Manifest_In_Progress)
{
// continue to disconnect USB and eventually reset asynchornously to ensure
// the response to this message is returned correctly.
DeviceState = STATE_dfuMANIFEST;
// get a nice output from dfu-util - original code entered STATE_dfuMANIFEST
// but this leaves a message Transitioning to dfuMANIFEST state as the last line, which just lingers with no clear indication of what to do next.
DeviceStatus[4] = STATE_dfuDNLOAD_IDLE;
//break;
}
else if ((Manifest_State == Manifest_complete) && \
((usbd_dfu_CfgDesc[(11 + (9 * USBD_DFU_INT_NUM))]) & 0x04))
{
DeviceState = STATE_dfuIDLE;
DeviceStatus[4] = DeviceState;
//break;
}
break;
case STATE_dfuMANIFEST:
{
DeviceState = STATE_dfuIDLE;
DeviceStatus[4] = DeviceState;
}
default :
break;
}
/* Send the status data over EP0 */
USBD_CtlSendData (pdev,
(uint8_t *)(&(DeviceStatus[0])),
6);
}
示例9: AUDIO_Req_GetCurrent
/**
* @brief AUDIO_Req_GetCurrent
* Handles the GET_CUR Audio control request.
* @param pdev: instance
* @param req: setup class request
* @retval status
*/
static void AUDIO_Req_GetCurrent(void *pdev, USB_SETUP_REQ *req)
{
/* Send the current mute state */
USBD_CtlSendData (pdev,
AudioCtl,
req->wLength);
}
示例10: USBD_GetStatus
//--------------------------------------------------------------
static void USBD_GetStatus(USB_OTG_CORE_HANDLE *pdev,
USB_SETUP_REQ *req)
{
switch (pdev->dev.device_status)
{
case USB_OTG_ADDRESSED:
case USB_OTG_CONFIGURED:
if (pdev->dev.DevRemoteWakeup)
{
USBD_cfg_status = USB_CONFIG_SELF_POWERED | USB_CONFIG_REMOTE_WAKEUP;
}
else
{
USBD_cfg_status = USB_CONFIG_SELF_POWERED;
}
USBD_CtlSendData (pdev,
(uint8_t *)&USBD_cfg_status,
1);
break;
default :
USBD_CtlError(pdev , req);
break;
}
}
示例11: USBD_GetStatus
/**
* @brief USBD_GetStatus
* Handle Get Status request
* @param pdev: device instance
* @param req: usb request
* @retval status
*/
static void USBD_GetStatus(USB_OTG_CORE_HANDLE *pdev,
USB_SETUP_REQ *req)
{
switch (pdev->dev.device_status)
{
case USB_OTG_ADDRESSED:
case USB_OTG_CONFIGURED:
#ifdef USBD_SELF_POWERED
USBD_cfg_status = USB_CONFIG_SELF_POWERED;
#else
USBD_cfg_status = 0x00;
#endif
if (pdev->dev.DevRemoteWakeup)
{
USBD_cfg_status |= USB_CONFIG_REMOTE_WAKEUP;
}
USBD_CtlSendData (pdev,
(uint8_t *)&USBD_cfg_status,
2);
break;
default :
dbg_printf(DBGMODE_ERR, "USBD_GetStatus Stall, unknown device_status 0x%02X, file " __FILE__ ":%d\r\n", pdev->dev.device_status, __LINE__);
USBD_CtlError(pdev , req);
break;
}
}
示例12: DFU_Req_GETSTATE
/**
* @brief DFU_Req_GETSTATE
* Handles the DFU GETSTATE request.
* @param pdev: device instance
* @retval None
*/
static void DFU_Req_GETSTATE(void *pdev)
{
/* Return the current state of the DFU interface */
USBD_CtlSendData (pdev,
&DeviceState,
1);
}
示例13: USBD_CDC_Setup
/**
* @brief USBD_CDC_Setup
* Handle the CDC specific requests
* @param pdev: instance
* @param req: usb requests
* @retval status
*/
static uint8_t USBD_CDC_Setup (USBD_HandleTypeDef *pdev,
USBD_SetupReqTypedef *req)
{
USBD_CDC_HandleTypeDef *hcdc = pdev->pClassData;
switch (req->bmRequest & USB_REQ_TYPE_MASK)
{
case USB_REQ_TYPE_CLASS :
if (req->wLength)
{
if (req->bmRequest & 0x80)
{
((USBD_CDC_ItfTypeDef *)pdev->pUserData)->Control(req->bRequest,
(uint8_t *)hcdc->data,
req->wLength);
USBD_CtlSendData (pdev,
(uint8_t *)hcdc->data,
req->wLength);
}
else
{
hcdc->CmdOpCode = req->bRequest;
hcdc->CmdLength = req->wLength;
USBD_CtlPrepareRx (pdev,
(uint8_t *)hcdc->data,
req->wLength);
}
break;
}
}
return USBD_OK;
}
示例14: USBD_GetStatus
/**
* @brief USBD_GetStatus
* Handle Get Status request
* @param pdev: device instance
* @param req: usb request
* @retval status
*/
static void USBD_GetStatus(USBD_HandleTypeDef *pdev ,
USBD_SetupReqTypedef *req)
{
switch (pdev->dev_state)
{
case USBD_STATE_ADDRESSED:
case USBD_STATE_CONFIGURED:
#if ( USBD_SELF_POWERED == 1)
pdev->dev_config_status = USB_CONFIG_SELF_POWERED;
#else
pdev->dev_config_status = 0;
#endif
if (pdev->dev_remote_wakeup)
{
pdev->dev_config_status |= USB_CONFIG_REMOTE_WAKEUP;
}
USBD_CtlSendData (pdev,
(uint8_t *)& pdev->dev_config_status,
2);
break;
default :
USBD_CtlError(pdev , req);
break;
}
}
示例15: usbd_rndis_setup
static uint8_t usbd_rndis_setup(void *pdev, USB_SETUP_REQ *req)
{
switch (req->bmRequest & USB_REQ_TYPE_MASK)
{
case USB_REQ_TYPE_CLASS :
if (req->wLength != 0) // is data setup packet?
{
/* Check if the request is Device-to-Host */
if (req->bmRequest & 0x80)
{
USBD_CtlSendData(pdev, encapsulated_buffer, ((rndis_generic_msg_t *)encapsulated_buffer)->MessageLength);
}
else /* Host-to-Device requeset */
{
USBD_CtlPrepareRx(pdev, encapsulated_buffer, req->wLength);
}
}
return USBD_OK;
default:
return USBD_OK;
// USBD_CtlError (pdev, req);
// return USBD_FAIL;
}
}