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
Revision 2:895f70862eb9, committed 2013-01-01
- Comitter:
- srsmitherman
- Date:
- Tue Jan 01 02:10:08 2013 +0000
- Parent:
- 1:ae49669c5e92
- Commit message:
- M3pi support
Changed in this revision
diff -r ae49669c5e92 -r 895f70862eb9 BTRuntime.cpp --- a/BTRuntime.cpp Sun Dec 30 05:16:28 2012 +0000 +++ b/BTRuntime.cpp Tue Jan 01 02:10:08 2013 +0000 @@ -120,6 +120,7 @@ static void OnHidInterrupt(int socket, SocketState state,const u8* data, int len, void* userData) { HIDBluetooth* t = (HIDBluetooth*)userData; + printf("OnHidInterrupt\r\n"); t->_ready = 0; if (data) {
diff -r ae49669c5e92 -r 895f70862eb9 USBHost.cpp --- a/USBHost.cpp Sun Dec 30 05:16:28 2012 +0000 +++ b/USBHost.cpp Tue Jan 01 02:10:08 2013 +0000 @@ -826,9 +826,9 @@ } #define HOST_CLK_EN (1<<0) - #define PORTSEL_CLK_EN (1<<3) - #define AHB_CLK_EN (1<<4) - #define CLOCK_MASK (HOST_CLK_EN | PORTSEL_CLK_EN | AHB_CLK_EN) + #define OTG_CLK_EN (1<<3) + #define AHB_CLK_EN (1<<4) + #define CLOCK_MASK (HOST_CLK_EN | OTG_CLK_EN | AHB_CLK_EN) #define FRAMEINTERVAL (12000-1) // 1ms #define DEFAULT_FMINTERVAL ((((6 * (FRAMEINTERVAL - 210)) / 7) << 16) | FRAMEINTERVAL) @@ -847,26 +847,28 @@ // turn on power for USB LPC_SC->PCONP |= (1UL<<31); // Enable USB host clock, port selection and AHB clock - LPC_USB->USBClkCtrl |= CLOCK_MASK; + LPC_USB->OTGClkCtrl |= CLOCK_MASK; // Wait for clocks to become available - while ((LPC_USB->USBClkSt & CLOCK_MASK) != CLOCK_MASK) + while ((LPC_USB->OTGClkSt & CLOCK_MASK) != CLOCK_MASK) ; // We are a Host LPC_USB->OTGStCtrl |= 1; - LPC_USB->USBClkCtrl &= ~PORTSEL_CLK_EN; // we don't need port selection clock until we do OTG + LPC_USB->OTGClkCtrl &= ~OTG_CLK_EN; // we don't need port selection clock until we do OTG + + // configure USB pins D+/D- + LPC_PINCON->PINSEL1 &= ~((3<<26)|(3<<28)); // Set PINSEL1 bits 26:29 to 0 + LPC_PINCON->PINSEL1 |= ((1<<26)|(1<<28)); // Set PINSEL1 bits 26 and 28 to 1 - // configure USB pins - LPC_PINCON->PINSEL1 &= ~((3<<26)|(3<<28)); - LPC_PINCON->PINSEL1 |= ((1<<26)|(1<<28)); // USB D+/D- - - LPC_PINCON->PINSEL3 &= ~((3 << 6) | (3 << 22)); // USB_PPWR, USB_OVRCR - LPC_PINCON->PINSEL3 |= ((2 << 6) | (2 << 22)); + // USB_PPWR, USB_OVRCR + LPC_PINCON->PINSEL3 &= ~((3 << 6) | (3 << 22)); // Set PINSEL3 bits 6,:7 and 22:23 to 0 + LPC_PINCON->PINSEL3 |= ((2 << 6) | (2 << 22)); // Set PINSEL3 bits 7 and 23 to 1 - LPC_PINCON->PINSEL4 &= ~(3 << 18); // USB_CONNECT - LPC_PINCON->PINSEL4 |= (1 << 18); + // USB_CONNECT + LPC_PINCON->PINSEL4 &= ~(3 << 18); // Set PINSEL4 bits 18:19 to 0 + LPC_PINCON->PINSEL4 |= (1 << 18); // Set PINSEL4 bits 18 to 1 - // Reset OHCI block + // Reset OHCI block LPC_USB->HcControl = 0; LPC_USB->HcControlHeadED = 0; LPC_USB->HcBulkHeadED = 0;
diff -r ae49669c5e92 -r 895f70862eb9 USBHost.h --- a/USBHost.h Sun Dec 30 05:16:28 2012 +0000 +++ b/USBHost.h Tue Jan 01 02:10:08 2013 +0000 @@ -126,27 +126,27 @@ typedef struct { - u8 bLength; - u8 bDescriptorType; - u16 bcdUSB; - u8 bDeviceClass; - u8 bDeviceSubClass; - u8 bDeviceProtocol; - u8 bMaxPacketSize; - u16 idVendor; - u16 idProduct; - u16 bcdDevice; // version - u8 iManufacturer; - u8 iProduct; - u8 iSerialNumber; - u8 bNumConfigurations; + u8 bLength; + u8 bDescriptorType; + u16 bcdUSB; + u8 bDeviceClass; + u8 bDeviceSubClass; + u8 bDeviceProtocol; + u8 bMaxPacketSize; + u16 idVendor; + u16 idProduct; + u16 bcdDevice; // version + u8 iManufacturer; + u8 iProduct; + u8 iSerialNumber; + u8 bNumConfigurations; } DeviceDescriptor; // 16 bytes typedef struct { u8 bLength; u8 bDescriptorType; - u16 wTotalLength; + u16 wTotalLength; u8 bNumInterfaces; u8 bConfigurationValue; // Value to use as an argument to select this configuration u8 iConfiguration; // Index of String Descriptor describing this configuration @@ -158,7 +158,7 @@ { u8 bLength; u8 bDescriptorType; - u8 bInterfaceNumber; + u8 bInterfaceNumber; u8 bAlternateSetting; u8 bNumEndpoints; u8 bInterfaceClass; @@ -173,7 +173,7 @@ u8 bDescriptorType; u8 bEndpointAddress; // Bits 0:3 endpoint, Bits 7 Direction 0 = Out, 1 = In (Ignored for Control Endpoints) u8 bmAttributes; // Bits 0:1 00 = Control, 01 = Isochronous, 10 = Bulk, 11 = Interrupt - u16 wMaxPacketSize; + u16 wMaxPacketSize; u8 bInterval; // Interval for polling endpoint data transfers. } EndpointDescriptor;
diff -r ae49669c5e92 -r 895f70862eb9 hci_private.h --- a/hci_private.h Sun Dec 30 05:16:28 2012 +0000 +++ b/hci_private.h Tue Jan 01 02:10:08 2013 +0000 @@ -54,7 +54,7 @@ #define HCI_OP_ROLE_DISCOVERY 0x0809 #define HCI_OP_SWITCH_ROLE 0x080b #define HCI_OP_READ_LINK_POLICY 0x080c -#define a 0x080d +#define HCI_OP_WRITE_LINK_POLICY 0x080d #define HCI_OP_READ_DEF_LINK_POLICY 0x080e #define HCI_OP_WRITE_DEF_LINK_POLICY 0x080f #define HCI_OP_SNIFF_SUBRATE 0x0811