请问各位,本人要用STM32F407枚举成USB HID自定义设备,用STM32_USB-Host-Device_Lib_V2.1.0中的Joystick Mouse进行修改,
现在的状况是MCU可以正确发送数据给PC,反过来,PC发送数据给MCU时,MCU却收不到,程序可以进DCD_HandleRxStatusQueueLevel_ISR(pdev)中断,
但不能进入DCD_HandleOutEP_ISR(pdev)中断。
在DCD_HandleRxStatusQueueLevel_ISR中断中读取FIFO的数据,发现不是PC发过来的数据。
请问MCU程序中要在哪个函数中收取PC发来的数据?是不是要进入 DCD_HandleOutEP_ISR(pdev)中断才能收到正确的数据?
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
#define HID_IN_EP 0x81
#define HID_OUT_EP 0x01
__ALIGN_BEGIN uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END =
{
0x12, /*bLength */
USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/
0x00, /*bcdUSB */
0x02,
0x00, /*bDeviceClass*/
0x00, /*bDeviceSubClass*/
0x00, /*bDeviceProtocol*/
USB_OTG_MAX_EP0_SIZE, /*bMaxPacketSize*/
LOBYTE(USBD_VID), /*idVendor*/
HIBYTE(USBD_VID), /*idVendor*/
LOBYTE(USBD_PID), /*idVendor*/
HIBYTE(USBD_PID), /*idVendor*/
0x00, /*bcdDevice rel. 2.00*/
0x02,
USBD_IDX_MFC_STR, /*Index of manufacturer string*/
USBD_IDX_PRODUCT_STR, /*Index of product string*/
USBD_IDX_SERIAL_STR, /*Index of serial number string*/
USBD_CFG_MAX_NUM /*bNumConfigurations*/
} ; /* USB_DeviceDescriptor */
__ALIGN_BEGIN static uint8_t USBD_HID_CfgDesc[USB_HID_CONFIG_DESC_SIZ] __ALIGN_END =
{
0x09, /* bLength: Configuration Descriptor size */
USB_CONFIGURATION_DESCRIPTOR_TYPE, /* bDescriptorType: Configuration */
USB_HID_CONFIG_DESC_SIZ,
/* wTotalLength: Bytes returned */
0x00,
0x01, /*bNumInterfaces: 1 interface*/
0x01, /*bConfigurationValue: Configuration value*/
0x00, /*iConfiguration: Index of string descriptor describing the configuration*/
0xE0, /*bmAttributes: bus powered and Support Remote Wake-up */
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,//xcs 0x01, /*bNumEndpoints*/
0x03, /*bInterfaceClass: HID*/
0x00,//xcs 0x01, /*bInterfaceSubClass: 1=BOOT, 0=no boot*/
0x00,//xcs 0x02, /*nInterfaceProtocol: 0=none, 1=keyboard, 2=mouse*/
0x00, /*iInterface: Index of string descriptor*/
/******************** Descriptor of Joystick Mouse 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*/
HID_MOUSE_REPORT_DESC_SIZE,/*wItemLength: Total length of Report descriptor*/
0x00,
/******************** Descriptor of Mouse endpoint ********************/
/* 27 */
0x07, /*bLength: Endpoint Descriptor size*/
USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/
HID_IN_EP, /*bEndpointAddress: Endpoint Address (IN)*/
0x03, /*bmAttributes: Interrupt endpoint*/
HID_IN_PACKET, /*wMaxPacketSize*/
0x00,
0x0A, /*bInterval: olling Interval (10 ms)*/
/* 34 */
//xcs************************************************
0x07, /*bLength: Endpoint Descriptor size*/
USB_ENDPOINT_DESCRIPTOR_TYPE, /*bDescriptorType:*/
HID_OUT_EP, /*bEndpointAddress: Endpoint Address (IN)*/
0x03, /*bmAttributes: Interrupt endpoint*/
HID_IN_PACKET, /*wMaxPacketSize*/
0x00,
0x0A, /*bInterval: olling Interval (10 ms)*/
/* 41 */
} ;
__ALIGN_BEGIN static uint8_t USBD_HID_Desc[USB_HID_DESC_SIZ] __ALIGN_END=
{
/* 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*/
HID_MOUSE_REPORT_DESC_SIZE,/*wItemLength: Total length of Report descriptor*/
0x00,
};
__ALIGN_BEGIN static uint8_t HID_MOUSE_ReportDesc[HID_MOUSE_REPORT_DESC_SIZE] __ALIGN_END = //xcs
{
0x05,0x8C, //USAGE_PAGE (Vendor Defined age 1)
0x09,0x01, //USAGE (Vendor Usage 1)
0xA1,0x01, //COLLECTION (Application)
0x09,0x03, //(Vendor Usage 1)
0x15,0x00, //LOGICAL_MINIMUM (0)
0x26,0xFF,0x00, //LOGICAL_MAXIMUM (255)
0x75,0x08, //REPORT_SIZE (8)
0x95,0x40, //REPORT_COUNT (64)
0x81,0x02, //INPUT (Data,Var,Abs)
0x09,0x04, //(Vendor Usage 1)
0x15,0x00, //LOGICAL_MINIMUM (0)
0x26,0xFF,0x00, //LOGICAL_MAXIMUM (255)
0x75,0x08, //REPORT_SIZE (8)
0x95,0x40, //REPORT_COUNT (64)
0x91,0x02, //OUTPUT (Data,Var,Abs)
0xC0 /* END_COLLECTION */
};
一周热门 更多>