USB初始化

//USB初始化
void CFileManagerDlg::usbinit()
{
#define BUFFER_SIZE 64
struct usb_bus *bus;
struct usb_device *mydev;

usb_init();
usb_find_busses();
usb_find_devices();

for(bus = usb_get_busses(); bus; bus = bus->next)
{
if((mydev=bus->devices)!=0)
{
for(mydev = bus->devices; mydev; mydev = mydev->next)
{
if(mydev->descriptor.idVendor == MY_VID && mydev->descriptor.idProduct == MY_PID)
{
dev = usb_open(mydev);
usb_set_configuration(dev, MY_CONFIG);
usb_claim_interface(dev, 0);

GetDlgItem(IDC_STATIC_STATUS)->SetWindowText("设备已连接...");
}
}
}
else
{
GetDlgItem(IDC_STATIC_STATUS)->SetWindowText("设备未连接...");
}
}

}

posted @ 2016-08-18 17:15  ye小白  阅读(285)  评论(0编辑  收藏  举报