10 #include "usb_proto.h"
15 tUSBHub *USB_RegisterHost(tUSBHostDef *HostDef, void *ControllerPtr, int nPorts)
21 void USB_DeviceConnected(tUSBHub *Hub, int Port)
23 if( Port >= Hub->nPorts ) return ;
24 if( Hub->Devices[Port] ) return ;
26 // 0. Perform port init? (done in hub?)
27 // 1. Assign an address
29 // 2. Get device information
32 void USB_DeviceDisconnected(tUSBHub *Hub, int Port)
37 void *USB_GetDeviceDataPtr(tUSBDevice *Dev) { return Dev->Data; }
38 void USB_SetDeviceDataPtr(tUSBDevice *Dev, void *Ptr) { Dev->Data = Ptr; }
40 int USB_int_AllocateAddress(tUSBHost *Host)
43 for( i = 1; i < 128; i ++ )
45 if(Host->AddressBitmap[i/8] & (1 << i))
52 int USB_int_SendSetupSetAddress(tUSBHost *Host, void *Ptr, int Address)
54 struct sDeviceRequest req;
55 req.ReqType = 0; // bmRequestType
56 req.Request = 5; // SET_ADDRESS
57 req.Value = Address & 0x7F; // wValue
58 req.Index = 0; // wIndex
59 req.Length = 0; // wLength
61 // Addr 0:0, Data Toggle = 0, no interrupt
62 return Host->HostDef->SendSETUP(Ptr, 0, 0, 0, FALSE, &req, sizeof(req)) == NULL;