这是ST的发送
/**
* @brief USBD_HID_SendReport
* Send HID Report
* @param pdev: device instance
* @param buff: pointer to report
* @retval status
*/
uint8_t USBD_HID_SendReport(USBD_HandleTypeDef *pdev,
uint8_t *report,
uint16_t len)
{
USBD_HID_HandleTypeDef *hhid = (USBD_HID_HandleTypeDef *)pdev->pClassData;
if (pdev->dev_state == USBD_STATE_CONFIGURED)
{
if (hhid->state == HID_IDLE)
{
hhid->state = HID_BUSY;
USBD_LL_Transmit(pdev,
HID_EPIN_ADDR,
report,
len);
}
}
return USBD_OK;
}
我想改成GD的
/*!
\brief send custom HID report
\param[in] pudev: pointer to USB device instance
\param[in] report: pointer to HID report
\param[in] len: data length
\param[out] none
\retval USB device operation status
*/
uint8_t custom_hid_report_send (usb_core_handle_struct *pudev, uint8_t *report, uint16_t len)
{
for(uint8_t n = 0; n < 100; n ++)
{
if(pudev->dev.status == USB_STATUS_CONFIGURED) //检测USB连接状态
{
usbd_ep_tx (pudev, CUSTOMHID_IN_EP, report, len);
}
delay(1);
}
return USBD_OK;
}
/////////////////////////////////////////
st的这几句 if (hhid->state == HID_IDLE)
{
hhid->state = HID_BUSY;
作用是什么,在GD上怎么写呢,麻烦各位大佬看看啊。 |