Opencv 3.1 project on GR-PEACH board

Fork of gr-peach-opencv-project by the do

Committer:
thedo
Date:
Tue Jul 04 06:23:13 2017 +0000
Revision:
170:54ff26da7eb6
Parent:
166:3a9487d57a5c
project opencv 3.1 on GR PEACH board, no use SD card.

Who changed what in which revision?

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