⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interrupt.c

📁 ebd9307开发板wince bsp源码,包括cs8900,lcd,nand,serial,touch,usb,gpio,wd等驱动
💻 C
📖 第 1 页 / 共 4 页
字号:
		*GPIO_BEOI = EGPIO_UART4_INT; // Clean all previous interrupt

		value = *GPIO_BINTEN;
		value |= EGPIO_UART4_INT; // Enable interrupt
		*GPIO_BINTEN = value;
		//RETAILMSG(1, (TEXT("...OEMInterruptEnable,idInt = SYSINTR_UART4\r\n")));
	}
	else if( idInt == SYSINTR_UART5) 
	{
		// Enable EGPIO11for UART5 interrupt.
		UINT value;

		value = *GPIO_PBDDR;
		value &= ~EGPIO_UART5_INT;
		*GPIO_PBDDR = value; // Set as input

		value = *GPIO_BINTEN;
		value &= ~EGPIO_UART5_INT;
		*GPIO_BINTEN = value; // Disable interrupt.

		value = *GPIO_BINTTYPE1;
		//value &= ~EGPIO_UART5_INT; // level trigure.
		value |= EGPIO_UART5_INT;
		*GPIO_BINTTYPE1 = value;

		value = *GPIO_BINTTYPE2;
		value |= EGPIO_UART5_INT; // high level 
		*GPIO_BINTTYPE2 = value;

		*GPIO_BEOI = EGPIO_UART5_INT; // Clean all previous interrupt

		value = *GPIO_BINTEN;
		value |= EGPIO_UART5_INT; // Enable interrupt
		*GPIO_BINTEN = value;
		//RETAILMSG(1, (TEXT("...OEMInterruptEnable,idInt = SYSINTR_UART5\r\n")));
	}
	else if( idInt == SYSINTR_UART6) 
	{
		// Enable EGPIO12 for UART6 interrupt.
		UINT value;

		value = *GPIO_PBDDR;
		value &= ~EGPIO_UART6_INT;
		*GPIO_PBDDR = value; // Set as input

		value = *GPIO_BINTEN;
		value &= ~EGPIO_UART6_INT;
		*GPIO_BINTEN = value; // Disable interrupt.

		value = *GPIO_BINTTYPE1;
		//value &= ~EGPIO_UART6_INT; // level trigure.
		value |= EGPIO_UART6_INT;
		*GPIO_BINTTYPE1 = value;

		value = *GPIO_BINTTYPE2;
		value |= EGPIO_UART6_INT; // high level 
		*GPIO_BINTTYPE2 = value;

		*GPIO_BEOI = EGPIO_UART6_INT; // Clean all previous interrupt

		value = *GPIO_BINTEN;
		value |= EGPIO_UART6_INT; // Enable interrupt
		*GPIO_BINTEN = value;
		//RETAILMSG(1, (TEXT("...OEMInterruptEnable,idInt = SYSINTR_UART6\r\n")));
	}
	else if( idInt == SYSINTR_UART7) 
	{
		// Enable EGPIO13 for UART7 interrupt.
		UINT value;

		value = *GPIO_PBDDR;
		value &= ~EGPIO_UART7_INT;
		*GPIO_PBDDR = value; // Set as input

		value = *GPIO_BINTEN;
		value &= ~EGPIO_UART7_INT;
		*GPIO_BINTEN = value; // Disable interrupt.

		value = *GPIO_BINTTYPE1;
		//value &= ~EGPIO_UART7_INT; // level trigure.
		value |= EGPIO_UART7_INT;
		*GPIO_BINTTYPE1 = value;

		value = *GPIO_BINTTYPE2;
		value |= EGPIO_UART7_INT; // high level 
		*GPIO_BINTTYPE2 = value;

		*GPIO_BEOI = EGPIO_UART7_INT; // Clean all previous interrupt

		value = *GPIO_BINTEN;
		value |= EGPIO_UART7_INT; // Enable interrupt
		*GPIO_BINTEN = value;
		//RETAILMSG(1, (TEXT("...OEMInterruptEnable,idInt = SYSINTR_UART7\r\n")));
	}
