如何編寫Windows CE.net的usb驅(qū)動(dòng)程序(2)
if(SubmitInterrupt())
{
while(!m_fClosing)
{
WaitForSingleObject(m_hEvent,INFINITE);
if(m_fClosing)
break;
if((*m_lpUsbFuncs->lpIsTransferComplete)(m_hInterruptTransfer))
{
if(!HandleInterrupt())
break;
}
else
{
RETAILMSG(1,(TEXT(!USBMouse:Eventsignalled,buttransfernotcompletern)));
//Theonlytimethisshouldhappenisifwegetanerroronthetransfer
ASSERT(m_fClosing||(m_hInterruptTransfer==NULL));
break;
}
}
}
RETAILMSG(1,(TEXT(USBMouse:Workerthreadexitingrn)));
return(0);
}
看到了沒有,其實(shí)USB的驅(qū)動(dòng)程序編寫就這么簡(jiǎn)單,類似的其他設(shè)備,例如打印機(jī)設(shè)備,就有BulkOUTPIPE,需要Bulk傳輸,那就需要了解一下IssueBulkTransfer()的應(yīng)用。當(dāng)然如果是開發(fā)USBMassStorageDisk的驅(qū)動(dòng),那就需要了解更多的協(xié)議,例如Bulk-OnlyTransport協(xié)議等。
微軟的WindowsCE.NET的PlatformBuild中已經(jīng)帶有USBPrinter和USBMassStorageDisk的驅(qū)動(dòng)的源代碼了,好好研究一下,你一定回受益非淺的。
評(píng)論