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