#include #include #include #include #include #include "drv/fft_drv.h" #include "fft.h" //static volatile int fft_channel; volatile fft_state fft_status = fft_idle ; //fftÓ²¼þ×ÊÔ´Õ¼ÓñêÖ¾,Á½ÖÖfft_idle, fft_busy //real, imag,real,imag...real,imag #pragma align 1024 static dm float fft_input[2*N]; static pm float fft_output[2*N]; //static fn_fft_completely pfft_notify =0 ; //static void* pfft_context=0; static int fft_count=0; void fft_isr(int sig) { if(*pFFTDMASTAT & ODMACHIRPT) { fft_count++; fft_status = fft_completed; } } void fft_monitor(void) { static int old_fft_count =0; static int fft_stop_count =0; if(old_fft_count == fft_count){ fft_stop_count ++ ; } else{ old_fft_count = fft_count; fft_stop_count = 0; } if(fft_stop_count > (N/64)){ //reset fft fft_status = fft_idle; fft_stop_count =0; } } float* fft_channel_inptr() { return fft_input; } void fft_reset() { int timeout =0 ; while(fft_status == fft_progress){ timeout++; if(timeout>0xffff) { break; } } fft_status = fft_idle; } float* fft_channel_outptr() { //µ÷ÓôνӿÚ×Ô¶¯Çå³ý״̬ fft_status = fft_idle; return fft_output; } void fft_start() { fft_startup((int)fft_input,(int)fft_output); fft_status = fft_progress; } void fft_init() { int i; fft_coeff_calculation(); fft_config(true,15); //15±íʾӳÉäÖжϵ½SIG_P15 interrupts(SIG_P15,fft_isr); fft_status = fft_idle; }