Skip to main content
zhangzq71
Associate
October 28, 2008
Question

How to make the USB host program?

  • October 28, 2008
  • 1 reply
  • 553 views
Posted on October 28, 2008 at 11:55

How to make the USB host program?

    This topic has been closed for replies.

    1 reply

    zhangzq71
    zhangzq71Author
    Associate
    May 17, 2011
    Posted on May 17, 2011 at 12:49

    Hi,

    I modified the Custom_HID USB demo program to make it keep sending the data in 'main' function,

    int main(void)

    {

    int i;

    unsigned short b;

    #ifdef DEBUG

    debug();

    #endif

    Set_System();

    USB_Interrupts_Config();

    Set_USBClock();

    USB_Init();

    while (1)

    {

    for (i = 0; i < 1000000; i++);

    b++;

    UserToPMABufferCopy((u8 *)&b, GetEPTxAddr(ENDP1), 2);

    SetEPTxCount(ENDP1, 2);

    SetEPTxValid(ENDP1);

    }

    }

    This firmware works well and the BUSHOUND can get that USB data. I want to make my host program to get that data, I tried to make that program in both Windows and Linux. In Windows, I call SetupDiGetDeviceInterfaceDetail to get the device path of that Custom_HID device, then call CreateFile to open that devicepath. I can properly to get the VID & PID by calling HidD_GetAttributes, but I don't know how to read the data send from Custom_HID device, I tried both HidD_GetFeature, and ReadFile, but failed.

    In Linux I used the libusb, after correctly opened that Custom_HID device, I still can not read that data by calling both usb_bulk_read & usb_interrupt_read.

    Who can make a sample program to read that data?

    Regards,

    ZhangZQ