//#endif
	else if(idInt == SYSINTR_CAN1)
	{
		*GPIO_PADDR &= ~EGPIO_CAN1_INT;   //EGPIO4(CAN_INT) INPUT

		*GPIO_AINTEN &= ~EGPIO_CAN1_INT;                //disable CAN_INT,set EGPIO4 as normal GPIO
		*GPIO_AINTTYPE1 &= ~EGPIO_CAN1_INT;                //level sensitive(EGPIO4)
		*GPIO_AINTTYPE2 &= ~EGPIO_CAN1_INT;                //low level sensitive(EGPIO4)
		*GPIO_AEOI |= EGPIO_CAN1_INT;                //clear  interrupt
		*GPIO_AINTEN |= EGPIO_CAN1_INT;                //enable CAN_INT
	}
	else if(idInt == SYSINTR_CAN2)
	{
		*GPIO_PADDR &= ~EGPIO_CAN2_INT;   //EGPIO5(CAN_INT) INPUT

		*GPIO_AINTEN &= ~EGPIO_CAN2_INT;                //disable CAN_INT,set EGPIO5 as normal GPIO
		*GPIO_AINTTYPE1 &= ~EGPIO_CAN2_INT;                //level sensitive(EGPIO5)
		*GPIO_AINTTYPE2 &= ~EGPIO_CAN2_INT;                //low level sensitive(EGPIO5)
		*GPIO_AEOI |= EGPIO_CAN2_INT;                //clear  interrupt
		*GPIO_AINTEN |= EGPIO_CAN2_INT;                //enable CAN_INT
	}


    INTERRUPTS_ON();

    return(bRet);
}

/*
 * @func   BOOL | OEMInterruptDisable | Disable a hardware interrupt
 *
 * @rdesc  none
 *
 * @parms
 *         idInt   Interrupt ID to be disabled.
 *                 See Interrupt ID's.Interrupt ID's>  for a list of
 *                 possble values.
 *
 * @comm   OEMInterruptDisable is called by the Kernel when a device driver
 *         calls <f InterruptDisable>. The system is not preemtible when this
 *         function is called.
 *
 * @xref
 *         Overview.Windows CE Kernel OEM Interface
 *         InterruptDisable
 */
