wince5.0 VirtualCopy绑定地址后,写寄存器失败
大家好!问题如题目所说,我使用VirtualCopy绑定GPIO寄存器的地址后,往GPGCON寄存器里写入值,但是读出来的数值是没有改变的,但是绑定函数并没有报错,不知道是什么问题引起的,请大家帮帮忙,多谢了!
以下是我的驱动代码:
...
void Virtual_Alloc()
{
// GPIO Virtual alloc
s2440IOP = (volatile IOPreg *) VirtualAlloc(0,sizeof(IOPreg),MEM_RESERVE, PAGE_NOACCESS);
if(s2440IOP == NULL) {
RETAILMSG(1,(TEXT("For s2440IOP: VirtualAlloc faiLED!\r\n")));
}
else {
//if(!VirtualCopy((PVOID)s2440IOP,(PVOID)(IOP_BASE),sizeof(IOPreg),PAGE_READWRITE | PAGE_NOCACHE )) {
if(!VirtualCopy((PVOID)s2440IOP,(PVOID)(0x56000000 >> 8),sizeof(IOPreg),PAGE_PHYSICAL | PAGE_READWRITE | PAGE_NOCACHE )) {
RETAILMSG(1,(TEXT("For s2440IOP: VirtualCopy faiLED!\r\n")));
}
}
}
...
BOOL LEDGpioInit()
{
//volatile IOPreg *s2440GPIO;
//s2440GPIO = (IOPreg *)IOP_BASE;
RETAILMSG(1,(TEXT("LED_Gpio_Setting----\r\n")));
RETAILMSG(1,(TEXT("1.s2440IOP->rGPGCON is %x\r\n")), s2440IOP->rGPGCON);
//s2440IOP->rGPGCON = (s2440IOP->rGPGCON &~(3 << 6)) | (1<< 6);// GPG3 == OUTPUT.
s2440IOP->rGPGCON = 0x55555555;// GPG3 == OUTPUT.
RETAILMSG(1,(TEXT("2.s2440IOP->rGPGCON is %x\r\n")), s2440IOP->rGPGCON);
s2440IOP->rGPGCON = (s2440IOP->rGPGCON &~(3 << 10)) | (1<< 10);// GPG5 == OUTPUT.
s2440IOP->rGPGCON = (s2440IOP->rGPGCON &~(3 << 12)) | (1<< 12);// GPG6 == OUTPUT.
s2440IOP->rGPGCON = (s2440IOP->rGPGCON &~(3 << 14)) | (1<< 14);// GPG7 == OUTPUT.
return TRUE;
}
...
DWORD LED_Init(DWORD dwContext)
{
RETAILMSG(1,(TEXT("LED_Init----\r\n")));
// 1. Virtual Alloc
Virtual_Alloc();
LEDGpioInit();
mInitialized = TRUE;
return TRUE;
}
[解决办法]
楼主读取出来的值是多少啊?