Autor Tema: USB descriptor  (Leído 6507 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado Crivi

  • PIC10
  • *
  • Mensajes: 9
USB descriptor
« en: 17 de Octubre de 2008, 15:42:52 »
Buenas. Supongo que ya le habrá pasado a más de uno, pero no he visto por el foro nada que me ayudase con mi problema. Me explico:

He estado mirando el código del picusb de J1M para enviar datos por bulk. Lo he usado para meterle un LCD y funciona bastante bien. Después de eso me interesó añadirle al LCD unos cuantos botones para configurar cosillas. Los botones en principio iban bien, pero cuando quise que me los detectara tipo joystick, el modo bulk no servía y me metí con el tema del HID, peeeero, en modo HID me pilla los botones pero no puedo controlar el LCD. Supongo que tendré que meterme de lleno con los descriptores esos que inventó el demonio.

Pues después de unas semanas creo que por fin tengo uno hecho. El caso es que si pongo el modo bulk como primera interface, puedo controlar el LCD, pero no aparecen los botones. Y si pongo los botones primero, aparece en dispositivos de juego de windows pero no puedo controlar el LCD. Y ahí empieza esta locura XD. Ya no sé ni que mirar ni que tocar. A ver si algun alma caritativa me puede ayudar con esto.

Dejo por aquí el código del descriptor que estoy usando:

Código: [Seleccionar]
#include <usb.h>

   const char USB_CLASS_SPECIFIC_DESC[] = {
      0x05, 0x01, // USAGE_PAGE (Generic Desktop)
      0x15, 0x00, // LOGICAL_MINIMUM (0)
      0x09, 0x04, // USAGE (Joystick)
      0xa1, 0x01, // COLLECTION (Application)
      0x05, 0x01, //   USAGE_PAGE (generic)
      0x05, 0x09, //   USAGE_PAGE (Button)
      0x19, 0x01, //   USAGE_MINIMUM (Button 1)
      0x29, 0x0C, //   USAGE_MAXIMUM (Button 12)
      0x15, 0x00, //   LOGICAL_MINIMUM (0)
      0x25, 0x01, //   LOGICAL_MAXIMUM (1)
      0x75, 0x01, //   REPORT_SIZE (1) //1 bit por botón
      0x95, 0x0C, //   REPORT_COUNT (12) //12 botones x 1 bits = 12 bits
      0x55, 0x00, //   UNIT_EXPONENT (0)
      0x65, 0x00, //   UNIT (None)
      0x81, 0x02, //   INPUT (Data,Var,Abs)
      0x75, 0x01, //   REPORT_SIZE (1) //En el primer byte no caben los 12 bits, pero se envía otro byte para los demás
      0x95, 0x04, //   REPORT_COUNT (4) //4 bits a enviar
      0x81, 0x01, //   INPUT (Constant) - 4 bits padding
      0xc0         // END_COLLECTION == 37
   };

   const int16 USB_CLASS_SPECIFIC_DESC_LOOKUP[USB_NUM_CONFIGURATIONS][1] =
   {
         0
   };

   const int16 USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[USB_NUM_CONFIGURATIONS][1] =
   {
      sizeof(USB_CLASS_SPECIFIC_DESC)
    };

   #DEFINE USB_TOTAL_CONFIG_LEN      57

   char const USB_CONFIG_DESC[] = {
   //config_descriptor for config index 1
         USB_DESC_CONFIG_LEN,     //length of descriptor size == 0
         USB_DESC_CONFIG_TYPE,         //constant CONFIGURATION (0x02) == 1
         USB_TOTAL_CONFIG_LEN,0,  //size of all data returned for this config == 2,3
         2,      //number of interfaces this device supports == 4
         0x01,                //identifier for this configuration.  (IF we had more than one configurations) == 5
         0x00,                //index of string descriptor for this configuration == 6
         0xC0,                //bit 6=1 if self powered, bit 5=1 if supports remote wakeup (we don't), bits 0-4 reserved and bit7=1 == 7
         0x32,                //maximum bus power required (maximum milliamperes/2)  (0x32 = 100mA) == 8

//**************//
   //interface descriptor 0 alt 0
         USB_DESC_INTERFACE_LEN,  //length of descriptor == 9
         USB_DESC_INTERFACE_TYPE,      //constant INTERFACE (0x04) == 10
         0x00,                //number defining this interface (IF we had more than one interface) == 11
         0x00,                //alternate setting = 12
         2,       //number of endpoints, not counting endpoint 0. == 13
         0xFF,                //class code, FF = vendor defined == 14
         0xFF,                //subclass code, FF = vendor == 15
         0xFF,                //protocol code, FF = vendor == 16
         0x00,                //index of string descriptor for interface == 17

   //endpoint descriptor
         USB_DESC_ENDPOINT_LEN, //length of descriptor == 18
         USB_DESC_ENDPOINT_TYPE,     //constant ENDPOINT (0x05)  == 19
         0x81,              //endpoint number and direction (0x81 = EP1 IN) == 20
         0x02,              //transfer type supported (0 is control, 1 is iso, 2 is bulk, 3 is interrupt) == 21
         USB_EP1_TX_SIZE,0x00,         //maximum packet size supported == 22,23
         0x01,              //polling interval in ms. (for interrupt transfers ONLY) == 24

   //endpoint descriptor
         USB_DESC_ENDPOINT_LEN, //length of descriptor == 25
         USB_DESC_ENDPOINT_TYPE,     //constant ENDPOINT (0x05) == 26
         0x01,              //endpoint number and direction (0x01 = EP1 OUT) == 27
         0x02,              //transfer type supported (0 is control, 1 is iso, 2 is bulk, 3 is interrupt) == 28
         USB_EP1_RX_SIZE,0x00,         //maximum packet size supported == 29, 30
         0x01,              //polling interval in ms. (for interrupt transfers ONLY)  == 31 (empiezar desde 0, total 32)
//***************//
   //interface descriptor 2 (Joystick)
         USB_DESC_INTERFACE_LEN, //length of descriptor == 32
         USB_DESC_INTERFACE_TYPE, //constant INTERFACE (INTERFACE 0x04) ==33
         0x01, //number defining this interface (IF we had more than one interface) ==34
         0x00, //alternate setting ==35
         1, //number of endpoints for this interface == 36
         0x03, //class code, 03 = HID == 37
         0x00,//0x01, //subclass code //boot == 38
         0x02, //protocol code == 39
         0x00, //index of string descriptor for interface == 40

   //class descriptor 2  (HID)
         USB_DESC_CLASS_LEN, //length of descriptor ==41
         USB_DESC_CLASS_TYPE, //dscriptor type (0x21 == HID) == 42
         0x00,0x01, //hid class release number (1.0) (try 1.10) == 43,44
         0x00, //localized country code (0 = none) == 45
         0x01, //number of hid class descrptors that follow (1) == 46
         0x22, //report descriptor type (0x22 == HID) == 47
         USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[0][0], 0x00, //length of report descriptor == 48,49

   //endpoint descriptor 2 IN
         USB_DESC_ENDPOINT_LEN, //length of descriptor == 50
         USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (ENDPOINT 0x05) == 51
         0x82, //endpoint number and direction (0x81 = EP1 IN) == 52
         USB_ENDPOINT_TYPE_INTERRUPT, //transfer type supported (0x03 is interrupt) == 53
         USB_EP2_TX_SIZE,0x00, //maximum packet size supported == 54,55
         10,  //polling interval, in ms.  (cant be smaller than 10 for slow speed devices) == 56
  };

   #define USB_NUM_HID_INTERFACES   1
   #define USB_MAX_NUM_INTERFACES   2

   const char USB_NUM_INTERFACES[USB_NUM_CONFIGURATIONS]={2};
   
   const int16 USB_CLASS_DESCRIPTORS[USB_NUM_CONFIGURATIONS][USB_NUM_HID_INTERFACES][1]=
   {
   //config 1
      //interface 0
         //class 1
         41
   };

   #if (sizeof(USB_CONFIG_DESC) != USB_TOTAL_CONFIG_LEN)
      #error USB_TOTAL_CONFIG_LEN not defined correctly
   #endif

   char const USB_DEVICE_DESC[] ={
         USB_DESC_DEVICE_LEN,          //the length of this report
         0x01,                //constant DEVICE (0x01)
         0x10,0x01,           //usb version in bcd
         0x00,                //class code (if 0, interface defines class.  FF is vendor defined)
         0x00,                //subclass code
         0x00,                //protocol code
         USB_MAX_EP0_PACKET_LENGTH,   //max packet size for endpoint 0. (SLOW SPEED SPECIFIES 8)
         0xD8,0x04,           //vendor id (0x04D8 is Microchip)
         0x10,0x01,           //product id, 0x0110 Lo que te salga de los cojones
         0x00, 0x01,//0x01,0x00,           //device release number
         0x01,                //index of string description of manufacturer. therefore we point to string_1 array (see below)
         0x02,                //index of string descriptor of the product
         0x00,                //index of string descriptor of serial number
         USB_NUM_CONFIGURATIONS   //number of possible configurations
   };

const char USB_STRING_DESC_OFFSET[]={0,4,12}; //el 12 sería 4 + 8 del string 1, si cambias el dato del 8, volver a cambiar a aquí la suma

#define USB_STRING_DESC_COUNT sizeof(USB_STRING_DESC_OFFSET)

char const USB_STRING_DESC[]={
   //string 0
         4, //length of string index
         USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
         0x09,0x04,   //Microsoft Defined for US-English
   //string 1 --> Lo que sea?
         8, //length of string index (número de letras + 1)*2->(3 + 1)*2=4*2=8
         USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
         'U',0,
         'S',0,
         'B',0,
   //string 2 --> nombre del dispositivo
         22, //length of string index (número de letras + 1)*2->(10 + 1)*2=11*2=22
         USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
         'P',0,
         'r',0,
         'o',0,
         'b',0,
         'a',0,
         'n',0,
         'd ',0,
         'o',0,
         '.',0,
         '.',0
};

Esto en el main:

//Para el LCD
#define USB_EP1_TX_ENABLE  USB_ENABLE_BULK
#define USB_EP1_RX_ENABLE  USB_ENABLE_BULK
#define USB_EP1_TX_SIZE    8
#define USB_EP1_RX_SIZE    8

//Para los botones
#DEFINE USB_HID_DEVICE  TRUE
#define USB_EP2_TX_ENABLE USB_ENABLE_INTERRUPT
#define USB_EP2_TX_SIZE 8

Ya no sé si tengo un fallo ahí o algún otro lugar. Supongo que pueden haber otros modos para conectar el LCD y los botones, pero ahí ni idea. El modo bulk más que nada para poder usar el msusbapi.dll.

Espero puedan ayudarme.

Un saludo.

Desconectado Modulay

  • Moderadores
  • DsPIC30
  • *****
  • Mensajes: 2651
Re: USB descriptor
« Respuesta #1 en: 17 de Octubre de 2008, 16:54:42 »
Para no confundirnos veo oportuno aclarar que el término "bulk" va asociado a los endpoints, no al tipo de dispositivo o al tipo de interfaz.

La solución: IAD...

// Interface Association Descriptor
         0x08,    // length
         0x0B,    // Interface assocication descriptor type
         0x00,    // The first associated interface
         0x01,    // Number of contiguous associated interface
         0x03,    // bInterfaceClass of the first interface
         0x01,    // bInterfaceSubclass of the first interface
         0x02,    // bInterfaceProtocol of the first interface
         0x00     // Interface string index

// Device descriptor
char const USB_DEVICE_DESC[] ={
         0x12,                // length
         0x01,                // constant DEVICE (0x01)
         0x00,0x02,           // usb version in bcd
         0xEF,                // class code
         0x02,                // subclass code
         0x01,                // protocol code
         ......
         ......
         ......


...teniendo presente que el descriptor IAD deberás llenarlo con los valores que se ajustan a tu dispositivo y sus interfaces.

Desconectado Crivi

  • PIC10
  • *
  • Mensajes: 9
Re: USB descriptor
« Respuesta #2 en: 18 de Octubre de 2008, 04:00:43 »
Buenas.

¿Tengo que crear un usb_device_desc por cada dispositivo?



Desconectado Modulay

  • Moderadores
  • DsPIC30
  • *****
  • Mensajes: 2651
Re: USB descriptor
« Respuesta #3 en: 18 de Octubre de 2008, 04:15:37 »
No. Sigues teniendo un dispositivo, pero con 2 interfaces asociadas
Simplemente añade el descriptor IAD y haz las modificaciones pertinentes al resto.

Desconectado Crivi

  • PIC10
  • *
  • Mensajes: 9
Re: USB descriptor
« Respuesta #4 en: 19 de Octubre de 2008, 06:59:47 »
Lo he estado probando y nada, sigue sin funcionar. ¿Sabes de algún tutorial que explique ese tema con más detalle?

Desconectado Modulay

  • Moderadores
  • DsPIC30
  • *****
  • Mensajes: 2651
Re: USB descriptor
« Respuesta #5 en: 19 de Octubre de 2008, 07:04:48 »
Postea todos los descriptores que usaste que echemos un ojo

Desconectado Modulay

  • Moderadores
  • DsPIC30
  • *****
  • Mensajes: 2651
Re: USB descriptor
« Respuesta #6 en: 19 de Octubre de 2008, 07:07:56 »
Se me olvidaba...IAD requiere XP SP2 o superior

Desconectado Crivi

  • PIC10
  • *
  • Mensajes: 9
Re: USB descriptor
« Respuesta #7 en: 19 de Octubre de 2008, 09:17:41 »
Pues va mal la cosa. De hecho le he puesto el que tenía por defecto porque no paraba de darme pantallazos azules. Ahora mismo tengo el xp sp3.
No sé si coger y ponerle los botones en otro pic aunque tenga que usar dos conectores usb.

Y otra duda a parte de la de arriba. Al tener dos interfaces. Con el hid se supone que no necesito drivers, pero con el otro si. ¿Habría que hacerle alguna modifcación al inf del driver?

En mi caso tengo esto:

[DeviceList]
%DESCRIPTION%=DriverInstall, USB\VID_04D8&PID_0110

No recuerdo dónde leí algo de añadirle &MI_00 al final de la línea. Pero como no sé para que sirve... Igual es ahí donde está el verdadero problema.

Desconectado Modulay

  • Moderadores
  • DsPIC30
  • *****
  • Mensajes: 2651
Re: USB descriptor
« Respuesta #8 en: 19 de Octubre de 2008, 10:35:37 »
El sp3 es superior al sp2, por lo que en teoría vale.
Yo he llegado a implementar 4 interfaces con un sólo pic con este método, por lo que poder, se puede.
Si windows no te llega a a reconocer el dispositivo (tampoco has especificado qué fallo te da ni en qué momento te lo da), el problema no está en cuestiones de drivers para el interfaz de clase VENDOR DEFINED que tienes, aparte de la de clase HID (la cual, al ser class compliant, no precisa driver).
Para encarar una implementación así, lo apropiado es que comiences implementando un dispositivo con una única interfaz (por ejemplo la de clase HID)...y una vez funcione bien, vayas añadiendo lo demás.
Si posteas los descriptores al completo podremos mirar los posibles errores

Desconectado Crivi

  • PIC10
  • *
  • Mensajes: 9
Re: USB descriptor
« Respuesta #9 en: 19 de Octubre de 2008, 11:11:54 »
Lo de descriptores al completo no sé muy bien a qué te refieres, porque ya estoy hecho un lío  :-)

Pero te pongo lo del hid, que funciona bien.

Código: [Seleccionar]
#IFNDEF __USB_DESCRIPTORS__
#DEFINE __USB_DESCRIPTORS__

#include <usb.h>

   const char USB_CLASS_SPECIFIC_DESC[] =
   {
      0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
      0x15, 0x00,                    // LOGICAL_MINIMUM (0)
      0x09, 0x04,                    // USAGE (Joystick)
      0xa1, 0x01,                    // COLLECTION (Application)
      0x05, 0x01,                    //   USAGE_PAGE (generic)
      0x05, 0x09,                    //   USAGE_PAGE (Button)
      0x19, 0x01,                    //   USAGE_MINIMUM (Button 1)
      0x29, 0x0C,                    //   USAGE_MAXIMUM (Button 12)
      0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
      0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
      0x75, 0x01,                    //   REPORT_SIZE (1) //1 bit por botón
      0x95, 0x0C,                    //   REPORT_COUNT (12) //12 botones x 1 bits = 12 bits
      0x55, 0x00,                    //   UNIT_EXPONENT (0)
      0x65, 0x00,                    //   UNIT (None)
      0x81, 0x02,                    //   INPUT (Data,Var,Abs)
      0x75, 0x01,                    //   REPORT_SIZE (1) //En el primer byte no caben los 12 bits, pero se envía otro byte para los demás
      0x95, 0x04,                    //   REPORT_COUNT (4) //4 bits a enviar
      0x81, 0x01,                    //   INPUT (Constant) - 4 bit padding
      0xc0                           // END_COLLECTION
   };
   
   const int16 USB_CLASS_SPECIFIC_DESC_LOOKUP[USB_NUM_CONFIGURATIONS][1] =
   {
         0
   };

   const int16 USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[USB_NUM_CONFIGURATIONS][1] =
   {
      sizeof(USB_CLASS_SPECIFIC_DESC)
   };

   #DEFINE USB_TOTAL_CONFIG_LEN      34

   const char USB_CONFIG_DESC[] = {
   //config_descriptor for config index 1
         USB_DESC_CONFIG_LEN, //length of descriptor size          ==1
         USB_DESC_CONFIG_TYPE, //constant CONFIGURATION (CONFIGURATION 0x02)     ==2
         USB_TOTAL_CONFIG_LEN,0, //size of all data returned for this config      ==3,4
         1, //number of interfaces this device supports       ==5
         0x01, //identifier for this configuration.  (IF we had more than one configurations)      ==6
         0x00, //index of string descriptor for this configuration      ==7
         0xC0, //bit 6=1 if self powered, bit 5=1 if supports remote wakeup (we don't), bits 0-4 unused and bit7=1         ==8
         0x32, //maximum bus power required (maximum milliamperes/2)  (0x32 = 100mA)

   //interface descriptor 1
         USB_DESC_INTERFACE_LEN, //length of descriptor      =10
         USB_DESC_INTERFACE_TYPE, //constant INTERFACE (INTERFACE 0x04)       =11
         0x00, //number defining this interface (IF we had more than one interface)    ==12
         0x00, //alternate setting     ==13
         1, //number of endpoins, except 0 (pic167xx has 3, but we dont have to use all).       ==14
         0x03, //class code, 03 = HID     ==15
         0x00, //subclass code //boot     ==16
         0x00, //protocol code      ==17
         0x00, //index of string descriptor for interface      ==18

   //class descriptor 1  (HID)
         USB_DESC_CLASS_LEN, //length of descriptor    ==19
         USB_DESC_CLASS_TYPE, //dscriptor type (0x21 == HID)      ==20
         0x00,0x01, //hid class release number (1.0) (try 1.10)      ==21,22
         0x00, //localized country code (0 = none)       ==23
         0x01, //number of hid class descrptors that follow (1)      ==24
         0x22, //report descriptor type (0x22 == HID)                ==25
         USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[0][0], 0x00, //length of report descriptor            ==26,27

   //endpoint descriptor
         USB_DESC_ENDPOINT_LEN, //length of descriptor                   ==28
         USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (ENDPOINT 0x05)          ==29
         0x81, //endpoint number and direction (0x81 = EP1 IN)       ==30
         USB_ENDPOINT_TYPE_INTERRUPT, //transfer type supported (0x03 is interrupt)         ==31
         USB_EP1_TX_SIZE,0x00, //maximum packet size supported                  ==32,33
         10  //polling interval, in ms.  (cant be smaller than 10 for slow speed devices)     ==34
   };


   #define USB_NUM_HID_INTERFACES   1
   #define USB_MAX_NUM_INTERFACES   1

   const char USB_NUM_INTERFACES[USB_NUM_CONFIGURATIONS]={1};
   const int16 USB_CLASS_DESCRIPTORS[USB_NUM_CONFIGURATIONS][USB_NUM_HID_INTERFACES][1]=
   {
         18
   };

   #if (sizeof(USB_CONFIG_DESC) != USB_TOTAL_CONFIG_LEN)
      #error USB_TOTAL_CONFIG_LEN not defined correctly
   #endif


const char USB_DEVICE_DESC[] = {
         //starts of with device configuration. only one possible
         USB_DESC_DEVICE_LEN, //the length of this report   ==1
         0x01, //the constant DEVICE (DEVICE 0x01)  ==2
         0x10,0x01, //usb version in bcd (pic167xx is 1.1) ==3,4
         0x00, //class code ==5
         0x00, //subclass code ==6
         0x00, //protocol code ==7
         USB_MAX_EP0_PACKET_LENGTH, //max packet size for endpoint 0. (SLOW SPEED SPECIFIES 8) ==8
         0xD8,0x04, //vendor id (0x04D8 is Microchip, or is it 0x0461 ??)
         0x10, 0x21,//product id  (0x18D1  //don't use ffff says usb-by-example guy.  oops
         0x10,0x21, //device release number  ==13,14
         0x01, //index of string description of manufacturer. therefore we point to string_1 array (see below)  ==15
         0x02, //index of string descriptor of the product  ==16
         0x00, //index of string descriptor of serial number  ==17
         USB_NUM_CONFIGURATIONS  //number of possible configurations  ==18
};

#if (sizeof(USB_DEVICE_DESC) != USB_DESC_DEVICE_LEN)
   #error USB_DESC_DEVICE_LEN not defined correctly
#endif

const char USB_STRING_DESC_OFFSET[]={0,4,12}; //el 12 sería 4 + 8 del string 1, si cambias el dato del 8, volver a cambiar a aquí la suma

#define USB_STRING_DESC_COUNT sizeof(USB_STRING_DESC_OFFSET)

char const USB_STRING_DESC[]={
   //string 0
         4, //length of string index
         USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
         0x09,0x04,   //Microsoft Defined for US-English
   //string 1 --> Lo que sea?
         8, //length of string index (número de letras + 1)*2->(3 + 1)*2=4*2=8
         USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
         'U',0,
         'S',0,
         'B',0,
   //string 2 --> nombre del dispositivo
         22, //length of string index (número de letras + 1)*2->(10 + 1)*2=11*2=22
         USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
         'P',0,
         'r',0,
         'o',0,
         'b',0,
         'a',0,
         'n',0,
         'd',0,
         'o',0,
         '.',0,
         '.',0
};

#endif

Con eso de ahí lo detecta como joystick, aunque solo se puedan ver los 12 botones. Que es lo que yo quiero.
Ahora sería añadir el resto, como en el ejemplo del ex_usb_scope, pero ahí es donde vienen todos mis errores.

Le digo al USB_CONFIG_DESC que tengo dos interfaces en vez de 1. Y meto el otro trozo de código de abajo, y ya no detecta el HID, solo el custom device. No sé que tocar para que me detecte las dos cosas.

El trozo este lo pongo después del HID:

Código: [Seleccionar]
   //interface descriptor 1
         USB_DESC_INTERFACE_LEN,  //length of descriptor ==1
         USB_DESC_INTERFACE_TYPE,      //constant INTERFACE (0x04)
         0x01,                //number defining this interface (IF we had more than one interface)
         0x00,                //alternate setting
         2,       //number of endpoints, not counting endpoint 0.
         0xFF,                //class code, FF = vendor defined
         0xFF,                //subclass code, FF = vendor
         0xFF,                //protocol code, FF = vendor
         0x00,                //index of string descriptor for interface

   //endpoint descriptor
         USB_DESC_ENDPOINT_LEN, //length of descriptor == 10
         USB_DESC_ENDPOINT_TYPE,     //constant ENDPOINT (0x05)
         0x82,              //endpoint number and direction (0x82 = EP2 IN)
         0x02,              //transfer type supported (0 is control, 1 is iso, 2 is bulk, 3 is interrupt)
         USB_EP2_TX_SIZE,0x00,         //maximum packet size supported
         0x01,              //polling interval in ms. (for interrupt transfers ONLY)

   //endpoint descriptor
         USB_DESC_ENDPOINT_LEN, //length of descriptor ==17
         USB_DESC_ENDPOINT_TYPE,     //constant ENDPOINT (0x05)
         0x02,              //endpoint number and direction (0x02 = EP2 OUT)
         0x02,              //transfer type supported (0 is control, 1 is iso, 2 is bulk, 3 is interrupt)
         USB_EP2_RX_SIZE,0x00,         //maximum packet size supported
         0x01              //polling interval in ms. (for interrupt transfers ONLY)  == 23

Pero no entiendo porqué no me detecta después el del HID.
« Última modificación: 19 de Octubre de 2008, 12:00:19 por Crivi »

Desconectado Modulay

  • Moderadores
  • DsPIC30
  • *****
  • Mensajes: 2651
Re: USB descriptor
« Respuesta #10 en: 19 de Octubre de 2008, 11:57:05 »
¿Tienes el problema al compilar el código o al enchufar el dispositivo al pc para que lo reconozca?
En ese último caso ¿te llega a pedir el driver para la interfaz del lcd o simplemente windows te tira error al intentar reconocer el dispositivo?
Cuando digo que pongas los descriptores al completo me refiero a que los pongas todos (todo el contenido del fichero .h en el que se supone que los tienes, incluyendo la implementación de las 2 interfaces que te lleva al error)

Desconectado Crivi

  • PIC10
  • *
  • Mensajes: 9
Re: USB descriptor
« Respuesta #11 en: 19 de Octubre de 2008, 12:08:24 »
El código compila bien, sin ningún tipo de error. Al enchufar el dispositivo. Con hid y la otra interface, me pide solo el driver para el LCD. Pero deja de detectar el del joystick. Arriba te he puesto algo más, que no he visto que ya había un mensaje tuyo. Está todo el fichero. Pero te pongo aquí todo el código nuevo con la modificación del de arriba, porque seguramente me esté dejando algo atrás y la verdad es que no lo veo.

Código: [Seleccionar]
#IFNDEF __USB_DESCRIPTORS__
#DEFINE __USB_DESCRIPTORS__

#include <usb.h>

   const char USB_CLASS_SPECIFIC_DESC[] =
   {
      0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
      0x15, 0x00,                    // LOGICAL_MINIMUM (0)
      0x09, 0x04,                    // USAGE (Joystick)
      0xa1, 0x01,                    // COLLECTION (Application)
      0x05, 0x01,                    //   USAGE_PAGE (generic)
      0x05, 0x09,                    //   USAGE_PAGE (Button)
      0x19, 0x01,                    //   USAGE_MINIMUM (Button 1)
      0x29, 0x0C,                    //   USAGE_MAXIMUM (Button 12)
      0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
      0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
      0x75, 0x01,                    //   REPORT_SIZE (1) //1 bit por botón
      0x95, 0x0C,                    //   REPORT_COUNT (12) //12 botones x 1 bits = 12 bits
      0x55, 0x00,                    //   UNIT_EXPONENT (0)
      0x65, 0x00,                    //   UNIT (None)
      0x81, 0x02,                    //   INPUT (Data,Var,Abs)
      0x75, 0x01,                    //   REPORT_SIZE (1) //En el primer byte no caben los 12 bits, pero se envía otro byte para los demás
      0x95, 0x04,                    //   REPORT_COUNT (4) //4 bits a enviar
      0x81, 0x01,                    //   INPUT (Constant) - 4 bit padding
      0xc0                           // END_COLLECTION
   };
   
   const int16 USB_CLASS_SPECIFIC_DESC_LOOKUP[USB_NUM_CONFIGURATIONS][1] =
   {
         0
   };

   const int16 USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[USB_NUM_CONFIGURATIONS][1] =
   {
      sizeof(USB_CLASS_SPECIFIC_DESC)
   };

   #DEFINE USB_TOTAL_CONFIG_LEN      57//34+23//34

   const char USB_CONFIG_DESC[] = {
   //config_descriptor for config index 1
         USB_DESC_CONFIG_LEN, //length of descriptor size          ==1
         USB_DESC_CONFIG_TYPE, //constant CONFIGURATION (CONFIGURATION 0x02)     ==2
         USB_TOTAL_CONFIG_LEN,0, //size of all data returned for this config      ==3,4
         2, //number of interfaces this device supports       ==5
         0x01, //identifier for this configuration.  (IF we had more than one configurations)      ==6
         0x00, //index of string descriptor for this configuration      ==7
         0xC0, //bit 6=1 if self powered, bit 5=1 if supports remote wakeup (we don't), bits 0-4 unused and bit7=1         ==8
         0x32, //maximum bus power required (maximum milliamperes/2)  (0x32 = 100mA)

   //interface descriptor 1
         USB_DESC_INTERFACE_LEN, //length of descriptor      =10
         USB_DESC_INTERFACE_TYPE, //constant INTERFACE (INTERFACE 0x04)       =11
         0x00, //number defining this interface (IF we had more than one interface)    ==12
         0x00, //alternate setting     ==13
         1, //number of endpoins, except 0 (pic167xx has 3, but we dont have to use all).       ==14
         0x03, //class code, 03 = HID     ==15
         0x01, //subclass code //boot     ==16
         0x02, //protocol code      ==17
         0x00, //index of string descriptor for interface      ==18

   //class descriptor 1  (HID)
         USB_DESC_CLASS_LEN, //length of descriptor    ==19
         USB_DESC_CLASS_TYPE, //dscriptor type (0x21 == HID)      ==20
         0x00,0x01, //hid class release number (1.0) (try 1.10)      ==21,22
         0x00, //localized country code (0 = none)       ==23
         0x01, //number of hid class descriptors that follow (1)      ==24
         0x22, //report descriptor type (0x22 == HID)                ==25
         USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[0][0], 0x00, //length of report descriptor            ==26,27

   //endpoint descriptor
         USB_DESC_ENDPOINT_LEN, //length of descriptor                   ==28
         USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (ENDPOINT 0x05)          ==29
         0x81, //endpoint number and direction (0x81 = EP1 IN)       ==30
         USB_ENDPOINT_TYPE_INTERRUPT, //transfer type supported (0x03 is interrupt)         ==31
         USB_EP1_TX_SIZE,0x00, //maximum packet size supported                  ==32,33
         10,  //polling interval, in ms.  (cant be smaller than 10 for slow speed devices)     ==34
   
   //************//
   //PARTE NUEVA
   //interface descriptor 1
         USB_DESC_INTERFACE_LEN,  //length of descriptor ==1
         USB_DESC_INTERFACE_TYPE,      //constant INTERFACE (0x04)
         0x01,                //number defining this interface (IF we had more than one interface)
         0x00,                //alternate setting
         2,       //number of endpoints, not counting endpoint 0.
         0xFF,                //class code, FF = vendor defined
         0xFF,                //subclass code, FF = vendor
         0xFF,                //protocol code, FF = vendor
         0x00,                //index of string descriptor for interface

   //endpoint descriptor
         USB_DESC_ENDPOINT_LEN, //length of descriptor == 10
         USB_DESC_ENDPOINT_TYPE,     //constant ENDPOINT (0x05)
         0x82,              //endpoint number and direction (0x82 = EP2 IN)
         0x02,              //transfer type supported (0 is control, 1 is iso, 2 is bulk, 3 is interrupt)
         USB_EP2_TX_SIZE,0x00,         //maximum packet size supported
         0x01,              //polling interval in ms. (for interrupt transfers ONLY)

   //endpoint descriptor
         USB_DESC_ENDPOINT_LEN, //length of descriptor ==17
         USB_DESC_ENDPOINT_TYPE,     //constant ENDPOINT (0x05)
         0x02,              //endpoint number and direction (0x02 = EP2 OUT)
         0x02,              //transfer type supported (0 is control, 1 is iso, 2 is bulk, 3 is interrupt)
         USB_EP2_RX_SIZE,0x00,         //maximum packet size supported
         0x01              //polling interval in ms. (for interrupt transfers ONLY)  == 23
   };

   #define USB_NUM_HID_INTERFACES   1
   #define USB_MAX_NUM_INTERFACES   2

   const char USB_NUM_INTERFACES[USB_NUM_CONFIGURATIONS]={1};
   const int16 USB_CLASS_DESCRIPTORS[USB_NUM_CONFIGURATIONS][USB_NUM_HID_INTERFACES][1]=
   {
         18
   };

   #if (sizeof(USB_CONFIG_DESC) != USB_TOTAL_CONFIG_LEN)
      #error USB_TOTAL_CONFIG_LEN not defined correctly
   #endif


const char USB_DEVICE_DESC[] = {
         //starts of with device configuration. only one possible
         USB_DESC_DEVICE_LEN, //the length of this report   ==1
         0x01, //the constant DEVICE (DEVICE 0x01)  ==2
         0x10,0x01, //usb version in bcd (pic167xx is 1.1) ==3,4
         0x00, //class code ==5
         0x00, //subclass code ==6
         0x00, //protocol code ==7
         USB_MAX_EP0_PACKET_LENGTH, //max packet size for endpoint 0. (SLOW SPEED SPECIFIES 8) ==8
         0xD8,0x04, //vendor id (0x04D8 is Microchip, or is it 0x0461 ??)
         0x11, 0x22,//product id  (0x18D1  //don't use ffff says usb-by-example guy.  oops
         0x10,0x21, //device release number  ==13,14
         0x01, //index of string description of manufacturer. therefore we point to string_1 array (see below)  ==15
         0x02, //index of string descriptor of the product  ==16
         0x00, //index of string descriptor of serial number  ==17
         USB_NUM_CONFIGURATIONS  //number of possible configurations  ==18
};

#if (sizeof(USB_DEVICE_DESC) != USB_DESC_DEVICE_LEN)
   #error USB_DESC_DEVICE_LEN not defined correctly
#endif

const char USB_STRING_DESC_OFFSET[]={0,4,12}; //el 12 sería 4 + 8 del string 1, si cambias el dato del 8, volver a cambiar a aquí la suma

#define USB_STRING_DESC_COUNT sizeof(USB_STRING_DESC_OFFSET)

char const USB_STRING_DESC[]={
   //string 0
         4, //length of string index
         USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
         0x09,0x04,   //Microsoft Defined for US-English
   //string 1 --> Lo que sea?
         8, //length of string index (número de letras + 1)*2->(3 + 1)*2=4*2=8
         USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
         'U',0,
         'S',0,
         'B',0,
   //string 2 --> nombre del dispositivo
         22, //length of string index (número de letras + 1)*2->(10 + 1)*2=11*2=22
         USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
         'P',0,
         'r',0,
         'o',0,
         'b',0,
         'a',0,
         'n',0,
         'd',0,
         'o',0,
         '.',0,
         '.',0
};
#endif

A simple vista, y después de mirarme todo esto un montón de veces, es que no le veo el fallo por ningún sitio. Y mira que estoy siguiendo paso a paso los pdfs de la web usb.org que explican todo el tema del HID.
« Última modificación: 19 de Octubre de 2008, 12:53:26 por Crivi »

Desconectado Modulay

  • Moderadores
  • DsPIC30
  • *****
  • Mensajes: 2651
Re: USB descriptor
« Respuesta #12 en: 19 de Octubre de 2008, 12:34:05 »
Ok luego lo miro con más tranquilidad a ver si veo algo raro

Desconectado Modulay

  • Moderadores
  • DsPIC30
  • *****
  • Mensajes: 2651
Re: USB descriptor
« Respuesta #13 en: 20 de Octubre de 2008, 06:18:33 »
No veo el descriptor IAD, y tampoco las modificaciones que hay que hacer al descriptor de dispositivo

///////////////////////////////////// IAD //////////////////////////////////////

Este descriptor puedes ponerlo después de los descriptores de endpoint del interfaz VENDOR DEFINED, dentro del descriptor de configuración (todos los descriptores,excepto descriptor de dispositivo,reports de interfaces HID y descriptor de strings, están dentro del descriptor de configuración)

// Interface Association Descriptor
         0x08,    // length
         0x0B,    // Interface assocication descriptor type
         0x00,    // The first associated interface - Interfaz 0
         0x01,    // Number of contiguous associated interface - Número de interfaces asociadas a la interfaz 0
         0x03,    // bInterfaceClass of the first interface - Clase del interfaz 0 (HID)
         0x01,    // bInterfaceSubclass of the first interface - Subclase del interfaz 0
         0x02,    // bInterfaceProtocol of the first interface - Protocolo del interfaz 0
         0x00     // Interface string index

}; // Fin del descriptor de configuración



