isr.c

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

C
91
字号
///////////////////////////////////////////////////////////////////////////////////////
//NAME:     isr.c (Block-based Talkthrough)
//DATE:     9/18/03
//PURPOSE:  Talkthrough framework for sending and receiving samples to the AD1835.
//
//USAGE:    This file contains SPORT0 Interrupt Service Routine. Three buffers are used
//          for this example. One is filled by the ADC, another is sent to the DAC, and
//          the final buffer is processed. Each buffer rotates between these functions
//          upon each SP0 interrupt received.
///////////////////////////////////////////////////////////////////////////////////////
/*
   Here is the mapping between the SPORTS and the DACS
   ADC -> DSP  : SPORT0A : IIS
   DSP -> DAC1 : SPORT1A : IIS
   DSP -> DAC2 : SPORT1B : IIS
   DSP -> DAC3 : SPORT2A : IIS
   DSP -> DAC4 : SPORT2B : IIS
*/

#include "tt.h"
#include <stdio.h>
#include <SRU.h>
#include "CS8416.h"

void SetupSPICS8416(void);
void DisableSPICS8416(void);
void SetupSPICS8416(void);
void DisableSPICS8416(void);
void ProcessingTooLong(void);

extern unsigned int Block_A[NUM_SAMPLES] ;
extern unsigned int Block_B[NUM_SAMPLES] ;
extern unsigned int Block_C[NUM_SAMPLES] ;

extern unsigned int OFFSET ;


    //Pointer to the blocks

unsigned int *src_pointer[3] = {Block_A,
                                Block_B,
                                Block_C};

// Counter to choose which buffer to process                            
int int_cntr=2;
// Semaphore to indicate to main that a block is ready for processing
int blockReady=0;
// Semaphore to indicate to the isr that the processing has not completed before the
// buffer will be overwritten.
int isProcessing=0;

// Output should be muted if the stream received from the SPDIF receiver
// is not linear PCM
int outputMuted=0;

//If the processing takes too long, the program will be stuck in this infinite loop.
void ProcessingTooLong()
{
    while(1);
}

void TalkThroughISR(int sig_int)
{
	int isNonAudio = (*(volatile int *)DAI_PIN_STAT & 0x08000);
    if(isNonAudio && !outputMuted)
    {
		SetupSPICS8416();
		WriteCS8416Register(SPDIF_CTRL1, CTRL1_MUTESAO);
		DisableSPICS8416();
    	outputMuted = 1;
    }

    if(!isNonAudio && outputMuted)
    {
		SetupSPICS8416();
    	WriteCS8416Register(SPDIF_CTRL1, 0x00);
		DisableSPICS8416();
    	outputMuted = 0;
    }
        
    if(isProcessing)
        ProcessingTooLong();

    //Increment the block pointer
    int_cntr++;
    int_cntr %= 3;

    blockReady = 1;

}

⌨️ 快捷键说明

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