keyboard->mbed->PC (mbed->SDcard)

Dependencies:   mbed-rtos

Fork of USBHost by mbed official

Committer:
Kojto
Date:
Thu Jul 20 10:13:56 2017 +0100
Revision:
37:f1e388e7b752
Parent:
24:868cbfe611a7
Update libraries (ed9d1da)

Who changed what in which revision?

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