sportisr.c
来自「ADI 公司的DSP ADSP21262 EZ-KIT LITE开发板的全部源代」· C语言 代码 · 共 65 行
C
65 行
#include "Sample Playback.h"
#include <stdio.h>
//function is called when there is room in the TXSP2 buffer
//for another audio word.
void play_sample_ISR(int sig_int)
{
Csample* p2samp;
float temp, div;
int nSamps=1;
//toggle LRflag (is LRflag == zero? if true set 1:if false set 0)
LRflag = (LRflag==0 ? 1 : 0) ;
//Sample in FLASH is mono sample, and the same data is played back
//over both left and right channels. Because the CODEC connnection
//is using I2S data, this means that every other word is a R sample
//and then L sample. These two facts require a new audio sample on
//every-other interrupt, not EVERY interrupt.
if (LRflag == 1) {
UpdatePlaylist(); //increment pointers and wrap if necessary
read_flash_samples();
}
//adjust_balance returns a float - first cast to (int), then
//to make left-justified, shift left by 16 (or multiply by 2^16)
adjust_balance();
//always play first sample
//if current sample is L sample
if (LRflag == 1) {
temp = FirstSample->CurrentVal * Lgain;
}
//if current sample is R sample
else{
temp = FirstSample->CurrentVal *= Rgain;
}
p2samp = FirstSample->Next;
//for each next active sample, combine values
while(p2samp){
div=0.5; //1/(float)nSamps;
//average-in this sample
temp = (temp*div) + (p2samp ->CurrentVal)*(div);
//point to next sample and increment the number of samples
p2samp=p2samp->Next;
}
(*pTXSP2B)= (int)temp<<16;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?