A fully-Android-compatible two joysticks USB driver for LPC1768. The joysticks have 1 hat, 6 buttons, and there are 1P, 2P buttons.

Dependencies:   mbed

Fork of app-board-Joystick by Chris Styles

Committer:
Alberto_Wino
Date:
Fri Dec 16 18:17:42 2016 +0000
Revision:
1:76c47d2ba442
Child:
3:f1a8ec4659f8
Import for dual joystick support, suitable for an arcade machine.; Based on code from Phil Wright.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Alberto_Wino 1:76c47d2ba442 1 /* usbdc.h */
Alberto_Wino 1:76c47d2ba442 2 /* USB device controller */
Alberto_Wino 1:76c47d2ba442 3 /* Copyright (c) Phil Wright 2008 */
Alberto_Wino 1:76c47d2ba442 4
Alberto_Wino 1:76c47d2ba442 5 #ifndef USBDC_H
Alberto_Wino 1:76c47d2ba442 6 #define USBDC_H
Alberto_Wino 1:76c47d2ba442 7
Alberto_Wino 1:76c47d2ba442 8 /* Endpoints */
Alberto_Wino 1:76c47d2ba442 9 #define EP0OUT (0) /* Control */
Alberto_Wino 1:76c47d2ba442 10 #define EP0IN (1) /* Control */
Alberto_Wino 1:76c47d2ba442 11 #define EP1OUT (2) /* Interrupt */
Alberto_Wino 1:76c47d2ba442 12 #define EP1IN (3) /* Interrupt */
Alberto_Wino 1:76c47d2ba442 13 #define EP2OUT (4) /* Bulk */
Alberto_Wino 1:76c47d2ba442 14 #define EP2IN (5) /* Bulk */
Alberto_Wino 1:76c47d2ba442 15
Alberto_Wino 1:76c47d2ba442 16 #include "mbed.h"
Alberto_Wino 1:76c47d2ba442 17
Alberto_Wino 1:76c47d2ba442 18 class usbdc //: public Base
Alberto_Wino 1:76c47d2ba442 19 {
Alberto_Wino 1:76c47d2ba442 20 public:
Alberto_Wino 1:76c47d2ba442 21 usbdc();
Alberto_Wino 1:76c47d2ba442 22 void connect(void);
Alberto_Wino 1:76c47d2ba442 23 void disconnect(void);
Alberto_Wino 1:76c47d2ba442 24 protected:
Alberto_Wino 1:76c47d2ba442 25 void setAddress(unsigned char address);
Alberto_Wino 1:76c47d2ba442 26 void realiseEndpoint(unsigned char endpoint, unsigned long maxPacket);
Alberto_Wino 1:76c47d2ba442 27 void enableEndpointEvent(unsigned char endpoint);
Alberto_Wino 1:76c47d2ba442 28 void disableEndpointEvent(unsigned char endpoint);
Alberto_Wino 1:76c47d2ba442 29 void stallEndpoint(unsigned char endpoint);
Alberto_Wino 1:76c47d2ba442 30 void unstallEndpoint(unsigned char endpoint);
Alberto_Wino 1:76c47d2ba442 31 bool getEndpointStallState(unsigned char endpoint);
Alberto_Wino 1:76c47d2ba442 32 void configureDevice(void);
Alberto_Wino 1:76c47d2ba442 33 void unconfigureDevice(void);
Alberto_Wino 1:76c47d2ba442 34 unsigned long endpointRead(unsigned char endpoint, unsigned char *buffer);
Alberto_Wino 1:76c47d2ba442 35 void endpointWrite(unsigned char endpoint, unsigned char *buffer, unsigned long size);
Alberto_Wino 1:76c47d2ba442 36 void enableEvents(void);
Alberto_Wino 1:76c47d2ba442 37 void disableEvents(void);
Alberto_Wino 1:76c47d2ba442 38 virtual void deviceEventReset(void);
Alberto_Wino 1:76c47d2ba442 39 virtual void deviceEventFrame(void);
Alberto_Wino 1:76c47d2ba442 40 virtual void endpointEventEP0Setup(void);
Alberto_Wino 1:76c47d2ba442 41 virtual void endpointEventEP0In(void);
Alberto_Wino 1:76c47d2ba442 42 virtual void endpointEventEP0Out(void);
Alberto_Wino 1:76c47d2ba442 43 virtual void endpointEventEP1In(void);
Alberto_Wino 1:76c47d2ba442 44 virtual void endpointEventEP1Out(void);
Alberto_Wino 1:76c47d2ba442 45 virtual void endpointEventEP2In(void);
Alberto_Wino 1:76c47d2ba442 46 virtual void endpointEventEP2Out(void);
Alberto_Wino 1:76c47d2ba442 47 private:
Alberto_Wino 1:76c47d2ba442 48 void SIECommand(unsigned long command);
Alberto_Wino 1:76c47d2ba442 49 void SIEWriteData(unsigned char data);
Alberto_Wino 1:76c47d2ba442 50 unsigned char SIEReadData(unsigned long command);
Alberto_Wino 1:76c47d2ba442 51 void setDeviceStatus(unsigned char status);
Alberto_Wino 1:76c47d2ba442 52 void setEndpointStatus(unsigned char endpoint, unsigned char status);
Alberto_Wino 1:76c47d2ba442 53 unsigned char getDeviceStatus(void);
Alberto_Wino 1:76c47d2ba442 54 unsigned char selectEndpoint(unsigned char endpoint);
Alberto_Wino 1:76c47d2ba442 55 unsigned char selectEndpointClearInterrupt(unsigned char endpoint);
Alberto_Wino 1:76c47d2ba442 56 unsigned char clearBuffer(void);
Alberto_Wino 1:76c47d2ba442 57 void validateBuffer(void);
Alberto_Wino 1:76c47d2ba442 58 void usbisr(void);
Alberto_Wino 1:76c47d2ba442 59 unsigned long endpointStallState;
Alberto_Wino 1:76c47d2ba442 60 static void _usbisr(void);
Alberto_Wino 1:76c47d2ba442 61 static usbdc *instance;
Alberto_Wino 1:76c47d2ba442 62 };
Alberto_Wino 1:76c47d2ba442 63
Alberto_Wino 1:76c47d2ba442 64 #endif