dhgdh

Dependencies:   MAX44000 PWM_Tone_Library nexpaq_mdk

Fork of LED_Demo by joey shelton

Committer:
nexpaq
Date:
Sat Sep 17 16:32:05 2016 +0000
Revision:
1:55a6170b404f
checking in for sharing

Who changed what in which revision?

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