积极答复者
请教EVC中调用底层驱动,运行时间过长的问题

问题
-
我参照何老师的编的电机流驱动。
在WINCE4.2中编写的驱动如下:
DWORD CCD_Open(DWORD hDeviceContext,DWORD AccessCode,DWORD ShareMode)
{
OutputDebugString(L"MyDriver - CCD_Open\n");
ccd_sle=0x01550000;
ccd_sle_up=0x000000ff;
ccd_sle_data|=0x01fff;
return TRUE;
}DWORD CCD_Write(DWORD hDeviceContext,LPVOID pBuffer,DWORD Count)
{
OutputDebugString(L"MyDriver - CCD_Write\r\n");
(*(volatile unsigned char *)CCD_GPJDATA)= * (unsigned char *)pBuffer;
return 1;}
DWORD CCD_Read(DWORD hDeviceContext,LPVOID pBuffer,DWORD Count)
{
*(int *)pBuffer=(*(volatile unsigned char *)CCD_GPJDATA);
OutputDebugString(L"MyDriver - CCD_Read\r\n");
return NULL;
}EVC编写的应用程序如下
for(int i=0,int j=0;i<2048;i++)
{
result=ad_result(hDrv,dwWritten);
}
int ad_result(HANDLE hDrv,DWORD dwWritten)
{
int count;
int ret,j;
int rec1,rec2,rec;
bool b;
ret=0x7;
count=WriteFile(hDrv,&ret,1,&dwWritten,NULL);
ret=0x6;
count=WriteFile(hDrv,&ret,1,&dwWritten,NULL);
ret=0x2;
count=WriteFile(hDrv,&ret,1,&dwWritten,NULL);
ret=0x6;
count=WriteFile(hDrv,&ret,1,&dwWritten,NULL);
ret=0x2;
count=WriteFile(hDrv,&ret,1,&dwWritten,NULL);
//cs high,rc low
ret=0x6;
ret=ret|cdcon;
count=WriteFile(hDrv,&ret,1,&dwWritten,NULL);
ret=0x7;
count=WriteFile(hDrv,&ret,1,&dwWritten,NULL);
ret=0x3;
count=WriteFile(hDrv,&ret,1,&dwWritten,NULL);
ret=0x1;
count=WriteFile(hDrv,&ret,1,&dwWritten,NULL);
b=ReadFile(hDrv,&rec1,1,&dwWritten,NULL);
ret=0x3;
count=WriteFile(hDrv,&ret,1,&dwWritten,NULL);
b=ReadFile(hDrv,&rec2,1,&dwWritten,NULL);
rec=(rec2<<8)|rec1;
rec=rec&0xffff;
rec=rec;
return rec;
}结果发现,完成for(int i=0,int j=0;i<2048;i++)
{
result=ad_result(hDrv,dwWritten);
}
这个运行时间长达50多秒。不知是不是因为我通过microsoft activesync同步调试的问题(调试时候我是执行到光标处,不是纯单步),是不是下载到开放板里就不会有这样的问题。