#include<def21479.h>

.extern _Init_FFT;

.global  FFT_IP_buff;
.global  FFT_OP_buff;
.global  FFT_VCF_buff;
.global  FFT_HCF_buff;
.global  FFT_IM_OP_buff;
.global  FFT_SP_CF_buff;

.global _FFT_DMA_ISR;

.global _main;

#define N 2048

#define V 32
#define H 64

.section/dm seg_dmda;

	.var FFT_IP_buff[2*N]={
		
							#include "fft_input.dat"
	};
	
	.var FFT_OP_buff[2*N];
	
	.var FFT_OP1_buff[N/2];
	
	

	.var FFT_VCF_buff[2*V]={
							#include "twiddle_32.dat"
	};
	
	.var FFT_HCF_buff[2*H]={
							#include "twiddle_64.dat"
	};
	
							
	.var FFT_SP_CF_buff[4*N]=
						{
							
							#include "pw_twiddle_2048.dat"
						};
						
	.var  FFT_IM_OP_buff[2*N];
	
	.var  fft_done=0;

.section/pm seg_pmco;
_main:

	bit set MODE1 IRPTEN;
	nop;
	
	call _Init_FFT;
	
	wait1:
	
	ustat1=dm(fft_done);
	bit tst ustat1 0x00000001;
	
	if not tf jump wait1;	
	

	jump(pc,0);

_FFT_DMA_ISR:


	ustat1=dm(FFTDMASTAT);
	bit tst ustat1 ODMACHIRPT;
	if not tf jump skip1;
		
		r0=1;
		dm(fft_done)=r0;
		
	skip1:	
rti;		
	
