请问周工,我用的2478,打算用来读U盘,但是枚举的时候出错USB_INT32S Host_EnumDev (void)
{
USB_INT32S rc;
// PRINT_Log("Connect a Mass Storage device\n\r");
while (!HOST_RhscIntr);
Host_DelayMS(100); // USB 2.0 spec says atleast 50ms delay beore port reset
HcRhPortStatus |= OR_RH_PORT_PRS; // Apply port reset
执行这里的时候U盘灯量了
Host_DelayMS(100); // Wait for 100 MS after port reset
EDCtrl->Control = 8 << 16; // Put max pkt size = 8
// Read first 8 bytes of device desc
rc = HOST_GET_DESCRIPTOR(USB_DESCRIPTOR_TYPE_DEVICE, 0, TDBuffer, 8);
if (rc != OK) {
// PRINT_Err(rc);
return (rc);
}
EDCtrl->Control = TDBuffer[7] << 16; // Get max pkt size of endpoint 0
rc = HOST_SET_ADDRESS(1); // Set the device address to 1
if (rc != OK) {
//PRINT_Err(rc);
return (rc);
}
Host_DelayMS(2);
EDCtrl->Control = (EDCtrl->Control) | 1; // Modify control pipe with address 1
// Get the configuration descriptor
rc = HOST_GET_DESCRIPTOR(USB_DESCRIPTOR_TYPE_CONFIGURATION, 0, TDBuffer, 9);
if (rc != OK) {
// PRINT_Err(rc);
return (rc);
}
// Get the first configuration data
rc = HOST_GET_DESCRIPTOR(USB_DESCRIPTOR_TYPE_CONFIGURATION, 0, TDBuffer, ReadLE16U(&TDBuffer[2]));
if (rc != OK) {
// PRINT_Err(rc);
return (rc);
}
rc = MS_ParseConfiguration(); // Parse the configuration
if (rc != OK) {
// PRINT_Err(rc);
return (rc);
}
rc = USBH_SET_CONFIGURATION(1); // Select device configuration 1
if (rc != OK) {
// PRINT_Err(rc);
}
Host_DelayMS(100); // Some devices may require this delay
return (rc);
}
读取设备描述的时候返回错误,请问我应该从哪个地方去找问题 |