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

📄 usbdscr_config.c

📁 DM642的一些基本功能例程。包括一些图像处理例子
💻 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.10.00.23 07-02-03 (ddk-b12)" */
/*
 *  ======== usbdscr_config.c ========
 *  This file defines example USB configuration descriptors used
 *    by test applications requiring an USB IN and USB OUT BULK
 *     transfer type endpoints.
 */
 
#include <std.h>
#include <csl.h>
#include <csl_usb.h>
#include <c5509_usb.h>       /* iom usb driver interface */


#define MAXPKTLEN 64  /* max USB transfer length in bytes */

extern C5509_USB_DeviceConfig myDeviceConfig;  /* device configuration */

/*
 *  USB endpoint descriptors
 *  The following are endpoint descriptors for USB interface 0 alternate set 0.
 */
static C5509_USB_EndptDesc endPtDesc[] =
{
    /*
     *  bulk endpoint descriptor - endpt2 OUT 
     */
    {
        0x0000,    
        (C5509_USB_DESCRIPTOR_ENDPT<<8) | 7,    /* bLength, bDescriptorType */
        0x0202,    /* bEndpointAddress = 2 OUT, bmAttributes = bulk */
        MAXPKTLEN, /* wMaxPacketSize = 64 bytes */
        0x00,      /* bInterval */
    },
    /*
     *  bulk endpoint descriptor - endpt2 IN 
     */
    {
        0x0000,    
        (C5509_USB_DESCRIPTOR_ENDPT<<8) | 7,   /* bLength, bDescriptorType */
        0x0282,    /* bEndpointAddress = 2 IN , bmAttributes */
        MAXPKTLEN, /* wMaxPacketSize */
        0x00       /* bInterval */
    }
};

/*
 * Determine number of IOM channels needed for this configuration.
 */
#define NUMCHANS (sizeof(endPtDesc) / sizeof(C5509_USB_EndptDesc)) 

/*
 *  USB endpoint link list used to describe the configuration to the PC Host.
 */
static USB_DataStruct endptDescLink[NUMCHANS] = {    
    {
        7, (Uint16 *)&endPtDesc[0], &endptDescLink[1]
    },
    {
        7, (Uint16 *)&endPtDesc[1], NULL
    }
};

/* 
 *  IOM channel object array. 
 */
static C5509_USB_ChanObj chans[NUMCHANS]; 

/*
 *  USB driver endpoint configuration array.
 *  Used to initialize the mini-driver and underlying USB CSL.
 *  Note: Endpoint number, transfer size and type need to match the
 *   above endpoint descriptors. 
 */
static C5509_USB_EpConfig endptsConfig[NUMCHANS] = {

    /* 
     * EP #2 OUT, BULK transfer type, max transfer size, OR'd event mask=EOT 
     */
    {
        &chans[0], USB_OUT_EP2, USB_BULK, MAXPKTLEN, USB_EVENT_EOT
    },
    /* 
     * EP #2 IN, BULK transfer type, max transfer size, OR'd event mask=EOT
     */
    {
        &chans[1], USB_IN_EP2, USB_BULK, MAXPKTLEN, USB_EVENT_EOT
    }
};




/*
 *  Configuration descriptor. Used by host to determine the configuration.
 */
static Uint16 configurationDescriptor[] = {
    0x0000,    /* field for xfer_byte_cnt - used by the data */
               /* transfer API, not an integral part of descriptor */
    (C5509_USB_DESCRIPTOR_CONFIG<<8) | 9,    /* bLength, bDescriptorType */
    (18 + (NUMCHANS * 7)),      /* wTotalLength = 9 + 9 + 7 * NUMCHANS */
    0x0101,    /* bNumInterfaces = 1, bConfigurationValue = 1 */
    0xC003,    /* iConfiguration, bmAttributes = bus/self pwr, no rwu */
    0          /* bMaxPower = none */
};


/*
 *  Interface Descriptor
 */
static Uint16 usbIfc0Alt0Descriptor[] =  {  /* interface 0 alt_set = 0 */

    0x0000,    /* field for xfer_byte_cnt - used by the data */
               /* transfer API, not an integral part of descriptor */
    (C5509_USB_DESCRIPTOR_INTRFC << 8) | 9,    /* bLength, bDescriptorType */
    0x0000,    /* bInterfaceNumber, bAlternateSetting */
    (0x00 << 8) | NUMCHANS,    /* bNumEndpoints , bInterfaceClass */
    0x0000,    /* bInterfaceSubClass, bInterfaceProtocol */
    0x04       /* iInterface = index in string descriptor */
};


/*
 * Ifc 0, Alt 0 endpoint link list
 */
static USB_DataStruct usbIfc0Alt0DescLink[] = {     /* Interface Descriptor */
    9,
    (Uint16 *)&usbIfc0Alt0Descriptor[0],  
    &endptDescLink[0]
};


/*
 * USB configuration and interface(s) link list.
 */
static USB_DataStruct configDescLink[] = {     
    9,
    (Uint16 *)&configurationDescriptor[0],   
    &usbIfc0Alt0DescLink[0]
};


/*
 *  USB interface config used by iom driver's devParams.
 */
C5509_USB_IfcConfig myIfcConfig = {
    NUMCHANS,              /* total number of configured endpoints */
    &configDescLink[0],  /* USB config and interface descriptor list */
    &endptsConfig[0]     /* endpoint configuration array */
};


⌨️ 快捷键说明

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