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:
va009039
Date:
Mon Feb 03 13:00:16 2014 +0000
Revision:
9:7f9f64cf5ded
Parent:
8:6463cd1964c0
Child:
10:40c7f6788902
add interrupt write transfer.

Who changed what in which revision?

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