void OEMInterruptDisable(DWORD idInt)
{
    // NKDbgPrintfW(L"OEMInterruptDisable: Interrupt #%02d\r\n", idInt);

    BOOL    bRet = TRUE;
    ULONG   ulIntMask1, ulIntMask2;


    bRet = SysIntrNumToInterruptMask(idInt, &ulIntMask1, &ulIntMask2);
    INTERRUPTS_OFF();

//#ifdef BSP_EXT_UART
	if(idInt == SYSINTR_UART4)
	{
		UINT value;

		*GPIO_BEOI = EGPIO_UART4_INT; // Clean all previous interrupt
		
		value = *GPIO_BINTEN;
		value &= ~EGPIO_UART4_INT;	// Disable interrupt.
		*GPIO_BINTEN = value;

		//gdwInterruptMask2  &= ~ulIntMask2;
		INTERRUPTS_ON();
		//RETAILMSG(1, (TEXT("OEMInterruptDisable,idInt = SYSINTR_UART4\r\n")));
		return;
	}
	else if(idInt == SYSINTR_UART5)
	{
		UINT value;

		*GPIO_BEOI = EGPIO_UART5_INT; // Clean all previous interrupt
		
		value = *GPIO_BINTEN;
		value &= ~EGPIO_UART5_INT;	// Disable interrupt.
		*GPIO_BINTEN = value;

		//gdwInterruptMask2  &= ~ulIntMask2;
		INTERRUPTS_ON();
		//RETAILMSG(1, (TEXT("OEMInterruptDisable,idInt = SYSINTR_UART5\r\n")));
		return;
	}
	else if(idInt == SYSINTR_UART6)
	{
		UINT value;

		*GPIO_BEOI = EGPIO_UART6_INT; // Clean all previous interrupt
		
		value = *GPIO_BINTEN;
		value &= ~EGPIO_UART6_INT;	// Disable interrupt.
		*GPIO_BINTEN = value;

		//gdwInterruptMask2  &= ~ulIntMask2;
		INTERRUPTS_ON();
		//RETAILMSG(1, (TEXT("OEMInterruptDisable,idInt = SYSINTR_UART6\r\n")));
		return;
	}
	else if(idInt == SYSINTR_UART7)
	{
		UINT value;

		*GPIO_BEOI = EGPIO_UART7_INT; // Clean all previous interrupt
		
		value = *GPIO_BINTEN;
		value &= ~EGPIO_UART7_INT;	// Disable interrupt.
		*GPIO_BINTEN = value;

		//gdwInterruptMask2  &= ~ulIntMask2;
		INTERRUPTS_ON();
		//RETAILMSG(1, (TEXT("OEMInterruptDisable,idInt = SYSINTR_UART7\r\n")));
		return;
	}
//#endif
	else if(idInt == SYSINTR_CAN1)
	{
		UINT value;

		*GPIO_AEOI = EGPIO_CAN1_INT; // Clean all previous interrupt
		
		value = *GPIO_AINTEN;
		value &= ~EGPIO_CAN1_INT;	// Disable interrupt.
		*GPIO_AINTEN = value;

		//gdwInterruptMask2  &= ~ulIntMask2;
		INTERRUPTS_ON();
		return;
	}
	else if(idInt == SYSINTR_CAN2)
	{
		UINT value;

		*GPIO_AEOI = EGPIO_CAN2_INT; // Clean all previous interrupt
		
		value = *GPIO_AINTEN;
		value &= ~EGPIO_CAN2_INT;	// Disable interrupt.
		*GPIO_AINTEN = value;

		//gdwInterruptMask2  &= ~ulIntMask2;
		INTERRUPTS_ON();
		return;
	}


    if(ulIntMask1)
    {
        *VIC1_INTCLEAR      = ulIntMask1;
        gdwInterruptMask1   &= ~ulIntMask1;
    }

    if(ulIntMask2)
    {
        *VIC2_INTCLEAR     = ulIntMask2;
        gdwInterruptMask2  &= ~ulIntMask2;
    }

    if(idInt == SYSINTR_PIO_PLAYBACK )
    {
        if(!sRecord.bIntEnabled)
        {
            if(gbAC97)
            {
                *VIC1_INTCLEAR          = INT1_AAC;
                gdwInterruptMask1       &= ~INT1_AAC;
            }
            else
            {
                *VIC2_INTCLEAR          = INT2_SAI;
                gdwInterruptMask2       &= ~INT2_SAI;
            }
        }
        sPlayBack.bEnabled      = FALSE;
        sPlayBack.bIntEnabled   = FALSE;
    }

    if(idInt == SYSINTR_PIO_RECORD )
    {
        if(!sPlayBack.bIntEnabled)
        {
            if(gbAC97)
            {
                *VIC1_INTCLEAR          = INT1_AAC;
                gdwInterruptMask1       &= ~INT1_AAC;
            }
            else
            {
                *VIC2_INTCLEAR          = INT2_SAI;
                gdwInterruptMask2       &= ~INT2_SAI;
            }
        }
        sRecord.bEnabled        = FALSE;
        sRecord.bIntEnabled     = FALSE;
    }
/*
#ifdef EDB9315A_CIR
	if(idInt == SYSINTR_PIO_CIR )
	{
		// Initialize EGPIO13 for CIR interrupt.
		UINT value;

	    //OEMWriteDebugByte('D');
	    //OEMWriteDebugByte('\r');
	    //OEMWriteDebugByte('\n');
	    
		value = *GPIO_BINTEN;
		value &= ~0x20;	// Disable interrupt.
		*GPIO_BINTEN = value;

		gnWi = 0;
		gnKeyCode = 0;

	}
#endif
*/

    INTERRUPTS_ON();
	//RETAILMSG(1, (TEXT("......................OEMInterruptDisable,idInt = 0x%X\r\n"),idInt));
    return;
}

