3 * - By John Hodge (thePowersGang)
12 #include "usb_async.h"
15 extern tUSBHost *gUSB_Hosts;
18 void USB_StartPollingEndpoint(tUSBInterface *Iface, int Endpoint);
23 void USB_int_PollCallback(void *Ptr, void *Data, size_t Length)
26 tUSBEndpoint *ep = Ptr;
28 op = malloc(sizeof(*op));
33 op->Data = ep->InputData;
35 Workqueue_AddWork(&gUSB_AsyncQueue, op);
38 void USB_StartPollingEndpoint(tUSBInterface *Iface, int Endpoint)
42 ENTER("pIface iEndpoint", Iface, Endpoint);
45 if(Endpoint <= 0 || Endpoint > Iface->nEndpoints) {
49 endpt = &Iface->Endpoints[Endpoint-1];
50 LOG("endpt(%p)->PollingPeriod = %i", endpt, endpt->PollingPeriod);
51 if(endpt->PollingPeriod > 256 || endpt->PollingPeriod <= 0) {
56 // TODO: Check that this endpoint isn't already on the queue
58 endpt->InputData = malloc(endpt->MaxPacketSize);
60 Iface->Dev->Host->HostDef->InterruptIN(
61 Iface->Dev->Host->Ptr,
62 Iface->Dev->Address * 16 + endpt->EndpointNum,
64 USB_int_PollCallback, endpt,
65 endpt->InputData, endpt->MaxPacketSize
71 * \brief USB polling thread
73 int USB_PollThread(void *unused)
75 Threads_SetName("USB Polling Thread");
79 for( tUSBHost *host = gUSB_Hosts; host; host = host->Next )
81 host->HostDef->CheckPorts(host->Ptr);