WANDongleInitializer.h 2.6 KB

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