A compilation of code from different sources to provide support for a Playstation 3 controller via bluetooth on the m3pi.
Fork of mbed_TANK_PS3 by
Diff: USBHost.cpp
- Revision:
- 1:ae49669c5e92
- Parent:
- 0:44619612f575
- Child:
- 2:895f70862eb9
diff -r 44619612f575 -r ae49669c5e92 USBHost.cpp --- a/USBHost.cpp Tue Jul 05 08:25:40 2011 +0000 +++ b/USBHost.cpp Sun Dec 30 05:16:28 2012 +0000 @@ -399,7 +399,7 @@ int AddEndpoint(int device, int ep, int attributes, int maxPacketSize, int interval) { - LOG("AddEndpoint D:%02X A:%02X T:%02X P:%04X I:%02X\r\n",device,ep,attributes,maxPacketSize,interval); + //LOG("AddEndpoint D:%02X A:%02X T:%02X P:%04X I:%02X\r\n",device,ep,attributes,maxPacketSize,interval); Device* dev = &Devices[device-1]; Endpoint* endpoint = AllocateEndpoint(device,ep,attributes,maxPacketSize); if (!endpoint) @@ -632,7 +632,7 @@ int device = AddDeviceCore(hub,port,isLowSpeed); if (device < 0) { - LOG("========RETRY ADD DEVICE========\r\n"); // This will go for ever.. TODO power cycle root? + //LOG("========RETRY ADD DEVICE========\r\n"); // This will go for ever.. TODO power cycle root? Disconnect(hub,port); // Could not read descriptor at assigned address, reset this port and try again ResetPort(hub,port); // Cheap bluetooth dongles often need this on a hotplug return -1; @@ -648,7 +648,7 @@ int r = GetDescriptor(0,DESCRIPTOR_TYPE_DEVICE,0,(u8*)&desc,8); if (r < 0) { - LOG("FAILED TO LOAD DESCRIPTOR FOR DEVICE 0\r\n"); + //LOG("FAILED TO LOAD DESCRIPTOR FOR DEVICE 0\r\n"); return r; } @@ -657,7 +657,7 @@ if (r < 0) return r; - LOG("\nClass %02X found %04X:%04X\r\n",desc.bDeviceClass,desc.idVendor,desc.idProduct); + //LOG("\nClass %02X found %04X:%04X\r\n",desc.bDeviceClass,desc.idVendor,desc.idProduct); // Now assign the device an address, move off EndpointZero int device = 0; @@ -733,7 +733,7 @@ AddEndpoint(device,(EndpointDescriptor*)d); break; default: - LOG("Skipping descriptor %02X (%d bytes)\r\n",d[1],d[0]); + //LOG("Skipping descriptor %02X (%d bytes)\r\n",d[1],d[0]); } d += d[0]; } @@ -750,7 +750,7 @@ void Init() { - LOG("USB INIT (Controller is %d bytes)\r\n",sizeof(*this)); + //LOG("USB INIT (Controller is %d bytes)\r\n",sizeof(*this)); memset(this,0,sizeof(HostController)); EndpointZero.CurrentState = Endpoint::NotQueued; HWInit(&CommunicationArea); @@ -759,7 +759,7 @@ void ResetPort(int hub, int port) { - LOG("ResetPort Hub:%d Port:%d\r\n",hub,port); + //LOG("ResetPort Hub:%d Port:%d\r\n",hub,port); _connectPending++; // Only reset/add 1 device at a time if (hub == 0) LPC_USB->HcRhPortStatus1 = PortResetStatus; // Reset Root Hub, port 1 @@ -769,7 +769,7 @@ void Disconnect(int hub, int port) { - LOG("Disconnect Hub:%d Port:%d\r\n",hub,port); // Mark a device for destruction + //LOG("Disconnect Hub:%d Port:%d\r\n",hub,port); // Mark a device for destruction for (int i = 0; i < MAX_DEVICES; i++) { Device* dev = Devices + i; @@ -796,14 +796,14 @@ // called after reset void Connect(int hub, int port, bool lowspeed) { - LOG("Connect Hub:%d Port:%d %s\r\n",hub,port,lowspeed ? "slow" : "full"); + //LOG("Connect Hub:%d Port:%d %s\r\n",hub,port,lowspeed ? "slow" : "full"); AddDevice(hub,port,lowspeed); } // Called from interrupt void HubStatusChange(int hub, int port, u32 status) { - LOG("HubStatusChange Hub:%d Port:%d %08X\r\n",hub,port,status); + //LOG("HubStatusChange Hub:%d Port:%d %08X\r\n",hub,port,status); if (status & ConnectStatusChange) { if (status & CurrentConnectStatus) // Connecting