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