程序是原子例程的触控鼠标改的,就修改了下描述文件。把LCD显示去掉。
改完之后PC上位机可以收到下位机发出的数据,可是上位机不能发给你下位机
上位机软件上点发送,显示发出数据字节数为-1,这点很不解,什么意思呢。
球高手解答
const uint8_t Joystick_DeviceDescriptor[JOYSTICK_SIZ_DEVICE_DESC] =
{
0x12, /*bLength */
USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType 描述符类型,设备描述符为0x01*/
0x00, /*bcdUSB USB版本*/
0x02,
0x00, /*bDeviceClass*/
0x00, /*bDeviceSubClass*/
0x00, /*bDeviceProtocol*/
0x40, /*bMaxPacketSize 64 端点0最大包长*/
0x83, /*idVendor (0x0483)*/
0x04,
0x50, /*idProduct = 0x5710*/
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*/
}
; /* Joystick_DeviceDescriptor */
/* USB Configuration Descriptor */
/* All Descriptors (Configuration, Interface, Endpoint, Class, Vendor */
//配置描述符
const uint8_t Joystick_ConfigDescriptor[JOYSTICK_SIZ_CONFIG_DESC] =
{
0x09, /* bLength: Configuration Descriptor size */
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
JOYSTICK_SIZ_CONFIG_DESC, 0x00,/* wTotalLength: Bytes returned */
0x01, /*bNumInterfaces: 1 interface*/
0x01, /*bConfigurationValue: Configuration value*/
0x00, /*iConfiguration: Index of string descriptor describing
the configuration*/
0x80, /*bmAttributes: Self powered */
0x32, /*MaxPower 100 mA: this current is used for detecting Vbus*/
/************** Descriptor of Joystick Mouse 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,//0x01, /*bInterfaceSubClass : 1=BOOT, 0=no boot*/
//0x02, /*nInterfaceProtocol : 0=none, 1=keyboard, 2=mouse*/
0x00, //该接口不使用协议
0, /*iInterface: Index of string descriptor*/
/******************** Descriptor of Joystick Mouse HID ********************///HID描述符
/* 18 */
0x09, /*bLength: HID Descriptor size*/
HID_DESCRIPTOR_TYPE, /*bDescriptorType: HID*/
0x11, /*bcdHID: HID Class Spec release number*/
0x01,
0x00, /*bCountryCode: Hardware target country*/
0x01, /*bNumDescriptors: Number of HID class descriptors to follow*/
0x22, /*bDescriptorType*/
JOYSTICK_SIZ_REPORT_DESC,/*wItemLength: Total length of Report descriptor*/
0x00,
/******************** Descriptor of Joystick Mouse endpoint ********************///端点描述符
/* 27 */
0x07, /*bLength: Endpoint Descriptor size*/
USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/
0x81, /*bEndpointAddress: Endpoint Address (IN)*/
0x03, /*bmAttributes: Interrupt endpoint*/
0x40, /*wMaxPacketSize: 64 Byte max */
0x00,
0x01, /*bInterval: Polling Interval (32 ms)*/
/* 34 */
/******************** Descriptor of Joystick Mouse endpoint ********************///端点描述符
0x07, /*bLength: Endpoint Descriptor size*/
USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/
0x01, /*bEndpointAddress: Endpoint Address (OUT)*/
0x03, /*bmAttributes: Interrupt endpoint*/
0x40, /*wMaxPacketSize: 64 Byte max */
0x00,
0x01, /*bInterval: Polling Interval (32 ms)*/
/* 34 */
}
; /* MOUSE_ConfigDescriptor */
//报告描述符
const uint8_t Joystick_ReportDescriptor[JOYSTICK_SIZ_REPORT_DESC] =
{
0x05, 0x01, /* USAGE_PAGE (Generic Desktop) */
0x09, 0x00, /* USAGE (Custom Device) */
0xa1, 0x01, /* COLLECTION (Application) */
// NEW Start//////////////////////////////////////////////////
/* The Input Report */
//0x85, 0x01, /* REPORT_ID (0x01) */
0x09, 0x01, /* USAGE (0x01) */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x26, 0x00, 0xFF, /* LOGICAL_MAXIMUM (255) */
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x40, //40, // REPORT_COUNT (64)
0x81, 0x02, // INPUT (Data,Var,Abs)
/* The Output Report */
//0x85, 0x02, /* REPORT_ID (0x02) */
0x09, 0x02, /* USAGE (0x02) */
0x15, 0x00, /* LOGICAL_MINIMUM (0) */
0x26, 0x00, 0xFF, /* LOGICAL_MAXIMUM (255) */
0x75, 0x08, // REPORT_SIZE (8)
0x95, 0x40, //40, // REPORT_COUNT (64)
0x91, 0x02, // OUTPUT (Data,Var,Abs)
0xc0 /* END_COLLECTION */
}
|