📄 utopia_interrupt.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_util.c
*
* @path $(CSLPATH)\example\c6486\utopia2\src
*
* @desc This file contains the utility function for utopia2 example
*
* =============================================================================
*/
#include <csl_intc.h>
#include <csl_intcAux.h>
#include <csl_utopia2.h>
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;
extern CSL_Utopia2Handle hUtopia2;
Uint32 UtopiaError;
volatile Uint32 Test_Done =0;
Uint32 Tput_Test_Done = 0;
/*
* =============================================================================
* @func UTOPIA_Setup_Interrupt
*
* @arg
* NONE
*
* @desc
* This function sets up the utopia2 interrupt.
*
* @return
* NONE
*
* =============================================================================
*/
void UTOPIA_Setup_Interrupt()
{
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
*
* @arg
* NONE
*
* @desc
* This function is ISR Routine for PDMA Transmit and Receive Interrupts
*
* @return
* NONE
*
* =============================================================================
*/
interrupt void UTOPIA_ISR(void)
{
CSL_BitMask16 UtopiaErrStatus;
CSL_utopia2GetHwStatus(hUtopia2, CSL_UTOPIA2_QUERY_ERR_PENDING_STATUS,
&UtopiaErrStatus);
if (UtopiaErrStatus != 0)
{
UtopiaError = 1;
}
}
/*
* =============================================================================
* @func PDMATX_ISR
*
* @arg
* NONE
*
* @desc
* Transmit Interrupt service routine for PDMA.
*
* @return
* NONE
*
* =============================================================================
*/
interrupt void PDMATX_ISR(void)
{
Test_Done++;
Tput_Test_Done++;
CSL_intcHwControl(hIntcPdmaTx ,CSL_INTC_CMD_EVTCLEAR,(void*)CSL_INTC_EVENTID_PXINT);
}
/*
* =============================================================================
* @func PDMARX_ISR
*
* @arg
* NONE
*
* @desc
* Receive Interrupt service routine for PDMA.
*
* @return
* NONE
*
* =============================================================================
*/
interrupt void PDMARX_ISR(void)
{
Tput_Test_Done++;
Test_Done++;
CSL_intcHwControl(hIntcPdmaRx ,CSL_INTC_CMD_EVTCLEAR,(void*)CSL_INTC_EVENTID_PRINT);
}
/*
* =============================================================================
* @func disable_interrupt
*
* @arg
* NONE
*
* @desc
* This function is to disable the interrupts.
*
* @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);
}
/* Close Interrupt Handles */
/*
* =============================================================================
* @func Close_Interrupt_Handle
*
* @arg
* NONE
*
* @desc
* This function closes the interrupt handle
*
* @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 + -