我从网上下载一个usb device的程序(据说是从uboot 的usb 下载功能移植到keil mdk的)。主程序大概如下:
int Main(void)
{
char *mode;
Port_Init();
rGPHCON = rGPHCON&~(0xf<<18)|(0x5<<18);
// USB device detection control
// rGPGCON &= ~(3<<24);
// rGPGCON |= (1<<24); // output
// rGPGUP |= (1<<12); // pullup disable
// rGPGDAT |= (1<<12); // output
rGPCCON &= ~(3<<10);
rGPCCON |= (1<<10); // output
rGPCUP |= (1<<5); // pullup disable
rGPCDAT |= (1<<5); // ourtput
// rGPCCON = 0xAAAAA6AA;
// rGPCDAT &= ~(1<<5);
//ChangeUPllValue(60,4,2); // 48MHz
//for(i=0; i<7; i++);
//ChangeClockDivider(13,12);
//ChangeMPllValue(97,1,2); //296Mhz
Isr_Init();
consoleNum=1; // Uart 1 select for debug.
Uart_Init(0,115200);
Uart_Select(0);
rMISCCR=rMISCCR&~(1<<3); // USBD is selected instead of USBH1
rMISCCR=rMISCCR&~(1<<13); // USB port 1 is enabled.
// USBD should be initialized first of all.
//
isUsbdSetConfiguration=0;
pISR_SWI=(_ISR_STARTADDRESS+0xf0); //for pSOS
//Led_Display(0x6);
UsbdMain();
Delay(0); //calibrate Delay()
#if USBDMA
mode="DMA";
#else
mode="Int";
#endif
// CLKOUT0/1 select.
//Uart_Printf("CLKOUT0:MPLL in, CLKOUT1:RTC clock.\n");
//Clk0_Enable(0); // 0:MPLLin, 1:UPLL, 2:FCLK, 3:HCLK, 4:PCLK, 5:DCLK0
//Clk1_Enable(2); // 0:MPLLout, 1:UPLL, 2:RTC, 3:HCLK, 4:PCLK, 5:DCLK1
Clk0_Disable();
Clk1_Disable();
//mpll_val = rMPLLCON;
//Uart_Printf("DIVN_UPLL%x\n", divn_upll);
//Uart_Printf("MPLLVal [M:%xh,P:%xh,S:%xh]\n", (mpll_val&(0xff<<12))>>12,(mpll_val&(0x3f<<4))>>4,(mpll_val&0x3));
//Uart_Printf("CLKDIVN:%xh\n", rCLKDIVN);
Uart_Printf("\n\n");
Uart_Printf("+---------------------------------------------+\n");
Uart_Printf("| S3C2440A USB Downloader ver R0.05 2008 August |\n");
Uart_Printf("+---------------------------------------------+\n");
Uart_Printf("FCLK=%4.1fMHz,%s mode\n",FCLK/1000000.,mode);
//Uart_Printf("USB: IN_ENDPOINT:1 OUT_ENDPOINT:3\n");
//Uart_Printf("FORMAT: <ADDR(DATA):4>+<SIZE(n+10):4>+<DATA:n>+<CS:2>\n");
Uart_Printf("NOTE: 1. Power off/on or press the reset button for 1 sec\n");
Uart_Printf(" in order to get a valid USB device address.\n");
Uart_Printf(" 2. For additional menu, Press any key. \n");
Uart_Printf("\n");
download_run=1; //The default menu is the Download & Run mode.
while(1)
{
if(menuUsed==1)Menu();
WaitDownload();
}
}
我将mini2440上电后连接PC机进行调试,PC机会发现硬件,但只会PC在右下角出现黄色背景的提示说:无法识别的USB设备。然后并没有弹出安装驱动的界面。
而串口打印的是:
+---------------------------------------------+
| S3C2440A USB Downloader ver R0.05 2008 August |
+---------------------------------------------+
FCLK=296NOTE: 1. Power off/on or press the reset button for 1 sec
in order to get a valid USB device address.
2. For additional menu, Press any key.
USB host is not connected yet.
+---------------------------------------------+
| S3C2440A USB Downloader ver R0.05 2008 August |
+---------------------------------------------+
FCLK=296NOTE: 1. Power off/on or press the reset button for 1 sec
in order to get a valid USB device address.
2. For additional menu, Press any key.
USB host is not connected yet.
我通过USBMonitor2_26来监测USB通信
发现只有如下信息:
000001: PnP Event: Query ID (UP), 15.08.2013 21:45:39.7187500 +97.7031250
Hardware IDs: USB\UNKNOWN
000002: PnP Event: Query ID (UP), 15.08.2013 21:45:39.7187500 +0.0
Compatible IDs: USB\UNKNOWN
000003: PnP Event: Device Disconnected (UP), 15.08.2013 21:45:39.7187500 +0.0
The USB device has just been removed from the system, all drivers unloaded.
000004: PnP Event: Query ID (UP), 15.08.2013 21:45:42.6718750 +2.9531250
Hardware IDs: USB\UNKNOWN
000005: PnP Event: Query ID (UP), 15.08.2013 21:45:42.6718750 +0.0
Compatible IDs: USB\UNKNOWN
并没有传说中的获取各描述符的命令。请各位大牛帮忙分析下。谢谢,完整代码如附:
usbdevice.zip (520 K) 下载次数:19 [ 此帖被qiuyigui在2013-08-15 21:57重新编辑 ]