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

#include "def21469.h"

.global _Init_FIR;

/* Declaring the external buffers needed for FIR Accelerator*/
.extern  FIR_IP_buff1;
.extern  FIR_OP_buff1;
.extern  FIR_CF_buff1;


/*Adding the TCB for FIR channels*/

.section/dm seg_dmda;


	.var FIR_TCB_CH1[13]={
				FIR_TCB_CH1+12,
				512,
				1,
				FIR_CF_buff1,
				FIR_OP_buff1,
				1024,
				1,
				FIR_OP_buff1+0,
				FIR_IP_buff1,
				1535,
				1,
				FIR_IP_buff1+0,
				511|(1023<<14)
			};


/* Adding the FIR Initialization Code Now */

.section/pm seg_pmco;

_Init_FIR:

		//Mapping the FIR DMA interrupt
		ustat3=dm(PICR0);
		bit clr ustat3 P0I0|P0I1|P0I2|P0I3|P0I4;
		bit set ustat3 P0I0|P0I1|P0I3|P0I4;
		dm(PICR0)=ustat3;

		//Unmasking the FIR DMA interrupt

		bit set IMASK P0I;

		//Selecting the FIR Accelerator
		ustat1=dm(PMCTL1);
		bit clr ustat1 BIT_17|BIT_18;
		bit set ustat1 FIRACCSEL;
		dm(PMCTL1)=ustat1;

		//PMCTL1 effect latency
		nop;nop;nop;nop;

		//Initializing the Chain Pointer Register
		ustat1=FIR_TCB_CH1+12-0x80000;
		dm(CPFIR)=ustat1;

		//Now Enabling the FIR Accelerator
		ustat1=FIR_EN|FIR_DMAEN|FIR_CH1|FIR_RND0;
		dm(FIRCTL1)=ustat1;

		rts;


_Init_FIR.END: