2018.07.26

Dependencies:   FATFileSystem mbed-rtos

Fork of USBHost by mbed official

Committer:
sayzyas
Date:
Thu Jul 26 00:18:29 2018 +0000
Revision:
43:52b15824a019
2018.07.26

Who changed what in which revision?

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