Committer:
borlanic
Date:
Fri Mar 30 14:07:05 2018 +0000
Revision:
4:75df35ef4fb6
Parent:
0:380207fcb5c1
commentar

Who changed what in which revision?

UserRevisionLine numberNew contents of line
borlanic 0:380207fcb5c1 1 /* Copyright (c) 2010-2012 mbed.org, MIT License
borlanic 0:380207fcb5c1 2 *
borlanic 0:380207fcb5c1 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
borlanic 0:380207fcb5c1 4 * and associated documentation files (the "Software"), to deal in the Software without
borlanic 0:380207fcb5c1 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
borlanic 0:380207fcb5c1 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
borlanic 0:380207fcb5c1 7 * Software is furnished to do so, subject to the following conditions:
borlanic 0:380207fcb5c1 8 *
borlanic 0:380207fcb5c1 9 * The above copyright notice and this permission notice shall be included in all copies or
borlanic 0:380207fcb5c1 10 * substantial portions of the Software.
borlanic 0:380207fcb5c1 11 *
borlanic 0:380207fcb5c1 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
borlanic 0:380207fcb5c1 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
borlanic 0:380207fcb5c1 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
borlanic 0:380207fcb5c1 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
borlanic 0:380207fcb5c1 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
borlanic 0:380207fcb5c1 17 */
borlanic 0:380207fcb5c1 18
borlanic 0:380207fcb5c1 19 #ifndef WANDONGLEINITIALIZER_H
borlanic 0:380207fcb5c1 20 #define WANDONGLEINITIALIZER_H
borlanic 0:380207fcb5c1 21
borlanic 0:380207fcb5c1 22 #include "USBHostConf.h"
borlanic 0:380207fcb5c1 23
borlanic 0:380207fcb5c1 24 #ifdef USBHOST_3GMODULE
borlanic 0:380207fcb5c1 25
borlanic 0:380207fcb5c1 26 #include <stdint.h>
borlanic 0:380207fcb5c1 27
borlanic 0:380207fcb5c1 28 #include "USBHost.h"
borlanic 0:380207fcb5c1 29 #include "IUSBEnumerator.h"
borlanic 0:380207fcb5c1 30
borlanic 0:380207fcb5c1 31 // [TODO] move these declarations to a proper place
borlanic 0:380207fcb5c1 32 #define WANDONGLE_MAX_SERIAL_PORTS 2
borlanic 0:380207fcb5c1 33 #define WANDONGLE_MAX_INITIALIZERS 6
borlanic 0:380207fcb5c1 34
borlanic 0:380207fcb5c1 35 #define WAN_DONGLE_TYPE_UNKNOWN (-1)
borlanic 0:380207fcb5c1 36
borlanic 0:380207fcb5c1 37 class WANDongleInitializer : public IUSBEnumerator
borlanic 0:380207fcb5c1 38 {
borlanic 0:380207fcb5c1 39 protected:
borlanic 0:380207fcb5c1 40 WANDongleInitializer(USBHost* pHost) { m_pHost = pHost; }
borlanic 0:380207fcb5c1 41 USBHost* m_pHost;
borlanic 0:380207fcb5c1 42 uint8_t m_serialIntfMap[WANDONGLE_MAX_SERIAL_PORTS];
borlanic 0:380207fcb5c1 43
borlanic 0:380207fcb5c1 44 public:
borlanic 0:380207fcb5c1 45 virtual ~WANDongleInitializer() {}
borlanic 0:380207fcb5c1 46 virtual uint16_t getMSDVid() = 0;
borlanic 0:380207fcb5c1 47 virtual uint16_t getMSDPid() = 0;
borlanic 0:380207fcb5c1 48
borlanic 0:380207fcb5c1 49 virtual uint16_t getSerialVid() = 0;
borlanic 0:380207fcb5c1 50 virtual uint16_t getSerialPid() = 0;
borlanic 0:380207fcb5c1 51
borlanic 0:380207fcb5c1 52 virtual bool switchMode(USBDeviceConnected* pDev) = 0;
borlanic 0:380207fcb5c1 53
borlanic 0:380207fcb5c1 54 virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) {
borlanic 0:380207fcb5c1 55 return pDev->getEndpoint(m_serialIntfMap[serialPortNumber], BULK_ENDPOINT, tx ? OUT : IN, 0);
borlanic 0:380207fcb5c1 56 }
borlanic 0:380207fcb5c1 57
borlanic 0:380207fcb5c1 58 virtual int getSerialPortCount() = 0;
borlanic 0:380207fcb5c1 59
borlanic 0:380207fcb5c1 60 virtual void setVidPid(uint16_t vid, uint16_t pid) = 0;
borlanic 0:380207fcb5c1 61
borlanic 0:380207fcb5c1 62 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
borlanic 0:380207fcb5c1 63
borlanic 0:380207fcb5c1 64 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) = 0; //Must return true if the endpoint will be used
borlanic 0:380207fcb5c1 65
borlanic 0:380207fcb5c1 66 virtual int getType() = 0;
borlanic 0:380207fcb5c1 67
borlanic 0:380207fcb5c1 68 virtual uint8_t getSerialIntf(int index) { return m_serialIntfMap[index]; }
borlanic 0:380207fcb5c1 69 };
borlanic 0:380207fcb5c1 70
borlanic 0:380207fcb5c1 71 #endif /* USBHOST_3GMODULE */
borlanic 0:380207fcb5c1 72
borlanic 0:380207fcb5c1 73 #endif