USBHost library with fixes

Dependencies:   mbed-rtos FATFileSystem

Dependents:   mbedica

Committer:
zrussell3
Date:
Thu Dec 13 19:24:21 2018 +0000
Revision:
0:b176d95bb38f
Modified USBHost library to fix modifier input

Who changed what in which revision?

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