Vodafone K3770/K3772-Z modems driver & networking library

Dependencies:   Socket

This library is deprecated. Please use the newest production branch of the library from https://mbed.org/users/mbed_official/code/VodafoneUSBModem/

Committer:
donatien
Date:
Thu Nov 01 09:57:11 2012 +0000
Revision:
2:50930edb6eb3
Parent:
0:bd5343539e38
Deprecated library, pointing out to new one

Who changed what in which revision?

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