cancel
Showing results for 
Search instead for 
Did you mean: 

How to make the USB host program?

zhangzq71
Associate
Posted on October 28, 2008 at 11:55

How to make the USB host program?

1 REPLY 1
zhangzq71
Associate
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