如何实现WinCE系统中USB设备自动检测 如何实现WinCE系统中USB设备自动检测

作者&投稿:鞠溥 (若有异议请与网页底部的电邮联系)
  如果能够实现在启动系统后,切换USB HOST的电源,然后再上电,应该就能够识别USB设备了,另外也可以通过上下拉USB的数据线实现,但是由于硬件电路已经接死了,故无法通过硬件的机制实现。
  网上同样有人遇到类似的问题,有老外给出如下解决方案:
  The file describes the cause and the fix of Windows CE 5.0's USB device
  detection problem during power-up.

  1. USB Device Detection Problem during Powering-Up
  - Connect USB devices to EDB93xx's USB ports when the board is
  powered-off.
  - Power on EDB93xx.
  - Wait until CE 5.0 is fully loaded.
  - One or several USB devices are not detected by CE 5.0.

  2. The Cause
  In USB's Open Host Controller Interface (OHCI) Specification, in
  Register HcRhDescriptorA (EP93xx address 0x80020048), Bits 24-31
  are PowerOnToPowerGoodTime. This POTPGT byte specifies the duration
  Host Controller Driver has to wait before accessing a powered-on port
  of the Root Hub. It is implementation-specific. The unit of time
  is 2 msec. The duration is calculated as POTPGT x 2msec.

  EP93xx's default value of Register HcRhDescriptorA is 0x02001203.
  The value of the POTPGT byte is 0x02. 2*2msec=4msec. It needs 4 msec
  delay after the Host Controller has supplied power to the Root Hub.
  
  The start-up sequence for EDB93xx's USB host controller should be

  1. Host Controller supplies power to the Root Hub.
  2. Delay 4 msec.
  3. Set Host Controller to Operational state. Access USB ports. Start
  to send SOF tokens...etc.

  CE 5.0's USB driver doesn't implement the code to read the HcRhDescriptorA
  register and deploy the required delay.
  
  
  3. The Fix:
  
  Add the 4-msec delay to CE's USB host driver then rebuild the platform.

  Modify the filebr> WINCE500/PUBLIC/COMMON/OAK/DRIVERS/USB/HCD/OHCD2/chw.cpp
  Please look at the code "//QQQQQ" below.

  BOOL CHW::Initialize(void)
  {
  ..................
  InterruptDisable( m_dwSysIntr ); // Just to make sure this is really ours.
  // Initialize Interrupt. When interrupt id # m_sysIntr is triggered,
  // m_hUsbInterruptEvent will be signaled. Last 2 params must be NULL
  if ( !InterruptInitialize( m_dwSysIntr, m_hUsbInterruptEvent, NULL, NULL) )
  {
  DEBUGMSG(ZONE_ERROR, (TEXT("-CHW::Initialize. Error on
  InterruptInitializern")));
  return FALSE;
  }

  // Apply power to all root hub ports, just like OHCI.
  m_portBase->HcRhDescriptorA.NPS = 1;
  m_portBase->HcRhStatus.reg= HcRegisters::HcRhStatus:PSC;

  //QQQQQQQ Add 4msec delay that is required by Host Controller.
  Sleep(4);
  
  // Start up our IST - the parameter passed to the thread
  // is unused for now
  DEBUGCHK( m_hUsbInterruptThread == NULL &&
  m_fUsbInterruptThreadClosing == FALSE );
  m_hUsbInterruptThread = CreateThread( 0, 0, UsbInterruptThreadStub, this, 0,
  NULL );
  if ( m_hUsbInterruptThread == NULL ) {
  DEBUGMSG(ZONE_ERROR, (TEXT("-CHW::Initialize. Error creating
  ISTn")));
  return FALSE;
  }
  CeSetThreadPriority( m_hUsbInterruptThread, g_IstThreadPriority );
  ......................
  }
  这是public下的一段代码,在d:/wince500/public/common/oak/drivers/usb/hcd/ohcd2/Chw.cpp以及d:/wince500/public/common/oak/drivers/usb/hcd/uhcd/Chw.cpp文件的BOOL CHW::Initialize()函数中添加一个4ms的延时,然后build and sysgen,重新下载NK,问题解决。
  看来这是微软USB驱动的一个小的BUG。CSDN上有牛人Paul_chao翻了WINCE6.0的源码,发现6.0中使用的如下语句:
  Sleep(m_portBase->HcRhDescriptorA.POTPGT * 2);
  由于编译一次需要1个小时以上,这里仅测试了使用Sleep(4),即已解决问题。

如何实现WinCE系统中USB设备自动检测~

思路是在应用程序创建一个线程,在线程里循环定时查询系统中是否存在USB存储设备,可以通过读取系统注册表或调用 API函数来实现,下面是通过API函数查询USB存储设备的程序片段。
STOREINFO StoreInfo;
hDevice = FindFirstStore( &StoreInfo );
if( INVALID_HANDLE_VALUE != hDevice )
{
do
{
//判断是否为USB存储设备
if( 0 == _tcscmp( StoreInfo.szStoreName, _T('USB Hard Disk Drive') ) )
{
//如果查找到USB存储设备,则打印信息到调试串口
RETAILMSG( 1, (TEXT('USB%shas been inserted
' ) ,
StoreInfo.szDeviceName ));
}
}while( FindNextStore( hDevice, &StoreInfo ) );
}

 如果能够实现在启动系统后,切换USB HOST的电源,然后再上电,应该就能够识别USB设备了,另外也可以通过上下拉USB的数据线实现,但是由于硬件电路已经接死了,故无法通过硬件的机制实现。   网上同样有人遇到类似的问题,有老外给出如下解决方案:   The file describes the cause and the fix of Windows CE 5.0's USB device   detection problem during power-up.   1. USB Device Detection Problem during Powering-Up   - Connect USB devices to EDB93xx's USB ports when the board is   powered-off.   - Power on EDB93xx.   - Wait until CE 5.0 is fully loaded.   - One or several USB devices are not detected by CE 5.0.   2. The Cause   In USB's...

最近应用winCE5.0中连接ID射频卡读卡器,无驱动,不能正常读卡,读卡器是...
答:1.你可以找厂家要,图片上不是有厂家的名称吗 2.拆开外壳,看芯片型号,通过芯片的型号找到芯片生产厂家,向厂家要

WinCE中eboot有什么作用
答:EBoot是WinCE一种默认的Bootloader,用来引导WinCE,升级WinCE,及各种调试工具 还有可以在EBoot中打开一些全局变量从而控制WinCE中的功能,比如USB的模式等(就是与WinCE约定了一个内存区域存放这种标志)

寻找GPS的USB驱动
答:另外,这个机器的系统好像是wince 5.0,英文版。能用的软件不多,地图也不好装。机器可以删除原来的导航系统,换成wince的explorer运行,方法:设置为移动硬盘模式连接计算机后,进入移动硬盘\map\apps下,修改那个nav开头的exe文件,替换为wince5下面的资源管理器,重新启动,选择导航就可以进入wince界面,...

请问能否用USB无线网卡插到GPS导航仪上实现上网---wifi?
答:一般导航仪操作系统是WINCE的,是智能系统。但是他的USB口一般只用于充电,如果能识别USB设备,需要这个设备支持USB HOST功能,市场上有一些PDA就支持USB HOST功能,例如 玛雅UMP-X8 这款不是GPS是MP4,但是只要插上GPS MOUSE就可以变成导航仪,如果插上USB口的无线网卡就可以实现wifi了。

哪位朋友的车机是WinCE系统,而且能和苹果手机互连
答:方法1、导航界面点设置,进入导航设置界面。2、点系统升级,系统自动调用进入Wince的界面,点 CE explorer进入wince界面。3、进入wince,将准备好的U盘上的文件拷贝到系统相应的目录,即可。USB中准备的文件 update.exe 进入wince的界面工具NAND FlASH 是ibook3存储位置升级后新的导航系统界面文件夹D2280...

请教如何向wince系统的目录下拷贝文件
答:后边有u口,插上U盘后在我的电脑下出现一个usbharddisk文件夹就是U盘文件了!

在XP系统下用 VS2005 连接 WinCE 注册表,都需要什么?
答:建议通过 USB 连接,但你需要一个双头 USB 接口的数据线(有驱动的要先装好)当然电脑要装好 VS2005 开发版的 <Microsoft ActiveSync> 这个必须要有 全装完毕后,重启,ActiveSync在右下角会有相应图标,确定连接至 设备 ,打开VS2005 里的“远程注册表编辑器”直接在里面选择Wince连接就可以了 ...

我想把ARM开发板接入网络 可是我只能用笔记本连接到WIFI 求怎么使开发...
答:1、如果你是 winCE 系统 那么用USB 同步后 直接用浏览器就可以上网了 2、如果你是linux系统,那么你只有笔记本的wifi的话 那么必须要找个线连接笔记本(串口估计不行) 然后笔记本装个代理软件 然后在设置你的linux开发板 应该是可以的(只是思路,具体你可以百度下)

usbStorage是什么文件
答:是一个程序,该程序演示了如何在各种USB FUNCTION之间进行切换.一个典型的应用就是把Windows Mobile/WINCE变成U盘使用. 注意设备一定要有支持USB Function Driver的硬件(即USB Client Control),一般市面上的智能手机/PDA都具有此功能.该功能适用于WINCE5.0以上内核. 使用Visual Studio 2005编译.C#代码. -...

WinCE系统车机可以安装carplay吗
答:现在最新的才会是android系统,车载导航一般都是Wince系统,想通过这个系统来读取卡里面的资料吗?那进入百宝箱里面有一个返回到windows桌面,然后在windows界面下就可以打开office文件。希望能够帮到你。