Fixing issues with library dependencies

Dependencies:   FATFileSystem mbed-rtos

Fork of USBHost by mbed official

Committer:
mbed_official
Date:
Wed Mar 06 16:27:14 2013 +0000
Revision:
0:a554658735bf
Child:
4:b320d68e98e7
first commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:a554658735bf 1 /* Copyright (c) 2010-2012 mbed.org, MIT License
mbed_official 0:a554658735bf 2 *
mbed_official 0:a554658735bf 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
mbed_official 0:a554658735bf 4 * and associated documentation files (the "Software"), to deal in the Software without
mbed_official 0:a554658735bf 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
mbed_official 0:a554658735bf 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
mbed_official 0:a554658735bf 7 * Software is furnished to do so, subject to the following conditions:
mbed_official 0:a554658735bf 8 *
mbed_official 0:a554658735bf 9 * The above copyright notice and this permission notice shall be included in all copies or
mbed_official 0:a554658735bf 10 * substantial portions of the Software.
mbed_official 0:a554658735bf 11 *
mbed_official 0:a554658735bf 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
mbed_official 0:a554658735bf 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
mbed_official 0:a554658735bf 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
mbed_official 0:a554658735bf 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
mbed_official 0:a554658735bf 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
mbed_official 0:a554658735bf 17 */
mbed_official 0:a554658735bf 18
mbed_official 0:a554658735bf 19 #ifndef USB_INC_H
mbed_official 0:a554658735bf 20 #define USB_INC_H
mbed_official 0:a554658735bf 21
mbed_official 0:a554658735bf 22 #include "mbed.h"
mbed_official 0:a554658735bf 23
mbed_official 0:a554658735bf 24 enum USB_TYPE {
mbed_official 0:a554658735bf 25 USB_TYPE_OK = 0,
mbed_official 0:a554658735bf 26
mbed_official 0:a554658735bf 27 // completion code
mbed_official 0:a554658735bf 28 USB_TYPE_CRC_ERROR = 1,
mbed_official 0:a554658735bf 29 USB_TYPE_BIT_STUFFING_ERROR = 2,
mbed_official 0:a554658735bf 30 USB_TYPE_DATA_TOGGLE_MISMATCH_ERROR = 3,
mbed_official 0:a554658735bf 31 USB_TYPE_STALL_ERROR = 4,
mbed_official 0:a554658735bf 32 USB_TYPE_DEVICE_NOT_RESPONDING_ERROR = 5,
mbed_official 0:a554658735bf 33 USB_TYPE_PID_CHECK_FAILURE_ERROR = 6,
mbed_official 0:a554658735bf 34 USB_TYPE_UNEXPECTED_PID_ERROR = 7,
mbed_official 0:a554658735bf 35 USB_TYPE_DATA_OVERRUN_ERROR = 8,
mbed_official 0:a554658735bf 36 USB_TYPE_DATA_UNDERRUN_ERROR = 9,
mbed_official 0:a554658735bf 37 USB_TYPE_RESERVED = 9,
mbed_official 0:a554658735bf 38 USB_TYPE_RESERVED_ = 10,
mbed_official 0:a554658735bf 39 USB_TYPE_BUFFER_OVERRUN_ERROR = 12,
mbed_official 0:a554658735bf 40 USB_TYPE_BUFFER_UNDERRUN_ERROR = 13,
mbed_official 0:a554658735bf 41
mbed_official 0:a554658735bf 42 // general usb state
mbed_official 0:a554658735bf 43 USB_TYPE_DISCONNECTED = 14,
mbed_official 0:a554658735bf 44 USB_TYPE_FREE = 15,
mbed_official 0:a554658735bf 45 USB_TYPE_IDLE = 16,
mbed_official 0:a554658735bf 46 USB_TYPE_PROCESSING = 17,
mbed_official 0:a554658735bf 47
mbed_official 0:a554658735bf 48 USB_TYPE_ERROR = 18,
mbed_official 0:a554658735bf 49 };
mbed_official 0:a554658735bf 50
mbed_official 0:a554658735bf 51
mbed_official 0:a554658735bf 52 enum ENDPOINT_DIRECTION {
mbed_official 0:a554658735bf 53 OUT = 1,
mbed_official 0:a554658735bf 54 IN
mbed_official 0:a554658735bf 55 };
mbed_official 0:a554658735bf 56
mbed_official 0:a554658735bf 57 enum ENDPOINT_TYPE {
mbed_official 0:a554658735bf 58 CONTROL_ENDPOINT = 0,
mbed_official 0:a554658735bf 59 ISOCHRONOUS_ENDPOINT,
mbed_official 0:a554658735bf 60 BULK_ENDPOINT,
mbed_official 0:a554658735bf 61 INTERRUPT_ENDPOINT
mbed_official 0:a554658735bf 62 };
mbed_official 0:a554658735bf 63
mbed_official 0:a554658735bf 64 #define AUDIO_CLASS 0x01
mbed_official 0:a554658735bf 65 #define CDC_CLASS 0x02
mbed_official 0:a554658735bf 66 #define HID_CLASS 0x03
mbed_official 0:a554658735bf 67 #define MSD_CLASS 0x08
mbed_official 0:a554658735bf 68 #define HUB_CLASS 0x09
mbed_official 0:a554658735bf 69 #define SERIAL_CLASS 0x0A
mbed_official 0:a554658735bf 70
mbed_official 0:a554658735bf 71 // ------------------ HcControl Register ---------------------
mbed_official 0:a554658735bf 72 #define OR_CONTROL_PLE 0x00000004
mbed_official 0:a554658735bf 73 #define OR_CONTROL_CLE 0x00000010
mbed_official 0:a554658735bf 74 #define OR_CONTROL_BLE 0x00000020
mbed_official 0:a554658735bf 75 #define OR_CONTROL_HCFS 0x000000C0
mbed_official 0:a554658735bf 76 #define OR_CONTROL_HC_OPER 0x00000080
mbed_official 0:a554658735bf 77 // ----------------- HcCommandStatus Register -----------------
mbed_official 0:a554658735bf 78 #define OR_CMD_STATUS_HCR 0x00000001
mbed_official 0:a554658735bf 79 #define OR_CMD_STATUS_CLF 0x00000002
mbed_official 0:a554658735bf 80 #define OR_CMD_STATUS_BLF 0x00000004
mbed_official 0:a554658735bf 81 // --------------- HcInterruptStatus Register -----------------
mbed_official 0:a554658735bf 82 #define OR_INTR_STATUS_WDH 0x00000002
mbed_official 0:a554658735bf 83 #define OR_INTR_STATUS_RHSC 0x00000040
mbed_official 0:a554658735bf 84 #define OR_INTR_STATUS_UE 0x00000010
mbed_official 0:a554658735bf 85 // --------------- HcInterruptEnable Register -----------------
mbed_official 0:a554658735bf 86 #define OR_INTR_ENABLE_WDH 0x00000002
mbed_official 0:a554658735bf 87 #define OR_INTR_ENABLE_RHSC 0x00000040
mbed_official 0:a554658735bf 88 #define OR_INTR_ENABLE_MIE 0x80000000
mbed_official 0:a554658735bf 89 // ---------------- HcRhDescriptorA Register ------------------
mbed_official 0:a554658735bf 90 #define OR_RH_STATUS_LPSC 0x00010000
mbed_official 0:a554658735bf 91 #define OR_RH_STATUS_DRWE 0x00008000
mbed_official 0:a554658735bf 92 // -------------- HcRhPortStatus[1:NDP] Register --------------
mbed_official 0:a554658735bf 93 #define OR_RH_PORT_CCS 0x00000001
mbed_official 0:a554658735bf 94 #define OR_RH_PORT_PRS 0x00000010
mbed_official 0:a554658735bf 95 #define OR_RH_PORT_CSC 0x00010000
mbed_official 0:a554658735bf 96 #define OR_RH_PORT_PRSC 0x00100000
mbed_official 0:a554658735bf 97 #define OR_RH_PORT_LSDA 0x00000200
mbed_official 0:a554658735bf 98
mbed_official 0:a554658735bf 99 #define FI 0x2EDF // 12000 bits per frame (-1)
mbed_official 0:a554658735bf 100 #define DEFAULT_FMINTERVAL ((((6 * (FI - 210)) / 7) << 16) | FI)
mbed_official 0:a554658735bf 101
mbed_official 0:a554658735bf 102 #define ED_SKIP (uint32_t) (0x00001000) // Skip this ep in queue
mbed_official 0:a554658735bf 103
mbed_official 0:a554658735bf 104 #define TD_ROUNDING (uint32_t) (0x00040000) // Buffer Rounding
mbed_official 0:a554658735bf 105 #define TD_SETUP (uint32_t)(0) // Direction of Setup Packet
mbed_official 0:a554658735bf 106 #define TD_IN (uint32_t)(0x00100000) // Direction In
mbed_official 0:a554658735bf 107 #define TD_OUT (uint32_t)(0x00080000) // Direction Out
mbed_official 0:a554658735bf 108 #define TD_DELAY_INT(x) (uint32_t)((x) << 21) // Delay Interrupt
mbed_official 0:a554658735bf 109 #define TD_TOGGLE_0 (uint32_t)(0x02000000) // Toggle 0
mbed_official 0:a554658735bf 110 #define TD_TOGGLE_1 (uint32_t)(0x03000000) // Toggle 1
mbed_official 0:a554658735bf 111 #define TD_CC (uint32_t)(0xF0000000) // Completion Code
mbed_official 0:a554658735bf 112
mbed_official 0:a554658735bf 113 #define DEVICE_DESCRIPTOR (1)
mbed_official 0:a554658735bf 114 #define CONFIGURATION_DESCRIPTOR (2)
mbed_official 0:a554658735bf 115 #define INTERFACE_DESCRIPTOR (4)
mbed_official 0:a554658735bf 116 #define ENDPOINT_DESCRIPTOR (5)
mbed_official 0:a554658735bf 117 #define HID_DESCRIPTOR (33)
mbed_official 0:a554658735bf 118
mbed_official 0:a554658735bf 119 // ----------- Control RequestType Fields -----------
mbed_official 0:a554658735bf 120 #define USB_DEVICE_TO_HOST 0x80
mbed_official 0:a554658735bf 121 #define USB_HOST_TO_DEVICE 0x00
mbed_official 0:a554658735bf 122 #define USB_REQUEST_TYPE_CLASS 0x20
mbed_official 0:a554658735bf 123 #define USB_REQUEST_TYPE_STANDARD 0x00
mbed_official 0:a554658735bf 124 #define USB_RECIPIENT_DEVICE 0x00
mbed_official 0:a554658735bf 125 #define USB_RECIPIENT_INTERFACE 0x01
mbed_official 0:a554658735bf 126 #define USB_RECIPIENT_ENDPOINT 0x02
mbed_official 0:a554658735bf 127
mbed_official 0:a554658735bf 128 // -------------- USB Standard Requests --------------
mbed_official 0:a554658735bf 129 #define SET_ADDRESS 0x05
mbed_official 0:a554658735bf 130 #define GET_DESCRIPTOR 0x06
mbed_official 0:a554658735bf 131 #define SET_CONFIGURATION 0x09
mbed_official 0:a554658735bf 132 #define SET_INTERFACE 0x0b
mbed_official 0:a554658735bf 133 #define CLEAR_FEATURE 0x01
mbed_official 0:a554658735bf 134
mbed_official 0:a554658735bf 135 // -------------- USB Descriptor Length --------------
mbed_official 0:a554658735bf 136 #define DEVICE_DESCRIPTOR_LENGTH 0x12
mbed_official 0:a554658735bf 137 #define CONFIGURATION_DESCRIPTOR_LENGTH 0x09
mbed_official 0:a554658735bf 138
mbed_official 0:a554658735bf 139 // ------------ HostController Transfer Descriptor ------------
mbed_official 0:a554658735bf 140 typedef __packed struct hcTd {
mbed_official 0:a554658735bf 141 __IO uint32_t control; // Transfer descriptor control
mbed_official 0:a554658735bf 142 __IO uint8_t * currBufPtr; // Physical address of current buffer pointer
mbed_official 0:a554658735bf 143 __IO uint32_t nextTD; // Physical pointer to next Transfer Descriptor
mbed_official 0:a554658735bf 144 __IO uint8_t * bufEnd; // Physical address of end of buffer
mbed_official 0:a554658735bf 145 void * ep; // ep address where a td is linked in
mbed_official 0:a554658735bf 146 uint32_t dummy[3]; // padding
mbed_official 0:a554658735bf 147 } HCTD;
mbed_official 0:a554658735bf 148
mbed_official 0:a554658735bf 149 // ----------- HostController EndPoint Descriptor -------------
mbed_official 0:a554658735bf 150 typedef __packed struct hcEd {
mbed_official 0:a554658735bf 151 __IO uint32_t control; // Endpoint descriptor control
mbed_official 0:a554658735bf 152 __IO HCTD * tailTD; // Physical address of tail in Transfer descriptor list
mbed_official 0:a554658735bf 153 __IO HCTD * headTD; // Physcial address of head in Transfer descriptor list
mbed_official 0:a554658735bf 154 __IO uint32_t nextED; // Physical address of next Endpoint descriptor
mbed_official 0:a554658735bf 155 } HCED;
mbed_official 0:a554658735bf 156
mbed_official 0:a554658735bf 157
mbed_official 0:a554658735bf 158 // ----------- Host Controller Communication Area ------------
mbed_official 0:a554658735bf 159 typedef __packed struct hcca {
mbed_official 0:a554658735bf 160 __IO uint32_t IntTable[32]; // Interrupt Table
mbed_official 0:a554658735bf 161 __IO uint32_t FrameNumber; // Frame Number
mbed_official 0:a554658735bf 162 __IO uint32_t DoneHead; // Done Head
mbed_official 0:a554658735bf 163 volatile uint8_t Reserved[116]; // Reserved for future use
mbed_official 0:a554658735bf 164 volatile uint8_t Unknown[4]; // Unused
mbed_official 0:a554658735bf 165 } HCCA;
mbed_official 0:a554658735bf 166
mbed_official 0:a554658735bf 167 typedef __packed struct {
mbed_official 0:a554658735bf 168 uint8_t bLength;
mbed_official 0:a554658735bf 169 uint8_t bDescriptorType;
mbed_official 0:a554658735bf 170 uint16_t bcdUSB;
mbed_official 0:a554658735bf 171 uint8_t bDeviceClass;
mbed_official 0:a554658735bf 172 uint8_t bDeviceSubClass;
mbed_official 0:a554658735bf 173 uint8_t bDeviceProtocol;
mbed_official 0:a554658735bf 174 uint8_t bMaxPacketSize;
mbed_official 0:a554658735bf 175 uint16_t idVendor;
mbed_official 0:a554658735bf 176 uint16_t idProduct;
mbed_official 0:a554658735bf 177 uint16_t bcdDevice;
mbed_official 0:a554658735bf 178 uint8_t iManufacturer;
mbed_official 0:a554658735bf 179 uint8_t iProduct;
mbed_official 0:a554658735bf 180 uint8_t iSerialNumber;
mbed_official 0:a554658735bf 181 uint8_t bNumConfigurations;
mbed_official 0:a554658735bf 182 } DeviceDescriptor;
mbed_official 0:a554658735bf 183
mbed_official 0:a554658735bf 184 typedef __packed struct {
mbed_official 0:a554658735bf 185 uint8_t bLength;
mbed_official 0:a554658735bf 186 uint8_t bDescriptorType;
mbed_official 0:a554658735bf 187 uint16_t wTotalLength;
mbed_official 0:a554658735bf 188 uint8_t bNumInterfaces;
mbed_official 0:a554658735bf 189 uint8_t bConfigurationValue;
mbed_official 0:a554658735bf 190 uint8_t iConfiguration;
mbed_official 0:a554658735bf 191 uint8_t bmAttributes;
mbed_official 0:a554658735bf 192 uint8_t bMaxPower;
mbed_official 0:a554658735bf 193 } ConfigurationDescriptor;
mbed_official 0:a554658735bf 194
mbed_official 0:a554658735bf 195 typedef struct {
mbed_official 0:a554658735bf 196 uint8_t bLength;
mbed_official 0:a554658735bf 197 uint8_t bDescriptorType;
mbed_official 0:a554658735bf 198 uint8_t bInterfaceNumber;
mbed_official 0:a554658735bf 199 uint8_t bAlternateSetting;
mbed_official 0:a554658735bf 200 uint8_t bNumEndpoints;
mbed_official 0:a554658735bf 201 uint8_t bInterfaceClass;
mbed_official 0:a554658735bf 202 uint8_t bInterfaceSubClass;
mbed_official 0:a554658735bf 203 uint8_t bInterfaceProtocol;
mbed_official 0:a554658735bf 204 uint8_t iInterface;
mbed_official 0:a554658735bf 205 } InterfaceDescriptor;
mbed_official 0:a554658735bf 206
mbed_official 0:a554658735bf 207 typedef struct {
mbed_official 0:a554658735bf 208 uint8_t bLength;
mbed_official 0:a554658735bf 209 uint8_t bDescriptorType;
mbed_official 0:a554658735bf 210 uint8_t bEndpointAddress;
mbed_official 0:a554658735bf 211 uint8_t bmAttributes;
mbed_official 0:a554658735bf 212 uint16_t wMaxPacketSize;
mbed_official 0:a554658735bf 213 uint8_t bInterval;
mbed_official 0:a554658735bf 214 } EndpointDescriptor;
mbed_official 0:a554658735bf 215
mbed_official 0:a554658735bf 216 typedef struct {
mbed_official 0:a554658735bf 217 uint8_t bDescLength;
mbed_official 0:a554658735bf 218 uint8_t bDescriptorType;
mbed_official 0:a554658735bf 219 uint8_t bNbrPorts;
mbed_official 0:a554658735bf 220 uint16_t wHubCharacteristics;
mbed_official 0:a554658735bf 221 uint8_t bPwrOn2PwrGood;
mbed_official 0:a554658735bf 222 uint8_t bHubContrCurrent;
mbed_official 0:a554658735bf 223 uint8_t DeviceRemovable;
mbed_official 0:a554658735bf 224 uint8_t PortPweCtrlMak;
mbed_official 0:a554658735bf 225 } HubDescriptor;
mbed_official 0:a554658735bf 226
mbed_official 0:a554658735bf 227 #endif
mbed_official 0:a554658735bf 228