//////////////////////////////// DEVICE ////////////////////////////////////////

Descriptor de dispositivo

// Device descriptor
char const USB_DEVICE_DESC[] ={
         0x12,                // length
         0x01,                // constant DEVICE (0x01)
         0x00,0x02,           // usb version in bcd: 2.0
         0xEF,                // class code
         0x02,                // subclass code
         0x01,                // protocol code
         USB_MAX_EP0_PACKET_LENGTH,   // max packet size for endpoint 0.
         0xD8,0x04,           // vendor id
         0x11,0x22,           // product id
         0x01,0x00,           // device release number
         0x01,                // index of string description of manufacturer.
         0x02,                // index of string descriptor of the product
         0x00,                // index of string descriptor of serial number
         USB_NUM_CONFIGURATIONS   // number of possible configurations
};



Te lo pongo todo para que copies y pegues

Código: C++
  1. #IFNDEF __USB_DESCRIPTORS__
  2. #DEFINE __USB_DESCRIPTORS__
  3.  
  4. #include <usb.h>
  5.  
  6.    const char USB_CLASS_SPECIFIC_DESC[] =
  7.    {
  8.       0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
  9.       0x15, 0x00,                    // LOGICAL_MINIMUM (0)
  10.       0x09, 0x04,                    // USAGE (Joystick)
  11.       0xa1, 0x01,                    // COLLECTION (Application)
  12.       0x05, 0x01,                    //   USAGE_PAGE (generic)
  13.       0x05, 0x09,                    //   USAGE_PAGE (Button)
  14.       0x19, 0x01,                    //   USAGE_MINIMUM (Button 1)
  15.       0x29, 0x0C,                    //   USAGE_MAXIMUM (Button 12)
  16.       0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
  17.       0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
  18.       0x75, 0x01,                    //   REPORT_SIZE (1) //1 bit por botón
  19.       0x95, 0x0C,                    //   REPORT_COUNT (12) //12 botones x 1 bits = 12 bits
  20.       0x55, 0x00,                    //   UNIT_EXPONENT (0)
  21.       0x65, 0x00,                    //   UNIT (None)
  22.       0x81, 0x02,                    //   INPUT (Data,Var,Abs)
  23.       0x75, 0x01,                    //   REPORT_SIZE (1) //En el primer byte no caben los 12 bits, pero se envía otro byte para los demás
  24.       0x95, 0x04,                    //   REPORT_COUNT (4) //4 bits a enviar
  25.       0x81, 0x01,                    //   INPUT (Constant) - 4 bit padding
  26.       0xc0                           // END_COLLECTION
  27.    };
  28.    
  29.    const int16 USB_CLASS_SPECIFIC_DESC_LOOKUP[USB_NUM_CONFIGURATIONS][1] =
  30.    {
  31.          0
  32.    };
  33.  
  34.    const int16 USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[USB_NUM_CONFIGURATIONS][1] =
  35.    {
  36.       sizeof(USB_CLASS_SPECIFIC_DESC)
  37.    };
  38.  
  39.    #DEFINE USB_TOTAL_CONFIG_LEN     65
  40.  
  41.    const char USB_CONFIG_DESC[] = {
  42.    //config_descriptor for config index 1
  43.          USB_DESC_CONFIG_LEN, //length of descriptor size          ==1
  44.          USB_DESC_CONFIG_TYPE, //constant CONFIGURATION (CONFIGURATION 0x02)     ==2
  45.          USB_TOTAL_CONFIG_LEN,0, //size of all data returned for this config      ==3,4
  46.          2, //number of interfaces this device supports       ==5
  47.          0x01, //identifier for this configuration.  (IF we had more than one configurations)      ==6
  48.          0x00, //index of string descriptor for this configuration      ==7
  49.          0xC0, //bit 6=1 if self powered, bit 5=1 if supports remote wakeup (we don't), bits 0-4 unused and bit7=1         ==8
  50.          0x32, //maximum bus power required (maximum milliamperes/2)  (0x32 = 100mA)
  51.  
  52.    //interface descriptor 1
  53.          USB_DESC_INTERFACE_LEN, //length of descriptor      =10
  54.          USB_DESC_INTERFACE_TYPE, //constant INTERFACE (INTERFACE 0x04)       =11
  55.          0x00, //number defining this interface (IF we had more than one interface)    ==12
  56.          0x00, //alternate setting     ==13
  57.          1, //number of endpoins, except 0 (pic167xx has 3, but we dont have to use all).       ==14
  58.          0x03, //class code, 03 = HID     ==15
  59.          0x01, //subclass code //boot     ==16
  60.          0x02, //protocol code      ==17
  61.          0x00, //index of string descriptor for interface      ==18
  62.  
  63.    //class descriptor 1  (HID)
  64.          USB_DESC_CLASS_LEN, //length of descriptor    ==19
  65.          USB_DESC_CLASS_TYPE, //dscriptor type (0x21 == HID)      ==20
  66.          0x00,0x01, //hid class release number (1.0) (try 1.10)      ==21,22
  67.          0x00, //localized country code (0 = none)       ==23
  68.          0x01, //number of hid class descriptors that follow (1)      ==24
  69.          0x22, //report descriptor type (0x22 == HID)                ==25
  70.          USB_CLASS_SPECIFIC_DESC_LOOKUP_SIZE[0][0], 0x00, //length of report descriptor            ==26,27
  71.  
  72.    //endpoint descriptor
  73.          USB_DESC_ENDPOINT_LEN, //length of descriptor                   ==28
  74.          USB_DESC_ENDPOINT_TYPE, //constant ENDPOINT (ENDPOINT 0x05)          ==29
  75.          0x81, //endpoint number and direction (0x81 = EP1 IN)       ==30
  76.          USB_ENDPOINT_TYPE_INTERRUPT, //transfer type supported (0x03 is interrupt)         ==31
  77.          USB_EP1_TX_SIZE,0x00, //maximum packet size supported                  ==32,33
  78.          10,  //polling interval, in ms.  (cant be smaller than 10 for slow speed devices)     ==34
  79.    
  80.    //************//
  81.    //PARTE NUEVA
  82.    //interface descriptor 1
  83.          USB_DESC_INTERFACE_LEN,  //length of descriptor ==1
  84.          USB_DESC_INTERFACE_TYPE,      //constant INTERFACE (0x04)
  85.          0x01,                //number defining this interface (IF we had more than one interface)
  86.          0x00,                //alternate setting
  87.          2,       //number of endpoints, not counting endpoint 0.
  88.          0xFF,                //class code, FF = vendor defined
  89.          0xFF,                //subclass code, FF = vendor
  90.          0xFF,                //protocol code, FF = vendor
  91.          0x00,                //index of string descriptor for interface
  92.  
  93.    //endpoint descriptor
  94.          USB_DESC_ENDPOINT_LEN, //length of descriptor == 10
  95.          USB_DESC_ENDPOINT_TYPE,     //constant ENDPOINT (0x05)
  96.          0x82,              //endpoint number and direction (0x82 = EP2 IN)
  97.          0x02,              //transfer type supported (0 is control, 1 is iso, 2 is bulk, 3 is interrupt)
  98.          USB_EP2_TX_SIZE,0x00,         //maximum packet size supported
  99.          0x01,              //polling interval in ms. (for interrupt transfers ONLY)
  100.  
  101.    //endpoint descriptor
  102.          USB_DESC_ENDPOINT_LEN, //length of descriptor ==17
  103.          USB_DESC_ENDPOINT_TYPE,     //constant ENDPOINT (0x05)
  104.          0x02,              //endpoint number and direction (0x02 = EP2 OUT)
  105.          0x02,              //transfer type supported (0 is control, 1 is iso, 2 is bulk, 3 is interrupt)
  106.          USB_EP2_RX_SIZE,0x00,         //maximum packet size supported
  107.          0x01              //polling interval in ms. (for interrupt transfers ONLY)  == 23
  108.  
  109. // Interface Association Descriptor
  110.          0x08,    // length
  111.          0x0B,    // Interface assocication descriptor type
  112.          0x00,    // The first associated interface - Interfaz HID
  113.          0x01,    // Number of contiguous associated interface - Número de interfaces asociadas a la interfaz HID
  114.          0x03,    // bInterfaceClass of the first interface - Clase del interfaz HID
  115.          0x01,    // bInterfaceSubclass of the first interface - Subclase del interfaz HID
  116.          0x02,    // bInterfaceProtocol of the first interface - Protocolo del interfaz HID
  117.          0x00     // Interface string index
  118.  
  119.    };
  120.  
  121.    #define USB_NUM_HID_INTERFACES   1
  122.    #define USB_MAX_NUM_INTERFACES   2
  123.  
  124.    const char USB_NUM_INTERFACES[USB_NUM_CONFIGURATIONS]={1};
  125.    const int16 USB_CLASS_DESCRIPTORS[USB_NUM_CONFIGURATIONS][USB_NUM_HID_INTERFACES][1]=
  126.    {
  127.          18
  128.    };
  129.  
  130.    #if (sizeof(USB_CONFIG_DESC) != USB_TOTAL_CONFIG_LEN)
  131.       #error USB_TOTAL_CONFIG_LEN not defined correctly
  132.    #endif
  133.  
  134.  
  135. const char USB_DEVICE_DESC[] = {
  136.          //starts of with device configuration. only one possible
  137.          USB_DESC_DEVICE_LEN, //the length of this report   ==1
  138.          0x01, //the constant DEVICE (DEVICE 0x01)  ==2
  139.          0x00,0x02, //usb version: 2.0
  140.          0xEF, //class code
  141.          0x02, //subclass code
  142.          0x01, //protocol code
  143.          USB_MAX_EP0_PACKET_LENGTH, //max packet size for endpoint 0. (SLOW SPEED SPECIFIES 8) ==8
  144.          0xD8,0x04, //vendor id (0x04D8 is Microchip, or is it 0x0461 ??)
  145.          0x11, 0x22,//product id  (0x18D1  //don't use ffff says usb-by-example guy.  oops
  146.          0x10,0x21, //device release number  ==13,14
  147.          0x01, //index of string description of manufacturer. therefore we point to string_1 array (see below)  ==15
  148.          0x02, //index of string descriptor of the product  ==16
  149.          0x00, //index of string descriptor of serial number  ==17
  150.          USB_NUM_CONFIGURATIONS  //number of possible configurations  ==18
  151. };
  152.  
  153. #if (sizeof(USB_DEVICE_DESC) != USB_DESC_DEVICE_LEN)
  154.    #error USB_DESC_DEVICE_LEN not defined correctly
  155. #endif
  156.  
  157. const char USB_STRING_DESC_OFFSET[]={0,4,12}; //el 12 sería 4 + 8 del string 1, si cambias el dato del 8, volver a cambiar a aquí la suma
  158.  
  159. #define USB_STRING_DESC_COUNT sizeof(USB_STRING_DESC_OFFSET)
  160.  
  161. char const USB_STRING_DESC[]={
  162.    //string 0
  163.          4, //length of string index
  164.          USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
  165.          0x09,0x04,   //Microsoft Defined for US-English
  166.    //string 1 --> Lo que sea?
  167.          8, //length of string index (número de letras + 1)*2->(3 + 1)*2=4*2=8
  168.          USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
  169.          'U',0,
  170.          'S',0,
  171.          'B',0,
  172.    //string 2 --> nombre del dispositivo
  173.          22, //length of string index (número de letras + 1)*2->(10 + 1)*2=11*2=22
  174.          USB_DESC_STRING_TYPE, //descriptor type 0x03 (STRING)
  175.          'P',0,
  176.          'r',0,
  177.          'o',0,
  178.          'b',0,
  179.          'a',0,
  180.          'n',0,
  181.          'd',0,
  182.          'o',0,
  183.          '.',0,
  184.          '.',0
  185. };
  186. #endif

Desconectado Crivi

  • PIC10
  • *
  • Mensajes: 9
Re: USB descriptor
« Respuesta #14 en: 24 de Octubre de 2008, 05:14:24 »
Eso es lo que tenía hecho y es lo que me daba los pantallazos azules. Al final lo he tenido que hacer en dos circuitos porque no encontraba el fallo. De todas maneras gracias por la ayuda.