/*
 * @func   BOOL | OEMInterruptDone | Signal completion of interrupt processing
 *
 * @rdesc  none
 *
 * @parms
 *         idInt   Interrupt ID to be enabled.
 *                 See Interrupt ID's.Interrupt ID's>  for a list of
 *                 possble values.
 *
 * @comm   OEMInterruptDone is called by the Kernel when a device driver
 *         calls InterruptDone(). The system is not preemtible when this
 *         function is called.
 *
 * @xref
 *         Overview.Kernel Interrupt Support
 *         InterruptDone
 */
void OEMInterruptDone(DWORD idInt)
{
    BOOL    bRet = TRUE;
    ULONG   ulIntMask1, ulIntMask2;


    bRet = SysIntrNumToInterruptMask(idInt, &ulIntMask1, &ulIntMask2);

    INTERRUPTS_OFF();

    // NOTE: we expect the interrupt to be turned off at the device.  The
    // state isn't latched in any board-level registers.

    // Enable interrupt.
    //OEMInterruptEnable(idInt, NULL, 0);
    if(idInt == SYSINTR_PIO_PLAYBACK )
    {
        *VIC1_SOFTINTCLEAR  = INT1_UNUSED1;
    }
    if(idInt == SYSINTR_PIO_RECORD )
    {
        *VIC1_SOFTINTCLEAR  = INT1_UNUSED2;
    }
/*
#ifdef EDB9315A_CIR
	if(idInt == SYSINTR_PIO_CIR )
	{
		UINT value;
		
	    //OEMWriteDebugByte('N');
	    //OEMWriteDebugByte('\r');
	    //OEMWriteDebugByte('\n');

		//gnWi = 0;
		//gnKeyCode = 0;

		*GPIO_BEOI = 0x20; // Clean previous interrupt

		value = *GPIO_BINTEN;
		value |= 0x20; // Enable interrupt
		*GPIO_BINTEN = value;	
	}
#endif
*/
//#ifdef BSP_EXT_UART
	if(idInt == SYSINTR_UART4)
	{
		UINT value;
		
		//*GPIO_BEOI = EGPIO_UART4_INT; // Clean all previous interrupt

		value = *GPIO_BINTEN;
		value |= EGPIO_UART4_INT; // Enable interrupt
		*GPIO_BINTEN = value;

		INTERRUPTS_ON();
		//delay();
		//RETAILMSG(1, (TEXT("......OEMInterruptDone,idInt = SYSINTR_UART4\r\n")));
		return;
	}
	else if(idInt == SYSINTR_UART5)
	{
		UINT value;

		//*GPIO_BEOI = EGPIO_UART5_INT; // Clean all previous interrupt

		value = *GPIO_BINTEN;
		value |= EGPIO_UART5_INT; // Enable interrupt
		*GPIO_BINTEN = value;

		INTERRUPTS_ON();
		//delay();
		//RETAILMSG(1, (TEXT("......OEMInterruptDone,idInt = SYSINTR_UART5\r\n")));
		return;
	}
	else if(idInt == SYSINTR_UART6)
	{
		UINT value;

		//*GPIO_BEOI = EGPIO_UART6_INT; // Clean all previous interrupt

		value = *GPIO_BINTEN;
		value |= EGPIO_UART6_INT; // Enable interrupt
		*GPIO_BINTEN = value;

		INTERRUPTS_ON();
		//delay();
		//RETAILMSG(1, (TEXT("......OEMInterruptDone,idInt = SYSINTR_UART6\r\n")));
		return;
	}
	else if(idInt == SYSINTR_UART7)
	{
		UINT value;

		//*GPIO_BEOI = EGPIO_UART7_INT; // Clean all previous interrupt

		value = *GPIO_BINTEN;
		value |= EGPIO_UART7_INT; // Enable interrupt
		*GPIO_BINTEN = value;

		INTERRUPTS_ON();
		//delay();
		//RETAILMSG(1, (TEXT("......OEMInterruptDone,idInt = SYSINTR_UART7\r\n")));
		return;
	}
//#endif
	else if(idInt == SYSINTR_CAN1)
	{
		UINT value;

		//*GPIO_BEOI = EGPIO_CAN1_INT; // Clean all previous interrupt

		value = *GPIO_AINTEN;
		value |= EGPIO_CAN1_INT; // Enable interrupt
		*GPIO_AINTEN = value;

		INTERRUPTS_ON();
		//delay();
		//RETAILMSG(1, (TEXT("......OEMInterruptDone,idInt = SYSINTR_UART7\r\n")));
		return;
	}
	else if(idInt == SYSINTR_CAN2)
	{
		UINT value;

		//*GPIO_BEOI = EGPIO_CAN2_INT; // Clean all previous interrupt

		value = *GPIO_AINTEN;
		value |= EGPIO_CAN2_INT; // Enable interrupt
		*GPIO_AINTEN = value;

		INTERRUPTS_ON();
		//delay();
		//RETAILMSG(1, (TEXT("......OEMInterruptDone,idInt = SYSINTR_UART7\r\n")));
		return;
	}

    if(ulIntMask1)
    {
        *VIC1_INTENABLE     = ulIntMask1;
        // ASSERT(gdwInterruptMask1 & ulIntMask1);
    }

    if(ulIntMask2)
    {
        *VIC2_INTENABLE     = ulIntMask2;
        // ASSERT(gdwInterruptMask2 & ulIntMask2);
    }


    INTERRUPTS_ON();

}

