1
回答
我的usb midi描述符 源码 共享
百度AI开发者大赛带你边学边开发,赢100万奖金,加群:418589053   

这里发一个midi描述符,意在投石问路,与大家交流。

usb midi描述符 源码:

/******************** (C) COPYRIGHT 2008 STMicroelectronics ********************
* File Name          : usb_desc.c
* Author             : MCD Application Team
* Version            : V2.2.0
* Date               : 06/13/2008
* Description        : Descriptors for Custom MIDI ********************************************************************************
* THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
* WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
* AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
* INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
* CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
* INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
*******************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include "usb_lib.h"
#include "usb_desc.h"

/* USB Standard Device Descriptor */
const u8 CustomHID_DeviceDescriptor[CUSTOMHID_SIZ_DEVICE_DESC] =
  {
    0x12,                       /*bLength */
    USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/
 0x10,1,0,0,0,0x40,0x86,0x1a,0x10,2,0,1,1,2,3,1//    0x00,   mid 345pid=1a86  /*bcdUSB  stm32f103 _2 */
  }
  ; /* CustomHID_DeviceDescriptor */


/* USB Configuration Descriptor */
/*   All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
const u8 CustomHID_ConfigDescriptor[CUSTOMHID_SIZ_CONFIG_DESC] =
  {
    0x09, /* bLength: Configuation Descriptor size */
    USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
    CUSTOMHID_SIZ_CONFIG_DESC,
    /* wTotalLength: Bytes returned */
// db 65h,0;57h,0;配置信息总长度
 0,
 2, //;支持接口数
// db  3 ;支持接口数
  1, //;配置值
   3, //;字符串描述符的索引值
   0x40, //;80h ;配置特性
   0x10, //;30h;0fah;30h ;最大电流
    /************** Descriptor of Joystick Mouse interface ****************/
    /* 09 */
    0x09,         /* bLength: Interface Descriptor size */
    USB_INTERFACE_DESCRIPTOR_TYPE,/* bDescriptorType: Interface descriptor type */
  0, //;2 bInterfaceNumber 1 00h 
  0, //;3 bAlternateSetting 1 00h 
  0, //;4 bNumEndpoints 1 00h 
  1, //;5 bInterfaceClass 1 01h =Audio,if 3=hid  
  1, //;6 bInterfaceSubClass 1 01h Audio Control ,if 2=Audio Streaming, 3=MIDI Streaming
  0, //;7 bInterfaceProtocol 1 00h 
  0, //;8 iInterface 1 00h

    9,0x24,1,0,1,9,0,1,1, //Audio Control Interface Header Descriptor类特殊音频描述符;第二字节为0X024
//;---------------- MIDI Streaming  
//;Interface Descriptor 1/0 Audio, 2 Endpoints MIDI流接口描述符;第二字节为0X04
//;Offset Field Size Value Description
  9,// ;0 bLength 1 09h 
  4,// ;1 bDescriptorType 1 04h Interface
  1,// ;2 bInterfaceNumber 1 01h 
  0,// ;3 bAlternateSetting 1 00h 
  2,// ;4 bNumEndpoints 1 02h  =1?
  1,// ;5 bInterfaceClass 1 01h Audio
  3,// ;6 bInterfaceSubClass 1 03h MIDI Streaming
  0,// ;7 bInterfaceProtocol 1 00h 
  0,// ;8 iInterface 1 00h 
 
    7,0x24,1,0,1,0x41,0, //MIDI Streaming Interface Header Descriptor类特殊MIDI流接口描述符;第二字节为0X024
  6,
  0x24,// ;  音频专属类
  2,// ;子类输入端口
  1, //;对应实体ID号为1
  1,0,// ;端口种类0101h为USB数据流
    6,0x24,2,2,2,0, //内嵌输入描述符;第二字节为0X024
  9,
  0x24,//h ;  音频专属类
  3,// ;子类输出端口
  1,// ;对应实体ID号为1
  3,1,// ;端口种类; 0301h为喇叭类
  2,
  1,
  0,
  9,0x24,3,2,4,1,1,1,0, //外部输出 描述符;第二字节为0X024
  9,5,1,2,4,0,0,0,0,//Endpoint Descriptor 01 1 Out, Bulk, 32 bytes端点描述符;第二字节为5;第三字节为0X02 out2
  5,0x25,1,1,1,//;3, //Unknown Descriptor描述符;第二字节为0X025
