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