Control the wondrous spinning-frog game of Zuma's Revenge with a rotating chair and an Airzooka. Maps compass rotation, flex sensor and push button input to USB actions to control Zuma's Revenge (http://www.popcap.com/games/zumas-revenge/online)
Dependencies: LSM303DLHC mbed
Note that content for USB HID and USB Device is actually from the USBDevice mbed library. However, we made a couple of small changes to this library (allowing USB clicks at a particular location) that required us to break it off from the main project if we wanted to publish without pushing upstream.
USBDevice/USBHAL.h@0:4df415dde990, 2014-09-29 (annotated)
- Committer:
- andrewhead
- Date:
- Mon Sep 29 01:12:20 2014 +0000
- Revision:
- 0:4df415dde990
Initial Commit.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andrewhead | 0:4df415dde990 | 1 | /* Copyright (c) 2010-2011 mbed.org, MIT License |
andrewhead | 0:4df415dde990 | 2 | * |
andrewhead | 0:4df415dde990 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
andrewhead | 0:4df415dde990 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
andrewhead | 0:4df415dde990 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
andrewhead | 0:4df415dde990 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
andrewhead | 0:4df415dde990 | 7 | * Software is furnished to do so, subject to the following conditions: |
andrewhead | 0:4df415dde990 | 8 | * |
andrewhead | 0:4df415dde990 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
andrewhead | 0:4df415dde990 | 10 | * substantial portions of the Software. |
andrewhead | 0:4df415dde990 | 11 | * |
andrewhead | 0:4df415dde990 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
andrewhead | 0:4df415dde990 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
andrewhead | 0:4df415dde990 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
andrewhead | 0:4df415dde990 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
andrewhead | 0:4df415dde990 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
andrewhead | 0:4df415dde990 | 17 | */ |
andrewhead | 0:4df415dde990 | 18 | |
andrewhead | 0:4df415dde990 | 19 | #ifndef USBBUSINTERFACE_H |
andrewhead | 0:4df415dde990 | 20 | #define USBBUSINTERFACE_H |
andrewhead | 0:4df415dde990 | 21 | |
andrewhead | 0:4df415dde990 | 22 | #include "mbed.h" |
andrewhead | 0:4df415dde990 | 23 | #include "USBEndpoints.h" |
andrewhead | 0:4df415dde990 | 24 | |
andrewhead | 0:4df415dde990 | 25 | class USBHAL { |
andrewhead | 0:4df415dde990 | 26 | public: |
andrewhead | 0:4df415dde990 | 27 | /* Configuration */ |
andrewhead | 0:4df415dde990 | 28 | USBHAL(); |
andrewhead | 0:4df415dde990 | 29 | ~USBHAL(); |
andrewhead | 0:4df415dde990 | 30 | void connect(void); |
andrewhead | 0:4df415dde990 | 31 | void disconnect(void); |
andrewhead | 0:4df415dde990 | 32 | void configureDevice(void); |
andrewhead | 0:4df415dde990 | 33 | void unconfigureDevice(void); |
andrewhead | 0:4df415dde990 | 34 | void setAddress(uint8_t address); |
andrewhead | 0:4df415dde990 | 35 | void remoteWakeup(void); |
andrewhead | 0:4df415dde990 | 36 | |
andrewhead | 0:4df415dde990 | 37 | /* Endpoint 0 */ |
andrewhead | 0:4df415dde990 | 38 | void EP0setup(uint8_t *buffer); |
andrewhead | 0:4df415dde990 | 39 | void EP0read(void); |
andrewhead | 0:4df415dde990 | 40 | void EP0readStage(void); |
andrewhead | 0:4df415dde990 | 41 | uint32_t EP0getReadResult(uint8_t *buffer); |
andrewhead | 0:4df415dde990 | 42 | void EP0write(uint8_t *buffer, uint32_t size); |
andrewhead | 0:4df415dde990 | 43 | void EP0getWriteResult(void); |
andrewhead | 0:4df415dde990 | 44 | void EP0stall(void); |
andrewhead | 0:4df415dde990 | 45 | |
andrewhead | 0:4df415dde990 | 46 | /* Other endpoints */ |
andrewhead | 0:4df415dde990 | 47 | EP_STATUS endpointRead(uint8_t endpoint, uint32_t maximumSize); |
andrewhead | 0:4df415dde990 | 48 | EP_STATUS endpointReadResult(uint8_t endpoint, uint8_t *data, uint32_t *bytesRead); |
andrewhead | 0:4df415dde990 | 49 | EP_STATUS endpointWrite(uint8_t endpoint, uint8_t *data, uint32_t size); |
andrewhead | 0:4df415dde990 | 50 | EP_STATUS endpointWriteResult(uint8_t endpoint); |
andrewhead | 0:4df415dde990 | 51 | void stallEndpoint(uint8_t endpoint); |
andrewhead | 0:4df415dde990 | 52 | void unstallEndpoint(uint8_t endpoint); |
andrewhead | 0:4df415dde990 | 53 | bool realiseEndpoint(uint8_t endpoint, uint32_t maxPacket, uint32_t options); |
andrewhead | 0:4df415dde990 | 54 | bool getEndpointStallState(unsigned char endpoint); |
andrewhead | 0:4df415dde990 | 55 | uint32_t endpointReadcore(uint8_t endpoint, uint8_t *buffer); |
andrewhead | 0:4df415dde990 | 56 | |
andrewhead | 0:4df415dde990 | 57 | protected: |
andrewhead | 0:4df415dde990 | 58 | virtual void busReset(void){}; |
andrewhead | 0:4df415dde990 | 59 | virtual void EP0setupCallback(void){}; |
andrewhead | 0:4df415dde990 | 60 | virtual void EP0out(void){}; |
andrewhead | 0:4df415dde990 | 61 | virtual void EP0in(void){}; |
andrewhead | 0:4df415dde990 | 62 | virtual void connectStateChanged(unsigned int connected){}; |
andrewhead | 0:4df415dde990 | 63 | virtual void suspendStateChanged(unsigned int suspended){}; |
andrewhead | 0:4df415dde990 | 64 | virtual void SOF(int frameNumber){}; |
andrewhead | 0:4df415dde990 | 65 | |
andrewhead | 0:4df415dde990 | 66 | virtual bool EP1_OUT_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 67 | virtual bool EP1_IN_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 68 | virtual bool EP2_OUT_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 69 | virtual bool EP2_IN_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 70 | virtual bool EP3_OUT_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 71 | virtual bool EP3_IN_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 72 | virtual bool EP4_OUT_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 73 | virtual bool EP4_IN_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 74 | |
andrewhead | 0:4df415dde990 | 75 | #if !defined(TARGET_LPC11U24) |
andrewhead | 0:4df415dde990 | 76 | virtual bool EP5_OUT_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 77 | virtual bool EP5_IN_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 78 | virtual bool EP6_OUT_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 79 | virtual bool EP6_IN_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 80 | virtual bool EP7_OUT_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 81 | virtual bool EP7_IN_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 82 | virtual bool EP8_OUT_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 83 | virtual bool EP8_IN_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 84 | virtual bool EP9_OUT_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 85 | virtual bool EP9_IN_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 86 | virtual bool EP10_OUT_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 87 | virtual bool EP10_IN_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 88 | virtual bool EP11_OUT_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 89 | virtual bool EP11_IN_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 90 | virtual bool EP12_OUT_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 91 | virtual bool EP12_IN_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 92 | virtual bool EP13_OUT_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 93 | virtual bool EP13_IN_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 94 | virtual bool EP14_OUT_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 95 | virtual bool EP14_IN_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 96 | virtual bool EP15_OUT_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 97 | virtual bool EP15_IN_callback(){return false;}; |
andrewhead | 0:4df415dde990 | 98 | #endif |
andrewhead | 0:4df415dde990 | 99 | |
andrewhead | 0:4df415dde990 | 100 | private: |
andrewhead | 0:4df415dde990 | 101 | void usbisr(void); |
andrewhead | 0:4df415dde990 | 102 | static void _usbisr(void); |
andrewhead | 0:4df415dde990 | 103 | static USBHAL * instance; |
andrewhead | 0:4df415dde990 | 104 | |
andrewhead | 0:4df415dde990 | 105 | #if defined(TARGET_LPC11U24) |
andrewhead | 0:4df415dde990 | 106 | bool (USBHAL::*epCallback[10 - 2])(void); |
andrewhead | 0:4df415dde990 | 107 | #else |
andrewhead | 0:4df415dde990 | 108 | bool (USBHAL::*epCallback[32 - 2])(void); |
andrewhead | 0:4df415dde990 | 109 | #endif |
andrewhead | 0:4df415dde990 | 110 | |
andrewhead | 0:4df415dde990 | 111 | |
andrewhead | 0:4df415dde990 | 112 | }; |
andrewhead | 0:4df415dde990 | 113 | #endif |