Igor Martinovski
/
USBJoystick
N64 to USB HID interface
Embed:
(wiki syntax)
Show/hide line numbers
usbdc.h
00001 /* usbdc.h */ 00002 /* USB device controller */ 00003 /* Copyright (c) Phil Wright 2008 */ 00004 00005 #ifndef USBDC_H 00006 #define USBDC_H 00007 00008 /* Endpoints */ 00009 #define EP0OUT (0) /* Control */ 00010 #define EP0IN (1) /* Control */ 00011 #define EP1OUT (2) /* Interrupt */ 00012 #define EP1IN (3) /* Interrupt */ 00013 #define EP2OUT (4) /* Bulk */ 00014 #define EP2IN (5) /* Bulk */ 00015 00016 #include "mbed.h" 00017 00018 class usbdc : public Base 00019 { 00020 public: 00021 usbdc(); 00022 void connect(void); 00023 void disconnect(void); 00024 protected: 00025 void setAddress(unsigned char address); 00026 void realiseEndpoint(unsigned char endpoint, unsigned long maxPacket); 00027 void enableEndpointEvent(unsigned char endpoint); 00028 void disableEndpointEvent(unsigned char endpoint); 00029 void stallEndpoint(unsigned char endpoint); 00030 void unstallEndpoint(unsigned char endpoint); 00031 bool getEndpointStallState(unsigned char endpoint); 00032 void configureDevice(void); 00033 void unconfigureDevice(void); 00034 unsigned long endpointRead(unsigned char endpoint, unsigned char *buffer); 00035 void endpointWrite(unsigned char endpoint, unsigned char *buffer, unsigned long size); 00036 void enableEvents(void); 00037 void disableEvents(void); 00038 virtual void deviceEventReset(void); 00039 virtual void deviceEventFrame(void); 00040 virtual void endpointEventEP0Setup(void); 00041 virtual void endpointEventEP0In(void); 00042 virtual void endpointEventEP0Out(void); 00043 virtual void endpointEventEP1In(void); 00044 virtual void endpointEventEP1Out(void); 00045 virtual void endpointEventEP2In(void); 00046 virtual void endpointEventEP2Out(void); 00047 private: 00048 void SIECommand(unsigned long command); 00049 void SIEWriteData(unsigned char data); 00050 unsigned char SIEReadData(unsigned long command); 00051 void setDeviceStatus(unsigned char status); 00052 void setEndpointStatus(unsigned char endpoint, unsigned char status); 00053 unsigned char getDeviceStatus(void); 00054 unsigned char selectEndpoint(unsigned char endpoint); 00055 unsigned char selectEndpointClearInterrupt(unsigned char endpoint); 00056 unsigned char clearBuffer(void); 00057 void validateBuffer(void); 00058 void usbisr(void); 00059 unsigned long endpointStallState; 00060 static void _usbisr(void); 00061 static usbdc *instance; 00062 }; 00063 00064 00065 #endif
Generated on Tue Jul 12 2022 21:12:14 by 1.7.2