打印
[应用相关]

USB HID照着圈圈的做的,可以只能IN不能OUT

[复制链接]
4390|8
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
coslight|  楼主 | 2009-5-21 21:09 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
我用的是圈圈做的USB HID的配置,可是在我的程序上只能在端点1发送数据,端点2确收不到数据,感觉中断也没有。不知道是什么原因,请香版主和圈圈帮我看看是咋回事。
const u8 CustomHID_DeviceDescriptor[CUSTOMHID_SIZ_DEVICE_DESC] =
  {
    0x12,                       /*bLength */
    USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/
    0x10,                       /*bcdUSB */
    0x01,
    0x00,                       /*bDeviceClass*/
    0x00,                       /*bDeviceSubClass*/
    0x00,                       /*bDeviceProtocol*/
    0x40,                       /*bMaxPacketSize40*/
    0x83,                       /*idVendor (0x0483)*/
    0x04,
    0x50,                       /*idProduct = 0x5750*/
    0x57,
    0x00,                       /*bcdDevice rel. 2.00*/
    0x02,
    1,                          /*Index of string descriptor describing
                                              manufacturer */
    2,                          /*Index of string descriptor describing
                                             product*/
    3,                          /*Index of string descriptor describing the
                                             device serial number */
    0x01                        /*bNumConfigurations*/
  }
  ; /* 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 */
    0x00,
    0x01,         /* bNumInterfaces: 1 interface */
    0x01,         /* bConfigurationValue: Configuration value */
    0x00,         /* iConfiguration: Index of string descriptor describing
                                 the configuration*/
    0x40,         /* bmAttributes: Bus powered */
    0x32,         /* MaxPower 100 mA: this current is used for detecting Vbus */

    /************** Descriptor of Custom HID interface ****************/
    /* 09 */
    0x09,         /* bLength: Interface Descriptor size */
    USB_INTERFACE_DESCRIPTOR_TYPE,/* bDescriptorType: Interface descriptor type */
    0x00,         /* bInterfaceNumber: Number of Interface */
    0x00,         /* bAlternateSetting: Alternate setting */
    0x02,         /* bNumEndpoints */
    0x03,         /* bInterfaceClass: HID */
    0x00,         /* bInterfaceSubClass : 1=BOOT, 0=no boot */
    0x00,         /* nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse */
    0,            /* iInterface: Index of string descriptor */
    /******************** Descriptor of Custom HID HID ********************/
    /* 18 */
    0x09,         /* bLength: HID Descriptor size */
    HID_DESCRIPTOR_TYPE, /* bDescriptorType: HID */
    0x10,         /* bcdHID: HID Class Spec release number */
    0x01,
    0x00,         /* bCountryCode: Hardware target country */
    0x01,         /* bNumDescriptors: Number of HID class descriptors to follow */
    0x22,         /* bDescriptorType */
    CUSTOMHID_SIZ_REPORT_DESC,/* wItemLength: Total length of Report descriptor */
    0x00,
    /******************** Descriptor of Custom HID endpoints ******************/
    /* 27 */
    0x07,          /* bLength: Endpoint Descriptor size */
    USB_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType: */

    0x81,          /* bEndpointAddress: Endpoint Address (IN) */
    0x03,          /* bmAttributes: Interrupt endpoint */
    0x40,          /* wMaxPacketSize: 64 Bytes max */
    0x00,
    0x20,          /* bInterval: Polling Interval (32 ms) */
    /* 34 */
        
    0x07,    /* bLength: Endpoint Descriptor size */
    USB_ENDPOINT_DESCRIPTOR_TYPE,    /* bDescriptorType: */
            /*    Endpoint descriptor type */
    0x02,    /* bEndpointAddress: */
            /*    Endpoint Address (OUT) */
    0x03,    /* bmAttributes: Interrupt endpoint */
    0x40,    /* wMaxPacketSize: 64 Bytes max  */
    0x00,
    0x14,    /* bInterval: Polling Interval (20 ms) */
    /* 41 */
  }
  ; /* CustomHID_ConfigDescriptor */
const u8 CustomHID_ReportDescriptor[CUSTOMHID_SIZ_REPORT_DESC] =
  {    
    0x05, 0xFF,            /* USAGE_PAGE (User Define)           */                   
    0x09, 0xFF,            /* USAGE (User Define )               */    
    0xa1, 0x01,            /* COLLECTION (Application)       */            
    /* 6 */
    /*in*/    
    0x05, 0x01,                    // USAGE_PAGE(1)
    0x19, 0x00,                    //   USAGE_MINIMUM(0)
    0x29, 0xFF,                    //   USAGE_MAXIMUM(255)
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x25, 0xFF,                    //   LOGICAL_MAXIMUM (255)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x95, 0x40,                    //   REPORT_COUNT (64)
    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
    /*22*/
    /*out*/
    0x05, 0x02,                    // USAGE_PAGE(2)
    0x19, 0x00,                    //   USAGE_MINIMUM (0)
    0x29, 0xFF,                    //   USAGE_MAXIMUM (255)
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x25, 0xFF,                    //   LOGICAL_MAXIMUM (255)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x95, 0x40,                    //   REPORT_COUNT (64)
    0x91, 0x02,                    //   OUTPUT (Data,Var,Abs)
    /* 38 */

    0xc0               /*     END_COLLECTION                 */
  }; /* CustomHID_ReportDescriptor */
沙发
coslight|  楼主 | 2009-5-22 08:44 | 只看该作者

香版主和圈圈帮忙看看啊

不知道错处在那里,EP2的out我已经处理了,就是没有反应

使用特权

评论回复
板凳
coslight|  楼主 | 2009-5-22 09:45 | 只看该作者

我发现了一个问题

如果把EP2改为EP1的话就可以正常接收了,但是EP2就不可以正常接收到PC的数据,不明白怎么回事,相应的配置都改了

EP2    0x02,    /* bEndpointAddress: */
EP1    0x01,    /* bEndpointAddress: */

使用特权

评论回复
地板
computer00| | 2009-5-22 09:46 | 只看该作者

是你的端点初始化不正确吧?

使用特权

评论回复
5
coslight|  楼主 | 2009-5-22 10:27 | 只看该作者

我都是按你的例子搞的

我现在设成IN和OUT都是EP1的话可以收发,但是只能收到PC的一个字节,而且如果1分钟左右如果没有数据交换就不在响应中断了,为什么

使用特权

评论回复
6
computer00| | 2009-5-22 12:49 | 只看该作者

搞不懂...你直接把我的hex文件烧进去运行可以不?

使用特权

评论回复
7
coslight|  楼主 | 2009-5-22 20:08 | 只看该作者

解决的一部分问题,但是还有点问题

有一个1.5K电阻使能的问题,不能同时用。
不过我现在把IN和OUT都用EP1,感觉挺好,收发都正常了,只能收到一个字节的问题搞明白了,是我把接收到用户内存拷贝的过程拷少了,所以不对,改正后正常了。
      PMAToUserBufferCopy(USB_ReceBuf, ENDP1_RXADDR, 2);

不过时间长不访问EP1端点后,任然有再访问不能产生接收中断的问题。

使用特权

评论回复
8
zhujian_sz| | 2009-11-3 11:06 | 只看该作者
不过时间长不访问EP1端点后,任然有再访问不能产生接收中断的问题。


我也是这个问题 LZ这个问题解决了吗, 如果解决了  告诉我下为什么阿  急!!!!!

使用特权

评论回复
9
javasdk| | 2010-7-22 18:09 | 只看该作者
关注

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

61

主题

927

帖子

5

粉丝