2021-06-09 01:18 AM
I am able to send the data but unable to receive from USB HID Demonstrator.
Here is my code:
uint8_t USBD_CUSTOM_HID_ReceivePacket(USBD_HandleTypeDef *pdev)
{
USBD_CUSTOM_HID_HandleTypeDef *hhid;
if (pdev->pClassData == NULL)
{
return (uint8_t)USBD_FAIL;
}
hhid = (USBD_CUSTOM_HID_HandleTypeDef *)pdev->pClassData;
/* Resume USB Out process */
(void)USBD_LL_PrepareReceive(pdev, CUSTOM_HID_EPOUT_ADDR, hhid->Report_buf,
USBD_CUSTOMHID_OUTREPORT_BUF_SIZE);
for(uint8_t i=0;i<1;i++)
{
rx_data[i]=hhid->Report_buf[i];
}
if(rx_data[0]==1) HAL_GPIO_TogglePin(GPIOE, GPIO_PIN_1);
if(rx_data[0]==2) HAL_GPIO_TogglePin(GPIOB, GPIO_PIN_14);
return (uint8_t)USBD_OK;
}
__ALIGN_BEGIN static uint8_t CUSTOM_HID_ReportDesc_FS[USBD_CUSTOM_HID_REPORT_DESC_SIZE] __ALIGN_END =
{/* USER CODE BEGIN 0 */
0x06, 0x00, 0xFF, // Usage Page = 0xFF00 (Vendor Defined Page 1)
0x09, 0x01, // Usage (Vendor Usage 1)
0xA1, 0x01, // Collection (Application)
// Input report
0x19, 0x01, // Usage Minimum
0x29, 0x40, // Usage Maximum
0x15, 0x80,//0x00, // Logical Minimum (data bytes in the report may have minimum value = 0x00)
//0x26, 0xFF, 0x00, // Logical Maximum (data bytes in the report may have maximum value = 0x00FF = unsigned 255)
0x25,0x7f,
0x75, 0x08, // Report Size: 8-bit field size
0x95, CUSTOM_HID_EPIN_SIZE,// Report Count
0x81, 0x02, // Input (Data, Array, Abs)
// Output report
0x19, 0x01, // Usage Minimum
0x29, 0x40, // Usage Maximum
0x75, 0x08, // Report Size: 8-bit field size
0x95, CUSTOM_HID_EPOUT_SIZE,// Report Count
0x91, 0x02, // Output (Data, Array, Abs)
0xC0
/* USER CODE END 0 */
/* END_COLLECTION */
};
#ifndef CUSTOM_HID_EPIN_SIZE
#define CUSTOM_HID_EPIN_SIZE 0x20U
#endif
#define CUSTOM_HID_EPOUT_ADDR 0x01U
#ifndef CUSTOM_HID_EPOUT_SIZE
#define CUSTOM_HID_EPOUT_SIZE 0x20U
#endif
Here is I setup done.I am unable to receive data .I forgot to intilasation the parameter or I am using wrong terminal? Because I am using USB Custome HID inerface.Can someone Help me?
Solved! Go to Solution.
2021-06-22 09:26 AM
Hello @MDeva.1 ,
You can refer to following example available under STM32CubeH7 package (path: Projects\STM32H743I-EVAL\Applications\USB_Device\CustomHID_Standalone ).
You could use this as inspiration.
BeST Regards,
Walid
2021-06-22 09:26 AM
Hello @MDeva.1 ,
You can refer to following example available under STM32CubeH7 package (path: Projects\STM32H743I-EVAL\Applications\USB_Device\CustomHID_Standalone ).
You could use this as inspiration.
BeST Regards,
Walid