打印
[应用相关]

改Joystic实现USB收发数据出现问题

[复制链接]
1768|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
zxw001|  楼主 | 2008-12-22 11:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
ST, USB, ic, TI, TE
usb_desc.c 中改的地方 
/******************** Descriptor of USBCom endpoint 1 ********************/
    /* 18 */
    0x07,                              /*bLength: Endpoint Descriptor size*/
    USB_ENDPOINT_DESCRIPTOR_TYPE,         /*bDescriptorType:*/

    0x81,                          /*bEndpointAddress: Endpoint Address (IN)*/
    0x03,                          /*bmAttributes: Interrupt endpoint*/
    0x10,                          /*wMaxPacketSize: 16 Byte max */
    0x00,
    0x20,                          /*bInterval: Polling Interval (32 ms)*/
  /******************** Descriptor of USBCom endpoint 2********************/
    /* 25 */
    0x07,                          /*bLength: Endpoint Descriptor size*/
    USB_ENDPOINT_DESCRIPTOR_TYPE,         /*bDescriptorType:*/

    0x02,                          /*bEndpointAddress: Endpoint Address (OUT)*/
    0x03,                          /*bmAttributes: Interrupt endpoint*/
    0x10,                          /*wMaxPacketSize: 16 Byte max */
    0x00,
    0x20,                          /*bInterval: Polling Interval (32 ms)*/
    /* 32 */
  }
  ;                         /* MOUSE_ConfigDescriptor */

usb_desc.h 也改了描述 #define USBCOM_SIZ_CONFIG_DESC                32

usb_prop.c中也改了
*******************************************************************************/
void USBCom_Reset(void)
{
                                                                                /* Set USBCom_DEVICE as not configured */
  pInformation->Current_Configuration = 0;
  pInformation->Current_Interface = 0;                                          /*the default Interface*/
  SetBTABLE(BTABLE_ADDRESS);

                                                                                /* Initialize Endpoint 0 */
  SetEPType(ENDP0, EP_CONTROL);
  SetEPTxStatus(ENDP0, EP_TX_STALL);
  SetEPRxAddr(ENDP0, ENDP0_RXADDR);
  SetEPTxAddr(ENDP0, ENDP0_TXADDR);
  Clear_Status_Out(ENDP0);
  SetEPRxCount(ENDP0, Device_Property.MaxPacketSize);
  SetEPRxValid(ENDP0);
                                                                     /* Initialize Endpoint 1 */
  SetEPType(ENDP1, EP_INTERRUPT);
  SetEPTxAddr(ENDP1, ENDP1_TXADDR);
  SetEPTxCount(ENDP1, 16);
  SetEPRxStatus(ENDP1, EP_RX_DIS);
  SetEPTxStatus(ENDP1, EP_TX_NAK);
                          /* Initialize Endpoint 2 */
  SetEPType(ENDP2, EP_INTERRUPT);
  SetEPTxAddr(ENDP2, ENDP2_RXADDR);
  SetEPTxCount(ENDP2, 16);
  SetEPRxStatus(ENDP2, EP_TX_DIS);
  SetEPTxStatus(ENDP2, EP_RX_NAK);

  
  SetDeviceAddress(0);                                                                            /* Set this device to response on default address */
}

usb_config.h 中的改动
#define EP_NUM     (3)

/*-------------------------------------------------------------*/
/* --------------   Buffer Description Table  -----------------*/
/*-------------------------------------------------------------*/
/* buffer table base address */
/* buffer table base address */
#define BTABLE_ADDRESS      (0x00)

/* EP0  */
/* rx/tx buffer base address */
#define ENDP0_RXADDR        (0x18)
#define ENDP0_TXADDR        (0x58)

/* EP1  */
/* tx buffer base address */
#define ENDP1_TXADDR        (0x100)
#define ENDP1_RXADDR        (0x140)

#define ENDP2_TXADDR        (0x180)
#define ENDP2_RXADDR        (0x1C0)

主函数中写了一个发射,一个接收函数。USB向PC发没有问题,能发16Bytes的数据,但是程序执行到接收程序(PC->USB一次发16Bytes)就出现硬件故障。PC->USB,发1Byte可以实现。一改,只要不是1byte就死机,为什么?如何设置才能实现收发实现16byte的功能?请大家帮帮忙!!!
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

1

主题

1

帖子

0

粉丝