|
[googleman帮我看看]定时器产生的中断请求,无法进入中断帮忙看看!
[复制链接]
static HANDLE TimerEvent;
static HANDLE TimerThread;
static UINT32 g_TIMER2Irq = IRQ_TIMER2;
static UINT32 g_TIMER2SysIntr = SYSINTR_UNDEFINED;
/*******************************************************************************************
函数名称: TimerGpioInit
描 述: 配置GPB4禁止上拉 引脚为TCLK[0] Select PCLK with CLKOUT0
定时器4 :TCFG0 TCFG1 清零 GPG7为OUTPUT
输入参数: 无
输出参数: 无
返 回: 无
********************************************************************************************/
BOOL TimerGpioInit()
{
RETAILMSG(1,(TEXT("TIMER_INTR_Gpio_setting --- \r\n")));
s2440IO->rGPGCON=GPG7_out;
s2440IO->rGPBCON &=~(0x03 << 4);
s2440IO->rGPBCON |= (0x02 << 4); //GPB2设置为TOUT2
s2440IO->rGPBUP |= 0x1 << 2;
return TRUE;
}
/*******************************************************************************************
函数名称:Timer4_Setup
描 述: 配置了Timer2定时器。
输入参数: 无
输出参数: 无
返 回: 无
*******************************************************************************************/
void Timer2_Setup()
{
s2440PWM->rTCFG0 &= ~0xFF00; // Timer2 预分频恢复为0
//s2440PWM->rTCFG0 |= 0x4400; // 设置定时器 2 的预分频值 68
s2440PWM->rTCFG0 |= 0x2200; // 设置定时器 2 的预分频值 68
s2440PWM->rTCFG1 &= ~(0xF<<8);
s2440PWM->rTCFG1 &= 0x0ff; // MUX2: 1/2
s2440PWM->rTCNTB2 = 2000;
s2440PWM->rTCMPB2 = 1000;
s2440PWM->rTCON &= ~(0xF<<12);
s2440PWM->rTCON |= (0xB<<12);// /interval, inv-off, update TCNTB3&TCMPB3, start timer2
s2440PWM->rTCON &= ~(2<<12);//clear manual update bit
}
/*******************************************************************************************
函数名称: TimerIntrProcessThread(void)
描 述:IST的具体执行过程在TimerIntrProcessThread函数中实现:
输入参数:
输出参数: 无
返 回:
*******************************************************************************************/
DWORD TimerIntrProcessThread(void)
{
while(1)
{
DWORD ret;
RETAILMSG(1,(TEXT("I am in IST !!!\r\n")));
ret= WaitForSingleObject(TimerEvent, INFINITE);
if (ret == WAIT_OBJECT_0)
{
if((s2440IO->rGPGDAT &0x80)==0) //灯亮
s2440IO->rGPGDAT |= 0xFFFF; //GPG7>>LED3灭
else
s2440IO->rGPGDAT &= 0xFF7F; //GPG7>>LED3亮
}
InterruptDone(g_TIMER2SysIntr);
}
return TRUE;
}
/*******************************************************************************************
函数名称: TIM_Init
描 述: 驱动程序初始化函数
输入参数: DWORD dwContext: 设备管理器传递给本驱动的参数, 通常为流接口驱动在注册表内的位置
输出参数: 无
返 回: 驱动程序句柄
*******************************************************************************************/
DWORD TIM_Init(DWORD dwcontext)
{
DWORD IDThread;
TimerGpioInit();
Timer2_Setup();
// 创建中断中断事件
TimerEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
// 初始化外部按键中断: 注册中断事件, 允许外部中断
if (!(InterruptInitialize(g_TIMER2SysIntr, TimerEvent, 0, 0)))
{
RETAILMSG(1, (TEXT("ERROR: TIMER2TIM: InterruptInitialize failed.\r\n")));
CloseHandle(TimerEvent);
return 0;
}
// 从 OAL 请求一个 SYSINTR 值
if (!KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &g_TIMER2Irq, sizeof(UINT32), &g_TIMER2SysIntr, sizeof(UINT32), NULL))
{
RETAILMSG(1, (TEXT("ERROR: TIMER2: Failed to request sysintr value for EINT interrupt.\r\n")));
return(0);
}
RETAILMSG(1,(TEXT("INFO: TIMER2: Mapped Irq 0x%x to SysIntr 0x%x.\r\n"), g_TIMER2Irq, g_TIMER2SysIntr));
// 创建一个外部中断处理线程 IST
TimerThread = CreateThread(0, 0, (LPTHREAD_START_ROUTINE) TimerIntrProcessThread, 0, 0, &IDThread);
if (TimerThread == NULL)
{
RETAILMSG(1, (TEXT("::: TIM_Init: CreateThread() Fail.\r\n")));
KernelIoControl(IOCTL_HAL_RELEASE_SYSINTR, &g_TIMER2SysIntr, sizeof(UINT32), NULL, 0, NULL);
return 0;
}
RETAILMSG(1, (TEXT("::: TIM_Init Sucessfully! \r\n")));
// 返回不为0的数
return (DWORD)TimerThread;
}
BOOL TIM_Deinit(DWORD hDeviceContext)
{
BOOL bRet = TRUE;
RETAILMSG(1, (TEXT("TIMER_INTR_Deinit --- \r\n")));
InterruptDisable(g_TIMER2SysIntr);
CloseHandle(TimerThread);
VirtualFree((void*)s2440IO, sizeof(IOPreg), MEM_RELEASE);
VirtualFree((void*)s2440INT, sizeof(INTreg), MEM_RELEASE);
VirtualFree((void*)s2440PWM, sizeof(PWMreg), MEM_RELEASE);
return TRUE;
}
**********************************************************************
各位大侠 帮忙看看啊,哪里设置不对了呢,为什么中断没有呢?求解答,拜托了!!
加载驱动就失败 但是TIMER2端口有脉冲波出来~~~~·再不做出来,后果很严重了 ,555555555
可联系我QQ20461368
|
|