/* This file includes the initialization codes for FIR, IIR and FFT Accelerators */

#include "def21469.h"



#include "Cdef21469.h"

void Init_IIR();

/* Declaring the external buffers needed for IIR Accelerator*/
extern int IIR_IP_buff1[];
extern int IIR_OP_buff1[];
extern int IIR_CF_buff1[];


/*Adding the TCB for IIR channels*/
int IIR_TCB_CH1[13]={
				0,
				42,
				1,
				IIR_CF_buff1,
				IIR_OP_buff1,
				1024,
				1,
				IIR_OP_buff1+0,
				IIR_IP_buff1,
				1024,
				1,
				IIR_IP_buff1+0,
				5|(1023<<14)
			};


/* Adding the Initialization Code for IIR Accelerator Now */

void Init_IIR()
{

	int temp;

	IIR_TCB_CH1[0]=IIR_TCB_CH1+12;

	//Mapping the IIR DMA interrupt
	temp=*pPICR0;
	temp&=~(P0I0|P0I1|P0I2|P0I3|P0I4);
	temp|=P0I0|P0I1|P0I3|P0I4;
	*pPICR0=temp;

	//Selecting the IIR Accelerator
	temp=*pPMCTL1;
	temp&=~(BIT_17|BIT_18);
	temp|=IIRACCSEL;
	*pPMCTL1=temp;

	//PMCTL1 effect latency
		asm("nop;nop;nop;nop;");

		//Initializing the chain pointer register
	*pCPIIR=IIR_TCB_CH1+12-0x80000;

	//Now Enabling the IIR Accelerator
	*pIIRCTL1=IIR_EN|IIR_DMAEN|IIR_CH1|IIR_RND0;

}

