2018.07.26

Dependencies:   FATFileSystem2 mbed-rtos

Fork of USBHost by mbed official

Committer:
sayzyas
Date:
Thu Jul 26 00:29:30 2018 +0000
Revision:
44:e437b1c7c61e
Parent:
43:78f328f311dc
2018.07.26

Who changed what in which revision?

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