当前位置: 首页>>代码示例>>C++>>正文


C++ USBD_CtlSendData函数代码示例

本文整理汇总了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;
}
开发者ID:madcowswe,项目名称:ODrive,代码行数:67,代码来源:usbd_cdc.c

示例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;
    }
  }
}
开发者ID:Poopi,项目名称:UsbXlater,代码行数:41,代码来源:usbd_req.c

示例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;
    }
  }
}
开发者ID:Denis-J,项目名称:ChocoStep,代码行数:33,代码来源:usbd_req.c

示例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;
    }
  }
}
开发者ID:Autonobotics,项目名称:NavigationFirmware,代码行数:39,代码来源:usbd_ctlreq.c

示例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;
}
开发者ID:8bitgeek,项目名称:Espruino,代码行数:53,代码来源:usbd_cdc_hid.c

示例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;
}
开发者ID:volpi3000,项目名称:U23-Library,代码行数:31,代码来源:USB_Device.c

示例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;
  }
}
开发者ID:HuanDeng,项目名称:Qproject,代码行数:37,代码来源:usbd_req.c

示例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);
}
开发者ID:spark,项目名称:firmware,代码行数:66,代码来源:usbd_dfu_core.c

示例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);
}
开发者ID:12019,项目名称:STM32F4_UVC_Camera,代码行数:14,代码来源:usbd_audio_core.c

示例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;
  }
}
开发者ID:Denis-J,项目名称:ChocoStep,代码行数:29,代码来源:usbd_req.c

示例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;
  }
}
开发者ID:Poopi,项目名称:UsbXlater,代码行数:39,代码来源:usbd_req.c

示例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);
}
开发者ID:RobertNewkirk,项目名称:particle,代码行数:13,代码来源:usbd_dfu_core.c

示例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;
}
开发者ID:Samwuzhitao,项目名称:My_MINI103_Github,代码行数:40,代码来源:usbd_cdc.c

示例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;
  }
}
开发者ID:Autonobotics,项目名称:NavigationFirmware,代码行数:38,代码来源:usbd_ctlreq.c

示例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;
  }
}
开发者ID:nandojve,项目名称:lrndis,代码行数:25,代码来源:usbd_rndis_core.c


注:本文中的USBD_CtlSendData函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。