00001
00042 #ifndef usbprivatetypes_H
00043 #define usbprivatetypes_H
00044
00045 #include "usbbasictypes.h"
00046 #include "usbconstants.h"
00047 #include "usbprivateconstants.h"
00048 #include "usbdeviceparam.h"
00049
00050 typedef struct
00051 {
00052 UINT32 frames;
00053
00054 UINT32 irqCount;
00055
00056 UINT32 Rx;
00057 UINT32 Tx;
00058 UINT32 DRx;
00059 UINT32 DTx;
00060
00061 UINT32 bytesRx;
00062 UINT32 bytesTx;
00063
00064 UINT32 setup;
00065 } USBDeviceCounters;
00066
00067 typedef struct
00068 {
00069 UINT32 Rx;
00070 UINT32 Tx;
00071 UINT32 DRx;
00072 UINT32 DTx;
00073
00074 UINT32 fifoUnderruns;
00075 UINT32 fifoOverflows;
00076
00077 UINT32 bytesRx;
00078 UINT32 bytesTx;
00079
00080 UINT32 irqCount;
00081 } USBEndpointCounters;
00082
00083 typedef struct
00084 {
00085 IX_USB_MBLK *base[MAX_QUEUE_SIZE];
00086 UINT32 head;
00087 UINT32 len;
00088 } USBDataQueue;
00089
00090 typedef struct
00091 {
00092 USBDevice *device;
00093
00094 USBEndpointNumber endpointNumber;
00095
00096 USBEndpointDirection direction;
00097
00098 USBEndpointType type;
00099
00100 UINT32 fifoSize;
00101
00102 #ifdef IX_USB_DMA
00103
00104 BOOL dmaEnabled;
00105
00106 UINT32 dmaSize;
00107
00108 #endif
00109
00110 IX_USB_MBLK *currentBuffer;
00111
00112 UINT32 currentOffset;
00113
00114 UINT32 currentTransferSize;
00115
00116 BOOL transferAllowed;
00117
00118 #ifdef IX_USB_HAS_TIMESTAMP_CHECKS
00119
00120 UINT32 lastTimestamp;
00121
00122 #endif
00123
00124 USBDataQueue queue;
00125
00126 USBEndpointCounters counters;
00127
00128 volatile UINT32 *UDCCS;
00129 volatile UINT32 *UDDR;
00130 volatile UINT32 *UBCR;
00131 } EPStatusData;
00132
00133 typedef struct
00134 {
00135 USBToken currentToken;
00136
00137 EP0State state;
00138
00139 USBControlTransfer transferType;
00140
00141 char setupBuffer[SETUP_PACKET_SIZE];
00142
00143 UINT16 expected, transferred;
00144 } EP0ControlData;
00145
00146 typedef struct
00147 {
00148 USBEventCallback eventCallback;
00149
00150 USBEventMap eventMap;
00151
00152 USBSetupCallback setupCallback;
00153
00154 USBReceiveCallback receiveCallback;
00155 } USBEventProcessor;
00156
00157
00158 typedef struct
00159 {
00160 volatile UINT32 UDCCR;
00161 volatile UINT32 RESERVED[3];
00162 volatile UINT32 UDCCS0;
00163 volatile UINT32 UDCCS1;
00164 volatile UINT32 UDCCS2;
00165 volatile UINT32 UDCCS3;
00166 volatile UINT32 UDCCS4;
00167 volatile UINT32 UDCCS5;
00168 volatile UINT32 UDCCS6;
00169 volatile UINT32 UDCCS7;
00170 volatile UINT32 UDCCS8;
00171 volatile UINT32 UDCCS9;
00172 volatile UINT32 UDCCS10;
00173 volatile UINT32 UDCCS11;
00174 volatile UINT32 UDCCS12;
00175 volatile UINT32 UDCCS13;
00176 volatile UINT32 UDCCS14;
00177 volatile UINT32 UDCCS15;
00178 volatile UINT32 UICR0;
00179 volatile UINT32 UICR1;
00180 volatile UINT32 USIR0;
00181 volatile UINT32 USIR1;
00182 volatile UINT32 UFNHR;
00183 volatile UINT32 UFNLR;
00184 volatile UINT32 UBCR2;
00185 volatile UINT32 UBCR4;
00186 volatile UINT32 UBCR7;
00187 volatile UINT32 UBCR9;
00188 volatile UINT32 UBCR12;
00189 volatile UINT32 UBCR14;
00190 volatile UINT32 UDDR0;
00191 volatile UINT32 RESERVED0[7];
00192 volatile UINT32 UDDR5;
00193 volatile UINT32 RESERVED5[7];
00194 volatile UINT32 UDDR10;
00195 volatile UINT32 RESERVED10[7];
00196 volatile UINT32 UDDR15;
00197 volatile UINT32 RESERVED15[7];
00198 volatile UINT32 UDDR1;
00199 volatile UINT32 RESERVED1[31];
00200 volatile UINT32 UDDR2;
00201 volatile UINT32 RESERVED2[31];
00202 volatile UINT32 UDDR3;
00203 volatile UINT32 RESERVED3[127];
00204 volatile UINT32 UDDR4;
00205 volatile UINT32 RESERVED4[127];
00206 volatile UINT32 UDDR6;
00207 volatile UINT32 RESERVED6[31];
00208 volatile UINT32 UDDR7;
00209 volatile UINT32 RESERVED7[31];
00210 volatile UINT32 UDDR8;
00211 volatile UINT32 RESERVED8[127];
00212 volatile UINT32 UDDR9;
00213 volatile UINT32 RESERVED9[127];
00214 volatile UINT32 UDDR11;
00215 volatile UINT32 RESERVED11[31];
00216 volatile UINT32 UDDR12;
00217 volatile UINT32 RESERVED12[31];
00218 volatile UINT32 UDDR13;
00219 volatile UINT32 RESERVED13[127];
00220 volatile UINT32 UDDR14;
00221 } UDCRegisters;
00222
00223 typedef struct
00224 {
00225 UINT32 checkPattern;
00226
00227 USBDevice *device;
00228
00229 UDCRegisters *registers;
00230
00231 EP0ControlData ep0ControlData;
00232
00233 EPStatusData epStatusData[NUM_ENDPOINTS];
00234
00235 USBEventProcessor eventProcessor;
00236
00237 USBDeviceCounters counters;
00238
00239 BOOL enabled;
00240 } USBDeviceContext;
00241
00242 #endif