Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of MSCFileSystem_Lib by
usbhost_lpc17xx.h
00001 /* 00002 ************************************************************************************************************** 00003 * NXP USB Host Stack 00004 * 00005 * (c) Copyright 2008, NXP SemiConductors 00006 * (c) Copyright 2008, OnChip Technologies LLC 00007 * All Rights Reserved 00008 * 00009 * www.nxp.com 00010 * www.onchiptech.com 00011 * 00012 * File : usbhost_lpc17xx.h 00013 * Programmer(s) : Ravikanth.P 00014 * Version : 00015 * 00016 ************************************************************************************************************** 00017 */ 00018 00019 #ifndef USBHOST_LPC17xx_H 00020 #define USBHOST_LPC17xx_H 00021 00022 /* 00023 ************************************************************************************************************** 00024 * INCLUDE HEADER FILES 00025 ************************************************************************************************************** 00026 */ 00027 00028 #include "usbhost_inc.h" 00029 00030 /* 00031 ************************************************************************************************************** 00032 * PRINT CONFIGURATION 00033 ************************************************************************************************************** 00034 */ 00035 00036 #define PRINT_ENABLE 1 00037 00038 #if PRINT_ENABLE 00039 #define PRINT_Log(...) printf(__VA_ARGS__) 00040 #define PRINT_Err(rc) printf("ERROR: In %s at Line %u - rc = %d\n", __FUNCTION__, __LINE__, rc) 00041 00042 #else 00043 #define PRINT_Log(...) do {} while(0) 00044 #define PRINT_Err(rc) do {} while(0) 00045 00046 #endif 00047 00048 /* 00049 ************************************************************************************************************** 00050 * GENERAL DEFINITIONS 00051 ************************************************************************************************************** 00052 */ 00053 00054 #define DESC_LENGTH(x) x[0] 00055 #define DESC_TYPE(x) x[1] 00056 00057 00058 #define HOST_GET_DESCRIPTOR(descType, descIndex, data, length) \ 00059 Host_CtrlRecv(USB_DEVICE_TO_HOST | USB_RECIPIENT_DEVICE, GET_DESCRIPTOR, \ 00060 (descType << 8)|(descIndex), 0, length, data) 00061 00062 #define HOST_SET_ADDRESS(new_addr) \ 00063 Host_CtrlSend(USB_HOST_TO_DEVICE | USB_RECIPIENT_DEVICE, SET_ADDRESS, \ 00064 new_addr, 0, 0, NULL) 00065 00066 #define USBH_SET_CONFIGURATION(configNum) \ 00067 Host_CtrlSend(USB_HOST_TO_DEVICE | USB_RECIPIENT_DEVICE, SET_CONFIGURATION, \ 00068 configNum, 0, 0, NULL) 00069 00070 #define USBH_SET_INTERFACE(ifNum, altNum) \ 00071 Host_CtrlSend(USB_HOST_TO_DEVICE | USB_RECIPIENT_INTERFACE, SET_INTERFACE, \ 00072 altNum, ifNum, 0, NULL) 00073 00074 /* 00075 ************************************************************************************************************** 00076 * OHCI OPERATIONAL REGISTER FIELD DEFINITIONS 00077 ************************************************************************************************************** 00078 */ 00079 00080 /* ------------------ HcControl Register --------------------- */ 00081 #define OR_CONTROL_CLE 0x00000010 00082 #define OR_CONTROL_BLE 0x00000020 00083 #define OR_CONTROL_HCFS 0x000000C0 00084 #define OR_CONTROL_HC_OPER 0x00000080 00085 /* ----------------- HcCommandStatus Register ----------------- */ 00086 #define OR_CMD_STATUS_HCR 0x00000001 00087 #define OR_CMD_STATUS_CLF 0x00000002 00088 #define OR_CMD_STATUS_BLF 0x00000004 00089 /* --------------- HcInterruptStatus Register ----------------- */ 00090 #define OR_INTR_STATUS_WDH 0x00000002 00091 #define OR_INTR_STATUS_RHSC 0x00000040 00092 /* --------------- HcInterruptEnable Register ----------------- */ 00093 #define OR_INTR_ENABLE_WDH 0x00000002 00094 #define OR_INTR_ENABLE_RHSC 0x00000040 00095 #define OR_INTR_ENABLE_MIE 0x80000000 00096 /* ---------------- HcRhDescriptorA Register ------------------ */ 00097 #define OR_RH_STATUS_LPSC 0x00010000 00098 #define OR_RH_STATUS_DRWE 0x00008000 00099 /* -------------- HcRhPortStatus[1:NDP] Register -------------- */ 00100 #define OR_RH_PORT_CCS 0x00000001 00101 #define OR_RH_PORT_PRS 0x00000010 00102 #define OR_RH_PORT_CSC 0x00010000 00103 #define OR_RH_PORT_PRSC 0x00100000 00104 00105 00106 /* 00107 ************************************************************************************************************** 00108 * FRAME INTERVAL 00109 ************************************************************************************************************** 00110 */ 00111 00112 #define FI 0x2EDF /* 12000 bits per frame (-1) */ 00113 #define DEFAULT_FMINTERVAL ((((6 * (FI - 210)) / 7) << 16) | FI) 00114 00115 /* 00116 ************************************************************************************************************** 00117 * TRANSFER DESCRIPTOR CONTROL FIELDS 00118 ************************************************************************************************************** 00119 */ 00120 00121 #define TD_ROUNDING (USB_INT32U) (0x00040000) /* Buffer Rounding */ 00122 #define TD_SETUP (USB_INT32U)(0) /* Direction of Setup Packet */ 00123 #define TD_IN (USB_INT32U)(0x00100000) /* Direction In */ 00124 #define TD_OUT (USB_INT32U)(0x00080000) /* Direction Out */ 00125 #define TD_DELAY_INT(x) (USB_INT32U)((x) << 21) /* Delay Interrupt */ 00126 #define TD_TOGGLE_0 (USB_INT32U)(0x02000000) /* Toggle 0 */ 00127 #define TD_TOGGLE_1 (USB_INT32U)(0x03000000) /* Toggle 1 */ 00128 #define TD_CC (USB_INT32U)(0xF0000000) /* Completion Code */ 00129 00130 /* 00131 ************************************************************************************************************** 00132 * USB STANDARD REQUEST DEFINITIONS 00133 ************************************************************************************************************** 00134 */ 00135 00136 #define USB_DESCRIPTOR_TYPE_DEVICE 1 00137 #define USB_DESCRIPTOR_TYPE_CONFIGURATION 2 00138 #define USB_DESCRIPTOR_TYPE_INTERFACE 4 00139 #define USB_DESCRIPTOR_TYPE_ENDPOINT 5 00140 /* ----------- Control RequestType Fields ----------- */ 00141 #define USB_DEVICE_TO_HOST 0x80 00142 #define USB_HOST_TO_DEVICE 0x00 00143 #define USB_REQUEST_TYPE_CLASS 0x20 00144 #define USB_RECIPIENT_DEVICE 0x00 00145 #define USB_RECIPIENT_INTERFACE 0x01 00146 /* -------------- USB Standard Requests -------------- */ 00147 #define SET_ADDRESS 5 00148 #define GET_DESCRIPTOR 6 00149 #define SET_CONFIGURATION 9 00150 #define SET_INTERFACE 11 00151 00152 /* 00153 ************************************************************************************************************** 00154 * TYPE DEFINITIONS 00155 ************************************************************************************************************** 00156 */ 00157 00158 typedef struct hcEd { /* ----------- HostController EndPoint Descriptor ------------- */ 00159 volatile USB_INT32U Control; /* Endpoint descriptor control */ 00160 volatile USB_INT32U TailTd; /* Physical address of tail in Transfer descriptor list */ 00161 volatile USB_INT32U HeadTd; /* Physcial address of head in Transfer descriptor list */ 00162 volatile USB_INT32U Next; /* Physical address of next Endpoint descriptor */ 00163 } HCED; 00164 00165 typedef struct hcTd { /* ------------ HostController Transfer Descriptor ------------ */ 00166 volatile USB_INT32U Control; /* Transfer descriptor control */ 00167 volatile USB_INT32U CurrBufPtr; /* Physical address of current buffer pointer */ 00168 volatile USB_INT32U Next; /* Physical pointer to next Transfer Descriptor */ 00169 volatile USB_INT32U BufEnd; /* Physical address of end of buffer */ 00170 } HCTD; 00171 00172 typedef struct hcca { /* ----------- Host Controller Communication Area ------------ */ 00173 volatile USB_INT32U IntTable[32]; /* Interrupt Table */ 00174 volatile USB_INT32U FrameNumber; /* Frame Number */ 00175 volatile USB_INT32U DoneHead; /* Done Head */ 00176 volatile USB_INT08U Reserved[116]; /* Reserved for future use */ 00177 volatile USB_INT08U Unknown[4]; /* Unused */ 00178 } HCCA; 00179 00180 /* 00181 ************************************************************************************************************** 00182 * EXTERN DECLARATIONS 00183 ************************************************************************************************************** 00184 */ 00185 00186 extern volatile HCED *EDBulkIn; /* BulkIn endpoint descriptor structure */ 00187 extern volatile HCED *EDBulkOut; /* BulkOut endpoint descriptor structure */ 00188 extern volatile HCTD *TDHead; /* Head transfer descriptor structure */ 00189 extern volatile HCTD *TDTail; /* Tail transfer descriptor structure */ 00190 extern volatile USB_INT08U *TDBuffer; /* Current Buffer Pointer of transfer descriptor */ 00191 00192 /* 00193 ************************************************************************************************************** 00194 * FUNCTION PROTOTYPES 00195 ************************************************************************************************************** 00196 */ 00197 00198 void Host_Init (void); 00199 00200 extern "C" void USB_IRQHandler(void) __irq; 00201 00202 USB_INT32S Host_EnumDev (void); 00203 00204 USB_INT32S Host_ProcessTD(volatile HCED *ed, 00205 volatile USB_INT32U token, 00206 volatile USB_INT08U *buffer, 00207 USB_INT32U buffer_len); 00208 00209 void Host_DelayUS ( USB_INT32U delay); 00210 void Host_DelayMS ( USB_INT32U delay); 00211 00212 00213 void Host_TDInit (volatile HCTD *td); 00214 void Host_EDInit (volatile HCED *ed); 00215 void Host_HCCAInit (volatile HCCA *hcca); 00216 00217 USB_INT32S Host_CtrlRecv ( USB_INT08U bm_request_type, 00218 USB_INT08U b_request, 00219 USB_INT16U w_value, 00220 USB_INT16U w_index, 00221 USB_INT16U w_length, 00222 volatile USB_INT08U *buffer); 00223 00224 USB_INT32S Host_CtrlSend ( USB_INT08U bm_request_type, 00225 USB_INT08U b_request, 00226 USB_INT16U w_value, 00227 USB_INT16U w_index, 00228 USB_INT16U w_length, 00229 volatile USB_INT08U *buffer); 00230 00231 void Host_FillSetup( USB_INT08U bm_request_type, 00232 USB_INT08U b_request, 00233 USB_INT16U w_value, 00234 USB_INT16U w_index, 00235 USB_INT16U w_length); 00236 00237 00238 void Host_WDHWait (void); 00239 00240 00241 USB_INT32U ReadLE32U (volatile USB_INT08U *pmem); 00242 void WriteLE32U (volatile USB_INT08U *pmem, 00243 USB_INT32U val); 00244 USB_INT16U ReadLE16U (volatile USB_INT08U *pmem); 00245 void WriteLE16U (volatile USB_INT08U *pmem, 00246 USB_INT16U val); 00247 USB_INT32U ReadBE32U (volatile USB_INT08U *pmem); 00248 void WriteBE32U (volatile USB_INT08U *pmem, 00249 USB_INT32U val); 00250 USB_INT16U ReadBE16U (volatile USB_INT08U *pmem); 00251 void WriteBE16U (volatile USB_INT08U *pmem, 00252 USB_INT16U val); 00253 00254 #endif
Generated on Sat Jul 16 2022 17:42:28 by
1.7.2
