求个s3c6410,wince6下外部中断16驱动程序,
只要能接收中断就行,
如果产生中断,调用ReadFile()返回,没有中断,ReadFile()阻塞。
6 个解决方案
#1
不太明白你要做什么哦,嘿嘿。
#2
就是想做个外部中断的驱动,
我有个设备,中断线接在6410的gpl8/eint16上,
我想做个wince6下的驱动,
我自己做了一个,运行一会,就不响应了,不知道怎么回事。
#3
记得调用InterruptDone重新使能中断。
#4
以前2443,wince5下做过相应的驱动,没啥问题,
刚整的6410,wince6,问题还挺多。
#5
没人指导一下吗?
我的驱动如下:
使用的是gpn6/eint6,
运行几次后,就收不到中断了,大牛指导一下。
#include <windows.h>
//#include <types.h> //
#include <nkintr.h>
#include <ceddk.h> //For DMA Buffer Alloc
#include <memory.h>
//#include <bsp_cfg.h>
#include <s3c6410.h> // for 6410
#include <DrvLib.h>
#include "Golf.h"
#include "oal_intr.h"
static HANDLE gReadEvent[2];
static HANDLE gWaitEvent11;
static HANDLE gEINT14Thread;
static UINT32 gOpenCount=0;
static UINT32 g_bKillIST=FALSE;
static UINT32 g_EINTIrq = IRQ_EINT6;
static UINT32 g_EINTSysIntr = SYSINTR_UNDEFINED;
//static volatile S3C6410_GPIO_REG ;
static volatile S3C6410_GPIO_REG *v_pIOPregs;
//static volatile S3C2443_INTR_REG *v_pINTregs;
//BOOL WINAPI DllEntry(HANDLE hInstDll, DWORD dwReason, LPVOID lpvReserved)
BOOL WINAPI DllEntry(HANDLE hInstDll, DWORD dwReason, LPVOID lpvReserved)
{
switch( dwReason)
{
case DLL_PROCESS_ATTACH:
RETAILMSG(1, (TEXT("Golf: DLL_PROCESS_ATTACH.\r\n")));
//DisableThreadLibraryCalls((HMODULE)hInstDll);
break;
case DLL_PROCESS_DETACH:
RETAILMSG(1, (TEXT("Golf: DLL_PROCESS_DETACH.\r\n")));
break;
}
return TRUE;
}
static BOOL EINT_InitializeAddress(VOID)
{
BOOL RetValue= TRUE;
RETAILMSG(1, (TEXT(">>> EINT initialize.\r\n")));
v_pIOPregs = (volatile S3C6410_GPIO_REG *)DrvLib_MapIoSpace(S3C6410_BASE_REG_PA_GPIO, sizeof(S3C6410_GPIO_REG), FALSE);
if(v_pIOPregs == NULL)
{
ERRORMSG(1, (TEXT("For IOPregs: DrvLib_MapIoSpace failed.\r\n")));
RetValue = FALSE;
}
return RetValue;
}
//config interrupt
static void EINT_configInterruptPin(void)
{
/*
//gpl8/eint16
v_pIOPregs->GPLCON1 &= 0xfffffff0;
v_pIOPregs->GPLCON1 |= 0x3;
v_pIOPregs->EINT0CON1 &= 0xfffffff0;
v_pIOPregs->EINT0CON1 |= 0x3;
*/
//gpn6/eint6
v_pIOPregs->GPNCON &= 0xffffcfff;
v_pIOPregs->GPNCON |= 0x2000;
v_pIOPregs->EINT0CON0 &= 0xffff0fff;
v_pIOPregs->EINT0CON0 |= 0x3000;
//v_pIOPregs->EXTINT1 = 0x5410fcf0;
//RETAILMSG(1, (TEXT("... EXTINT1: %x!\r\n")), (v_pIOPregs->EXTINT1) );
}
DWORD GLF_Init(DWORD dwContext)
{
DWORD IDThread;
if(EINT_InitializeAddress()==FALSE) return 0;
//eint0con1
EINT_configInterruptPin();
if( !KernelIoControl( IOCTL_HAL_REQUEST_SYSINTR, &g_EINTIrq, sizeof(UINT32), &g_EINTSysIntr, sizeof(UINT32), NULL) )
{
RETAILMSG(1, (TEXT("ERROR, Failed to request sysintr value for EINT interrupt.\r\n")) );
}
gEINT14Thread = CreateThread(0,0, (LPTHREAD_START_ROUTINE)EINTGolf_IntrThread, 0,0, &IDThread);
if(gEINT14Thread == NULL)
{
RETAILMSG(1, (TEXT(":::Golf_init: CreateThread fail.\r\n")) );
KernelIoControl(IOCTL_HAL_RELEASE_SYSINTR, &g_EINTSysIntr, sizeof(UINT32), NULL, 0, NULL);
return 0;
}
gReadEvent[0] = CreateEvent(NULL, FALSE, FALSE, NULL);
gReadEvent[1] = CreateEvent(NULL, FALSE, FALSE, NULL);
RETAILMSG(1, (TEXT("::: Golf_init successful.\r\n")) );
return (DWORD)gEINT14Thread;
}
DWORD EINTGolf_IntrThread(PVOID pArg)
{
DWORD ret;
gWaitEvent11 = CreateEvent(NULL, FALSE, FALSE, NULL);
if( !(InterruptInitialize(g_EINTSysIntr, gWaitEvent11, 0,0)) )
{
RETAILMSG(1, (TEXT("ERROR: InterruptInitialize failed.\r\n")) );
CloseHandle(gWaitEvent11);
return 0;
}
while(1)
{
ret = WaitForSingleObject(gWaitEvent11, INFINITE);
//msk interrupt
v_pIOPregs->EINT0MASK |= 0x40;
//clear pending
v_pIOPregs->EINT0PEND |= 0x40;
if((ret == WAIT_OBJECT_0) && (g_bKillIST==FALSE))
{
RETAILMSG(1, (TEXT("EINT\n")));
SetEvent(gReadEvent[0]);
}else
{
CloseHandle(gWaitEvent11);
RETAILMSG(1, (TEXT("INFO: EINTGolf_IntrThread Exit.\r\n")) );
return 0;
}
InterruptDone(g_EINTSysIntr);
v_pIOPregs->EINT0MASK &= 0xffffffbf;
}
return 1;
}
DWORD GLF_Open(DWORD hDeviceContext, DWORD AccessCode, DWORD ShareMode)
{
if(gOpenCount>0)
return 0;
gOpenCount++;
v_pIOPregs->EINT0PEND |= 0x40;
v_pIOPregs->EINT0MASK &= 0xfffffffbf;
return gOpenCount;
}
DWORD GLF_Read(DWORD Handle, LPVOID pBuffer, DWORD dwNumBytes)
{
DWORD ret;
HRESULT hr;
ret = WaitForMultipleObjects(2, gReadEvent, FALSE, INFINITE);
if(ret == WAIT_OBJECT_0)
{
ResetEvent(gReadEvent[0]);
}else if(ret == WAIT_OBJECT_0+1)
{
ResetEvent(gReadEvent[1]);
}
return 1;
}
BOOL GLF_Close(DWORD Handle)
{
if(gOpenCount>0)
SetEvent(gReadEvent[1]);
gOpenCount =0;
return TRUE;
}
static void EINT_ConfigPinDefault()
{
//v_pIOPregs->GPGCON &= ~(0x3<<12);
//v_pIOPregs->GPGCON &= ~(3<<12);
}
BOOL GLF_Deinit(DWORD dwContext)
{
g_bKillIST = TRUE;
SetEvent(gWaitEvent11);
Sleep(200);
SetEvent(gReadEvent[1]);
InterruptDone(g_EINTSysIntr);
InterruptDisable(g_EINTSysIntr);
KernelIoControl(IOCTL_HAL_RELEASE_SYSINTR, &g_EINTSysIntr, sizeof(UINT32), NULL, 0, NULL);
EINT_ConfigPinDefault();
if(v_pIOPregs)
{
//VirtualFree((PVOID)v_pIOPregs, 0, MEM_RELEASE);
DrvLib_UnmapIoSpace((PVOID)v_pIOPregs);
}
gOpenCount = 0;
CloseHandle(gReadEvent[0]);
CloseHandle(gReadEvent[1]);
return TRUE;
}
DWORD GLF_Write(DWORD Handle, LPVOID pBuffer, DWORD dwNumBytes)
{
return 0;
}
DWORD GLF_Seek(DWORD hOpenContext, long Amount, DWORD Type)
{
return 0;
}
void GLF_PowerUp(void)
{
return;
}
void GLF_PowerDown(void)
{
return;
}
BOOL GLF_IOControl(DWORD hOpenContext, DWORD dwcode, PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut)
{
return TRUE;
}
我的驱动如下:
使用的是gpn6/eint6,
运行几次后,就收不到中断了,大牛指导一下。
#include <windows.h>
//#include <types.h> //
#include <nkintr.h>
#include <ceddk.h> //For DMA Buffer Alloc
#include <memory.h>
//#include <bsp_cfg.h>
#include <s3c6410.h> // for 6410
#include <DrvLib.h>
#include "Golf.h"
#include "oal_intr.h"
static HANDLE gReadEvent[2];
static HANDLE gWaitEvent11;
static HANDLE gEINT14Thread;
static UINT32 gOpenCount=0;
static UINT32 g_bKillIST=FALSE;
static UINT32 g_EINTIrq = IRQ_EINT6;
static UINT32 g_EINTSysIntr = SYSINTR_UNDEFINED;
//static volatile S3C6410_GPIO_REG ;
static volatile S3C6410_GPIO_REG *v_pIOPregs;
//static volatile S3C2443_INTR_REG *v_pINTregs;
//BOOL WINAPI DllEntry(HANDLE hInstDll, DWORD dwReason, LPVOID lpvReserved)
BOOL WINAPI DllEntry(HANDLE hInstDll, DWORD dwReason, LPVOID lpvReserved)
{
switch( dwReason)
{
case DLL_PROCESS_ATTACH:
RETAILMSG(1, (TEXT("Golf: DLL_PROCESS_ATTACH.\r\n")));
//DisableThreadLibraryCalls((HMODULE)hInstDll);
break;
case DLL_PROCESS_DETACH:
RETAILMSG(1, (TEXT("Golf: DLL_PROCESS_DETACH.\r\n")));
break;
}
return TRUE;
}
static BOOL EINT_InitializeAddress(VOID)
{
BOOL RetValue= TRUE;
RETAILMSG(1, (TEXT(">>> EINT initialize.\r\n")));
v_pIOPregs = (volatile S3C6410_GPIO_REG *)DrvLib_MapIoSpace(S3C6410_BASE_REG_PA_GPIO, sizeof(S3C6410_GPIO_REG), FALSE);
if(v_pIOPregs == NULL)
{
ERRORMSG(1, (TEXT("For IOPregs: DrvLib_MapIoSpace failed.\r\n")));
RetValue = FALSE;
}
return RetValue;
}
//config interrupt
static void EINT_configInterruptPin(void)
{
/*
//gpl8/eint16
v_pIOPregs->GPLCON1 &= 0xfffffff0;
v_pIOPregs->GPLCON1 |= 0x3;
v_pIOPregs->EINT0CON1 &= 0xfffffff0;
v_pIOPregs->EINT0CON1 |= 0x3;
*/
//gpn6/eint6
v_pIOPregs->GPNCON &= 0xffffcfff;
v_pIOPregs->GPNCON |= 0x2000;
v_pIOPregs->EINT0CON0 &= 0xffff0fff;
v_pIOPregs->EINT0CON0 |= 0x3000;
//v_pIOPregs->EXTINT1 = 0x5410fcf0;
//RETAILMSG(1, (TEXT("... EXTINT1: %x!\r\n")), (v_pIOPregs->EXTINT1) );
}
DWORD GLF_Init(DWORD dwContext)
{
DWORD IDThread;
if(EINT_InitializeAddress()==FALSE) return 0;
//eint0con1
EINT_configInterruptPin();
if( !KernelIoControl( IOCTL_HAL_REQUEST_SYSINTR, &g_EINTIrq, sizeof(UINT32), &g_EINTSysIntr, sizeof(UINT32), NULL) )
{
RETAILMSG(1, (TEXT("ERROR, Failed to request sysintr value for EINT interrupt.\r\n")) );
}
gEINT14Thread = CreateThread(0,0, (LPTHREAD_START_ROUTINE)EINTGolf_IntrThread, 0,0, &IDThread);
if(gEINT14Thread == NULL)
{
RETAILMSG(1, (TEXT(":::Golf_init: CreateThread fail.\r\n")) );
KernelIoControl(IOCTL_HAL_RELEASE_SYSINTR, &g_EINTSysIntr, sizeof(UINT32), NULL, 0, NULL);
return 0;
}
gReadEvent[0] = CreateEvent(NULL, FALSE, FALSE, NULL);
gReadEvent[1] = CreateEvent(NULL, FALSE, FALSE, NULL);
RETAILMSG(1, (TEXT("::: Golf_init successful.\r\n")) );
return (DWORD)gEINT14Thread;
}
DWORD EINTGolf_IntrThread(PVOID pArg)
{
DWORD ret;
gWaitEvent11 = CreateEvent(NULL, FALSE, FALSE, NULL);
if( !(InterruptInitialize(g_EINTSysIntr, gWaitEvent11, 0,0)) )
{
RETAILMSG(1, (TEXT("ERROR: InterruptInitialize failed.\r\n")) );
CloseHandle(gWaitEvent11);
return 0;
}
while(1)
{
ret = WaitForSingleObject(gWaitEvent11, INFINITE);
//msk interrupt
v_pIOPregs->EINT0MASK |= 0x40;
//clear pending
v_pIOPregs->EINT0PEND |= 0x40;
if((ret == WAIT_OBJECT_0) && (g_bKillIST==FALSE))
{
RETAILMSG(1, (TEXT("EINT\n")));
SetEvent(gReadEvent[0]);
}else
{
CloseHandle(gWaitEvent11);
RETAILMSG(1, (TEXT("INFO: EINTGolf_IntrThread Exit.\r\n")) );
return 0;
}
InterruptDone(g_EINTSysIntr);
v_pIOPregs->EINT0MASK &= 0xffffffbf;
}
return 1;
}
DWORD GLF_Open(DWORD hDeviceContext, DWORD AccessCode, DWORD ShareMode)
{
if(gOpenCount>0)
return 0;
gOpenCount++;
v_pIOPregs->EINT0PEND |= 0x40;
v_pIOPregs->EINT0MASK &= 0xfffffffbf;
return gOpenCount;
}
DWORD GLF_Read(DWORD Handle, LPVOID pBuffer, DWORD dwNumBytes)
{
DWORD ret;
HRESULT hr;
ret = WaitForMultipleObjects(2, gReadEvent, FALSE, INFINITE);
if(ret == WAIT_OBJECT_0)
{
ResetEvent(gReadEvent[0]);
}else if(ret == WAIT_OBJECT_0+1)
{
ResetEvent(gReadEvent[1]);
}
return 1;
}
BOOL GLF_Close(DWORD Handle)
{
if(gOpenCount>0)
SetEvent(gReadEvent[1]);
gOpenCount =0;
return TRUE;
}
static void EINT_ConfigPinDefault()
{
//v_pIOPregs->GPGCON &= ~(0x3<<12);
//v_pIOPregs->GPGCON &= ~(3<<12);
}
BOOL GLF_Deinit(DWORD dwContext)
{
g_bKillIST = TRUE;
SetEvent(gWaitEvent11);
Sleep(200);
SetEvent(gReadEvent[1]);
InterruptDone(g_EINTSysIntr);
InterruptDisable(g_EINTSysIntr);
KernelIoControl(IOCTL_HAL_RELEASE_SYSINTR, &g_EINTSysIntr, sizeof(UINT32), NULL, 0, NULL);
EINT_ConfigPinDefault();
if(v_pIOPregs)
{
//VirtualFree((PVOID)v_pIOPregs, 0, MEM_RELEASE);
DrvLib_UnmapIoSpace((PVOID)v_pIOPregs);
}
gOpenCount = 0;
CloseHandle(gReadEvent[0]);
CloseHandle(gReadEvent[1]);
return TRUE;
}
DWORD GLF_Write(DWORD Handle, LPVOID pBuffer, DWORD dwNumBytes)
{
return 0;
}
DWORD GLF_Seek(DWORD hOpenContext, long Amount, DWORD Type)
{
return 0;
}
void GLF_PowerUp(void)
{
return;
}
void GLF_PowerDown(void)
{
return;
}
BOOL GLF_IOControl(DWORD hOpenContext, DWORD dwcode, PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut)
{
return TRUE;
}
#6
楼主,你的驱动成功了吗,我也在做这个。能否指导一下?
#1
不太明白你要做什么哦,嘿嘿。
#2
就是想做个外部中断的驱动,
我有个设备,中断线接在6410的gpl8/eint16上,
我想做个wince6下的驱动,
我自己做了一个,运行一会,就不响应了,不知道怎么回事。
#3
记得调用InterruptDone重新使能中断。
#4
以前2443,wince5下做过相应的驱动,没啥问题,
刚整的6410,wince6,问题还挺多。
#5
没人指导一下吗?
我的驱动如下:
使用的是gpn6/eint6,
运行几次后,就收不到中断了,大牛指导一下。
#include <windows.h>
//#include <types.h> //
#include <nkintr.h>
#include <ceddk.h> //For DMA Buffer Alloc
#include <memory.h>
//#include <bsp_cfg.h>
#include <s3c6410.h> // for 6410
#include <DrvLib.h>
#include "Golf.h"
#include "oal_intr.h"
static HANDLE gReadEvent[2];
static HANDLE gWaitEvent11;
static HANDLE gEINT14Thread;
static UINT32 gOpenCount=0;
static UINT32 g_bKillIST=FALSE;
static UINT32 g_EINTIrq = IRQ_EINT6;
static UINT32 g_EINTSysIntr = SYSINTR_UNDEFINED;
//static volatile S3C6410_GPIO_REG ;
static volatile S3C6410_GPIO_REG *v_pIOPregs;
//static volatile S3C2443_INTR_REG *v_pINTregs;
//BOOL WINAPI DllEntry(HANDLE hInstDll, DWORD dwReason, LPVOID lpvReserved)
BOOL WINAPI DllEntry(HANDLE hInstDll, DWORD dwReason, LPVOID lpvReserved)
{
switch( dwReason)
{
case DLL_PROCESS_ATTACH:
RETAILMSG(1, (TEXT("Golf: DLL_PROCESS_ATTACH.\r\n")));
//DisableThreadLibraryCalls((HMODULE)hInstDll);
break;
case DLL_PROCESS_DETACH:
RETAILMSG(1, (TEXT("Golf: DLL_PROCESS_DETACH.\r\n")));
break;
}
return TRUE;
}
static BOOL EINT_InitializeAddress(VOID)
{
BOOL RetValue= TRUE;
RETAILMSG(1, (TEXT(">>> EINT initialize.\r\n")));
v_pIOPregs = (volatile S3C6410_GPIO_REG *)DrvLib_MapIoSpace(S3C6410_BASE_REG_PA_GPIO, sizeof(S3C6410_GPIO_REG), FALSE);
if(v_pIOPregs == NULL)
{
ERRORMSG(1, (TEXT("For IOPregs: DrvLib_MapIoSpace failed.\r\n")));
RetValue = FALSE;
}
return RetValue;
}
//config interrupt
static void EINT_configInterruptPin(void)
{
/*
//gpl8/eint16
v_pIOPregs->GPLCON1 &= 0xfffffff0;
v_pIOPregs->GPLCON1 |= 0x3;
v_pIOPregs->EINT0CON1 &= 0xfffffff0;
v_pIOPregs->EINT0CON1 |= 0x3;
*/
//gpn6/eint6
v_pIOPregs->GPNCON &= 0xffffcfff;
v_pIOPregs->GPNCON |= 0x2000;
v_pIOPregs->EINT0CON0 &= 0xffff0fff;
v_pIOPregs->EINT0CON0 |= 0x3000;
//v_pIOPregs->EXTINT1 = 0x5410fcf0;
//RETAILMSG(1, (TEXT("... EXTINT1: %x!\r\n")), (v_pIOPregs->EXTINT1) );
}
DWORD GLF_Init(DWORD dwContext)
{
DWORD IDThread;
if(EINT_InitializeAddress()==FALSE) return 0;
//eint0con1
EINT_configInterruptPin();
if( !KernelIoControl( IOCTL_HAL_REQUEST_SYSINTR, &g_EINTIrq, sizeof(UINT32), &g_EINTSysIntr, sizeof(UINT32), NULL) )
{
RETAILMSG(1, (TEXT("ERROR, Failed to request sysintr value for EINT interrupt.\r\n")) );
}
gEINT14Thread = CreateThread(0,0, (LPTHREAD_START_ROUTINE)EINTGolf_IntrThread, 0,0, &IDThread);
if(gEINT14Thread == NULL)
{
RETAILMSG(1, (TEXT(":::Golf_init: CreateThread fail.\r\n")) );
KernelIoControl(IOCTL_HAL_RELEASE_SYSINTR, &g_EINTSysIntr, sizeof(UINT32), NULL, 0, NULL);
return 0;
}
gReadEvent[0] = CreateEvent(NULL, FALSE, FALSE, NULL);
gReadEvent[1] = CreateEvent(NULL, FALSE, FALSE, NULL);
RETAILMSG(1, (TEXT("::: Golf_init successful.\r\n")) );
return (DWORD)gEINT14Thread;
}
DWORD EINTGolf_IntrThread(PVOID pArg)
{
DWORD ret;
gWaitEvent11 = CreateEvent(NULL, FALSE, FALSE, NULL);
if( !(InterruptInitialize(g_EINTSysIntr, gWaitEvent11, 0,0)) )
{
RETAILMSG(1, (TEXT("ERROR: InterruptInitialize failed.\r\n")) );
CloseHandle(gWaitEvent11);
return 0;
}
while(1)
{
ret = WaitForSingleObject(gWaitEvent11, INFINITE);
//msk interrupt
v_pIOPregs->EINT0MASK |= 0x40;
//clear pending
v_pIOPregs->EINT0PEND |= 0x40;
if((ret == WAIT_OBJECT_0) && (g_bKillIST==FALSE))
{
RETAILMSG(1, (TEXT("EINT\n")));
SetEvent(gReadEvent[0]);
}else
{
CloseHandle(gWaitEvent11);
RETAILMSG(1, (TEXT("INFO: EINTGolf_IntrThread Exit.\r\n")) );
return 0;
}
InterruptDone(g_EINTSysIntr);
v_pIOPregs->EINT0MASK &= 0xffffffbf;
}
return 1;
}
DWORD GLF_Open(DWORD hDeviceContext, DWORD AccessCode, DWORD ShareMode)
{
if(gOpenCount>0)
return 0;
gOpenCount++;
v_pIOPregs->EINT0PEND |= 0x40;
v_pIOPregs->EINT0MASK &= 0xfffffffbf;
return gOpenCount;
}
DWORD GLF_Read(DWORD Handle, LPVOID pBuffer, DWORD dwNumBytes)
{
DWORD ret;
HRESULT hr;
ret = WaitForMultipleObjects(2, gReadEvent, FALSE, INFINITE);
if(ret == WAIT_OBJECT_0)
{
ResetEvent(gReadEvent[0]);
}else if(ret == WAIT_OBJECT_0+1)
{
ResetEvent(gReadEvent[1]);
}
return 1;
}
BOOL GLF_Close(DWORD Handle)
{
if(gOpenCount>0)
SetEvent(gReadEvent[1]);
gOpenCount =0;
return TRUE;
}
static void EINT_ConfigPinDefault()
{
//v_pIOPregs->GPGCON &= ~(0x3<<12);
//v_pIOPregs->GPGCON &= ~(3<<12);
}
BOOL GLF_Deinit(DWORD dwContext)
{
g_bKillIST = TRUE;
SetEvent(gWaitEvent11);
Sleep(200);
SetEvent(gReadEvent[1]);
InterruptDone(g_EINTSysIntr);
InterruptDisable(g_EINTSysIntr);
KernelIoControl(IOCTL_HAL_RELEASE_SYSINTR, &g_EINTSysIntr, sizeof(UINT32), NULL, 0, NULL);
EINT_ConfigPinDefault();
if(v_pIOPregs)
{
//VirtualFree((PVOID)v_pIOPregs, 0, MEM_RELEASE);
DrvLib_UnmapIoSpace((PVOID)v_pIOPregs);
}
gOpenCount = 0;
CloseHandle(gReadEvent[0]);
CloseHandle(gReadEvent[1]);
return TRUE;
}
DWORD GLF_Write(DWORD Handle, LPVOID pBuffer, DWORD dwNumBytes)
{
return 0;
}
DWORD GLF_Seek(DWORD hOpenContext, long Amount, DWORD Type)
{
return 0;
}
void GLF_PowerUp(void)
{
return;
}
void GLF_PowerDown(void)
{
return;
}
BOOL GLF_IOControl(DWORD hOpenContext, DWORD dwcode, PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut)
{
return TRUE;
}
我的驱动如下:
使用的是gpn6/eint6,
运行几次后,就收不到中断了,大牛指导一下。
#include <windows.h>
//#include <types.h> //
#include <nkintr.h>
#include <ceddk.h> //For DMA Buffer Alloc
#include <memory.h>
//#include <bsp_cfg.h>
#include <s3c6410.h> // for 6410
#include <DrvLib.h>
#include "Golf.h"
#include "oal_intr.h"
static HANDLE gReadEvent[2];
static HANDLE gWaitEvent11;
static HANDLE gEINT14Thread;
static UINT32 gOpenCount=0;
static UINT32 g_bKillIST=FALSE;
static UINT32 g_EINTIrq = IRQ_EINT6;
static UINT32 g_EINTSysIntr = SYSINTR_UNDEFINED;
//static volatile S3C6410_GPIO_REG ;
static volatile S3C6410_GPIO_REG *v_pIOPregs;
//static volatile S3C2443_INTR_REG *v_pINTregs;
//BOOL WINAPI DllEntry(HANDLE hInstDll, DWORD dwReason, LPVOID lpvReserved)
BOOL WINAPI DllEntry(HANDLE hInstDll, DWORD dwReason, LPVOID lpvReserved)
{
switch( dwReason)
{
case DLL_PROCESS_ATTACH:
RETAILMSG(1, (TEXT("Golf: DLL_PROCESS_ATTACH.\r\n")));
//DisableThreadLibraryCalls((HMODULE)hInstDll);
break;
case DLL_PROCESS_DETACH:
RETAILMSG(1, (TEXT("Golf: DLL_PROCESS_DETACH.\r\n")));
break;
}
return TRUE;
}
static BOOL EINT_InitializeAddress(VOID)
{
BOOL RetValue= TRUE;
RETAILMSG(1, (TEXT(">>> EINT initialize.\r\n")));
v_pIOPregs = (volatile S3C6410_GPIO_REG *)DrvLib_MapIoSpace(S3C6410_BASE_REG_PA_GPIO, sizeof(S3C6410_GPIO_REG), FALSE);
if(v_pIOPregs == NULL)
{
ERRORMSG(1, (TEXT("For IOPregs: DrvLib_MapIoSpace failed.\r\n")));
RetValue = FALSE;
}
return RetValue;
}
//config interrupt
static void EINT_configInterruptPin(void)
{
/*
//gpl8/eint16
v_pIOPregs->GPLCON1 &= 0xfffffff0;
v_pIOPregs->GPLCON1 |= 0x3;
v_pIOPregs->EINT0CON1 &= 0xfffffff0;
v_pIOPregs->EINT0CON1 |= 0x3;
*/
//gpn6/eint6
v_pIOPregs->GPNCON &= 0xffffcfff;
v_pIOPregs->GPNCON |= 0x2000;
v_pIOPregs->EINT0CON0 &= 0xffff0fff;
v_pIOPregs->EINT0CON0 |= 0x3000;
//v_pIOPregs->EXTINT1 = 0x5410fcf0;
//RETAILMSG(1, (TEXT("... EXTINT1: %x!\r\n")), (v_pIOPregs->EXTINT1) );
}
DWORD GLF_Init(DWORD dwContext)
{
DWORD IDThread;
if(EINT_InitializeAddress()==FALSE) return 0;
//eint0con1
EINT_configInterruptPin();
if( !KernelIoControl( IOCTL_HAL_REQUEST_SYSINTR, &g_EINTIrq, sizeof(UINT32), &g_EINTSysIntr, sizeof(UINT32), NULL) )
{
RETAILMSG(1, (TEXT("ERROR, Failed to request sysintr value for EINT interrupt.\r\n")) );
}
gEINT14Thread = CreateThread(0,0, (LPTHREAD_START_ROUTINE)EINTGolf_IntrThread, 0,0, &IDThread);
if(gEINT14Thread == NULL)
{
RETAILMSG(1, (TEXT(":::Golf_init: CreateThread fail.\r\n")) );
KernelIoControl(IOCTL_HAL_RELEASE_SYSINTR, &g_EINTSysIntr, sizeof(UINT32), NULL, 0, NULL);
return 0;
}
gReadEvent[0] = CreateEvent(NULL, FALSE, FALSE, NULL);
gReadEvent[1] = CreateEvent(NULL, FALSE, FALSE, NULL);
RETAILMSG(1, (TEXT("::: Golf_init successful.\r\n")) );
return (DWORD)gEINT14Thread;
}
DWORD EINTGolf_IntrThread(PVOID pArg)
{
DWORD ret;
gWaitEvent11 = CreateEvent(NULL, FALSE, FALSE, NULL);
if( !(InterruptInitialize(g_EINTSysIntr, gWaitEvent11, 0,0)) )
{
RETAILMSG(1, (TEXT("ERROR: InterruptInitialize failed.\r\n")) );
CloseHandle(gWaitEvent11);
return 0;
}
while(1)
{
ret = WaitForSingleObject(gWaitEvent11, INFINITE);
//msk interrupt
v_pIOPregs->EINT0MASK |= 0x40;
//clear pending
v_pIOPregs->EINT0PEND |= 0x40;
if((ret == WAIT_OBJECT_0) && (g_bKillIST==FALSE))
{
RETAILMSG(1, (TEXT("EINT\n")));
SetEvent(gReadEvent[0]);
}else
{
CloseHandle(gWaitEvent11);
RETAILMSG(1, (TEXT("INFO: EINTGolf_IntrThread Exit.\r\n")) );
return 0;
}
InterruptDone(g_EINTSysIntr);
v_pIOPregs->EINT0MASK &= 0xffffffbf;
}
return 1;
}
DWORD GLF_Open(DWORD hDeviceContext, DWORD AccessCode, DWORD ShareMode)
{
if(gOpenCount>0)
return 0;
gOpenCount++;
v_pIOPregs->EINT0PEND |= 0x40;
v_pIOPregs->EINT0MASK &= 0xfffffffbf;
return gOpenCount;
}
DWORD GLF_Read(DWORD Handle, LPVOID pBuffer, DWORD dwNumBytes)
{
DWORD ret;
HRESULT hr;
ret = WaitForMultipleObjects(2, gReadEvent, FALSE, INFINITE);
if(ret == WAIT_OBJECT_0)
{
ResetEvent(gReadEvent[0]);
}else if(ret == WAIT_OBJECT_0+1)
{
ResetEvent(gReadEvent[1]);
}
return 1;
}
BOOL GLF_Close(DWORD Handle)
{
if(gOpenCount>0)
SetEvent(gReadEvent[1]);
gOpenCount =0;
return TRUE;
}
static void EINT_ConfigPinDefault()
{
//v_pIOPregs->GPGCON &= ~(0x3<<12);
//v_pIOPregs->GPGCON &= ~(3<<12);
}
BOOL GLF_Deinit(DWORD dwContext)
{
g_bKillIST = TRUE;
SetEvent(gWaitEvent11);
Sleep(200);
SetEvent(gReadEvent[1]);
InterruptDone(g_EINTSysIntr);
InterruptDisable(g_EINTSysIntr);
KernelIoControl(IOCTL_HAL_RELEASE_SYSINTR, &g_EINTSysIntr, sizeof(UINT32), NULL, 0, NULL);
EINT_ConfigPinDefault();
if(v_pIOPregs)
{
//VirtualFree((PVOID)v_pIOPregs, 0, MEM_RELEASE);
DrvLib_UnmapIoSpace((PVOID)v_pIOPregs);
}
gOpenCount = 0;
CloseHandle(gReadEvent[0]);
CloseHandle(gReadEvent[1]);
return TRUE;
}
DWORD GLF_Write(DWORD Handle, LPVOID pBuffer, DWORD dwNumBytes)
{
return 0;
}
DWORD GLF_Seek(DWORD hOpenContext, long Amount, DWORD Type)
{
return 0;
}
void GLF_PowerUp(void)
{
return;
}
void GLF_PowerDown(void)
{
return;
}
BOOL GLF_IOControl(DWORD hOpenContext, DWORD dwcode, PBYTE pBufIn, DWORD dwLenIn, PBYTE pBufOut, DWORD dwLenOut, PDWORD pdwActualOut)
{
return TRUE;
}
#6
楼主,你的驱动成功了吗,我也在做这个。能否指导一下?