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