TODOPIC

Microcontroladores PIC => Todo en microcontroladores PIC => Mensaje iniciado por: Joaquín en 11 de Enero de 2007, 07:53:21

Título: Endpoints USB en pic 18F2550
Publicado por: Joaquín en 11 de Enero de 2007, 07:53:21
Hola, estoy intentando definir dos endpoints USB en un pic 18F2550.

Estoy usando CCS y me estoy basando en el PICUSB de JIM.

He añadido en el fichero PICUSB.h las líneas correspondientes para definir un endpoint nuevo, os las pego aquí
   //endpoint descriptor
    //ep_recepcion1
         USB_DESC_ENDPOINT_LEN, //length of descriptor
         USB_DESC_ENDPOINT_TYPE,     //constant ENDPOINT (0x05)
         0x81,              //endpoint number and direction (0x81 = EP1 IN)
         0x02,              //transfer type supported (0 is control, 1 is iso, 2 is bulk, 3 is interrupt)
         USB_EP1_TX_SIZE,0x00,         //maximum packet size supported
         0x01,              //polling interval in ms. (for interrupt transfers ONLY)
   //endpoint descriptor
    //ep_recepcion2
         USB_DESC_ENDPOINT_LEN, //length of descriptor
         USB_DESC_ENDPOINT_TYPE,     //constant ENDPOINT (0x05)
         0x82,              //endpoint number and direction (0x81 = EP1 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
    //ep_transmision1
         USB_DESC_ENDPOINT_LEN, //length of descriptor
         USB_DESC_ENDPOINT_TYPE,     //constant ENDPOINT (0x05)
         0x01,              //endpoint number and direction (0x01 = EP1 OUT)
         0x02,              //transfer type supported (0 is control, 1 is iso, 2 is bulk, 3 is interrupt)
         USB_EP1_RX_SIZE,0x00,         //maximum packet size supported
         0x01,              //polling interval in ms. (for interrupt transfers ONLY)
   //endpoint descriptor
    //ep_transmision2
         USB_DESC_ENDPOINT_LEN, //length of descriptor
         USB_DESC_ENDPOINT_TYPE,     //constant ENDPOINT (0x05)
         0x02,              //endpoint number and direction (0x01 = EP1 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)

¿Está bien así, o cambia el orden?

En el fichero PICUSB.c tengo los siguientes defines:

#define USB_HID_DEVICE     FALSE             //deshabilitamos el uso de las directivas HID
//ENDOPINT 1
#define USB_EP1_TX_ENABLE  USB_ENABLE_BULK   //turn on EP1(EndPoint1) for IN bulk/interrupt transfers
#define USB_EP1_RX_ENABLE  USB_ENABLE_BULK   //turn on EP1(EndPoint1) for OUT bulk/interrupt transfers
#define USB_EP1_TX_SIZE    1                 //size to allocate for the tx endpoint 1 buffer
#define USB_EP1_RX_SIZE    1              //size to allocate for the rx endpoint 1 buffer

//ENDPOINT 2
#define USB_EP2_TX_ENABLE  USB_ENABLE_BULK   //turn on EP1(EndPoint1) for IN bulk/interrupt transfers
#define USB_EP2_RX_ENABLE  USB_ENABLE_BULK   //turn on EP1(EndPoint1) for OUT bulk/interrupt transfers
#define USB_EP2_TX_SIZE    64                 //size to allocate for the tx endpoint 1 buffer
#define USB_EP2_RX_SIZE    64              //size to allocate for the rx endpoint 1 buffer

EL problema que tengo es que no me transmite ni recibe por ningún endpoint.

Si hace falta el código completo o alguna cosa más pedírmela.

Un saludo y gracias.
Título: Re: Endpoints USB en pic 18F2550
Publicado por: Joaquín en 13 de Enero de 2007, 08:19:14
Hola de nuevo.

Se me ha ocurrido una solución poco ortodoxa pero creo que me servirá.

Consiste en usar sólo dos endpoints, uno de entrada y otro de saldia, como en el picusb y pasarle por los dos primeros bytes de cada paquete lo que quiero que haga con ellos. Sé que no es la solución más adecuada, pero creo que puede servirme. Cuando lo pruebe os lo comento por si a alguien le sirve de algo.

Saludos.

Joaquín.