|
- //------------------以GPG8,GPG9口为例子---------------------
- // Pointer to device control registers
- volatile S3C2440A_IOPORT_REG *v_pIOPregs;
- BOOL InitializeAddresses(VOID)
- {
- BOOL RetValue = TRUE;
-
- /* IO Register Allocation */
- //RETAILMSG(1,(TEXT("GPG Run Test: %u \r\n"), v_pIOPregs->GPGDAT));
- DEBUGMSG(ZONE_PDD, (_T("NLedDriverInitialize: invoked2\r\n")));
- v_pIOPregs = (volatile S3C2440A_IOPORT_REG *)VirtualAlloc(0, sizeof(S3C2440A_IOPORT_REG), MEM_RESERVE, PAGE_NOACCESS);
- if (v_pIOPregs == NULL)
- {
- ERRORMSG(1,(TEXT("For IOPregs : VirtualAlloc failed!\r\n")));
- DEBUGMSG(ZONE_PDD, (_T("NLedDriverInitialize:VirtualAlloc fail\r\n")));
- RetValue = FALSE;
- }
- else
- {
- if (!VirtualCopy((PVOID)v_pIOPregs, (PVOID)(S3C2440A_BASE_REG_PA_IOPORT >> 8), sizeof(S3C2440A_IOPORT_REG), PAGE_PHYSICAL | PAGE_READWRITE | PAGE_NOCACHE))
- {
- ERRORMSG(1,(TEXT("For IOPregs: VirtualCopy failed!\r\n")));
- DEBUGMSG(ZONE_PDD, (_T("NLedDriverInitialize:VirtualCopy failed\r\n")));
- RetValue = FALSE;
- }
- }
- if (!RetValue)
- {
- if (v_pIOPregs)
- {
- VirtualFree((PVOID) v_pIOPregs, 0, MEM_RELEASE);
- }
- v_pIOPregs = NULL;
- }
- return(RetValue);
- }
- BOOL WINAPI
- NLedDriverInitialize(
- VOID
- )
- {
- //DEBUGMSG(ZONE_PDD, (_T("NLedDriverInitialize: invoked\r\n")));
- //现在可行了,这个打印函数有了
- RETAILMSG(1,(TEXT("---------NLedDriverInitialize---------\r\n")));
- if (!InitializeAddresses())
- return (FALSE);
- //----------GPG8 Setting------------
- v_pIOPregs->GPGCON &= ~(0x3 << 16);
- v_pIOPregs->GPGCON |= (0x1 << 16);
- v_pIOPregs->GPGDAT &= ~(0x1 << 8);//输出低电平
- v_pIOPregs->GPGDAT |= (0x1 << 8);//输出高电平
- v_pIOPregs->GPGUP |= (0x1 << 8);//禁止上拉,在上电没有执行程序的时候上拉高电平输出
- //v_pIOPregs->GPGUP &= ~(0x1 << 8);//使能上拉
- DEBUGMSG(ZONE_PDD, (_T("TEST GPG8 run\r\n")));
- //----------GPG9 Setting------------
- v_pIOPregs->GPGCON &= ~(0x3 << 18);
- v_pIOPregs->GPGCON |= (0x1 << 18);
- v_pIOPregs->GPGDAT &= ~(0x1 << 9);//输出低电平
- //v_pIOPregs->GPGDAT |= (0x1 << 9);//输出高电平
- v_pIOPregs->GPGUP |= (0x1 << 9);//禁止上拉,在上电没有执行程序的时候上拉高电平输出
- //v_pIOPregs->GPGUP &= ~(0x1 << 9);//使能上拉
- DEBUGMSG(ZONE_PDD, (_T("TEST GPG9 run\r\n")));
- gLEDThread= CreateThread(0, 0, (LPTHREAD_START_ROUTINE) NLED_Thread, 0, 0, 0);
- return (TRUE);
- }
复制代码 |
|