Modified for PS3 Joystick
Fork of USBDevice by
USBDevice/USBHAL.h@1:ac5cca60029a, 2013-07-27 (annotated)
- Committer:
- sankichi
- Date:
- Sat Jul 27 14:05:26 2013 +0000
- Revision:
- 1:ac5cca60029a
- Parent:
- 0:140cdf8e2d60
First Release
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
samux | 0:140cdf8e2d60 | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
samux | 0:140cdf8e2d60 | 2 | * |
samux | 0:140cdf8e2d60 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
samux | 0:140cdf8e2d60 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
samux | 0:140cdf8e2d60 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
samux | 0:140cdf8e2d60 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
samux | 0:140cdf8e2d60 | 7 | * Software is furnished to do so, subject to the following conditions: |
samux | 0:140cdf8e2d60 | 8 | * |
samux | 0:140cdf8e2d60 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
samux | 0:140cdf8e2d60 | 10 | * substantial portions of the Software. |
samux | 0:140cdf8e2d60 | 11 | * |
samux | 0:140cdf8e2d60 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
samux | 0:140cdf8e2d60 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
samux | 0:140cdf8e2d60 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
samux | 0:140cdf8e2d60 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
samux | 0:140cdf8e2d60 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
samux | 0:140cdf8e2d60 | 17 | */ |
samux | 0:140cdf8e2d60 | 18 | |
samux | 0:140cdf8e2d60 | 19 | #ifndef USBBUSINTERFACE_H |
samux | 0:140cdf8e2d60 | 20 | #define USBBUSINTERFACE_H |
samux | 0:140cdf8e2d60 | 21 | |
samux | 0:140cdf8e2d60 | 22 | #include "mbed.h" |
samux | 0:140cdf8e2d60 | 23 | #include "USBEndpoints.h" |
samux | 0:140cdf8e2d60 | 24 | |
samux | 0:140cdf8e2d60 | 25 | class USBHAL { |
samux | 0:140cdf8e2d60 | 26 | public: |
samux | 0:140cdf8e2d60 | 27 | /* Configuration */ |
samux | 0:140cdf8e2d60 | 28 | USBHAL(); |
samux | 0:140cdf8e2d60 | 29 | ~USBHAL(); |
samux | 0:140cdf8e2d60 | 30 | void connect(void); |
samux | 0:140cdf8e2d60 | 31 | void disconnect(void); |
samux | 0:140cdf8e2d60 | 32 | void configureDevice(void); |
samux | 0:140cdf8e2d60 | 33 | void unconfigureDevice(void); |
samux | 0:140cdf8e2d60 | 34 | void setAddress(uint8_t address); |
samux | 0:140cdf8e2d60 | 35 | void remoteWakeup(void); |
samux | 0:140cdf8e2d60 | 36 | |
samux | 0:140cdf8e2d60 | 37 | /* Endpoint 0 */ |
samux | 0:140cdf8e2d60 | 38 | void EP0setup(uint8_t *buffer); |
samux | 0:140cdf8e2d60 | 39 | void EP0read(void); |
samux | 0:140cdf8e2d60 | 40 | uint32_t EP0getReadResult(uint8_t *buffer); |
samux | 0:140cdf8e2d60 | 41 | void EP0write(uint8_t *buffer, uint32_t size); |
samux | 0:140cdf8e2d60 | 42 | void EP0getWriteResult(void); |
samux | 0:140cdf8e2d60 | 43 | void EP0stall(void); |
samux | 0:140cdf8e2d60 | 44 | |
samux | 0:140cdf8e2d60 | 45 | /* Other endpoints */ |
samux | 0:140cdf8e2d60 | 46 | EP_STATUS endpointRead(uint8_t endpoint, uint32_t maximumSize); |
samux | 0:140cdf8e2d60 | 47 | EP_STATUS endpointReadResult(uint8_t endpoint, uint8_t *data, uint32_t *bytesRead); |
samux | 0:140cdf8e2d60 | 48 | EP_STATUS endpointWrite(uint8_t endpoint, uint8_t *data, uint32_t size); |
samux | 0:140cdf8e2d60 | 49 | EP_STATUS endpointWriteResult(uint8_t endpoint); |
samux | 0:140cdf8e2d60 | 50 | void stallEndpoint(uint8_t endpoint); |
samux | 0:140cdf8e2d60 | 51 | void unstallEndpoint(uint8_t endpoint); |
samux | 0:140cdf8e2d60 | 52 | bool realiseEndpoint(uint8_t endpoint, uint32_t maxPacket, uint32_t options); |
samux | 0:140cdf8e2d60 | 53 | bool getEndpointStallState(unsigned char endpoint); |
samux | 0:140cdf8e2d60 | 54 | uint32_t endpointReadcore(uint8_t endpoint, uint8_t *buffer); |
samux | 0:140cdf8e2d60 | 55 | |
samux | 0:140cdf8e2d60 | 56 | protected: |
samux | 0:140cdf8e2d60 | 57 | virtual void busReset(void){}; |
samux | 0:140cdf8e2d60 | 58 | virtual void EP0setupCallback(void){}; |
samux | 0:140cdf8e2d60 | 59 | virtual void EP0out(void){}; |
samux | 0:140cdf8e2d60 | 60 | virtual void EP0in(void){}; |
samux | 0:140cdf8e2d60 | 61 | virtual void connectStateChanged(unsigned int connected){}; |
samux | 0:140cdf8e2d60 | 62 | virtual void suspendStateChanged(unsigned int suspended){}; |
samux | 0:140cdf8e2d60 | 63 | virtual void SOF(int frameNumber){}; |
samux | 0:140cdf8e2d60 | 64 | virtual bool EP1_OUT_callback(){return false;}; |
samux | 0:140cdf8e2d60 | 65 | virtual bool EP1_IN_callback(){return false;}; |
samux | 0:140cdf8e2d60 | 66 | virtual bool EP2_OUT_callback(){return false;}; |
samux | 0:140cdf8e2d60 | 67 | virtual bool EP2_IN_callback(){return false;}; |
samux | 0:140cdf8e2d60 | 68 | virtual bool EP3_OUT_callback(){return false;}; |
samux | 0:140cdf8e2d60 | 69 | virtual bool EP3_IN_callback(){return false;}; |
samux | 0:140cdf8e2d60 | 70 | |
samux | 0:140cdf8e2d60 | 71 | private: |
samux | 0:140cdf8e2d60 | 72 | void usbisr(void); |
samux | 0:140cdf8e2d60 | 73 | static void _usbisr(void); |
samux | 0:140cdf8e2d60 | 74 | static USBHAL * instance; |
samux | 0:140cdf8e2d60 | 75 | }; |
samux | 0:140cdf8e2d60 | 76 | #endif |
samux | 0:140cdf8e2d60 | 77 |