3 * - By John Hodge (thePowersGang)
13 #define POLL_ATOM 25 // 25ms atom
14 #define POLL_MAX 256 // Max period that can be nominated
15 #define POLL_SLOTS ((int)(POLL_MAX/POLL_ATOM))
18 extern tUSBHost *gUSB_Hosts;
21 void USB_StartPollingEndpoint(tUSBInterface *Iface, int Endpoint);
26 void USB_int_PollCallback(void *Ptr, void *Data, size_t Length)
28 tUSBEndpoint *ep = Ptr;
30 ep->Interface->Driver->Endpoints[ep->EndpointIdx].DataAvail(ep->Interface, ep->EndpointIdx, Length, Data);
33 void USB_StartPollingEndpoint(tUSBInterface *Iface, int Endpoint)
37 ENTER("pIface iEndpoint", Iface, Endpoint);
41 if(Endpoint <= 0 || Endpoint > Iface->nEndpoints)
43 endpt = &Iface->Endpoints[Endpoint-1];
44 LOG("endpt(%p)->PollingPeriod = %i", endpt, endpt->PollingPeriod);
45 if(endpt->PollingPeriod > POLL_MAX || endpt->PollingPeriod <= 0)
48 // TODO: Check that this endpoint isn't already on the queue
50 endpt->InputData = malloc(endpt->MaxPacketSize);
52 Iface->Dev->Host->HostDef->InterruptIN(
53 Iface->Dev->Host->Ptr,
54 Iface->Dev->Address * 16 + endpt->EndpointNum,
56 USB_int_PollCallback, endpt,
57 endpt->InputData, endpt->MaxPacketSize
63 * \brief USB polling thread
65 int USB_PollThread(void *unused)
67 Threads_SetName("USB Polling Thread");
71 for( tUSBHost *host = gUSB_Hosts; host; host = host->Next )
73 host->HostDef->CheckPorts(host->Ptr);
76 Time_Delay(POLL_ATOM);