Hello,
I am interested to make USB HID HOST which can communicate with custom hid device instead of mice or keyboard.
For that I have to send data to that custom hid device. I have used below fuction for dataout USBH_InterruptSendData (pdev, (unsigned char *)&HID_Machine.buff, HID_Machine.length, HID_Machine.hc_num_out);
I am only doing out transaction form Host(STM32) to device. Everything is perfect and working fine up to 14th frame but 15th frame get corrupted, I have analyzer showing "child has an error". So I am unable to understand the cause of issue, is it memory overflow at host?
If I continue data transmission with new data then host is sending old data packet onwards
I used dual core example for ST and modified USBH_HID_Handle() as below (Only two cases are shown here)
case HID_SEND_DATA:
while(USB_OTG_IsEvenFrame(pdev) == FALSE);
USBH_InterruptSendData (pdev, (unsigned char *)&HID_Machine.buff, HID_Machine.length, HID_Machine.hc_num_out);
HID_Machine.state = HID_BUSY;
HID_Machine.timer = HCD_GetCurrentFrame(pdev);
break;
case HID_BUSY:
if(( HCD_GetCurrentFrame(pdev) - HID_Machine.timer) >= HID_Machine.poll)
{ HID_Machine.state = HID_SEND_DATA; //Retry++; //1 }
else if(HCD_GetURB_State(pdev , HID_Machine.hc_num_out) == URB_DONE) //last transaction was successful or not(USB request Block)
{ HID_Machine.state = HID_GET_DATA;
BD_Data_Sent_Flag=1;
}
else if(HCD_GetURB_State(pdev, HID_Machine.hc_num_out) == URB_STALL )
{
if( (USBH_ClrFeature(pdev, pphost, HID_Machine.ep_addr, HID_Machine.hc_num_out)) == USBH_OK)
HID_Machine.state = HID_SEND_DATA;
} }
Please help...
Thank you for reply. It appears eror at HID_Machine.cb = &HID_CUSTOM_cb; Where I need to define it. And after that how can I send data to HID device. Here ís my code int main(void) { __IO uint32_t i = 0, count; SystemInit(); USART_Config(); /*!< At this stage the microcontroller clock setting is already configured, this is done through SystemInit() function which is called from startup file (startup_stm32fxxx_xx.s) before to branch to application main. To reconfigure the default setting of SystemInit() function, refer to system_stm32fxxx.c file */
printf(" MCU Start\r\n");
/* Init Host Library */ USBH_Init(&USB_OTG_Core_dev, #ifdef USE_USB_OTG_FS USB_OTG_FS_CORE_ID, #else USB_OTG_HS_CORE_ID, #endif &USB_Host, &HID_cb, &USR_Callbacks);
while (1) { /* Host Task handler */ USBH_Process(&USB_OTG_Core_dev , &USB_Host); } } I modify from STM32_USB-Host-Device_Lib_V2.1.0 My Host HID (STM32-F4 Dícovery) is found HID device.