USB Host Driver with Socket Modem support. Works with revision 323 of mbed-src but broken with any later version.

Dependencies:   FATFileSystem

Fork of F401RE-USBHost by Norimasa Okamoto

Committer:
fritz291
Date:
Fri Jun 26 19:30:55 2015 +0000
Revision:
26:53970cabf56d
Parent:
12:b91fdea8c0a7
Fixed small error in testAT function

Who changed what in which revision?

UserRevisionLine numberNew contents of line
va009039 12:b91fdea8c0a7 1 /* mbed USBHost Library
va009039 12:b91fdea8c0a7 2 * Copyright (c) 2006-2013 ARM Limited
va009039 12:b91fdea8c0a7 3 *
va009039 12:b91fdea8c0a7 4 * Licensed under the Apache License, Version 2.0 (the "License");
va009039 12:b91fdea8c0a7 5 * you may not use this file except in compliance with the License.
va009039 12:b91fdea8c0a7 6 * You may obtain a copy of the License at
va009039 12:b91fdea8c0a7 7 *
va009039 12:b91fdea8c0a7 8 * http://www.apache.org/licenses/LICENSE-2.0
va009039 12:b91fdea8c0a7 9 *
va009039 12:b91fdea8c0a7 10 * Unless required by applicable law or agreed to in writing, software
va009039 12:b91fdea8c0a7 11 * distributed under the License is distributed on an "AS IS" BASIS,
va009039 12:b91fdea8c0a7 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
va009039 12:b91fdea8c0a7 13 * See the License for the specific language governing permissions and
va009039 12:b91fdea8c0a7 14 * limitations under the License.
va009039 12:b91fdea8c0a7 15 */
va009039 12:b91fdea8c0a7 16
va009039 12:b91fdea8c0a7 17 #include "USBDeviceConnected.h"
va009039 12:b91fdea8c0a7 18 #include "dbg.h"
va009039 12:b91fdea8c0a7 19
va009039 12:b91fdea8c0a7 20 USBDeviceConnected::USBDeviceConnected() {
va009039 12:b91fdea8c0a7 21 init();
va009039 12:b91fdea8c0a7 22 }
va009039 12:b91fdea8c0a7 23
va009039 12:b91fdea8c0a7 24 void USBDeviceConnected::init() {
va009039 12:b91fdea8c0a7 25 port = 0;
va009039 12:b91fdea8c0a7 26 vid = 0;
va009039 12:b91fdea8c0a7 27 pid = 0;
va009039 12:b91fdea8c0a7 28 nb_interf = 0;
va009039 12:b91fdea8c0a7 29 enumerated = false;
va009039 12:b91fdea8c0a7 30 device_class = 0;
va009039 12:b91fdea8c0a7 31 device_subclass = 0;
va009039 12:b91fdea8c0a7 32 proto = 0;
va009039 12:b91fdea8c0a7 33 lowSpeed = false;
va009039 12:b91fdea8c0a7 34 hub_parent = NULL;
va009039 12:b91fdea8c0a7 35 }
va009039 12:b91fdea8c0a7 36
va009039 12:b91fdea8c0a7 37 bool USBDeviceConnected::addInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol) {
va009039 12:b91fdea8c0a7 38 USB_DBG("intf_nb=%d", intf_nb);
va009039 12:b91fdea8c0a7 39 if (intf.count(intf_nb) > 0) {
va009039 12:b91fdea8c0a7 40 return false;
va009039 12:b91fdea8c0a7 41 }
va009039 12:b91fdea8c0a7 42 intf[intf_nb] = new INTERFACE(intf_class, intf_subclass, intf_protocol);
va009039 12:b91fdea8c0a7 43 return true;
va009039 12:b91fdea8c0a7 44 }
va009039 12:b91fdea8c0a7 45
va009039 12:b91fdea8c0a7 46 bool USBDeviceConnected::addEndpoint(uint8_t intf_nb, USBEndpoint * ept) {
va009039 12:b91fdea8c0a7 47 if (intf.count(intf_nb) > 0) {
va009039 12:b91fdea8c0a7 48 intf[intf_nb]->ep.push_back(ept);
va009039 12:b91fdea8c0a7 49 return true;
va009039 12:b91fdea8c0a7 50 }
va009039 12:b91fdea8c0a7 51 return false;
va009039 12:b91fdea8c0a7 52 }
va009039 12:b91fdea8c0a7 53
va009039 12:b91fdea8c0a7 54 void USBDeviceConnected::init(USBDeviceConnected* parent, uint8_t port_, bool lowSpeed_) {
va009039 12:b91fdea8c0a7 55 USB_DBG("init dev: %p", this);
va009039 12:b91fdea8c0a7 56 init();
va009039 12:b91fdea8c0a7 57 hub_parent = parent;
va009039 12:b91fdea8c0a7 58 port = port_;
va009039 12:b91fdea8c0a7 59 lowSpeed = lowSpeed_;
va009039 12:b91fdea8c0a7 60 }
va009039 12:b91fdea8c0a7 61
va009039 12:b91fdea8c0a7 62 void USBDeviceConnected::disconnect() {
va009039 12:b91fdea8c0a7 63 //for(int i = 0; i < MAX_INTF; i++) {
va009039 12:b91fdea8c0a7 64 // intf[i].detach.call();
va009039 12:b91fdea8c0a7 65 //}
va009039 12:b91fdea8c0a7 66 //init();
va009039 12:b91fdea8c0a7 67 }
va009039 12:b91fdea8c0a7 68
va009039 12:b91fdea8c0a7 69
va009039 12:b91fdea8c0a7 70 USBEndpoint * USBDeviceConnected::getEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir, uint8_t index) {
va009039 12:b91fdea8c0a7 71 USB_DBG("intf_nb=%d", intf_nb);
va009039 12:b91fdea8c0a7 72 USB_TEST_ASSERT(intf.count(intf_nb) > 0);
va009039 12:b91fdea8c0a7 73 INTERFACE* inter = intf[intf_nb];
va009039 12:b91fdea8c0a7 74 for (int i = 0; i < inter->ep.size(); i++) {
va009039 12:b91fdea8c0a7 75 if ((inter->ep[i]->getType() == type) && (inter->ep[i]->getDir() == dir)) {
va009039 12:b91fdea8c0a7 76 if(index) {
va009039 12:b91fdea8c0a7 77 index--;
va009039 12:b91fdea8c0a7 78 } else {
va009039 12:b91fdea8c0a7 79 return inter->ep[i];
va009039 12:b91fdea8c0a7 80 }
va009039 12:b91fdea8c0a7 81 }
va009039 12:b91fdea8c0a7 82 }
va009039 12:b91fdea8c0a7 83 return NULL;
va009039 12:b91fdea8c0a7 84 }
va009039 12:b91fdea8c0a7 85
va009039 12:b91fdea8c0a7 86 USBEndpoint * USBDeviceConnected::getEndpoint(uint8_t intf_nb, uint8_t index) {
va009039 12:b91fdea8c0a7 87 USB_TEST_ASSERT(intf.count(intf_nb) > 0);
va009039 12:b91fdea8c0a7 88 return intf[intf_nb]->ep[index];
va009039 12:b91fdea8c0a7 89 }