qipp
2025-09-16 e7ac407a6aa40e94a34a772dee14e8d5fb55c45b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <def21489.h>
#include <cdef21489.h>
#include <stdio.h>
#include <signal.h>
#include <config.h>
#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;
}