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

#include "def21469.h"



#include "Cdef21469.h"

void Init_FFT();

/* Declaring the external buffers needed for FFT Accelerator*/
extern int FFT_IP_buff[];
extern int FFT_OP_buff[];
extern int FFT_CF_buff[];


/*Adding the TCB for FFT Accelerator*/
	int FFT_IP_TCB[6]={
				(int)0,
				(int)FFT_IP_buff,
				512,
				512,
				1,
				(int)FFT_IP_buff
			};


	int FFT_OP_TCB[6]={
				(int)0,
				(int)FFT_OP_buff,
				512,
				512,
				1,
				(int)FFT_OP_buff
			};


	int FFT_CF_TCB[6]={
				(int)FFT_IP_TCB+5-0x80000,
				(int)FFT_CF_buff,
				512,
				512,
				1,
				(int)FFT_CF_buff
			};



/* Adding the FFT Initialization Code Now */

void Init_FFT()

{

	int temp;

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

	*pPMCTL1&=~(BIT_17|BIT_18);
	*pPMCTL1|=FFTACCSEL;

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

		//Clearing the FFTCTL registers
		*pFFTCTL2=0;

		*pFFTCTL1=FFT_RST;

		asm("nop;nop;nop;nop;");

		temp=(int)FFT_CF_TCB;

	*pCPIFFT=0x100000|temp+5-0x80000;

	*pCPOFFT=(int)FFT_OP_TCB+5-0x80000;

	*pFFTCTL2=VDIMDIV16_16|FFT_LOG2VDIM_8;

	*pFFTCTL1=FFT_EN|FFT_START|FFT_DMAEN;

};

