USB Host Library for Sprint Dongles
Fork of USBHostWANDongleSprint by
USB3GModule/WANDongleInitializer.h@8:65cd51339647, 2012-11-30 (annotated)
- Committer:
- donatien
- Date:
- Fri Nov 30 13:08:13 2012 +0000
- Revision:
- 8:65cd51339647
- Parent:
- 4:cd9864d1db52
Support for MC5728V dongle
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
donatien | 0:bfed5767d0a5 | 1 | /* Copyright (c) 2010-2012 mbed.org, MIT License |
donatien | 0:bfed5767d0a5 | 2 | * |
donatien | 0:bfed5767d0a5 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
donatien | 0:bfed5767d0a5 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
donatien | 0:bfed5767d0a5 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
donatien | 0:bfed5767d0a5 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
donatien | 0:bfed5767d0a5 | 7 | * Software is furnished to do so, subject to the following conditions: |
donatien | 0:bfed5767d0a5 | 8 | * |
donatien | 0:bfed5767d0a5 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
donatien | 0:bfed5767d0a5 | 10 | * substantial portions of the Software. |
donatien | 0:bfed5767d0a5 | 11 | * |
donatien | 0:bfed5767d0a5 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
donatien | 0:bfed5767d0a5 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
donatien | 0:bfed5767d0a5 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
donatien | 0:bfed5767d0a5 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
donatien | 0:bfed5767d0a5 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
donatien | 0:bfed5767d0a5 | 17 | */ |
donatien | 0:bfed5767d0a5 | 18 | |
donatien | 0:bfed5767d0a5 | 19 | #ifndef WANDONGLEINITIALIZER_H |
donatien | 0:bfed5767d0a5 | 20 | #define WANDONGLEINITIALIZER_H |
donatien | 0:bfed5767d0a5 | 21 | |
donatien | 0:bfed5767d0a5 | 22 | #include <cstdint> |
donatien | 0:bfed5767d0a5 | 23 | using std::uint16_t; |
donatien | 0:bfed5767d0a5 | 24 | using std::uint32_t; |
donatien | 0:bfed5767d0a5 | 25 | |
donatien | 0:bfed5767d0a5 | 26 | #include "USBHost.h" |
donatien | 0:bfed5767d0a5 | 27 | #include "IUSBEnumerator.h" |
donatien | 0:bfed5767d0a5 | 28 | |
donatien | 0:bfed5767d0a5 | 29 | enum WAN_DONGLE_TYPE |
donatien | 0:bfed5767d0a5 | 30 | { |
donatien | 0:bfed5767d0a5 | 31 | WAN_DONGLE_TYPE_UNKNOWN = -1, |
donatien | 0:bfed5767d0a5 | 32 | WAN_DONGLE_TYPE_SPRINT598U = 10, |
donatien | 8:65cd51339647 | 33 | WAN_DONGLE_TYPE_SPRINTMC5728V = 11, |
donatien | 0:bfed5767d0a5 | 34 | }; |
donatien | 0:bfed5767d0a5 | 35 | |
donatien | 0:bfed5767d0a5 | 36 | class WANDongleInitializer : public IUSBEnumerator |
donatien | 0:bfed5767d0a5 | 37 | { |
donatien | 0:bfed5767d0a5 | 38 | protected: |
donatien | 0:bfed5767d0a5 | 39 | WANDongleInitializer(USBHost* pHost); |
donatien | 0:bfed5767d0a5 | 40 | USBHost* m_pHost; |
donatien | 0:bfed5767d0a5 | 41 | |
donatien | 0:bfed5767d0a5 | 42 | public: |
donatien | 0:bfed5767d0a5 | 43 | virtual uint16_t getMSDVid() = 0; |
donatien | 0:bfed5767d0a5 | 44 | virtual uint16_t getMSDPid() = 0; |
donatien | 0:bfed5767d0a5 | 45 | |
donatien | 0:bfed5767d0a5 | 46 | virtual uint16_t getSerialVid() = 0; |
donatien | 0:bfed5767d0a5 | 47 | virtual uint16_t getSerialPid() = 0; |
donatien | 0:bfed5767d0a5 | 48 | |
donatien | 0:bfed5767d0a5 | 49 | virtual bool switchMode(USBDeviceConnected* pDev) = 0; |
donatien | 0:bfed5767d0a5 | 50 | |
donatien | 0:bfed5767d0a5 | 51 | virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) = 0; |
donatien | 0:bfed5767d0a5 | 52 | |
donatien | 0:bfed5767d0a5 | 53 | virtual int getSerialPortCount() = 0; |
donatien | 0:bfed5767d0a5 | 54 | |
donatien | 0:bfed5767d0a5 | 55 | virtual void setVidPid(uint16_t vid, uint16_t pid) = 0; |
donatien | 0:bfed5767d0a5 | 56 | |
donatien | 0:bfed5767d0a5 | 57 | virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol) = 0; //Must return true if the interface should be parsed |
donatien | 0:bfed5767d0a5 | 58 | |
donatien | 0:bfed5767d0a5 | 59 | virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) = 0; //Must return true if the endpoint will be used |
donatien | 0:bfed5767d0a5 | 60 | |
donatien | 0:bfed5767d0a5 | 61 | virtual WAN_DONGLE_TYPE getType() = 0; |
donatien | 0:bfed5767d0a5 | 62 | |
donatien | 0:bfed5767d0a5 | 63 | static WANDongleInitializer** getInitializers(USBHost* pHost); |
donatien | 0:bfed5767d0a5 | 64 | }; |
donatien | 0:bfed5767d0a5 | 65 | |
donatien | 0:bfed5767d0a5 | 66 | class Sprint598UInitializer : public WANDongleInitializer |
donatien | 0:bfed5767d0a5 | 67 | { |
donatien | 0:bfed5767d0a5 | 68 | public: |
donatien | 0:bfed5767d0a5 | 69 | Sprint598UInitializer(USBHost* pHost); |
donatien | 0:bfed5767d0a5 | 70 | |
donatien | 0:bfed5767d0a5 | 71 | virtual uint16_t getMSDVid(); |
donatien | 0:bfed5767d0a5 | 72 | virtual uint16_t getMSDPid(); |
donatien | 0:bfed5767d0a5 | 73 | |
donatien | 0:bfed5767d0a5 | 74 | virtual uint16_t getSerialVid(); |
donatien | 0:bfed5767d0a5 | 75 | virtual uint16_t getSerialPid(); |
donatien | 0:bfed5767d0a5 | 76 | |
donatien | 0:bfed5767d0a5 | 77 | virtual bool switchMode(USBDeviceConnected* pDev); |
donatien | 0:bfed5767d0a5 | 78 | |
donatien | 1:3bcca949166d | 79 | virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx); |
donatien | 0:bfed5767d0a5 | 80 | |
donatien | 0:bfed5767d0a5 | 81 | virtual int getSerialPortCount(); |
donatien | 0:bfed5767d0a5 | 82 | |
donatien | 1:3bcca949166d | 83 | virtual void setVidPid(uint16_t vid, uint16_t pid); |
donatien | 1:3bcca949166d | 84 | |
donatien | 0:bfed5767d0a5 | 85 | virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed |
donatien | 0:bfed5767d0a5 | 86 | |
donatien | 0:bfed5767d0a5 | 87 | virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used |
donatien | 0:bfed5767d0a5 | 88 | |
donatien | 0:bfed5767d0a5 | 89 | virtual WAN_DONGLE_TYPE getType(); |
donatien | 0:bfed5767d0a5 | 90 | |
donatien | 0:bfed5767d0a5 | 91 | private: |
donatien | 0:bfed5767d0a5 | 92 | |
donatien | 0:bfed5767d0a5 | 93 | bool m_hasSwitched; |
donatien | 0:bfed5767d0a5 | 94 | int m_currentSerialIntf; |
donatien | 4:cd9864d1db52 | 95 | int m_currentEndpoint; |
donatien | 0:bfed5767d0a5 | 96 | }; |
donatien | 0:bfed5767d0a5 | 97 | |
donatien | 8:65cd51339647 | 98 | class SprintMC5728VInitializer : public WANDongleInitializer |
donatien | 8:65cd51339647 | 99 | { |
donatien | 8:65cd51339647 | 100 | public: |
donatien | 8:65cd51339647 | 101 | SprintMC5728VInitializer(USBHost* pHost); |
donatien | 8:65cd51339647 | 102 | |
donatien | 8:65cd51339647 | 103 | virtual uint16_t getMSDVid(); |
donatien | 8:65cd51339647 | 104 | virtual uint16_t getMSDPid(); |
donatien | 8:65cd51339647 | 105 | |
donatien | 8:65cd51339647 | 106 | virtual uint16_t getSerialVid(); |
donatien | 8:65cd51339647 | 107 | virtual uint16_t getSerialPid(); |
donatien | 8:65cd51339647 | 108 | |
donatien | 8:65cd51339647 | 109 | virtual bool switchMode(USBDeviceConnected* pDev); |
donatien | 8:65cd51339647 | 110 | |
donatien | 8:65cd51339647 | 111 | virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx); |
donatien | 8:65cd51339647 | 112 | |
donatien | 8:65cd51339647 | 113 | virtual int getSerialPortCount(); |
donatien | 8:65cd51339647 | 114 | |
donatien | 8:65cd51339647 | 115 | virtual void setVidPid(uint16_t vid, uint16_t pid); |
donatien | 8:65cd51339647 | 116 | |
donatien | 8:65cd51339647 | 117 | virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed |
donatien | 8:65cd51339647 | 118 | |
donatien | 8:65cd51339647 | 119 | virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used |
donatien | 8:65cd51339647 | 120 | |
donatien | 8:65cd51339647 | 121 | virtual WAN_DONGLE_TYPE getType(); |
donatien | 8:65cd51339647 | 122 | |
donatien | 8:65cd51339647 | 123 | private: |
donatien | 8:65cd51339647 | 124 | |
donatien | 8:65cd51339647 | 125 | int m_currentSerialIntf; |
donatien | 8:65cd51339647 | 126 | int m_currentEndpoint; |
donatien | 8:65cd51339647 | 127 | }; |
donatien | 8:65cd51339647 | 128 | |
donatien | 0:bfed5767d0a5 | 129 | #endif |