int IIR_TCB_LEFT[13]={
(int)IIR_TCB_RIGHT+12, // CP = Chain pointer register
21, // CC/CL = Coefficient buffer length register
1, // CM = Coefficient modifier register
(int)coeffs_low_pass, // CI = Cofficient index refister
(int)fBlockA.Tx_L1, // OB = Ouput data base register
NUM_SAMPLES, // OL/OC = Output buffer length register
1, // OM = Output modifier register
(int)fBlockA.Tx_L1, // OI = Output data index register
(int)fBlockA.Rx_L1, // IB = Input data base register
NUM_SAMPLES, // IL/IC = Input buffer length register
1, // IM = Input buffer modifier register
(int)fBlockA.Rx_L1, // II = Input data index register
2|(383<<14) // IIRCTL2 = Channel control register, no of biquads = 3, WINDOW SIZE=512
};
/* Adding the Initialization Code for IIR Accelerator Now */
void Init_IIR(void)
{
int temp;
IIR_TCB_RIGHT[0]=(int)IIR_TCB_LEFT+12;
//Mapping the IIR DMA interrupt
temp=*pPICR0;
temp&=~(P0I0|P0I1|P0I2|P0I3|P0I4);
temp|=P0I0|P0I1|P0I3|P0I4;
*pPICR0=temp;
adi_int_InstallHandler(ADI_CID_P0I,(ADI_INT_HANDLER_PTR)ACC_ISR, _NULL ,true);
//Selecting the IIR Accelerator
temp=*pPMCTL1;
temp&=~(BIT_17|BIT_18);
temp|=IIRACCSEL;
*pPMCTL1=temp;
asm("nop;nop;nop;nop;");
//Initializing the chain pointer register
*pCPIIR=(int)IIR_TCB_LEFT+12-0x80000;
//Now Enabling the IIR Accelerator
*pIIRCTL1=IIR_EN|IIR_DMAEN|IIR_CH2|IIR_RND0;
}
void Process_block(float* input_left,float* input_right, float* output_left, float* output_right, bool first_flag)
{
int i;
//Start the accelerator for first time
if(first_flag)
{
Init_IIR();
}
/*Move the accelerator from IDLE state to the Data Load state by resetting and clearing
the IIR_DMAEN bit*/
else
{
*pIIRCTL1&=~IIR_DMAEN;
*pIIRCTL1|=IIR_DMAEN;
}
/* Wait till IIR accelerator finishes the processing */
while(acc_over==0);
acc_over=0;
/*Multiply the output with filter gain */
for (i =0; i < NUM_SAMPLES; ++i)
{
output_left[i]=output_left[i]*coeffs_low_pass[21];
output_right[i]=output_right[i]*coeffs_low_pass[21];
}
}
void ACC_ISR()
{
acc_over=1;
}