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

📄 main_edma1.c

📁 开发TI C6000 DSP需要的Chip Support Library
💻 C
📖 第 1 页 / 共 2 页
字号:
  
  /* Since these variables are the source of an EDMA transfer, we     */
  /* need to flush them out of the cache since we just wrote to them. */
  CACHE_wbInvL2(&ping_data, 4, CACHE_WAIT);
  CACHE_wbInvL2(&pong_data, 4, CACHE_WAIT);

  /* Let's disable/clear related interrupts just in case they are pending */
  /* from a previous run of the program.                                  */  
  setupInterrupts();  /* defined below */
    
  /* Although not required, let's clear all of the EDMA parameter RAM. */
  /* This makes it easier to view the RAM and see the changes as we    */
  /* configure it.                                                     */
  EDMA_clearPram(0x00000000);
   
  /* Let's open up a timer device, we'll use this to simulate input events */
  /* at a given sample rate.                                                */
  hTimer = TIMER_open(TIMER_DEV1, TIMER_OPEN_RESET);

  /* Lets open up the EDMA channel associated with timer #1. */
  hEdma = EDMA_open(EDMA_CHA_TINT1, EDMA_OPEN_RESET);
  
  /* We also need two EDMA reload parameter sets so let's allocate them */
  /* here. Notice the -1, this means allocate any availale table.        */
  hEdmaPing = EDMA_allocTable(-1);
  hEdmaPong = EDMA_allocTable(-1);

  /* Let's copy the ping reload configuration structure to an */
  /* intermediate configuration structure.                    */
  cfgEdma = cfgEdmaPing;
  
  /* Let's initialize the link fields of the configuration structures */
  cfgEdmaPing.rld = EDMA_RLD_RMK(0,hEdmaPing);
  cfgEdmaPong.rld = EDMA_RLD_RMK(0,hEdmaPong);
  cfgEdma.rld     = EDMA_RLD_RMK(0,hEdmaPong);

  /* Now let's program up the EDMA channel with the configuration structure */
  EDMA_config(hEdma, &cfgEdma);   
  
  /* Let's also configure the reload parameter tables in the EDMA PRAM */
  /* with the values in the configuration structures.                  */
  EDMA_config(hEdmaPing, &cfgEdmaPing);
  EDMA_config(hEdmaPong, &cfgEdmaPong);   

  /* Configure up the timer. */
  TIMER_configArgs(hTimer, 
    TIMER_CTL_OF(0x00000200), 
    TIMER_PRD_OF(TPRD), /* timer period  */
    TIMER_CNT_OF(0)
  );   

  /* Enable the related interrupts */  
  IRQ_enable(IRQ_EVT_EDMAINT);
  EDMA_intDisable(TCCINTNUM);
  EDMA_intClear(TCCINTNUM);  
  EDMA_intEnable(TCCINTNUM);        
  
  /* Enable the EDMA channel */
  EDMA_enableChannel(hEdma);   
  
  /* Finally, enable the timer which will drive everything. */
  TIMER_start(hTimer);

  while(transferCount <= TRANSFER_CNT); /* waiting for interrupts */
}

/*----------------------------------------------------------------------------*/
void processbuff(int arg){

  int *inbuff;
  int x;
  printf("\n %2d -",transferCount); 
  if (pingpong){

    /* If pingpong is 0, then we own the ping input buffer */
    inbuff = ping;
    printf(" Ping ");
    
  }else{

    /* If pingpong is 1, then we own the pong input buffer */
    inbuff = pong;
    printf(" Pong " );
    
  }  
  
  transferCount++;
  /* Now let's process the input buffer, for simplicity, we'll */
  /* just copy it to the output buffer.                        */
  for (x=0; x<BUFF_SZ; x++) {
    outbuff[x] = inbuff[x];
  }

  /* If this example is enhanced to actually do something with the  */
  /* output buffer such as DMA it somewhere, you will want to flush */
  /* it out of the cache first.                                     */
   CACHE_wbInvL2(outbuff, (BUFF_SZ << 2), CACHE_WAIT);
 
  
  /* Since we're done processing the input buffer, clean it from cache, */
  /* this invalidates it from cache to ensure we read a fresh version   */
  /* the next time.                                                     */
   CACHE_wbInvL2(inbuff, (BUFF_SZ << 2), CACHE_WAIT);
}
/*----------------------------------------------------------------------------*/

/************************************************************************\
 name:      SetInterruptsEdma

 purpose:   Sets up interrupts to service EDMA transfers

 inputs:    void

 returns:   void
\************************************************************************/
void setupInterrupts(void)
{
     IRQ_setVecs(vectors);     /* point to the IRQ vector table	*/

     IRQ_nmiEnable();
     IRQ_globalEnable();
     
     IRQ_map(IRQ_EVT_EDMAINT, 8);
     IRQ_reset(IRQ_EVT_EDMAINT);
     
} /* End of SetInterruptsEdma() */


/************************************************************************\
 name:      Interrupt Service Routine c_int08

 purpose:   ISR to service EDMAINT. vecs.asm must be modified to include
            c_int08 entry.
            
 inputs:    n/a

 returns:   n/a
\************************************************************************/
interrupt void    
c_int08(void)    
{
  /* Clear the pending interrupt from the EDMA interrupt pending register */
  EDMA_intClear(TCCINTNUM);
  
  /* Perform ping-pong */
  pingpong = (pingpong + 1) & 1;

  /*Exit from the program if certain no of transfres are done*/
  if (transferCount >= TRANSFER_CNT)
  {
      TIMER_pause(hTimer);
      stopEdma();
      TIMER_close(hTimer);
      printf ("\nDone.....");
      exit(0);    
  }
  
  /* Based on if we ping'ed or pong'ed, we need to set the EDMA channel */
  /* link address for the NEXT frame.                                   */
	if (pingpong){
    /* Currently doing pong so setup next frame for ping */                     
  
    /* Modify the input data source, this just simulates */
    /* the input data changing.                          */
    ping_data++;

    /* Rememer to flush this variable out of the cache */
    /* since it's the source of an EDMA transfer       */
    CACHE_wbInvL2(&ping_data, 4, CACHE_WAIT);
    
    /* Now filling pong so set link to ping */
    EDMA_link(hEdma,hEdmaPing);
    
    
  }else{
    /* Currently doing ping so setup next frame for pong */                     
  
    /* Modify the output data source, this just simulates */
    /* the input data changing.                           */
    pong_data++;
    
    /* Rememer to flush this variable out of the cache */
    /* since it's the source of an EDMA transfer       */
    
    CACHE_wbInvL2(&pong_data, 4, CACHE_WAIT); 
    /* Now filling ping so set link to pong */
    
    EDMA_link(hEdma,hEdmaPong);
    
  }  
  processbuff(0);
  return;

} /* end c_int08 */


/************************************************************************\
 name:      stopEdma

 purpose:   Stops the EDMA service.

 inputs:    void

 returns:   void
\************************************************************************/
void stopEdma(void) {

    /*Disable interrupts, close EDMA channel before exit of the program*/
    IRQ_disable(IRQ_EVT_EDMAINT);
    EDMA_RSET(CCER,0x00000000);
    EDMA_disableChannel(hEdma);
    EDMA_intDisable(TCCINTNUM);
    EDMA_intClear(TCCINTNUM);

 	EDMA_close(hEdma);
 	EDMA_resetAll();
 	EDMA_RSET(CIPR,0xFFFFFFFF);
 	EDMA_RSET(ECR,0xFFFFFFFF);
}

⌨️ 快捷键说明

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