예제 #1
0
/* structure containing details of all the endpoints used by this device */ 
USB_ENDPOINTS usb_desc_ep =
{
    MSC_DESC_ENDPOINT_COUNT,
    ep
};

uint_8 g_device_descriptor[DEVICE_DESCRIPTOR_SIZE] =  
{
    /* "Device Dexcriptor Size */
    DEVICE_DESCRIPTOR_SIZE,               
    /* "Device" Type of descriptor */   
    USB_DEVICE_DESCRIPTOR,                
    /*  BCD USB version  */  
    USB_uint_16_low(BCD_USB_VERSION), USB_uint_16_high(BCD_USB_VERSION),
    /* Device Class is indicated in the interface descriptors */   
    DEVICE_DESC_DEVICE_CLASS,
    /*  Device Subclass is indicated in the interface descriptors  */      
    DEVICE_DESC_DEVICE_SUBCLASS,
    /*  Device Protocol  */     
    DEVICE_DESC_DEVICE_PROTOCOL,
    /* Max Packet size */
    CONTROL_MAX_PACKET_SIZE,
    /* Vendor ID */
    0x04,0x25,
    /* Product ID */
    0x00,0x02,  
    /* BCD Device version */
    0x02,0x00,
    /* Manufacturer string index */
예제 #2
0
#define USB_DEVICE_DESCRIPTOR     (1)
#define DEVICE_DESCRIPTOR_SIZE            (18)

#define DEVICE_DESC_DEVICE_CLASS             (0x00)
#define DEVICE_DESC_DEVICE_SUBCLASS          (0x00)
#define DEVICE_DESC_DEVICE_PROTOCOL          (0x00)
#define DEVICE_DESC_NUM_CONFIG_SUPPOTED      (0x01)
#define DEVICE_OTHER_DESC_NUM_CONFIG_SUPPOTED  (0) 
uint_8 g_device_descriptor[DEVICE_DESCRIPTOR_SIZE] =
{
    /* Device Dexcriptor Size */
    DEVICE_DESCRIPTOR_SIZE,
    /* "Device" Type of descriptor */   
    USB_DEVICE_DESCRIPTOR,
    /*  BCD USB version  */  
    USB_uint_16_low(BCD_USB_VERSION), USB_uint_16_high(BCD_USB_VERSION),
    /* Device Class is indicated in the interface descriptors */   
    DEVICE_DESC_DEVICE_CLASS,
    /*  Device Subclass is indicated in the interface descriptors  */      
    DEVICE_DESC_DEVICE_SUBCLASS,
    /*  Device Protocol  */     
    DEVICE_DESC_DEVICE_PROTOCOL,
    /* Max Packet size */
    CONTROL_MAX_PACKET_SIZE,
    /* Vendor ID */
    0x04, 0x25,
    /* Product ID */
    0x00, 0x01,  
    /* BCD Device version */
    0x02, 0x00,
    /* Manufacturer string index */
예제 #3
0
    0x20,                              /* Max Packet size                */
    0xAC, 0x05,                        /* Vendor ID                      */
    0x22,0x22,                         /* Product ID  */
    0x10, 0x00,                        /* BCD Device version             */
    0x01 ,                             /* Manufacturer string index      */
    0x02 ,                             /* Product string index           */
    0x03 ,                             /* Serial number string index     */
    0x01                               /* Number of configurations       */
};

/* Configuration Descriptor */
uint_8 g_config_descriptor[CONFIG_DESC_SIZE] =
{
    CONFIG_ONLY_DESC_SIZE,             /* Configuration Descriptor Size */
    USB_CONFIG_DESCRIPTOR,             /* Configuration type of descriptor */
    USB_uint_16_low(CONFIG_DESC_SIZE),USB_uint_16_high(CONFIG_DESC_SIZE), /* Total length of the Configuration descriptor */
    0x02,                              /* NumInterfaces*/
    0x01,                              /* Configuration Value */
    0x00,                              /* Configuration Description String Index*/
    (BUS_POWERED | SELF_POWERED),      /* Attributes.support RemoteWakeup and self power*/
    0x32,                              /* Current draw from bus*/
    /* Interface 0 Descriptor */
    IFACE_ONLY_DESC_SIZE,              /* Size of this descriptor */
    USB_IFACE_DESCRIPTOR,              /* INTERFACE descriptor type */
    0x00,                              /* Number of interface */
    0x00,                              /* Alternate Setting value */
    0x01,                              /* Number of endpoints */
    0x00,                              /* Interface Class */
    0x00,                              /* Interface Sub Class */
    0x00,                              /* Interface Protocol */
    0x00,                              /* Index of a string descriptor */
예제 #4
0
};
 
USB_ENDPOINTS usb_desc_ep = 
{
    CDC_DESC_ENDPOINT_COUNT, 
    ep
};

uint_8 g_device_descriptor[DEVICE_DESCRIPTOR_SIZE] =
{
    /* "Device Dexcriptor Size */
    DEVICE_DESCRIPTOR_SIZE,               
    /* "Device" Type of descriptor */   
    USB_DEVICE_DESCRIPTOR,                
    /*  BCD USB version  */  
    USB_uint_16_low(BCD_USB_VERSION), USB_uint_16_high(BCD_USB_VERSION),
    /* Device Class is indicated in the interface descriptors */   
    DEVICE_DESC_DEVICE_CLASS,
    /*  Device Subclass is indicated in the interface descriptors  */      
    DEVICE_DESC_DEVICE_SUBCLASS,
    /*  Device Protocol  */     
    DEVICE_DESC_DEVICE_PROTOCOL,
    /* Max Packet size */
    CONTROL_MAX_PACKET_SIZE,
    /* Vendor ID */
    0x04,0x25,
    /* Product ID */
    0x00,0x03,  
    /* BCD Device version */
    0x02,0x00,
    /* Manufacturer string index */
예제 #5
0
/* structure containing details of all the endpoints used by this device */
uint_8 usb_cdc_class_info[] =
{
    /* Class type */
    CDC_CC,
    /* Endpoint count */
    CDC_DESC_ENDPOINT_COUNT,
    /* Cdc endpoint */
#if DATA_CLASS_SUPPORT
    #if DIC_ISOCHRONOUS_SETTING
    DIC_ISO_IN_ENDPOINT,
    USB_ISOCHRONOUS_PIPE,
    USB_SEND,
    0,
    0,
    USB_uint_16_high(DIC_ISO_IN_ENDP_PACKET_SIZE),
    USB_uint_16_low(DIC_ISO_IN_ENDP_PACKET_SIZE),
    DIC_ISO_OUT_ENDPOINT,
    USB_ISOCHRONOUS_PIPE,
    USB_RECV,
    0,
    0,
    USB_uint_16_high(DIC_ISO_OUT_ENDP_PACKET_SIZE),
    USB_uint_16_low(DIC_ISO_OUT_ENDP_PACKET_SIZE),
    #else
    DIC_BULK_IN_ENDPOINT,
    USB_BULK_PIPE,
    USB_SEND,
    0,
    0,
    USB_uint_16_high(DIC_BULK_IN_ENDP_PACKET_SIZE),
예제 #6
0
USB_ENDPOINTS usb_desc_ep = 
{ 
    PHDC_DESC_ENDPOINT_COUNT,
    ep
};

 
uint_8 g_device_descriptor[DEVICE_DESCRIPTOR_SIZE] =
{
    /* Device Dexcriptor Size */
    DEVICE_DESCRIPTOR_SIZE,               
    /* Device" Type of descriptor */   
    USB_DEVICE_DESCRIPTOR,    
   /*  BCD USB version  */  
   USB_uint_16_low(BCD_USB_VERSION), USB_uint_16_high(BCD_USB_VERSION),
   /* Device Class is indicated in the interface descriptors */   
   DEVICE_DESC_DEVICE_CLASS,
   /*  Device Subclass is indicated in the interface descriptors  */      
   DEVICE_DESC_DEVICE_SUBCLASS,
   /*  Device Protocol  */     
   DEVICE_DESC_DEVICE_PROTOCOL,
   /* Max Packet size */
   CONTROL_MAX_PACKET_SIZE,
    /* Vendor ID */
    0x04,0x25,
    /* Product ID */
    0x01,0x04, /* for  Bridge device */ 
    /* BCD Device version */
    0x02,0x00,
    /* Manufacturer string index */
예제 #7
0
   AUDIO_INTERFACE_DESCRIPTOR_TYPE, /* bDescriptorType (CS_INTERFACE) */  
   AUDIO_STREAMING_FORMAT_TYPE,     /* DescriptorSubtype: AUDIO STREAMING FORMAT TYPE */ 
   AUDIO_FORMAT_TYPE_I,             /* Format Type: Type I */
   0x01,                            /* Number of Channels: one channel */ 
   0x01,                            /* SubFrame Size: one byte per audio subframe */  
   0x08,                            /* Bit Resolution: 8 bits per sample  */ 
   0x01,                            /* One frequency supported  */ 
   0x40,0x1F,0x00,                  /* 8 kHz */
   
   /*Endpoint 1 - standard descriptor*/
   ENDP_ONLY_DESC_SIZE,             /* bLength (9) */  
   USB_ENDPOINT_DESCRIPTOR,         /* Descriptor type (endpoint descriptor) */  
   AUDIO_ENDPOINT | (USB_SEND << 7),/* OUT endpoint address 1 */
   0x01,                            /* Isochronous endpoint */
   USB_uint_16_low(FS_ISO_OUT_ENDP_PACKET_SIZE), 
   USB_uint_16_high(FS_ISO_OUT_ENDP_PACKET_SIZE),/* 16 bytes  */ 
#if HIGH_SPEED
   HS_ISO_OUT_ENDP_INTERVAL,        /* bInterval(0x04): 2^x ms */
#else
   FS_ISO_OUT_ENDP_INTERVAL,        /* bInterval(0x01): 2^x ms */
#endif
   0x00,                            /* Unused */
   0x00,                            /* Unused */

   /* Endpoint 1 - Audio streaming descriptor */
   AUDIO_STREAMING_ENDP_DESC_SIZE,  /* bLength (7) */  
   USB_AUDIO_DESCRIPTOR,            /* AUDIO ENDPOINT DESCRIPTOR TYPE */  
   AUDIO_ENDPOINT_GENERAL,          /* AUDIO ENDPOINT GENERAL */
   0x00,                            /* bmAttributes: 0x00 */  
   0x00,                            /* unused */
   0x00,0x00,                       /* unused */
/**************************************************************************//*!
 *
 * @name  USB_Desc_Set_Speed
 *
 * @brief The function is used to set device speed
 *
 * @param handle:         handle
 * @param speed:          speed
 *
 * @return USB_OK                              When Success
 *         USBERR_INVALID_REQ_TYPE             when Error
 *****************************************************************************/
uint8_t USB_Desc_Set_Speed
(
    uint32_t handle,
    uint16_t speed
)
{
    descriptor_union_t ptr1, ptr2;
#if DATA_CLASS_SUPPORT
    uint16_t bulk_in = 0;
    uint16_t bulk_out = 0;
#endif
#if CIC_NOTIF_ELEM_SUPPORT
    uint16_t interrupt_size = 0;
    uint8_t interrupt_interval = 0;
#endif
    //UNUSED_ARGUMENT (handle);

    if (USB_SPEED_HIGH == speed)
    {
#if DATA_CLASS_SUPPORT
        bulk_in = HS_DIC_BULK_IN_ENDP_PACKET_SIZE;
        bulk_out = HS_DIC_BULK_OUT_ENDP_PACKET_SIZE;
#endif
#if CIC_NOTIF_ELEM_SUPPORT
        interrupt_size = HS_CIC_NOTIF_ENDP_PACKET_SIZE;
        interrupt_interval = HS_CIC_NOTIF_ENDP_INTERVAL;
#endif
    }
    else
    {
#if DATA_CLASS_SUPPORT
        bulk_in = FS_DIC_BULK_IN_ENDP_PACKET_SIZE;
        bulk_out = FS_DIC_BULK_OUT_ENDP_PACKET_SIZE;
#endif
#if CIC_NOTIF_ELEM_SUPPORT
        interrupt_size = FS_CIC_NOTIF_ENDP_PACKET_SIZE;
        interrupt_interval = FS_CIC_NOTIF_ENDP_INTERVAL;
#endif
    }

    ptr1.pntr = g_config_descriptor;
    ptr2.pntr = g_config_descriptor + CONFIG_DESC_SIZE;

    while (ptr1.word < ptr2.word)
    {
        if (ptr1.common->bDescriptorType == USB_DESC_TYPE_EP)
        {
            if (CIC_NOTIF_ENDPOINT == (ptr1.ndpt->bEndpointAddress & 0x7F))
            {
#if CIC_NOTIF_ELEM_SUPPORT
                ptr1.ndpt->wMaxPacketSize[0] = USB_uint_16_low(interrupt_size);
                ptr1.ndpt->wMaxPacketSize[1] = USB_uint_16_high(interrupt_size);
                ptr1.ndpt->iInterval = interrupt_interval;
#endif
            }
            else
            {
#if DATA_CLASS_SUPPORT
                if (ptr1.ndpt->bEndpointAddress & 0x80)
                {
                    ptr1.ndpt->wMaxPacketSize[0] = USB_uint_16_low(bulk_in);
                    ptr1.ndpt->wMaxPacketSize[1] = USB_uint_16_high(bulk_in);
                }
                else
                {
                    ptr1.ndpt->wMaxPacketSize[0] = USB_uint_16_low(bulk_out);
                    ptr1.ndpt->wMaxPacketSize[1] = USB_uint_16_high(bulk_out);
                }
#endif
            }
        }
        ptr1.word += ptr1.common->bLength;
    }
#if CIC_NOTIF_ELEM_SUPPORT
    cic_ep[0].size = interrupt_size;
#endif

#if DATA_CLASS_SUPPORT
    for (int i =0; i < DIC_ENDP_COUNT;i++)
    {
        if (USB_SEND == dic_ep[i].direction)
        {
            dic_ep[i].size = bulk_in;
        }
        else
        {
            dic_ep[i].size = bulk_out;
        }
    }
#endif
    return USB_OK;
}