Integrating the ublox LISA C200 modem
Fork of SprintUSBModemHTTPClientTest by
SprintUSBModem/USBHostWANDongleSprint/USBHost/USBDeviceConnected.h@5:3f93dd1d4cb3, 2013-09-26 (annotated)
- Committer:
- sam_grove
- Date:
- Thu Sep 26 00:44:20 2013 -0500
- Revision:
- 5:3f93dd1d4cb3
Exported program and replaced contents of the repo with the source
to build and debug using keil mdk. Libs NOT upto date are lwip, lwip-sys
and socket. these have newer versions under mbed_official but were starting
from a know working point
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sam_grove | 5:3f93dd1d4cb3 | 1 | /* Copyright (c) 2010-2012 mbed.org, MIT License |
sam_grove | 5:3f93dd1d4cb3 | 2 | * |
sam_grove | 5:3f93dd1d4cb3 | 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy of this software |
sam_grove | 5:3f93dd1d4cb3 | 4 | * and associated documentation files (the "Software"), to deal in the Software without |
sam_grove | 5:3f93dd1d4cb3 | 5 | * restriction, including without limitation the rights to use, copy, modify, merge, publish, |
sam_grove | 5:3f93dd1d4cb3 | 6 | * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the |
sam_grove | 5:3f93dd1d4cb3 | 7 | * Software is furnished to do so, subject to the following conditions: |
sam_grove | 5:3f93dd1d4cb3 | 8 | * |
sam_grove | 5:3f93dd1d4cb3 | 9 | * The above copyright notice and this permission notice shall be included in all copies or |
sam_grove | 5:3f93dd1d4cb3 | 10 | * substantial portions of the Software. |
sam_grove | 5:3f93dd1d4cb3 | 11 | * |
sam_grove | 5:3f93dd1d4cb3 | 12 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING |
sam_grove | 5:3f93dd1d4cb3 | 13 | * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
sam_grove | 5:3f93dd1d4cb3 | 14 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
sam_grove | 5:3f93dd1d4cb3 | 15 | * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
sam_grove | 5:3f93dd1d4cb3 | 16 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
sam_grove | 5:3f93dd1d4cb3 | 17 | */ |
sam_grove | 5:3f93dd1d4cb3 | 18 | |
sam_grove | 5:3f93dd1d4cb3 | 19 | #ifndef USBDEVICECONNECTED_H |
sam_grove | 5:3f93dd1d4cb3 | 20 | #define USBDEVICECONNECTED_H |
sam_grove | 5:3f93dd1d4cb3 | 21 | |
sam_grove | 5:3f93dd1d4cb3 | 22 | #include "stdint.h" |
sam_grove | 5:3f93dd1d4cb3 | 23 | #include "USBEndpoint.h" |
sam_grove | 5:3f93dd1d4cb3 | 24 | |
sam_grove | 5:3f93dd1d4cb3 | 25 | #define MAX_ENDPOINT_PER_INTERFACE 4 |
sam_grove | 5:3f93dd1d4cb3 | 26 | #define MAX_INTF 2 |
sam_grove | 5:3f93dd1d4cb3 | 27 | |
sam_grove | 5:3f93dd1d4cb3 | 28 | typedef struct { |
sam_grove | 5:3f93dd1d4cb3 | 29 | bool in_use; |
sam_grove | 5:3f93dd1d4cb3 | 30 | uint8_t nb_endpoint; |
sam_grove | 5:3f93dd1d4cb3 | 31 | uint8_t intf_class; |
sam_grove | 5:3f93dd1d4cb3 | 32 | uint8_t intf_subclass; |
sam_grove | 5:3f93dd1d4cb3 | 33 | uint8_t intf_protocol; |
sam_grove | 5:3f93dd1d4cb3 | 34 | USBEndpoint * ep[MAX_ENDPOINT_PER_INTERFACE]; |
sam_grove | 5:3f93dd1d4cb3 | 35 | FunctionPointer detach; |
sam_grove | 5:3f93dd1d4cb3 | 36 | }INTERFACE; |
sam_grove | 5:3f93dd1d4cb3 | 37 | |
sam_grove | 5:3f93dd1d4cb3 | 38 | |
sam_grove | 5:3f93dd1d4cb3 | 39 | class USBDeviceConnected { |
sam_grove | 5:3f93dd1d4cb3 | 40 | public: |
sam_grove | 5:3f93dd1d4cb3 | 41 | |
sam_grove | 5:3f93dd1d4cb3 | 42 | /* |
sam_grove | 5:3f93dd1d4cb3 | 43 | * Constructor |
sam_grove | 5:3f93dd1d4cb3 | 44 | */ |
sam_grove | 5:3f93dd1d4cb3 | 45 | USBDeviceConnected(); |
sam_grove | 5:3f93dd1d4cb3 | 46 | |
sam_grove | 5:3f93dd1d4cb3 | 47 | /* |
sam_grove | 5:3f93dd1d4cb3 | 48 | * Attach an USBEndpoint to this device |
sam_grove | 5:3f93dd1d4cb3 | 49 | * |
sam_grove | 5:3f93dd1d4cb3 | 50 | * @param ep pointeur on the USBEndpoint which will be attached |
sam_grove | 5:3f93dd1d4cb3 | 51 | * @returns true if successful, false otherwise |
sam_grove | 5:3f93dd1d4cb3 | 52 | */ |
sam_grove | 5:3f93dd1d4cb3 | 53 | bool addEndpoint(uint8_t intf_nb, USBEndpoint * ep); |
sam_grove | 5:3f93dd1d4cb3 | 54 | |
sam_grove | 5:3f93dd1d4cb3 | 55 | /* |
sam_grove | 5:3f93dd1d4cb3 | 56 | * Retrieve an USBEndpoint by its TYPE and DIRECTION |
sam_grove | 5:3f93dd1d4cb3 | 57 | * |
sam_grove | 5:3f93dd1d4cb3 | 58 | * @param intf_nb the interface on which to lookup the USBEndpoint |
sam_grove | 5:3f93dd1d4cb3 | 59 | * @param type type of the USBEndpoint looked for |
sam_grove | 5:3f93dd1d4cb3 | 60 | * @param direction of the USBEndpoint looked for |
sam_grove | 5:3f93dd1d4cb3 | 61 | * @param index the index of the USBEndpoint whitin the interface |
sam_grove | 5:3f93dd1d4cb3 | 62 | * @returns pointer on the USBEndpoint if found, NULL otherwise |
sam_grove | 5:3f93dd1d4cb3 | 63 | */ |
sam_grove | 5:3f93dd1d4cb3 | 64 | USBEndpoint * getEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir, uint8_t index = 0); |
sam_grove | 5:3f93dd1d4cb3 | 65 | |
sam_grove | 5:3f93dd1d4cb3 | 66 | /* |
sam_grove | 5:3f93dd1d4cb3 | 67 | * Retrieve an USBEndpoint by its index |
sam_grove | 5:3f93dd1d4cb3 | 68 | * |
sam_grove | 5:3f93dd1d4cb3 | 69 | * @param index index of the USBEndpoint |
sam_grove | 5:3f93dd1d4cb3 | 70 | * @returns pointer on the USBEndpoint if found, NULL otherwise |
sam_grove | 5:3f93dd1d4cb3 | 71 | */ |
sam_grove | 5:3f93dd1d4cb3 | 72 | USBEndpoint * getEndpoint(uint8_t intf_nb, uint8_t index); |
sam_grove | 5:3f93dd1d4cb3 | 73 | |
sam_grove | 5:3f93dd1d4cb3 | 74 | bool addInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); |
sam_grove | 5:3f93dd1d4cb3 | 75 | |
sam_grove | 5:3f93dd1d4cb3 | 76 | uint8_t getNbInterface() {return nb_interf;}; |
sam_grove | 5:3f93dd1d4cb3 | 77 | |
sam_grove | 5:3f93dd1d4cb3 | 78 | INTERFACE * getInterface(uint8_t index); |
sam_grove | 5:3f93dd1d4cb3 | 79 | |
sam_grove | 5:3f93dd1d4cb3 | 80 | /** |
sam_grove | 5:3f93dd1d4cb3 | 81 | * Attach a member function to call when a the device has been disconnected |
sam_grove | 5:3f93dd1d4cb3 | 82 | * |
sam_grove | 5:3f93dd1d4cb3 | 83 | * @param tptr pointer to the object to call the member function on |
sam_grove | 5:3f93dd1d4cb3 | 84 | * @param mptr pointer to the member function to be called |
sam_grove | 5:3f93dd1d4cb3 | 85 | */ |
sam_grove | 5:3f93dd1d4cb3 | 86 | template<typename T> |
sam_grove | 5:3f93dd1d4cb3 | 87 | void onDisconnect(uint8_t intf_nb, T* tptr, void (T::*mptr)(void)) { |
sam_grove | 5:3f93dd1d4cb3 | 88 | if ((mptr != NULL) && (tptr != NULL)) { |
sam_grove | 5:3f93dd1d4cb3 | 89 | intf[intf_nb].detach.attach(tptr, mptr); |
sam_grove | 5:3f93dd1d4cb3 | 90 | } |
sam_grove | 5:3f93dd1d4cb3 | 91 | } |
sam_grove | 5:3f93dd1d4cb3 | 92 | |
sam_grove | 5:3f93dd1d4cb3 | 93 | /** |
sam_grove | 5:3f93dd1d4cb3 | 94 | * Attach a callback called when the device has been disconnected |
sam_grove | 5:3f93dd1d4cb3 | 95 | * |
sam_grove | 5:3f93dd1d4cb3 | 96 | * @param fptr function pointer |
sam_grove | 5:3f93dd1d4cb3 | 97 | */ |
sam_grove | 5:3f93dd1d4cb3 | 98 | void onDisconnect(uint8_t intf_nb, void (*fn)(void)) { |
sam_grove | 5:3f93dd1d4cb3 | 99 | if (fn != NULL) { |
sam_grove | 5:3f93dd1d4cb3 | 100 | intf[intf_nb].detach.attach(fn); |
sam_grove | 5:3f93dd1d4cb3 | 101 | } |
sam_grove | 5:3f93dd1d4cb3 | 102 | } |
sam_grove | 5:3f93dd1d4cb3 | 103 | |
sam_grove | 5:3f93dd1d4cb3 | 104 | /* |
sam_grove | 5:3f93dd1d4cb3 | 105 | * Disconnect the device by calling a callback function registered by a driver |
sam_grove | 5:3f93dd1d4cb3 | 106 | */ |
sam_grove | 5:3f93dd1d4cb3 | 107 | void disconnect(); |
sam_grove | 5:3f93dd1d4cb3 | 108 | |
sam_grove | 5:3f93dd1d4cb3 | 109 | /* |
sam_grove | 5:3f93dd1d4cb3 | 110 | * Setters |
sam_grove | 5:3f93dd1d4cb3 | 111 | */ |
sam_grove | 5:3f93dd1d4cb3 | 112 | void init(uint8_t hub, uint8_t port, bool lowSpeed); |
sam_grove | 5:3f93dd1d4cb3 | 113 | void setAddress(uint8_t addr) { |
sam_grove | 5:3f93dd1d4cb3 | 114 | this->addr = addr; |
sam_grove | 5:3f93dd1d4cb3 | 115 | }; |
sam_grove | 5:3f93dd1d4cb3 | 116 | void setVid(uint16_t vid) { |
sam_grove | 5:3f93dd1d4cb3 | 117 | this->vid = vid; |
sam_grove | 5:3f93dd1d4cb3 | 118 | }; |
sam_grove | 5:3f93dd1d4cb3 | 119 | void setPid(uint16_t pid) { |
sam_grove | 5:3f93dd1d4cb3 | 120 | this->pid = pid; |
sam_grove | 5:3f93dd1d4cb3 | 121 | }; |
sam_grove | 5:3f93dd1d4cb3 | 122 | void setClass(uint8_t device_class) { |
sam_grove | 5:3f93dd1d4cb3 | 123 | this->device_class = device_class; |
sam_grove | 5:3f93dd1d4cb3 | 124 | }; |
sam_grove | 5:3f93dd1d4cb3 | 125 | void setSubClass(uint8_t device_subclass) { |
sam_grove | 5:3f93dd1d4cb3 | 126 | this->device_subclass = device_subclass; |
sam_grove | 5:3f93dd1d4cb3 | 127 | }; |
sam_grove | 5:3f93dd1d4cb3 | 128 | void setProtocol(uint8_t pr) { |
sam_grove | 5:3f93dd1d4cb3 | 129 | proto = pr; |
sam_grove | 5:3f93dd1d4cb3 | 130 | }; |
sam_grove | 5:3f93dd1d4cb3 | 131 | void setSizeControlEndpoint(uint32_t size) { |
sam_grove | 5:3f93dd1d4cb3 | 132 | sizeControlEndpoint = size; |
sam_grove | 5:3f93dd1d4cb3 | 133 | }; |
sam_grove | 5:3f93dd1d4cb3 | 134 | void activeAddress() { |
sam_grove | 5:3f93dd1d4cb3 | 135 | activeAddr = true; |
sam_grove | 5:3f93dd1d4cb3 | 136 | }; |
sam_grove | 5:3f93dd1d4cb3 | 137 | void setEnumerated() { |
sam_grove | 5:3f93dd1d4cb3 | 138 | enumerated = true; |
sam_grove | 5:3f93dd1d4cb3 | 139 | }; |
sam_grove | 5:3f93dd1d4cb3 | 140 | |
sam_grove | 5:3f93dd1d4cb3 | 141 | /* |
sam_grove | 5:3f93dd1d4cb3 | 142 | * Getters |
sam_grove | 5:3f93dd1d4cb3 | 143 | */ |
sam_grove | 5:3f93dd1d4cb3 | 144 | uint8_t getPort() { |
sam_grove | 5:3f93dd1d4cb3 | 145 | return port; |
sam_grove | 5:3f93dd1d4cb3 | 146 | }; |
sam_grove | 5:3f93dd1d4cb3 | 147 | uint8_t getHub() { |
sam_grove | 5:3f93dd1d4cb3 | 148 | return hub; |
sam_grove | 5:3f93dd1d4cb3 | 149 | }; |
sam_grove | 5:3f93dd1d4cb3 | 150 | uint8_t getAddress() { |
sam_grove | 5:3f93dd1d4cb3 | 151 | return addr; |
sam_grove | 5:3f93dd1d4cb3 | 152 | }; |
sam_grove | 5:3f93dd1d4cb3 | 153 | uint16_t getVid() { |
sam_grove | 5:3f93dd1d4cb3 | 154 | return vid; |
sam_grove | 5:3f93dd1d4cb3 | 155 | }; |
sam_grove | 5:3f93dd1d4cb3 | 156 | uint16_t getPid() { |
sam_grove | 5:3f93dd1d4cb3 | 157 | return pid; |
sam_grove | 5:3f93dd1d4cb3 | 158 | }; |
sam_grove | 5:3f93dd1d4cb3 | 159 | uint8_t getClass() { |
sam_grove | 5:3f93dd1d4cb3 | 160 | return device_class; |
sam_grove | 5:3f93dd1d4cb3 | 161 | }; |
sam_grove | 5:3f93dd1d4cb3 | 162 | uint8_t getSubClass() { |
sam_grove | 5:3f93dd1d4cb3 | 163 | return device_subclass; |
sam_grove | 5:3f93dd1d4cb3 | 164 | }; |
sam_grove | 5:3f93dd1d4cb3 | 165 | uint8_t getProtocol() { |
sam_grove | 5:3f93dd1d4cb3 | 166 | return proto; |
sam_grove | 5:3f93dd1d4cb3 | 167 | }; |
sam_grove | 5:3f93dd1d4cb3 | 168 | bool getSpeed() { |
sam_grove | 5:3f93dd1d4cb3 | 169 | return speed; |
sam_grove | 5:3f93dd1d4cb3 | 170 | }; |
sam_grove | 5:3f93dd1d4cb3 | 171 | uint32_t getSizeControlEndpoint() { |
sam_grove | 5:3f93dd1d4cb3 | 172 | return sizeControlEndpoint; |
sam_grove | 5:3f93dd1d4cb3 | 173 | }; |
sam_grove | 5:3f93dd1d4cb3 | 174 | bool isActiveAddress() { |
sam_grove | 5:3f93dd1d4cb3 | 175 | return activeAddr; |
sam_grove | 5:3f93dd1d4cb3 | 176 | }; |
sam_grove | 5:3f93dd1d4cb3 | 177 | bool isEnumerated() { |
sam_grove | 5:3f93dd1d4cb3 | 178 | return enumerated; |
sam_grove | 5:3f93dd1d4cb3 | 179 | }; |
sam_grove | 5:3f93dd1d4cb3 | 180 | |
sam_grove | 5:3f93dd1d4cb3 | 181 | |
sam_grove | 5:3f93dd1d4cb3 | 182 | private: |
sam_grove | 5:3f93dd1d4cb3 | 183 | INTERFACE intf[MAX_INTF]; |
sam_grove | 5:3f93dd1d4cb3 | 184 | //USBEndpoint * ep[MAX_ENDPOINT_PER_DEVICE]; |
sam_grove | 5:3f93dd1d4cb3 | 185 | uint32_t sizeControlEndpoint; |
sam_grove | 5:3f93dd1d4cb3 | 186 | uint8_t hub; |
sam_grove | 5:3f93dd1d4cb3 | 187 | uint8_t port; |
sam_grove | 5:3f93dd1d4cb3 | 188 | uint16_t vid; |
sam_grove | 5:3f93dd1d4cb3 | 189 | uint16_t pid; |
sam_grove | 5:3f93dd1d4cb3 | 190 | uint8_t addr; |
sam_grove | 5:3f93dd1d4cb3 | 191 | uint8_t device_class; |
sam_grove | 5:3f93dd1d4cb3 | 192 | uint8_t device_subclass; |
sam_grove | 5:3f93dd1d4cb3 | 193 | uint8_t proto; |
sam_grove | 5:3f93dd1d4cb3 | 194 | bool speed; |
sam_grove | 5:3f93dd1d4cb3 | 195 | bool activeAddr; |
sam_grove | 5:3f93dd1d4cb3 | 196 | bool enumerated; |
sam_grove | 5:3f93dd1d4cb3 | 197 | |
sam_grove | 5:3f93dd1d4cb3 | 198 | uint8_t nb_interf; |
sam_grove | 5:3f93dd1d4cb3 | 199 | |
sam_grove | 5:3f93dd1d4cb3 | 200 | |
sam_grove | 5:3f93dd1d4cb3 | 201 | void init(); |
sam_grove | 5:3f93dd1d4cb3 | 202 | |
sam_grove | 5:3f93dd1d4cb3 | 203 | }; |
sam_grove | 5:3f93dd1d4cb3 | 204 | |
sam_grove | 5:3f93dd1d4cb3 | 205 | #endif |