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

📄 utopia_interrupt.c

📁 dsp tms320c6486的csl例程
💻 C
字号:
/*  ============================================================================
 *   Copyright (c) Texas Instruments Inc 2002, 2003, 2004, 2005, 2006
 *
 *   Use of this software is controlled by the terms and conditions found
 *   in the license agreement under which this software has been supplied.
 *  ============================================================================
 */
/** ============================================================================
 *   @file  utopia_interrupt.c
 *
 *   @path  $(CSLPATH)\example\c6486\utopia2\src
 *
 *   @desc  This file contains the intterupt setup for UTOPIA.  
 *
 *  ============================================================================
 */

#include <csl_intc.h>
#include <csl_intcAux.h>
Uint32 profileStopLowRcv[6] = {0,0,0,0,0,0};
Uint32 profileStopHighRcv[6] = {0,0,0,0,0,0};
void disable_interrupt(void);

interrupt void PDMATX_ISR(void);
interrupt void PDMARX_ISR(void);
interrupt void UTOPIA_ISR(void);

void UTOPIA_Setup_Interrupt();
void Close_Interrupt_Handle();

CSL_IntcEventHandlerRecord Record1[3];

CSL_IntcHandle hIntcUtopia  = NULL,hIntcPdmaTx = NULL,hIntcPdmaRx = NULL;

CSL_IntcObj intcUtopiaObj,intcPdmaTxObj,intcPdmaRxObj;


volatile Uint32 Test_Done =0;
Uint32 Tput_Test_Done = 0;

/*
 * =============================================================================
 *   @func   UTOPIA_Setup_Interrupt
 *
 *   @desc
 *  @n This function is to setup interrupt for UTOPIA
 *
 *  @arg  
 *      None
 *
 *  @return
 *      None
 * =============================================================================
 */
void UTOPIA_Setup_Interrupt (
    void
)
{
    CSL_IntcContext context1;
    CSL_IntcParam vectId_0, vectId_1,vectId_2;
    CSL_IntcGlobalEnableState state;
    

    /* Setup the global Interrupt */
    context1.numEvtEntries = 24;
    context1.eventhandlerRecord = Record1; 
    CSL_intcInit(&context1);

    /* Enable NMIs  */
    CSL_intcGlobalNmiEnable();

    /* Enable Global Interrupts  */
    CSL_intcGlobalEnable(&state);

    /* Opening a handle for the Global Edma Event  */
    vectId_0 = CSL_INTC_VECTID_7;
    vectId_1 = CSL_INTC_VECTID_9;
    vectId_2 = CSL_INTC_VECTID_10;

    /* Event Id - 56 */
    hIntcUtopia	= CSL_intcOpen(&intcUtopiaObj,CSL_INTC_EVENTID_UINT,&vectId_0,
                               NULL);
    /* Event Id - 30 */
    hIntcPdmaRx = CSL_intcOpen(&intcPdmaRxObj,CSL_INTC_EVENTID_PRINT,&vectId_1,
                               NULL);
    /* Event Id - 31 */
    hIntcPdmaTx  = CSL_intcOpen(&intcPdmaTxObj,CSL_INTC_EVENTID_PXINT,&vectId_2,
                                NULL);

   	/*Hook the ISR*/
    CSL_intcHookIsr(vectId_0, &UTOPIA_ISR);
    CSL_intcHookIsr(vectId_1, &PDMARX_ISR);
    CSL_intcHookIsr(vectId_2, &PDMATX_ISR);

	/*Clear interrupts*/  
    CSL_intcHwControl(hIntcPdmaRx, CSL_INTC_CMD_EVTCLEAR,NULL);
    CSL_intcHwControl(hIntcPdmaTx, CSL_INTC_CMD_EVTCLEAR,NULL);
    CSL_intcHwControl(hIntcUtopia, CSL_INTC_CMD_EVTCLEAR,NULL);

   	/* Enable Event & interrupt */
    CSL_intcHwControl(hIntcUtopia,CSL_INTC_CMD_EVTENABLE,NULL);
    CSL_intcHwControl(hIntcPdmaTx,CSL_INTC_CMD_EVTENABLE,NULL);
    CSL_intcHwControl(hIntcPdmaRx,CSL_INTC_CMD_EVTENABLE,NULL);
}

/*
 * =============================================================================
 *   @func   UTOPIA_ISR
 *
 *   @desc
 *  @n This function is the ISR routine for utopia.
 *
 *  @arg  
 *      None
 *
 *  @return
 *      None
 * =============================================================================
 */
interrupt void UTOPIA_ISR (
    void
)
{
    Uint32 loopCnt = 0;
	while (loopCnt < 0x100)
	    loopCnt++;
}

/*
 * =============================================================================
 *   @func   PDMATX_ISR
 *
 *   @desc
 *  @n This function is the PDMA transmit interrupt service routine.
 *
 *  @arg  
 *      None
 *
 *  @return
 *      None
 * =============================================================================
 */
interrupt void PDMATX_ISR (
    void
)
{   
    Uint32 loopCnt = 0;

	while (loopCnt < 0x100)
	    loopCnt++;

    Test_Done++; 
	Tput_Test_Done++;
	CSL_intcHwControl(hIntcPdmaTx, CSL_INTC_CMD_EVTCLEAR, 
                      (void*)CSL_INTC_EVENTID_PXINT);
}

/*
 * =============================================================================
 *   @func   PDMARX_ISR
 *
 *   @desc
 *  @n This function is the PDMA receive interrupt service routine.
 *
 *  @arg  
 *      None
 *
 *  @return
 *      None
 * =============================================================================
 */
interrupt void PDMARX_ISR (
    void
)
{   
    Uint32 loopCnt = 0;

	while (loopCnt < 0x100)
	    loopCnt++;

	Tput_Test_Done++;
	Test_Done++;
	CSL_intcHwControl(hIntcPdmaRx, CSL_INTC_CMD_EVTCLEAR, 
                      (void*)CSL_INTC_EVENTID_PRINT);
}

/*
 * =============================================================================
 *   @func   disable_interrupt
 *
 *   @desc
 *  @n This function is to disable the interrupts
 *
 *  @arg  
 *      None
 *
 *  @return
 *      None
 * =============================================================================
 */
void disable_interrupt (
    void
)
{
	CSL_intcHwControl(hIntcPdmaTx, CSL_INTC_CMD_EVTDISABLE,
                      (void*)CSL_INTC_EVENTID_PXINT);
	CSL_intcHwControl(hIntcPdmaRx, CSL_INTC_CMD_EVTDISABLE, 
                      (void*)CSL_INTC_EVENTID_PRINT);
}

/*
 * =============================================================================
 *   @func   Close_Interrupt_Handle
 *
 *   @desc
 *  @n This function is to close pdma, interrupt and/or utopia instances
 *
 *  @arg  
 *      None
 *
 *  @return
 *      None
 * =============================================================================
 */
void Close_Interrupt_Handle (
    void
)
{
	if (hIntcPdmaTx != NULL) {
        	CSL_intcClose(hIntcPdmaTx);
	}
	if (hIntcPdmaRx != NULL) {
        	CSL_intcClose(hIntcPdmaRx);
	}
	if (hIntcUtopia != NULL) {
        	CSL_intcClose(hIntcUtopia);
	}
}
/*****************************************************************************\
* End of utopia_interrupt.c
\*****************************************************************************/

⌨️ 快捷键说明

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