Running multiple threads on mbed using RTOS

Dependencies:   4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player_appbd

Committer:
wschon
Date:
Mon Feb 29 03:46:10 2016 +0000
Revision:
4:5fdadaef5b1f
Parent:
1:2129bb91c172
fixed EVERYTHING

Who changed what in which revision?

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