sweep.c

来自「ADI 公司的DSP ADSP21262 EZ-KIT LITE开发板的全部源代」· C语言 代码 · 共 64 行

C
64
字号
//cycle LED's to coincide w/ sample playback from flash
#include "Sample Playback.h"
#include <signal.h>

#define SWEEP_RATE 0x60000


//This routine is running most of the time and uses the PP to write updated
//LED values to a latch.  Most of the time in this routine is spent in idle
//loops to controll the sweep rate. This routine is frequently interrupted 
//by the SPORT2 interrupt which is concurrently fetching audio data from
//the flash.  To avoid any contention over use of the PP, the SPORT2
//interrupt is temporarily masked while data is written to the LED latch.
 

void sweep(void){
    
    int i;
    int wait;
    
//sweep left
    for(i=0;i<14;i++) 
    {
        //temporarily mask the SP2 interrupt - note interrupts will still
        //be latched, the just won't be serviced immediately.  Writing to 
        //the LED latch is very fast relative to the rate at which samples
        //are being sent so this is not a problem.
        interrupts (SIG_SP2, SIG_IGN);
        
            //rotate left
            LED_value= (LED_value<<1)|(LED_value >> 32-1); 
            //write new value to LED latch
            latchLEDs(LED_value);
        
        //reenable SPORT2 interrupt
        interrupts (SIG_SP2, play_sample_ISR);
        interrupts (SIG_SP1, SIG_IGN); //Tools Anomaly sets SP1 int with all Even SPORTS
                          
        for(wait=SWEEP_RATE; wait>0; wait--) {
            asm("nop;");
        }
    }
        

//sweep right
    for(i=0;i<14;i++) 
    {
        interrupts (SIG_SP2, SIG_IGN);
        
            //rotate right
            LED_value=(LED_value>>1)|(LED_value << 32-1); 
            latchLEDs(LED_value);
            
        interrupts (SIG_SP2, play_sample_ISR);
        interrupts (SIG_SP1, SIG_IGN); //Tools Anomaly sets SP1 int with all Even SPORTS
        
                
        for(wait=SWEEP_RATE; wait>0; wait--) {
            asm("nop;");
        }
    }
   
}//end sweep()

⌨️ 快捷键说明

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