A web server for monitoring and controlling a MakerBot Replicator over the USB host and ethernet.
Dependencies: IAP NTPClient RTC mbed-rtos mbed Socket lwip-sys lwip BurstSPI
Fork of LPC1768_Mini-DK by
USBHostTypes.h
00001 /* mbed USBHost Library 00002 * Copyright (c) 2006-2013 ARM Limited 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00017 #ifndef USB_INC_H 00018 #define USB_INC_H 00019 00020 #include "mbed.h" 00021 00022 enum USB_TYPE { 00023 USB_TYPE_OK = 0, 00024 00025 // completion code 00026 USB_TYPE_CRC_ERROR = 1, 00027 USB_TYPE_BIT_STUFFING_ERROR = 2, 00028 USB_TYPE_DATA_TOGGLE_MISMATCH_ERROR = 3, 00029 USB_TYPE_STALL_ERROR = 4, 00030 USB_TYPE_DEVICE_NOT_RESPONDING_ERROR = 5, 00031 USB_TYPE_PID_CHECK_FAILURE_ERROR = 6, 00032 USB_TYPE_UNEXPECTED_PID_ERROR = 7, 00033 USB_TYPE_DATA_OVERRUN_ERROR = 8, 00034 USB_TYPE_DATA_UNDERRUN_ERROR = 9, 00035 USB_TYPE_RESERVED = 9, 00036 USB_TYPE_RESERVED_ = 10, 00037 USB_TYPE_BUFFER_OVERRUN_ERROR = 12, 00038 USB_TYPE_BUFFER_UNDERRUN_ERROR = 13, 00039 00040 // general usb state 00041 USB_TYPE_DISCONNECTED = 14, 00042 USB_TYPE_FREE = 15, 00043 USB_TYPE_IDLE = 16, 00044 USB_TYPE_PROCESSING = 17, 00045 00046 USB_TYPE_ERROR = 18, 00047 }; 00048 00049 00050 enum ENDPOINT_DIRECTION { 00051 OUT = 1, 00052 IN 00053 }; 00054 00055 enum ENDPOINT_TYPE { 00056 CONTROL_ENDPOINT = 0, 00057 ISOCHRONOUS_ENDPOINT, 00058 BULK_ENDPOINT, 00059 INTERRUPT_ENDPOINT 00060 }; 00061 00062 #define AUDIO_CLASS 0x01 00063 #define CDC_CLASS 0x02 00064 #define HID_CLASS 0x03 00065 #define MSD_CLASS 0x08 00066 #define HUB_CLASS 0x09 00067 #define SERIAL_CLASS 0x0A 00068 00069 // ------------------ HcControl Register --------------------- 00070 #define OR_CONTROL_PLE 0x00000004 00071 #define OR_CONTROL_CLE 0x00000010 00072 #define OR_CONTROL_BLE 0x00000020 00073 #define OR_CONTROL_HCFS 0x000000C0 00074 #define OR_CONTROL_HC_OPER 0x00000080 00075 // ----------------- HcCommandStatus Register ----------------- 00076 #define OR_CMD_STATUS_HCR 0x00000001 00077 #define OR_CMD_STATUS_CLF 0x00000002 00078 #define OR_CMD_STATUS_BLF 0x00000004 00079 // --------------- HcInterruptStatus Register ----------------- 00080 #define OR_INTR_STATUS_WDH 0x00000002 00081 #define OR_INTR_STATUS_RHSC 0x00000040 00082 #define OR_INTR_STATUS_UE 0x00000010 00083 // --------------- HcInterruptEnable Register ----------------- 00084 #define OR_INTR_ENABLE_WDH 0x00000002 00085 #define OR_INTR_ENABLE_RHSC 0x00000040 00086 #define OR_INTR_ENABLE_MIE 0x80000000 00087 // ---------------- HcRhDescriptorA Register ------------------ 00088 #define OR_RH_STATUS_LPSC 0x00010000 00089 #define OR_RH_STATUS_DRWE 0x00008000 00090 // -------------- HcRhPortStatus[1:NDP] Register -------------- 00091 #define OR_RH_PORT_CCS 0x00000001 00092 #define OR_RH_PORT_PRS 0x00000010 00093 #define OR_RH_PORT_CSC 0x00010000 00094 #define OR_RH_PORT_PRSC 0x00100000 00095 #define OR_RH_PORT_LSDA 0x00000200 00096 00097 #define FI 0x2EDF // 12000 bits per frame (-1) 00098 #define DEFAULT_FMINTERVAL ((((6 * (FI - 210)) / 7) << 16) | FI) 00099 00100 #define ED_SKIP (uint32_t) (0x00001000) // Skip this ep in queue 00101 00102 #define TD_ROUNDING (uint32_t) (0x00040000) // Buffer Rounding 00103 #define TD_SETUP (uint32_t)(0) // Direction of Setup Packet 00104 #define TD_IN (uint32_t)(0x00100000) // Direction In 00105 #define TD_OUT (uint32_t)(0x00080000) // Direction Out 00106 #define TD_DELAY_INT(x) (uint32_t)((x) << 21) // Delay Interrupt 00107 #define TD_TOGGLE_0 (uint32_t)(0x02000000) // Toggle 0 00108 #define TD_TOGGLE_1 (uint32_t)(0x03000000) // Toggle 1 00109 #define TD_CC (uint32_t)(0xF0000000) // Completion Code 00110 00111 #define DEVICE_DESCRIPTOR (1) 00112 #define CONFIGURATION_DESCRIPTOR (2) 00113 #define INTERFACE_DESCRIPTOR (4) 00114 #define ENDPOINT_DESCRIPTOR (5) 00115 #define HID_DESCRIPTOR (33) 00116 00117 // ----------- Control RequestType Fields ----------- 00118 #define USB_DEVICE_TO_HOST 0x80 00119 #define USB_HOST_TO_DEVICE 0x00 00120 #define USB_REQUEST_TYPE_CLASS 0x20 00121 #define USB_REQUEST_TYPE_STANDARD 0x00 00122 #define USB_RECIPIENT_DEVICE 0x00 00123 #define USB_RECIPIENT_INTERFACE 0x01 00124 #define USB_RECIPIENT_ENDPOINT 0x02 00125 00126 // -------------- USB Standard Requests -------------- 00127 #define SET_ADDRESS 0x05 00128 #define GET_DESCRIPTOR 0x06 00129 #define SET_CONFIGURATION 0x09 00130 #define SET_INTERFACE 0x0b 00131 #define CLEAR_FEATURE 0x01 00132 00133 // -------------- USB Descriptor Length -------------- 00134 #define DEVICE_DESCRIPTOR_LENGTH 0x12 00135 #define CONFIGURATION_DESCRIPTOR_LENGTH 0x09 00136 00137 // ------------ HostController Transfer Descriptor ------------ 00138 typedef __packed struct HCTD { 00139 __IO uint32_t control; // Transfer descriptor control 00140 __IO uint8_t * currBufPtr; // Physical address of current buffer pointer 00141 __IO HCTD * nextTD; // Physical pointer to next Transfer Descriptor 00142 __IO uint8_t * bufEnd; // Physical address of end of buffer 00143 void * ep; // ep address where a td is linked in 00144 uint32_t dummy[3]; // padding 00145 } HCTD; 00146 00147 // ----------- HostController EndPoint Descriptor ------------- 00148 typedef __packed struct hcEd { 00149 __IO uint32_t control; // Endpoint descriptor control 00150 __IO HCTD * tailTD; // Physical address of tail in Transfer descriptor list 00151 __IO HCTD * headTD; // Physcial address of head in Transfer descriptor list 00152 __IO hcEd * nextED; // Physical address of next Endpoint descriptor 00153 } HCED; 00154 00155 00156 // ----------- Host Controller Communication Area ------------ 00157 typedef __packed struct hcca { 00158 __IO uint32_t IntTable[32]; // Interrupt Table 00159 __IO uint32_t FrameNumber; // Frame Number 00160 __IO uint32_t DoneHead; // Done Head 00161 volatile uint8_t Reserved[116]; // Reserved for future use 00162 volatile uint8_t Unknown[4]; // Unused 00163 } HCCA; 00164 00165 typedef __packed struct { 00166 uint8_t bLength; 00167 uint8_t bDescriptorType; 00168 uint16_t bcdUSB; 00169 uint8_t bDeviceClass; 00170 uint8_t bDeviceSubClass; 00171 uint8_t bDeviceProtocol; 00172 uint8_t bMaxPacketSize; 00173 uint16_t idVendor; 00174 uint16_t idProduct; 00175 uint16_t bcdDevice; 00176 uint8_t iManufacturer; 00177 uint8_t iProduct; 00178 uint8_t iSerialNumber; 00179 uint8_t bNumConfigurations; 00180 } DeviceDescriptor; 00181 00182 typedef __packed struct { 00183 uint8_t bLength; 00184 uint8_t bDescriptorType; 00185 uint16_t wTotalLength; 00186 uint8_t bNumInterfaces; 00187 uint8_t bConfigurationValue; 00188 uint8_t iConfiguration; 00189 uint8_t bmAttributes; 00190 uint8_t bMaxPower; 00191 } ConfigurationDescriptor; 00192 00193 typedef struct { 00194 uint8_t bLength; 00195 uint8_t bDescriptorType; 00196 uint8_t bInterfaceNumber; 00197 uint8_t bAlternateSetting; 00198 uint8_t bNumEndpoints; 00199 uint8_t bInterfaceClass; 00200 uint8_t bInterfaceSubClass; 00201 uint8_t bInterfaceProtocol; 00202 uint8_t iInterface; 00203 } InterfaceDescriptor; 00204 00205 typedef struct { 00206 uint8_t bLength; 00207 uint8_t bDescriptorType; 00208 uint8_t bEndpointAddress; 00209 uint8_t bmAttributes; 00210 uint16_t wMaxPacketSize; 00211 uint8_t bInterval; 00212 } EndpointDescriptor; 00213 00214 typedef struct { 00215 uint8_t bDescLength; 00216 uint8_t bDescriptorType; 00217 uint8_t bNbrPorts; 00218 uint16_t wHubCharacteristics; 00219 uint8_t bPwrOn2PwrGood; 00220 uint8_t bHubContrCurrent; 00221 uint8_t DeviceRemovable; 00222 uint8_t PortPweCtrlMak; 00223 } HubDescriptor; 00224 00225 #endif
Generated on Tue Jul 12 2022 17:52:03 by 1.7.2