- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

csl_usb.h
Go to the documentation of this file.

    00001 /*  ============================================================================
    00002  *   Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005, 2008
    00003  *
    00004  *   Use of this software is controlled by the terms and conditions found in the
    00005  *   license agreement under which this software has been supplied.
    00006  *  ============================================================================
    00007  */
    00008
    00016 /* ============================================================================
    00017  * Revision History
    00018  * ================
    00019  * 05-Sep-2008 Created
    00020  * 25-Dec-2008 Added Isochronous Transfer Support
    00021  * ============================================================================
    00022  */
    00023
    00044 #ifndef _CSL_USB_H_
    00045 #define _CSL_USB_H_
    00046
    00047 #ifdef __cplusplus
    00048 extern "C" {
    00049 #endif
    00050
    00051 #include <cslr.h>
    00052 #include <csl_error.h>
    00053 #include <csl_types.h>
    00054 #include <cslr_usb.h>
    00055 #include <soc.h>
    00056 #include <csl_general.h>
    00057
    00058
    00077 /*****************************************************************************\
    00078           USB MUSB global macro declarations                                  *
    00079 \*****************************************************************************/
    00087 #define CSL_USB_EP0                                 (0)
    00088
    00089 #define CSL_USB_EP1                                 (1)
    00090
    00091 #define CSL_USB_EP2                                 (2)
    00092
    00093 #define CSL_USB_EP3                                 (3)
    00094
    00095 #define CSL_USB_EP4                                 (4)
    00096
    00099 #define CSL_USB_IN_TRANSFER                         (0x80)
    00100
    00101 #define CSL_USB_OUT_TRANSFER                        (0x00)
    00102
    00103 #define CSL_USB_MAX_EP0_FIFO_LEN                    (0x0040)
    00104
    00105 #define CSL_USB_SETUP_PACKET_LEN                    (4)
    00106
    00108 #define CSL_USB_EP0_PACKET_SIZE                     (0x40)
    00109
    00110 #define CSL_USB_EP_PACKET_SIZE_FS                   (0x40)
    00111
    00112 #define CSL_USB_EP_PACKET_SIZE_HS                   (0x200)
    00113
    00114 #define CSL_USB_EP1_PACKET_SIZE_FS                  (0x40)
    00115
    00116 #define CSL_USB_EP1_PACKET_SIZE_HS                  (0x200)
    00117
    00118 #define CSL_USB_EP2_PACKET_SIZE_FS                  (0x40)
    00119
    00120 #define CSL_USB_EP2_PACKET_SIZE_HS                  (0x200)
    00121
    00122 #define CSL_USB_EP3_PACKET_SIZE_FS                  (0x40)
    00123
    00124 #define CSL_USB_EP3_PACKET_SIZE_HS                  (0x200)
    00125
    00126 #define CSL_USB_EP4_PACKET_SIZE_FS                  (0x40)
    00127
    00128 #define CSL_USB_EP4_PACKET_SIZE_HS                  (0x200)
    00129
    00132 #define CSL_USB_FIFO_SIZE                           (512)
    00133
    00134 #define CSL_USB_IN_EP_FIFO_START                    (8)
    00135
    00136 #define CSL_USB_OUT_EP_FIFO_START                   (8)
    00137
    00139 #define CSL_USB_TXRXFIFOSZ_TX_SHIFT                 (0)
    00140
    00141 #define CSL_USB_TXRXFIFOSZ_RX_SHIFT                 (8)
    00142
    00144 #define CSL_USB_TX_FIFO_SIZE_8                      (0)
    00145
    00146 #define CSL_USB_TX_FIFO_SIZE_16                     (1)
    00147
    00148 #define CSL_USB_TX_FIFO_SIZE_32                     (2)
    00149
    00150 #define CSL_USB_TX_FIFO_SIZE_64                     (3)
    00151
    00152 #define CSL_USB_TX_FIFO_SIZE_128                    (4)
    00153
    00154 #define CSL_USB_TX_FIFO_SIZE_256                    (5)
    00155
    00156 #define CSL_USB_TX_FIFO_SIZE_512                    (6)
    00157
    00158 #define CSL_USB_TX_FIFO_SIZE_1024                   (7)
    00159
    00160 #define CSL_USB_TX_FIFO_SIZE_2048                   (8)
    00161
    00162 #define CSL_USB_TX_FIFO_SIZE_4096                   (9)
    00163
    00165 #define CSL_USB_RX_FIFO_SIZE_8               (0 << CSL_USB_TXRXFIFOSZ_RX_SHIFT)
    00166
    00167 #define CSL_USB_RX_FIFO_SIZE_16              (1 << CSL_USB_TXRXFIFOSZ_RX_SHIFT)
    00168
    00169 #define CSL_USB_RX_FIFO_SIZE_32              (2 << CSL_USB_TXRXFIFOSZ_RX_SHIFT)
    00170
    00171 #define CSL_USB_RX_FIFO_SIZE_64              (3 << CSL_USB_TXRXFIFOSZ_RX_SHIFT)
    00172
    00173 #define CSL_USB_RX_FIFO_SIZE_128             (4 << CSL_USB_TXRXFIFOSZ_RX_SHIFT)
    00174
    00175 #define CSL_USB_RX_FIFO_SIZE_256             (5 << CSL_USB_TXRXFIFOSZ_RX_SHIFT)
    00176
    00177 #define CSL_USB_RX_FIFO_SIZE_512             (6 << CSL_USB_TXRXFIFOSZ_RX_SHIFT)
    00178
    00179 #define CSL_USB_RX_FIFO_SIZE_1024            (7 << CSL_USB_TXRXFIFOSZ_RX_SHIFT)
    00180
    00181 #define CSL_USB_RX_FIFO_SIZE_2048            (8 << CSL_USB_TXRXFIFOSZ_RX_SHIFT)
    00182
    00183 #define CSL_USB_RX_FIFO_SIZE_4096            (9 << CSL_USB_TXRXFIFOSZ_RX_SHIFT)
    00184
    00186 #define CSL_USB_ENDPOINT_COUNT                      (8)
    00187
    00188 #define CSL_USB_MAX_OUTEP0BUF_LEN                   (128)
    00189
    00190 #define CSL_USB_MAX_NUMBER_OF_UI_MSG                (2)
    00191
    00194 #define CSL_USB_IOFLAG_NONE                         (0x0000)
    00195
    00196 #define CSL_USB_IOFLAG_NOSHORT                      (0x0001)
    00197
    00198 #define CSL_USB_IOFLAG_SWAP                         (0x0002)
    00199
    00200 #define CSL_USB_IOFLAG_LNK                          (0x0004)
    00201
    00203 #define CSL_USB_IOFLAG_CAT                          (0x0008)
    00204
    00205 #define CSL_USB_IOFLAG_EOLL                         (0x0010)
    00206
    00207 #define CSL_USB_IOFLAG_NOT                          (0x0020)
    00208
    00211 #define CSL_USB_EVENT_NONE                          (0x0000)
    00212
    00213 #define CSL_USB_EVENT_RESET                         (0x0001)
    00214
    00215 #define CSL_USB_EVENT_SOF                           (0x0002)
    00216
    00217 #define CSL_USB_EVENT_SUSPEND                       (0x0004)
    00218
    00219 #define CSL_USB_EVENT_RESUME                        (0x0008)
    00220
    00221 #define CSL_USB_EVENT_SETUP                         (0x0010)
    00222
    00223 #define CSL_USB_EVENT_EOT                           (0x0020)
    00224
    00225 #define CSL_USB_EVENT_STPOW                         (0x0040)
    00226
    00227 #define CSL_USB_EVENT_PSOF                          (0x0080)
    00228
    00229 #define CSL_USB_EVENT_HINT                          (0x0100)
    00230
    00231 #define CSL_USB_EVENT_HERR                          (0x0200)
    00232
    00233 #define CSL_USB_EVENT_ISO_TX                        (0x0400)
    00234
    00235 #define CSL_USB_EVENT_ISO_RX                        (0x0800)
    00236
    00237 #define CSL_USB_EVENT_READ_MEDIA                    (0x1000)
    00238
    00239 #define CSL_USB_EVENT_WRITE_MEDIA                   (0x2000)
    00240
    00241 #define CSL_USB_EVENT_HID_REPORT_TX                 (0x4000)
    00242
    00245 #define CSL_USB_GET_STATUS                          (0x00)
    00246
    00247 #define CSL_USB_CLEAR_FEATURE                       (0x01)
    00248
    00249 #define CSL_USB_SET_FEATURE                         (0x03)
    00250
    00251 #define CSL_USB_SET_ADDRESS                         (0x05)
    00252
    00253 #define CSL_USB_GET_DESCRIPTOR                      (0x06)
    00254
    00255 #define CSL_USB_SET_DESCRIPTOR                      (0x07)
    00256
    00257 #define CSL_USB_GET_CONFIGURATION                   (0x08)
    00258
    00259 #define CSL_USB_SET_CONFIGURATION                   (0x09)
    00260
    00261 #define CSL_USB_GET_INTERFACE                       (0x0A)
    00262
    00263 #define CSL_USB_SET_INTERFACE                       (0x0B)
    00264
    00265 #define CSL_USB_SYNCH_FRAME                         (0x0C)
    00266
    00267 #define CSL_USB_GET_MAX_LUN                         (0xFE)
    00268
    00269 #define CSL_USB_BOT_MSC_RESET                       (0xFF)
    00270
    00272 #define CSL_USB_REQUEST_TYPE_DEVICE_STATUS          (0x80)
    00273 #define CSL_USB_REQUEST_TYPE_INTERFACE_STATUS       (0x81)
    00274 #define CSL_USB_REQUEST_TYPE_ENDPOINT_STATUS        (0x82)
    00275
    00278 #define CSL_USB_SET_CUR                             (0x01)
    00279
    00280 #define CSL_USB_GET_CUR                             (0x81)
    00281
    00282 #define CSL_USB_SET_MIN                             (0x02)
    00283
    00284 #define CSL_USB_GET_MIN                             (0x82)
    00285
    00286 #define CSL_USB_SET_MAX                             (0x03)
    00287
    00288 #define CSL_USB_GET_MAX                             (0x83)
    00289
    00290 #define CSL_USB_SET_RES                             (0x04)
    00291
    00292 #define CSL_USB_GET_RES                             (0x84)
    00293
    00294 #define CSL_USB_SET_MEM                             (0x05)
    00295
    00296 #define CSL_USB_GET_MEM                             (0x85)
    00297
    00298 #define CSL_USB_GET_STAT                            (0xFF)
    00299
    00303 #define CSL_USB_GET_REPORT                          (0x01)
    00304
    00305 #define CSL_USB_GET_IDLE                            (0x02)
    00306
    00308 #define CSL_USB_GET_PROTOCOL                        (0x03)
    00309
    00311 #define CSL_USB_SET_REPORT                          (0x09)
    00312
    00314 #define CSL_USB_SET_IDLE                            (0x0A)
    00315
    00317 #define CSL_USB_SET_PROTOCOL                        (0x0B)
    00318
    00321 #define CSL_USB_DEVICE_DESCRIPTOR_TYPE               (0x01)
    00322
    00323 #define CSL_USB_CONFIGURATION_DESCRIPTOR_TYPE        (0x02)
    00324
    00325 #define CSL_USB_STRING_DESCRIPTOR_TYPE               (0x03)
    00326
    00327 #define CSL_USB_INTERFACE_DESCRIPTOR_TYPE            (0x04)
    00328
    00329 #define CSL_USB_ENDPOINT_DESCRIPTOR_TYPE             (0x05)
    00330
    00331 #define CSL_USB_DEVICE_QUAL_DESCRIPTOR_TYPE          (0x06)
    00332
    00333 #define CSL_USB_OTHERSPEED_CFG_DESCRIPTOR_TYPE       (0x07)
    00334
    00335 #define CSL_USB_HID_DESCRIPTOR_TYPE                  (0x21)
    00336
    00337 #define CSL_USB_HID_REPORT_DESCRIPTOR_TYPE           (0x22)
    00338
    00339 #define CSL_USB_FEATURE_ENDPOINT_STALL               (0x0000)
    00340
    00341 #define CSL_USB_FEATURE_REMOTE_WAKEUP                (0x0001)
    00342
    00345 #define CSL_USB_GBL_INT_SUSPEND                     (1<<0)
    00346
    00347 #define CSL_USB_GBL_INT_RESUME                      (1<<1)
    00348
    00349 #define CSL_USB_GBL_INT_RESET                       (1<<2)
    00350
    00351 #define CSL_USB_GBL_INT_SOF                         (1<<3)
    00352
    00353 #define CSL_USB_GBL_INT_DEVCONN                     (1<<4)
    00354
    00355 #define CSL_USB_GBL_INT_DEVDISCONN                  (1<<5)
    00356
    00357 #define CSL_USB_GBL_INT_SRP                         (1<<6)
    00358
    00359 #define CSL_USB_GBL_INT_VBUSERR                     (1<<7)
    00360
    00361 #define CSL_USB_GBL_INT_DRVVBUS                     (1<<8)
    00362
    00363
    00366 #define CSL_USB_RX_INT_EP4                          (1<<12)
    00367
    00368 #define CSL_USB_RX_INT_EP3                          (1<<11)
    00369
    00370 #define CSL_USB_RX_INT_EP2                          (1<<10)
    00371
    00372 #define CSL_USB_RX_INT_EP1                          (1<<9)
    00373
    00376 #define CSL_USB_TX_INT_EP4                          (1<<4)
    00377
    00378 #define CSL_USB_TX_INT_EP3                          (1<<3)
    00379
    00380 #define CSL_USB_TX_INT_EP2                          (1<<2)
    00381
    00382 #define CSL_USB_TX_INT_EP1                          (1<<1)
    00383
    00384 #define CSL_USB_TX_RX_INT_EP0                       (1<<0)
    00385
    00387 #define CSL_USB_DELAY                               (0xFF)
    00388
    00389 #define CSL_USB_DATA_DELAY                          (0xFFF)
    00390
    00392 #define CSL_USB_RESUME_DELAY                        (10)
    00393
    00395 #define CSL_USB_PER_RESTCOUNT                       (0x20)
    00396
    00399 #define CSL_USB_INTRUSB_INTRUSBE_DEFVAL             (0x7fff)
    00400
    00401 #define CSL_USB_INTMSKSETR1_DEFVAL                  (0xFFFF)
    00402
    00403 #define CSL_USB_INTMSKSETR2_DEFVAL                  (0xFFF7)
    00404
    00405 #define CSL_USB_SYS_CTRL_REG_DEF_VAL                (0x6040)
    00406
    00407 #define CSL_USB_CLOCKSTOP_REG_DEF_VAL               (0x0)
    00408
    00411 #define CSL_USB_DMA_SCHED_CTRL1_DEFVAL              (0x0001)
    00412
    00413 #define CSL_USB_ENTRYLSW_DEFVAL                     (0x0081)
    00414
    00415 #define CSL_USB_RXGCR1_DEFVAL                       (0x401A)
    00416
    00417 #define CSL_USB_RXGCR2_DEFVAL                       (0x8100)
    00418
    00419 #define CSL_USB_LRAM0SIZE_DEFVAL                    (0x200)
    00420
    00421 #define CSL_USB_QMEMRCTRL1_DEFVAL                   (0x200)
    00422
    00423 #define CSL_USB_QMEMRCTRL2_DEFVAL                   (0x0000)
    00424
    00425 #define CSL_USB_16BIT_REG_MASK                      (0xFFFF)
    00426
    00427 #define CSL_USB_16BIT_REG_SHIFT                     (16)
    00428
    00431 #if (defined(CHIP_C5505_C5515) || defined(CHIP_C5504_C5514))
    00432
    00433 #define CSL_USB_PLL_PLLCNTL1_DEFVAL                 (0x8BE8)
    00434
    00435 #else
    00436 #define CSL_USB_PLL_PLLCNTL1_DEFVAL                 (0x82FA)
    00437 #endif
    00438
    00440 #define CSL_USB_PLL_PLLINCNTL_DEFVAL                (0x8000)
    00441
    00442 #define CSL_USB_PLL_PLLCNTL2_DEFVAL                 (0x0806)
    00443
    00444 #define CSL_USB_PLL_PLLOUTCNTL_DEFVAL               (0x0000)
    00445
    00446 #define CSL_USB_PLL_TIMEOUT                         (0xFFFF)
    00447
    00449 #define CSL_USB_INTMASKEDRL_LSB                     (0)
    00450
    00451 #define CSL_USB_INTMASKEDRL_MSB                     (12)
    00452
    00453 #define CSL_USB_INTMASKEDRH_LSB                     (0)
    00454
    00455 #define CSL_USB_INTMASKEDRH_MSB                     (8)
    00456
    00457 #define CSL_USB_INTCLRRL_LSB                        (0)
    00458
    00459 #define CSL_USB_INTCLRRL_MSB                        (12)
    00460
    00461 #define CSL_USB_INTCLRRH_LSB                        (0)
    00462
    00463 #define CSL_USB_INTCLRRH_MSB                        (8)
    00464
    00466 #define CSL_USB_INVALID_MAXPOWER                    (0xFFFF)
    00467
    00469 #define CSL_USB_WORD_ACCESS                         (0)
    00470
    00471 #define CSL_USB_HIGHBYTE_ACCESS                     (1)
    00472
    00473 #define CSL_USB_LOWBYTE_ACCESS                      (2)
    00474
    00476 #define CSL_USB_MIN(a,b)                            (((a)<(b))?(a):(b))
    00477
    00484 #define CSL_USB_CHANGE_ACCESSTYPE(byte)                                       \
    00485                CSL_FINS(CSL_SYSCTRL_REGS->USBSCR, SYS_USBSCR_USBBYTEMODE, byte)
    00486
    00488 #define CSL_USB_BYTESWAP(word)                                                \
    00489                           ((((word) >> 8u) & 0xFFu) | (((word) & 0xFFu) << 8u))
    00490
    00492 typedef Uint16    CSL_UsbIoFlags;
    00494 typedef Uint16    CSL_UsbEventMask;
    00496 typedef Uint16    CSL_UsbByteCount;
    00498 typedef Uint16    CSL_UsbFrameNum;
    00499
    00501 typedef void      (*CSL_USB_EVENT_ISR)();
    00503 typedef void      (*CSL_USB_APP_CALLBACK)(Uint16 flag);
    00505 typedef CSL_Status (*CSL_USB_APP_TRANSFER_CALLBACK)(void *, void *);
    00506
    00510 /**************************************************************************\
    00511 * USB MUSB global typedef declarations                                     *
    00512 \**************************************************************************/
    00513
    00523 typedef enum {
    00526   CSL_USB_OUT_EP0  = 0x00,
    00528   CSL_USB_OUT_EP1  = 0x01,
    00530   CSL_USB_OUT_EP2  = 0x02,
    00532   CSL_USB_OUT_EP3  = 0x03,
    00534   CSL_USB_OUT_EP4  = 0x04,
    00536   CSL_USB_OUT_EP5  = 0x05,
    00538   CSL_USB_OUT_EP6  = 0x06,
    00540   CSL_USB_OUT_EP7  = 0x07,
    00543   CSL_USB_IN_EP0   = 0x08,
    00545   CSL_USB_IN_EP1   = 0x09,
    00547   CSL_USB_IN_EP2   = 0x0A,
    00549   CSL_USB_IN_EP3   = 0x0B,
    00551   CSL_USB_IN_EP4   = 0x0C,
    00553   CSL_USB_IN_EP5   = 0x0D,
    00555   CSL_USB_IN_EP6   = 0x0E,
    00557   CSL_USB_IN_EP7   = 0x0F
    00558 } CSL_UsbEpNum;
    00559
    00563 typedef enum {
    00565     CSL_USB_EP0_IDLE = 0,
    00567     CSL_USB_EP0_STATUS_IN,
    00569     CSL_USB_EP0_TX,
    00571     CSL_USB_EP0_RX
    00572 } CSL_UsbEp0State;
    00573
    00577 typedef enum {
    00579     CSL_USB_DEVICE_DETACH = 0,
    00581     CSL_USB_DEVICE_ATTACH
    00582 } CSL_UsbDeviceEvent;
    00583
    00587 typedef enum {
    00589     CSL_USB_BS_UNKNOWN_SPEED = 0,
    00591     CSL_USB_BS_FULL_SPEED    = (1 << 1),
    00593     CSL_USB_BS_HIGH_SPEED    = (1 << 2)
    00594 } CSL_UsbBusSpeed;
    00595
    00599 typedef enum {
    00601     CSL_USB_MSG_MSC_CTL      = 0,
    00603     CSL_USB_MSG_MSC_BULK_IN,
    00605     CSL_USB_MSG_MSC_BULK_OUT,
    00607     CSL_USB_MSG_ISO_OUT,
    00609     CSL_USB_MSG_ISO_IN,
    00611     CSL_USB_MSG_HID_INT_IN,
    00613     CSL_USB_MSG_MSC_TASK_EXIT
    00614 } CSL_UsbMscMsg;
    00615
    00619 typedef enum {
    00621     CSL_USB_MSG_USBUI_HOSTFEATURE = 0,
    00623     CSL_USB_MSG_USBUI_USBERROR,
    00625     CSL_USB_MSG_USBUI_TASK_EXIT
    00626 } CSL_UsbUiMsg;
    00627
    00631 typedef enum {
    00633     CSL_USB_MSG_DATA = 0,
    00635     CSL_USB_MSG_USB_INT,
    00637     CSL_USB_MSG_RESET_DEVICE,
    00639     CSL_USB_MSG_CONNECT_DEVICE,
    00641     CSL_USB_MSG_DISCONNECT_DEVICE,
    00643     CSL_USB_MSG_STALL_ENDPOINT,
    00645     CSL_USB_MSG_CLEAR_ENDPOINT_STALL,
    00647     CSL_USB_MSG_ABORT_TRANSFER,
    00649     CSL_USB_MSG_SEND_HAND_SHAKE,
    00651     CSL_USB_MSG_MAIN_TASK_EXIT
    00652 } CSL_UsbMainMsg;
    00653
    00657 typedef enum {
    00659     CSL_USB_CTRL  = 0x00,
    00661     CSL_USB_BULK  = 0x01,
    00663     CSL_USB_INTR  = 0x02,
    00665     CSL_USB_ISO   = 0x03,
    00667     CSL_USB_HPORT = 0x04
    00668 } CSL_UsbXferType;
    00669
    00673 typedef enum {
    00674     /* 1st USB module  - Currently supported mode                            */
    00675     CSL_USB0 = 0x00,
    00676     /* 2nd USB module  - if the DSP support 2 USB module                     */
    00677     CSL_USB1 = 0x01,
    00678     /* 3rd USB module  - if the DSP support 3 USB module                     */
    00679     CSL_USB2 = 0x02
    00680 } CSL_UsbDevNum;
    00681
    00685 typedef enum {
    00686     /* Endpoint0 data dir: Host -> Target                                    */
    00687     CSL_USB_EP0_DATA_OUT = 0x00,
    00688     /* Endpoint0 data dir: Target -> host                                    */
    00689     CSL_USB_EP0_DATA_IN  = 0x01
    00690 } CSL_UsbEp0DataDir;
    00691
    00695 typedef enum {
    00696     /* Status of the operation is FALSE                                      */
    00697     CSL_USB_FALSE = 0,
    00698     /* Status of the operation is TRUE                                       */
    00699     CSL_USB_TRUE
    00700 } CSL_UsbBoolean;
    00701
    00710 typedef enum {
    00711     /* FIFO data is directly accessed by the CPU                             */
    00712     CSL_USB_OPMODE_POLLED = 0,
    00713     /* RX and TX FIFO data is accessed by the CPPI DMA Engine                          */
    00714     CSL_USB_OPMODE_DMA,
    00715     /* TX FIFO data is accessed by the CPPI DMA Engine                          */
    00716     CSL_USB_OPMODE_DMA_TXONLY
    00717 } CSL_UsbOpMode;
    00718
    00719
    00723 /**************************************************************************\
    00724 * USB MUSB global data structure declarations                              *
    00725 \**************************************************************************/
    00726
    00737 typedef struct CSL_UsbTransfer {
    00739     DWORD             dwFlags;
    00741     DWORD             dwEndpoint;
    00743     PVOID             pvBuffer;
    00745     DWORD             cbBuffer;
    00747     DWORD             cbTransferred;
    00750     DWORD             prevTxferLen;
    00752     Bool              fComplete;
    00754     CSL_UsbIoFlags    ioFlags;
    00755 } CSL_UsbTransfer;
    00756
    00758 typedef CSL_UsbTransfer    *pUsbTransfer;
    00759
    00765 typedef struct CSL_UsbEpStatus {
    00767     DWORD                dwEndpoint;
    00769     CSL_UsbXferType      xferType;
    00771     DWORD                dwPacketSizeAssigned;
    00773     Bool                 fInitialized;
    00775     DWORD*               pFifoAddr;
    00777     CSL_UsbTransfer      *pTransfer;
    00779     WORD                 wUSBEvents;
    00781     WORD                 dataReadFromFifo;
    00783     CSL_USB_EVENT_ISR    hEventHandler;
    00785     Bool                 fStalled;
    00787     Bool                 fSelected;
    00788 } CSL_UsbEpStatus;
    00789
    00791 typedef CSL_UsbEpStatus  *pUsbEpStatus;
    00792
    00796 typedef struct CSL_UsbSetupStruct {
    00798     int       newPacket;
    00800     Uint16    bmRequestType;
    00802     Uint16    bRequest;
    00804     Uint16    wValue;
    00806     Uint16    wIndex;
    00808     Uint16    wLength;
    00809 } CSL_UsbSetupStruct;
    00810
    00818 typedef struct CSL_UsbDataStruct {
    00820     Uint16                      bytes;
    00822     Uint16                      *pBuffer;
    00824     struct CSL_UsbDataStruct    *pNextBuffer;
    00825 } CSL_UsbDataStruct;
    00826
    00834 typedef struct CSL_UsbEpObj {
    00836     CSL_UsbEpNum         epNum;
    00838     CSL_UsbXferType      xferType;
    00840     Uint16               maxPktSiz;
    00842     Uint16               eventMask;
    00847     CSL_USB_EVENT_ISR    fxn;
    00849     Uint16               dataFlags;
    00851     Uint16               status;
    00853     Uint16               epDescRegSAddr;
    00855     Uint16               dmaRegSAddr;
    00857     Uint16               totByteCnt;
    00859     Uint16               byteInThisSeg;
    00862     Uint16               *xferBytCnt;
    00864     Uint16               *pBuffer;
    00866     CSL_UsbDataStruct    *pNextBuffer;
    00868     Uint16               eventFlag;
    00869 } CSL_UsbEpObj;
    00870
    00872 typedef CSL_UsbEpObj    *pUsbEpHandle;
    00873
    00879 typedef struct CSL_UsbContext {
    00881     CSL_UsbOpMode           opMode;
    00883     WORD                    maxCurrent;
    00885     Bool                    fInitialized;
    00887     Bool                    fSetupPktCmd;
    00889     Bool                    fOutPhaseCmd;
    00891     Bool                    fWaitingOnFlagA;
    00893     Bool                    fWaitingOnFlagB;
    00895     Bool                    fWaitingOnEP0BUFAvail;
    00897     Bool                    fWaitingOnEP1InBUFAvail;
    00899     WORD                    *rgbDescriptors;
    00901     WORD                    cbDescriptors;
    00903     DWORD                   dwFlagAEndpointAssigned;
    00905     DWORD                   dwFlagBEndpointAssigned;
    00907     DWORD                   *pFIFOBaseAddress;
    00909     DWORD                   *pInterruptAddr;
    00911     Bool                    fSendHandshake;
    00913     Bool                    fMUSBIsReady;
    00915     WORD                    cbOutEP0Buf;
    00917     WORD                    cbOutEP0DataReceived;
    00919     DWORD                   dwOutEP0Buf[CSL_USB_MAX_OUTEP0BUF_LEN / 4];
    00920     //WORD                    dwOutEP0Buf[CSL_USB_MAX_OUTEP0BUF_LEN / 2];
    00922     Bool                    fEP0BUFAvailable;
    00924     Bool                    fEP1InBUFAvailable;
    00926     WORD                    dwQueuePend1;
    00928     Bool                    fEP3InBUFAvailable;
    00930     WORD                    dwIntSourceL;
    00932     WORD                    dwIntSourceH;
    00934     CSL_UsbBoolean          remoteWkpStat;
    00936     CSL_UsbEpStatus         *pEpStatus;
    00938     CSL_UsbBusSpeed         busSpeed;
    00940     CSL_UsbEp0State         ep0State;
    00942     CSL_UsbDeviceEvent      cableState;
    00944     CSL_UsbSetupStruct      usbSetup;
    00946     CSL_USB_APP_CALLBACK    suspendCallBackFxn;
    00948     CSL_USB_APP_CALLBACK    wakeupCallBackFxn;
    00950     CSL_USB_APP_TRANSFER_CALLBACK    startTransferCallback;
    00952     CSL_USB_APP_TRANSFER_CALLBACK    completeTransferCallback;
    00953     WORD                    dwFIFOStartAddr;
    00955     Uint16                  *deviceDescPtr;
    00957     Uint16                  *deviceQualDescPtr;
    00959     Uint16                  *cfgDescPtr;
    00961     Uint16                  *cfgDescFSPtr;
    00963     Uint16                  *strDescPtr[4];
    00965     Uint16                  devAddr;
    00967     CSL_UsbEpObj             ctrlInEpObj;
    00969     CSL_UsbDevNum            devNum;
    00971     CSL_UsbEpObj             ctrlOutEpObj;
    00973     Uint16                   suspendFlag;
    00975     pUsbEpHandle             hEpObjArray[CSL_USB_ENDPOINT_COUNT];
    00977     Uint16                   curConfigStat;
    00981     Bool                     usbSpeedCfg;
    00982 } CSL_UsbContext;
    00983
    00985 typedef CSL_UsbContext  *pUsbContext;
    00986
    00992 typedef struct CSL_UsbMsgObj {
    00994     WORD    wMsg;
    00996     WORD    wEndpoint;
    00997 } CSL_UsbMsgObj;
    00998
    01005 typedef struct CSL_UsbConfig {
    01007     CSL_UsbDevNum           devNum;
    01009     CSL_UsbOpMode           opMode;
    01011     Uint16                  maxCurrent;
    01013     CSL_USB_APP_CALLBACK    appSuspendCallBack;
    01015     CSL_USB_APP_CALLBACK    appWakeupCallBack;
    01017     CSL_USB_APP_TRANSFER_CALLBACK    startTransferCallback;
    01019     CSL_USB_APP_TRANSFER_CALLBACK    completeTransferCallback;
    01020 } CSL_UsbConfig;
    01021
    01022
    01026 typedef struct CSL_UsbHostPktDescr {
    01028     volatile Uint32    PacketInfoWord0;
    01030     volatile Uint32    PacketInfoWord1;
    01032     volatile Uint32    PacketInfoWord2;
    01034     volatile Uint32    Buffer0InfoWord0;
    01036     volatile Uint32    Buffer0InfoWord1;
    01038     volatile Uint32    LinkingWord;
    01040     volatile Uint32    OriginalBuffer0InfoWord0;
    01042     volatile Uint32    OriginalBuffer0InfoWord1;
    01043 } CSL_UsbHostPktDescr;
    01044
    01048 typedef struct CSL_UsbHostBufDescr {
    01050     volatile Uint32    Reserved0;
    01052     volatile Uint32    Reserved1;
    01054     volatile Uint32    PacketInfoWord2;
    01056     volatile Uint32    Buffer0InfoWord0;
    01058     volatile Uint32    Buffer0InfoWord1;
    01060     volatile Uint32    LinkingWord;
    01062     volatile Uint32    OriginalBuffer0InfoWord0;
    01064     volatile Uint32    OriginalBuffer0InfoWord1;
    01065 } CSL_UsbHostBufDescr;
    01066
    01070 /**************************************************************************\
    01071 * USB MUSB function declarations                                            *
    01072 \**************************************************************************/
    01073
    01113 CSL_Status USB_init(CSL_UsbConfig    *usbConfig);
    01114
    01154 CSL_Status USB_resetDev(CSL_UsbDevNum    devNum);
    01155
    01214 CSL_Status USB_initEndptObj(CSL_UsbDevNum        devNum,
    01215                             pUsbEpHandle         hEp,
    01216                             CSL_UsbEpNum         epNum,
    01217                             CSL_UsbXferType      xferType,
    01218                             Uint16               maxPktSize,
    01219                             Uint16               evMask,
    01220                             CSL_USB_EVENT_ISR    fxn);
    01221
    01270 CSL_UsbEventMask USB_getEvents(pUsbEpHandle    hEp,
    01271                                CSL_Status      *status);
    01272
    01323 CSL_UsbEventMask USB_peekEvents(pUsbEpHandle    hEp,
    01324                                 CSL_Status      *status);
    01325
    01374 CSL_Status USB_getSetupPacket(CSL_UsbDevNum         devNum,
    01375                               CSL_UsbSetupStruct    *usbSetup,
    01376                               Bool                  readFromFifo);
    01377
    01426 CSL_Status USB_postTransaction(pUsbEpHandle      hEp,
    01427                                Uint16            byteCnt,
    01428                                void              *data,
    01429                                CSL_UsbIoFlags    flags);
    01430
    01487 CSL_UsbBoolean USB_isTransactionDone(pUsbEpHandle    hEp,
    01488                                      CSL_Status      *status);
    01489
    01543 CSL_UsbByteCount USB_bytesRemaining(pUsbEpHandle    hEp,
    01544                                     CSL_Status      *status);
    01545
    01590 CSL_Status USB_stallEndpt(pUsbEpHandle  hEp);
    01591
    01641 CSL_Status USB_clearEndptStall(pUsbEpHandle  hEp);
    01642
    01693 CSL_UsbBoolean USB_getEndptStall(pUsbEpHandle    hEp,
    01694                                  CSL_Status      *status);
    01695
    01741 pUsbEpHandle USB_epNumToHandle(CSL_UsbDevNum    devNum,
    01742                                Uint16           endpt);
    01743
    01784 CSL_Status USB_abortTransaction(pUsbEpHandle    hEp);
    01785
    01825 CSL_Status USB_abortAllTransaction(CSL_UsbDevNum    devNum);
    01826
    01866 CSL_Status USB_connectDev(CSL_UsbDevNum    devNum);
    01867
    01903 CSL_Status USB_disconnectDev(CSL_UsbDevNum    devNum);
    01904
    01945 CSL_Status USB_setRemoteWakeup(CSL_UsbDevNum     devNum,
    01946                                CSL_UsbBoolean    rmtWkpStat);
    01947
    01986 CSL_UsbBoolean USB_getRemoteWakeupStat(CSL_UsbDevNum    devNum);
    01987
    02031 CSL_Status USB_issueRemoteWakeup(CSL_UsbDevNum    devNum,
    02032                                  Bool             resumeBitVal);
    02033
    02075 CSL_Status USB_setDevAddr(CSL_UsbDevNum    devNum,
    02076                           Uint16            addr);
    02077
    02117 CSL_UsbFrameNum USB_getFrameNo(CSL_UsbDevNum    devNum);
    02118
    02160 CSL_Status USB_suspendDevice(CSL_UsbDevNum    devNum);
    02161
    02216 CSL_Status USB_selfwakeup(CSL_UsbDevNum    devNum,
    02217                           Uint32           wakeupDelay);
    02218
    02249 void USB_initPLL(void);
    02250
    02286 CSL_Status USB_setParams(CSL_UsbDevNum    devNum,
    02287                          pUsbEpHandle     hEpObj[],
    02288                          Uint16           pSofTmrCnt);
    02289
    02330 WORD USB_getMaxPower(CSL_UsbDevNum    devNum);
    02331
    02370 void USB_setFullSpeedMode(Uint16    ep0DataSize);
    02371
    02416 Uint16 USB_getDataCountReadFromFifo (pUsbEpHandle    hEp);
    02417
    02418 // determine the fifo size according to the transfer type and the maximum packet size
    02419 Uint16 USB_findFifoSize(Uint16 maxPktSize, CSL_UsbXferType xferType);
    02420
    02421 // processing all the EP0 events for enumeration
    02422 // call the CDC event handler for further processing
    02423 CSL_Status USB_coreEventProcessEp0(pUsbContext pContext);
    02424
    02428 #ifdef __cplusplus
    02429 }
    02430 #endif
    02431
    02432 #endif    //_CSL_USB_H_
    02433