//****************************************************************************
// OEMInitInterrupts
//****************************************************************************
// Initialize the interrupt controller.
// 
//
void OEMInitInterrupts(void )
{
	//
    // Currently, interrupts on generate irq.  No FIQ's are generated.
    //
    *VIC1_INTSELECT     = 0;
    *VIC2_INTSELECT     = 0;

    //
    // Only the timer interrupt will be enabled initially.
    //
    *VIC1_INTCLEAR      = 0xFFFFFFFF;
    *VIC2_INTCLEAR      = 0xFFFFFFFF;

    //
    // Clear all software interrupts.
    //
    *VIC1_SOFTINTCLEAR  = 0xFFFFFFFF;
    *VIC2_SOFTINTCLEAR  = 0xFFFFFFFF;

    //
    // Allow the Vic to be programmed in all modes.
    //
    *VIC1_PROTECTION    = 0;
    *VIC2_PROTECTION    = 0;

    //
    // Even though we are not using the vectored part of the vectored interrupt
    // controller, we must write VECTCURADDR in order to make sure that lower
    // priority interrupts occur.
    //
    // If you don't do these write no interrupts may occur.
    //
    *VIC1_VECTCURADDR = 0;
    *VIC2_VECTCURADDR = 0;

    //
    // Enable the timer interrupt.
    //
    *VIC1_INTENABLE     = INT1_TIMER1;


    //
    // Initialize the PIO Audio Variables to zero.
    //
    sPlayBack.pulBuffer     = (PULONG)gulTransmitBuffer;
    sPlayBack.ulBufferSize  = 0;
    sPlayBack.pulBufferEnd  = 0;
    sPlayBack.pulBufferHalf = 0;
    sPlayBack.pulPosition   = 0;
    sPlayBack.bEnabled      = FALSE;
    sPlayBack.bIntEnabled   = FALSE;


    sRecord.pulBuffer       = (PULONG)gulRecieveBuffer;
    sRecord.ulBufferSize    = 0;
    sRecord.pulBufferEnd    = 0;
    sRecord.pulBufferHalf   = 0;
    sRecord.pulPosition     = 0;
    sRecord.bEnabled        = FALSE;
    sRecord.bIntEnabled     = FALSE;

    gbAC97                  = FALSE; 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -