USBHost modified for vmRideR2016b

Dependencies:   FATFileSystem mbed-rtos

Dependents:  

Fork of USBHost by mbed official

Committer:
pedrourdagomez
Date:
Wed Nov 22 15:01:41 2017 +0000
Revision:
39:6ae35848290b
Parent:
33:556baf244dc4
Working Version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JuanManuelAmador 33:556baf244dc4 1 /* mbed USBHost Library
JuanManuelAmador 33:556baf244dc4 2 * Copyright (c) 2006-2013 ARM Limited
JuanManuelAmador 33:556baf244dc4 3 *
JuanManuelAmador 33:556baf244dc4 4 * Licensed under the Apache License, Version 2.0 (the "License");
JuanManuelAmador 33:556baf244dc4 5 * you may not use this file except in compliance with the License.
JuanManuelAmador 33:556baf244dc4 6 * You may obtain a copy of the License at
JuanManuelAmador 33:556baf244dc4 7 *
JuanManuelAmador 33:556baf244dc4 8 * http://www.apache.org/licenses/LICENSE-2.0
JuanManuelAmador 33:556baf244dc4 9 *
JuanManuelAmador 33:556baf244dc4 10 * Unless required by applicable law or agreed to in writing, software
JuanManuelAmador 33:556baf244dc4 11 * distributed under the License is distributed on an "AS IS" BASIS,
JuanManuelAmador 33:556baf244dc4 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
JuanManuelAmador 33:556baf244dc4 13 * See the License for the specific language governing permissions and
JuanManuelAmador 33:556baf244dc4 14 * limitations under the License.
JuanManuelAmador 33:556baf244dc4 15 */
JuanManuelAmador 33:556baf244dc4 16
JuanManuelAmador 33:556baf244dc4 17 #ifndef USBHOSTHUB_H
JuanManuelAmador 33:556baf244dc4 18 #define USBHOSTHUB_H
JuanManuelAmador 33:556baf244dc4 19
JuanManuelAmador 33:556baf244dc4 20 #include "USBHostConf.h"
JuanManuelAmador 33:556baf244dc4 21
JuanManuelAmador 33:556baf244dc4 22 #if MAX_HUB_NB
JuanManuelAmador 33:556baf244dc4 23
JuanManuelAmador 33:556baf244dc4 24 #include "USBHostTypes.h"
JuanManuelAmador 33:556baf244dc4 25 #include "IUSBEnumerator.h"
JuanManuelAmador 33:556baf244dc4 26
JuanManuelAmador 33:556baf244dc4 27 class USBHost;
JuanManuelAmador 33:556baf244dc4 28 class USBDeviceConnected;
JuanManuelAmador 33:556baf244dc4 29 class USBEndpoint;
JuanManuelAmador 33:556baf244dc4 30
JuanManuelAmador 33:556baf244dc4 31 /**
JuanManuelAmador 33:556baf244dc4 32 * A class to use a USB Hub
JuanManuelAmador 33:556baf244dc4 33 */
JuanManuelAmador 33:556baf244dc4 34 class USBHostHub : public IUSBEnumerator {
JuanManuelAmador 33:556baf244dc4 35 public:
JuanManuelAmador 33:556baf244dc4 36 /**
JuanManuelAmador 33:556baf244dc4 37 * Constructor
JuanManuelAmador 33:556baf244dc4 38 */
JuanManuelAmador 33:556baf244dc4 39 USBHostHub();
JuanManuelAmador 33:556baf244dc4 40
JuanManuelAmador 33:556baf244dc4 41 /**
JuanManuelAmador 33:556baf244dc4 42 * Check if a USB Hub is connected
JuanManuelAmador 33:556baf244dc4 43 *
JuanManuelAmador 33:556baf244dc4 44 * @return true if a serial device is connected
JuanManuelAmador 33:556baf244dc4 45 */
JuanManuelAmador 33:556baf244dc4 46 bool connected();
JuanManuelAmador 33:556baf244dc4 47
JuanManuelAmador 33:556baf244dc4 48 /**
JuanManuelAmador 33:556baf244dc4 49 * Try to connect device
JuanManuelAmador 33:556baf244dc4 50 *
JuanManuelAmador 33:556baf244dc4 51 * @param dev device to connect
JuanManuelAmador 33:556baf244dc4 52 * @return true if connection was successful
JuanManuelAmador 33:556baf244dc4 53 */
JuanManuelAmador 33:556baf244dc4 54 bool connect(USBDeviceConnected * dev);
JuanManuelAmador 33:556baf244dc4 55
JuanManuelAmador 33:556baf244dc4 56 /**
JuanManuelAmador 33:556baf244dc4 57 * Automatically called by USBHost when a device
JuanManuelAmador 33:556baf244dc4 58 * has been enumerated by usb_thread
JuanManuelAmador 33:556baf244dc4 59 *
JuanManuelAmador 33:556baf244dc4 60 * @param dev device connected
JuanManuelAmador 33:556baf244dc4 61 */
JuanManuelAmador 33:556baf244dc4 62 void deviceConnected(USBDeviceConnected * dev);
JuanManuelAmador 33:556baf244dc4 63
JuanManuelAmador 33:556baf244dc4 64 /**
JuanManuelAmador 33:556baf244dc4 65 * Automatically called by USBHost when a device
JuanManuelAmador 33:556baf244dc4 66 * has been disconnected from this hub
JuanManuelAmador 33:556baf244dc4 67 *
JuanManuelAmador 33:556baf244dc4 68 * @param dev device disconnected
JuanManuelAmador 33:556baf244dc4 69 */
JuanManuelAmador 33:556baf244dc4 70 void deviceDisconnected(USBDeviceConnected * dev);
JuanManuelAmador 33:556baf244dc4 71
JuanManuelAmador 33:556baf244dc4 72 /**
JuanManuelAmador 33:556baf244dc4 73 * Rest a specific port
JuanManuelAmador 33:556baf244dc4 74 *
JuanManuelAmador 33:556baf244dc4 75 * @param port port number
JuanManuelAmador 33:556baf244dc4 76 */
JuanManuelAmador 33:556baf244dc4 77 void portReset(uint8_t port);
JuanManuelAmador 33:556baf244dc4 78
JuanManuelAmador 33:556baf244dc4 79 /*
JuanManuelAmador 33:556baf244dc4 80 * Called by USBHost to set the instance of USBHost
JuanManuelAmador 33:556baf244dc4 81 *
JuanManuelAmador 33:556baf244dc4 82 * @param host host instance
JuanManuelAmador 33:556baf244dc4 83 */
JuanManuelAmador 33:556baf244dc4 84 void setHost(USBHost * host);
JuanManuelAmador 33:556baf244dc4 85
JuanManuelAmador 33:556baf244dc4 86 /**
JuanManuelAmador 33:556baf244dc4 87 * Called by USBhost when a hub has been disconnected
JuanManuelAmador 33:556baf244dc4 88 */
JuanManuelAmador 33:556baf244dc4 89 void hubDisconnected();
JuanManuelAmador 33:556baf244dc4 90
JuanManuelAmador 33:556baf244dc4 91 protected:
JuanManuelAmador 33:556baf244dc4 92 //From IUSBEnumerator
JuanManuelAmador 33:556baf244dc4 93 virtual void setVidPid(uint16_t vid, uint16_t pid);
JuanManuelAmador 33:556baf244dc4 94 virtual bool parseInterface(uint8_t intf_nb, uint8_t intf_class, uint8_t intf_subclass, uint8_t intf_protocol); //Must return true if the interface should be parsed
JuanManuelAmador 33:556baf244dc4 95 virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used
JuanManuelAmador 33:556baf244dc4 96
JuanManuelAmador 33:556baf244dc4 97 private:
JuanManuelAmador 33:556baf244dc4 98 USBHost * host;
JuanManuelAmador 33:556baf244dc4 99 USBDeviceConnected * dev;
JuanManuelAmador 33:556baf244dc4 100 bool dev_connected;
JuanManuelAmador 33:556baf244dc4 101 USBEndpoint * int_in;
JuanManuelAmador 33:556baf244dc4 102 uint8_t nb_port;
JuanManuelAmador 33:556baf244dc4 103 uint8_t hub_characteristics;
JuanManuelAmador 33:556baf244dc4 104
JuanManuelAmador 33:556baf244dc4 105 void rxHandler();
JuanManuelAmador 33:556baf244dc4 106
JuanManuelAmador 33:556baf244dc4 107 uint8_t buf[sizeof(HubDescriptor)];
JuanManuelAmador 33:556baf244dc4 108
JuanManuelAmador 33:556baf244dc4 109 int hub_intf;
JuanManuelAmador 33:556baf244dc4 110 bool hub_device_found;
JuanManuelAmador 33:556baf244dc4 111
JuanManuelAmador 33:556baf244dc4 112 void setPortFeature(uint32_t feature, uint8_t port);
JuanManuelAmador 33:556baf244dc4 113 void clearPortFeature(uint32_t feature, uint8_t port);
JuanManuelAmador 33:556baf244dc4 114 uint32_t getPortStatus(uint8_t port);
JuanManuelAmador 33:556baf244dc4 115
JuanManuelAmador 33:556baf244dc4 116 USBDeviceConnected * device_children[MAX_HUB_PORT];
JuanManuelAmador 33:556baf244dc4 117
JuanManuelAmador 33:556baf244dc4 118 void init();
JuanManuelAmador 33:556baf244dc4 119 void disconnect();
JuanManuelAmador 33:556baf244dc4 120
JuanManuelAmador 33:556baf244dc4 121 };
JuanManuelAmador 33:556baf244dc4 122
JuanManuelAmador 33:556baf244dc4 123 #endif
JuanManuelAmador 33:556baf244dc4 124
JuanManuelAmador 33:556baf244dc4 125 #endif