//  9,5,0x81,2,0x0c,0,0,0,0,//;端点描述符;第二字节为5;第三字节为0X81 in1
/*Endpoint Descriptor 81 1 In, Interrupt
Offset Field Size Value Description
0 bLength 1 09h 
1 bDescriptorType 1 05h Endpoint
2 bEndpointAddress 1 81h 1 In
3 bmAttributes 1 03h Interrupt
 1..0: Transfer Type  ......11  Interrupt
 7..2: Reserved  000000..  
4 wMaxPacketSize 2 0004h 4 bytes
6 bInterval 1 00h 
7 bRefresh 1 00h 
8 bSynchAddress 1 00h */
  9,5,0x81,2,0x04,0,0,0,0,//;端点描述符;第二字节为5;第三字节为0X81 in1
//  9,5,0x81,3,0x04,0,0,0,0,//;端点描述符;第二字节为5;第三字节为0X81 in1,中断传输快

  5,0x25,1,1,3 //Unknown Descriptor描述符;第二字节为0X025
//;--------------------------------------------
  }
  ; /* CustomHID_ConfigDescriptor */
const u8 CustomHID_ReportDescriptor[CUSTOMHID_SIZ_REPORT_DESC] =
  {   
  6,0,0xff,// ;;;;长度34 byte
  9,1, 
  0xa1,1,//;,    //集合开始
 
  9,2,//;,   //Usage Page  用法
  15h,0,      //Logical  Minimun
  0x26,0,0xff,  //Logical  Maximun
  0x75,8,    //Report Size
  0x95, 0x40,    //Report Counet
  0x81, 6,    //Input
  9,2,   //Usage Page  用法
  0x15,0,   //Logical  Minimun
  0x26,0,0xff,  //Logical  Maximun
  0x75,8,    //Report Size
  0x95, 0x40,    //Report Counet
  0x91, 6,  //Output
  0xC0 
  }
  ; /* Joystick_ReportDescriptor */

/* USB String Descriptors (optional) */
const u8 CustomHID_StringLangID[CUSTOMHID_SIZ_STRING_LANGID] =
  {
    CUSTOMHID_SIZ_STRING_LANGID,
    USB_STRING_DESCRIPTOR_TYPE,
    0x09,
    0x04
  }
  ; /* LangID = 0x0409: U.S. English */

const u8 CustomHID_StringVendor[CUSTOMHID_SIZ_STRING_VENDOR] =
  {
    CUSTOMHID_SIZ_STRING_VENDOR, /* Size of Vendor string */
    USB_STRING_DESCRIPTOR_TYPE,  /* bDescriptorType*/
    /* Manufacturer: "STMicroelectronics" */
    'C', 0, 'a', 0, 'o', 0, 'w', 0, 'u', 0, 'e', 0, ' ', 0, 'D', 0, 'e', 0,'s', 0,'i', 0,'g', 0,  'n', 0 //Design Company
  };

const u8 CustomHID_StringProduct[CUSTOMHID_SIZ_STRING_PRODUCT] =
  {
    CUSTOMHID_SIZ_STRING_PRODUCT,          /* bLength */
    USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
 'M', 0, 'I',0, 'D',0, 'I',0, '-',0, '1',0 // MIDI-1
  };
u8 CustomHID_StringSerial[CUSTOMHID_SIZ_STRING_SERIAL] = //to call Get_SerialNum
//u8 CustomHID_StringSerial_usb[CUSTOMHID_SIZ_STRING_SERIAL] =
  {
    CUSTOMHID_SIZ_STRING_SERIAL,           /* bLength */
    USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
    'S', 0,  '_', 0, '3', 0, '2', 0, '1', 0, '0', 0
  };

/******************* (C) COPYRIGHT 2008 STMicroelectronics *****END OF FILE****/

 这里好像人气不旺,昨天注册了半天都不能够发帖,还要积分,可能是原因之一。这里投石问路

试一试,我还做过usb HID兼容usb midi 声卡等,欢迎大家来交流,我也是来学习的,如果一个月都没有人来光顾,说明我太肤浅了,我还是只能老老实实的潜水学习。就别再班门弄斧啦。在我的"发表博文"发表不了,可能是我这个水平有限不够“博文”,放到这里来捣乱了。

 

<无标签>
举报
powder
发帖于5年前 1回/599阅
顶部