TQ2440 WINCE6.0 ADC驱动无法加载
[复制链接]
刚开始学嵌入式,最近需要使用AD转换,可是TQ2440开发板没有提供WINCE6.0的ADC驱动,无奈找了很久,现在是在天嵌论坛找的一个WINCE5.0下开发的ADCDrv (http://bbs.embedsky.net/viewthread.php?tid=1140&extra=page%3D2) 包含ADCDrv.cpp、ADCDrv.h、ADCDrv.def、makefile、sources、Build.log 主要对原BSP做了以下修改: 1. 将ADCDrv文件夹复制到Drivers下,并将Drivers下的dirs增加语句:DIRS=······\ ADCDrv \······ ; 2. 修改platform.reg:
3. 修改platform.bib:
重新编译项目成功,烧写到开发板也正常,有人说ADC驱动会和触摸屏驱动冲突,这里触摸屏使用正常,使用VS2005打开NK.bin发现包含ADCDrv.dll文件,使用远程工具查看注册表项[HKEY_LOCAL_MACHINE\Drivers\BuiltIn]里也有ADCDrv项,可是在进程查看器的NK里却没找到ADCDrv.dll,[HKEY_LOCAL_MACHINE\Drivers\Active]下也没有找到ADCDrv项,这究竟是为什么呢? ADCDrv.cpp中包括各接口函数定义:
ADC_Close ADC_Deinit ADC_Init ADC_IOControl ADC_Open ADC_PowerDown ADC_PowerUp ADC_Read ADC_Seek ADC_Write 这里附上部分代码: DWORD ADC_Init(DWORD dwContext) { unsigned long unpreScaler=0; unsigned long unADCFreq = 1000000; //ADC Frequence: 1M Hz
RETAILMSG(1,(TEXT("ADC Initialize ..."))); if (!InitializeAddresses()) return (FALSE);
unpreScaler= (5000000/unADCFreq)-1; cbytPreScalerValue=(char)unpreScaler; //pADCPort->ADCDLY
mInitialized = TRUE; RETAILMSG(1,(TEXT(" ADC_Init OK !!!\n"))); return TRUE; } DllEntry(HANDLE hinstDLL, DWORD dwReason, LPVOID /* lpvReserved */) { switch(dwReason) { case DLL_PROCESS_ATTACH: DEBUGREGISTER((HINSTANCE)hinstDLL); return TRUE; case DLL_THREAD_ATTACH: break; case DLL_THREAD_DETACH: break; case DLL_PROCESS_DETACH: break; #ifdef UNDER_CE case DLL_PROCESS_EXITING: break; case DLL_SYSTEM_STARTED: break; #endif } return TRUE; } DWORD ADC_Read(DWORD hOpenContext, LPVOID pBuffer, DWORD Count) { int i;
Count=sizeof(nADC_Value); dwADCCON_Save=v_pADCregs->ADCCON;
for(i=0;i<4;i++) { nADC_Value=0; if(!bADC_Enable) continue; nADC_Value = ReadADC(i); Sleep(10); }
v_pADCregs->ADCCON = dwADCCON_Save; Sleep(20); memcpy(pBuffer,&nADC_Value[0],Count);
RETAILMSG(1,(TEXT("ADC_Control: ADC_Read\r\n"))); return TRUE; }
int ReadADC(int ch) { v_pADCregs->ADCCON = (1<<14)|(cbytPreScalerValue<<6)|(ch<<3); //setup channel v_pADCregs->ADCCON|=0x1; //start ADC while(v_pADCregs->ADCCON & 0x1); //check if Enable_start is low while(!(v_pADCregs->ADCCON & 0x8000)); //check if EC(End of Conversion) flag is high
RETAILMSG(1,(TEXT("NO: %d Data: %d\r\n"),ch,(int)v_pADCregs->ADCDAT0 & 0x3ff)); return ( (int)v_pADCregs->ADCDAT0 & 0x3ff ); }
[ 本帖最后由 zhengtu2010 于 2011-7-21 15:25 编辑 ]
|