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

📄 intc_setup.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  Intc_setup.c
 *
 *   PATH:  \$(CSLPATH)\\example\\emac\\src
 *
 *   @brief  EMAC CSL Example support file for tnterrupts configuration
 */

/* =============================================================================
 *  Revision History
 *  ===============
 *  16-Mar-06 PSk  file created
 * =============================================================================
 */

#include <stdio.h>
#include <soc.h> 
#include <csl_tmr.h>
#include <csl_intc.h>
 

extern void interrupt TimerTick(void);
extern void interrupt HwRxInt(void);
extern void interrupt HwTxInt(void);

 
/****** Static variable declarations ***********/
 
/* Intc objects */
static CSL_IntcContext context;
static CSL_IntcEventHandlerRecord Record[13];
 
/* timer interrupt object */
static CSL_IntcObj intcTimer;
static CSL_IntcObj intcEMACRx;
static CSL_IntcObj intcEMACTx;

static CSL_IntcHandle hIntcTimer; 
static CSL_IntcHandle hIntcEMACRx; 
static CSL_IntcHandle hIntcEMACTx; 

 
/* Timer object */
static CSL_TmrObj     tmrObj;
/* handle for Timer */
static CSL_TmrHandle  hTimer;


static volatile Bool bRun = TRUE;   // boolean that indicating if testcase is complete
 
/******* local function definitions **********/
void DoTimerInitialization(void)
{  
   CSL_Status     status;  
   CSL_TmrHwSetup hwSetup;
   CSL_TmrEnamode tmr_ena_mode = CSL_TMR_ENAMODE_CONT;
 
   hTimer   = CSL_tmrOpen(&tmrObj, CSL_TMR_0, NULL, &status);
   /* Get existing hwSetup values from Timer Registers */
   status   = CSL_tmrGetHwSetup(hTimer, &hwSetup);
   /* Timer 0 HW Setup Modifications */
   hwSetup.tmrTimerPeriodHi = 0;
   hwSetup.tmrTimerPeriodLo = 1750; // assuming CPU clock 1050 MHz
   hwSetup.tmrIpGateHi = CSL_TMR_CLOCK_INP_NOGATE;
   hwSetup.tmrIpGateLo = CSL_TMR_CLOCK_INP_NOGATE;
   hwSetup.tmrTimerCounterHi = 0x0;
   hwSetup.tmrTimerCounterLo = 0x0;
   hwSetup.tmrIpGateLo = CSL_TMR_CLOCK_INP_NOGATE;
   hwSetup.tmrClksrcLo= CSL_TMR_CLKSRC_INTERNAL;
   hwSetup.tmrClockPulseLo = CSL_TMR_CP_PULSE;      
   hwSetup.tmrInvOutpHi    = CSL_TMR_INVOUTP_UNINVERTED;      
   hwSetup.tmrInvOutpLo    = CSL_TMR_INVOUTP_UNINVERTED;      
   hwSetup.tmrTimerMode    = CSL_TMR_TIMMODE_DUAL_UNCHAINED;
 
   /* Program Timer 0 HW based on hwSetup Structure Modifications*/
   status   = CSL_tmrHwSetup(hTimer, &hwSetup);
   /* Start Timer 0 - And Enable */  
   status  = CSL_tmrHwControl(hTimer, CSL_TMR_CMD_START64, &tmr_ena_mode );
  
}

/*********************************************************
 * Intc setup
 *
 ********************************************************/
void DoInterruptsInitialization(void)
{
   CSL_IntcParam vectId1;
   CSL_IntcParam vectId2;
   CSL_IntcParam vectId3;

   CSL_IntcGlobalEnableState state;
   
   /* Setup the global Interrupt */
   context.numEvtEntries = 13;
   context.eventhandlerRecord = Record; 

   /* VectorID for the Global Edma Event  */
   vectId1 = CSL_INTC_VECTID_8;
   vectId2 = CSL_INTC_VECTID_9;
   vectId3 = CSL_INTC_VECTID_10;
	
   CSL_intcInit(&context);
   /* Enable NMIs  */
   CSL_intcGlobalNmiEnable();
   /* Enable Global Interrupts  */
   CSL_intcGlobalEnable(&state);
   
   /* Opening a handle for the timer */
   hIntcTimer = CSL_intcOpen(&intcTimer, CSL_INTC_EVENTID_TINTLO_LOCAL, &vectId1, NULL);
 
   /* Opening a handle for EMAC Rx interrupt */
   hIntcEMACRx = CSL_intcOpen(&intcEMACRx, CSL_INTC_EVENTID_MACRXINT0, &vectId2, NULL);

   /* Opening a handle for EMAC Tx interrupt */
   hIntcEMACTx = CSL_intcOpen(&intcEMACTx, CSL_INTC_EVENTID_MACTXINT0, &vectId3, NULL);
   
   /* Hook the ISRs */
   CSL_intcHookIsr(vectId1,&TimerTick);
   CSL_intcHookIsr(vectId2,&HwRxInt);
   CSL_intcHookIsr(vectId3,&HwTxInt);
  
   /* Clear the Interrupt */
   CSL_intcHwControl(hIntcTimer, CSL_INTC_CMD_EVTCLEAR, NULL);
   CSL_intcHwControl(hIntcEMACRx, CSL_INTC_CMD_EVTCLEAR, NULL);
   CSL_intcHwControl(hIntcEMACTx, CSL_INTC_CMD_EVTCLEAR, NULL);
     
    /* Enable the Event & the interrupt */
   CSL_intcHwControl(hIntcTimer, CSL_INTC_CMD_EVTENABLE, NULL);   
   CSL_intcHwControl(hIntcEMACRx, CSL_INTC_CMD_EVTENABLE, NULL);   
   CSL_intcHwControl(hIntcEMACTx, CSL_INTC_CMD_EVTENABLE, NULL);   
}

/*********************************************************
 * Intc close 
 *
 ********************************************************/

void DoInterruptEnd(void)
{
   CSL_intcGlobalDisable(NULL);
   CSL_intcClose(hIntcEMACRx);
   CSL_intcClose(hIntcEMACTx);
   CSL_intcClose(hIntcTimer);
}

⌨️ 快捷键说明

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