]> git.gir.st - tmk_keyboard.git/blob - tool/mbed/mbed-sdk/libraries/USBHost/USBHost3GModule/WANDongleInitializer.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[tmk_keyboard.git] / tool / mbed / mbed-sdk / libraries / USBHost / USBHost3GModule / WANDongleInitializer.h
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
19 #ifndef WANDONGLEINITIALIZER_H
20 #define WANDONGLEINITIALIZER_H
21
22 #include "USBHostConf.h"
23
24 #ifdef USBHOST_3GMODULE
25
26 #include <stdint.h>
27
28 #include "USBHost.h"
29 #include "IUSBEnumerator.h"
30
31 // [TODO] move these declarations to a proper place
32 #define WANDONGLE_MAX_SERIAL_PORTS 2
33 #define WANDONGLE_MAX_INITIALIZERS 6
34
35 #define WAN_DONGLE_TYPE_UNKNOWN (-1)
36
37 class WANDongleInitializer : public IUSBEnumerator
38 {
39 protected:
40 WANDongleInitializer(USBHost* pHost) { m_pHost = pHost; }
41 USBHost* m_pHost;
42 uint8_t m_serialIntfMap[WANDONGLE_MAX_SERIAL_PORTS];
43
44 public:
45 virtual ~WANDongleInitializer() {}
46 virtual uint16_t getMSDVid() = 0;
47 virtual uint16_t getMSDPid() = 0;
48
49 virtual uint16_t getSerialVid() = 0;
50 virtual uint16_t getSerialPid() = 0;
51
52 virtual bool switchMode(USBDeviceConnected* pDev) = 0;
53
54 virtual USBEndpoint* getEp(USBDeviceConnected* pDev, int serialPortNumber, bool tx) {
55 return pDev->getEndpoint(m_serialIntfMap[serialPortNumber], BULK_ENDPOINT, tx ? OUT : IN, 0);
56 }
57
58 virtual int getSerialPortCount() = 0;
59
60 virtual void setVidPid(uint16_t vid, uint16_t pid) = 0;
61
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
63
64 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir) = 0; //Must return true if the endpoint will be used
65
66 virtual int getType() = 0;
67
68 virtual uint8_t getSerialIntf(int index) { return m_serialIntfMap[index]; }
69 };
70
71 #endif /* USBHOST_3GMODULE */
72
73 #endif
Imprint / Impressum