Fixing issues with library dependencies

Dependencies:   FATFileSystem mbed-rtos

Fork of USBHost by mbed official

Committer:
samux
Date:
Thu Mar 14 11:49:53 2013 +0000
Revision:
8:93da8ea2708b
Parent:
4:b320d68e98e7
Child:
13:b58a2204422f
update doc + license

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