⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c5509_usb_create.c

📁 基于TMS320VC5507DSP和CF卡的MP3项目的源代码、电路图、PCB文件
💻 C
字号:
/*
 *  Copyright 2003 by Texas Instruments Incorporated.
 *  All rights reserved. Property of Texas Instruments Incorporated.
 *  Restricted rights to use, duplicate or disclose this code are
 *  granted through contract.
 *  
 */
/* "@(#) DDK 1.11.00.00 11-04-03 (ddk-b13)" */
/*
 *  ======== _C5509_USB_mdCreateChan.c ========
 *  This file implements C5509_USB_mdCreateChan() function 
 */

#include <std.h>
#include <que.h>
#include <iom.h>
#include <mem.h>
#include <csl.h>
#include <csl_usb.h>
#include <_c5509_usb.h>
#include <c5509_usb.h>


/*
 * ======== _C5509_USB_mdCreateChan ========
 * This function is called to open a channel.
 *  
 *  chanp is used to output initialized channel object to IOM.
 *  
 *  devp is the global device object
 *
 *  name is the device string name
 *
 *  mode is IOM_INPUT or IOM_OUTPUT. Other mode is illegal.
 *
 *  chanParams are optional channel specific parameters, but not used.
 *  
 *  cbFxn and cbArg is the IOM callback pointer and argument
 */
Int _C5509_USB_mdCreateChan(Ptr * chanp, Ptr devp, String name, Int mode, 
        Ptr chanParams, IOM_TiomCallback cbFxn,Ptr cbArg) 
{   
    C5509_USB_ChanHandle  chan;
    Uint16      epNum;
    C5509_USB_EpConfig * cfgPtr;              
    _C5509_USB_DevHandle port = (_C5509_USB_DevHandle)devp;
    Int i; 

    
    if (chanp == NULL ) {
        return IOM_EBADARGS;
    }

    *chanp = NULL;  /* make sure NULL on error */

    epNum = (Uint16)*name - 0x30;  /* atoi - ascii conversion shortcut */

    /* 
     * Return error if user supplied illegal endpoint #
     * Note Endpoint 0 IN & OUTis reserved for driver control channel.
     */
    if ((epNum < USB_OUT_EP1) || (epNum > USB_OUT_EP7)) {  
        return IOM_EBADIO;
    }

    if (mode == IOM_OUTPUT) { /* to host */
        epNum |= 0x08;    /* USB_IN_EP1...USB_IN_EP7  */
    } 
 
    /* Get this endpoint number from configured EP list */
    cfgPtr =  _C5509_USB_devParams->ifcConfig->epConfig;

    for (i = 0; i < _C5509_USB_devParams->ifcConfig->numEps; i++, cfgPtr++) {
    
        if (epNum == cfgPtr->epNum) {           
            if (port->chans[i]) {
                return (IOM_EBADIO);    /* ERROR! channel is already open! */
            }
            chan = cfgPtr->chanp;
            break;
        }
        if (i == (_C5509_USB_devParams->ifcConfig->numEps - 1)) {
            return IOM_EBADIO;   /* not in user EP configuration */
        }
    }
        
    QUE_new( &chan->pendList );    /* initialize pend list */
    chan->cbFxn = cbFxn;    /* IOM call back */
    chan->cbArg = cbArg;    /* call back arg */   
    chan->mode = mode;    /* mode */ 
    chan->dataPacket = NULL;    /* dataPacket */
    chan->flushPacket = NULL;   /* flushPacket */
    chan->fxnConnect = NULL;    /* fxn called when bus enum is complete */
    chan->argConnect = NULL;    /* argument to fxnConnect */
    port->chans[epNum] = chan;  /* remember this chan is open */

    *chanp = chan;    /* output chan to IOM */
            
    return (IOM_COMPLETED);
}



⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -