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:
Sat Dec 17 15:10:12 2016 +0000
Revision:
3:f1a8ec4659f8
Parent:
1:76c47d2ba442
Added a two-interface configuration, which fully works on Android.

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