在看TI的源码看到sgen.calc(&sgen)。
很疑惑,看不懂。sgen.calc(&sgen);是如何影响gen.out的值?求大神讲解一下运行的过程。
例如:
/* ==============================================================================
System Name: Complex FFT - Software Test Bench (STB)
File Name: FFTCD.C
Description: Primary System file for demonstrating the Complex FFT module
Originator: Advanced Embeeded Control (AEC) - Texas Instruments
Target dependency: x28x
Description:
============
*/
#include <stb.h>
#include <fft.h>
/* Create an instance of Signal generator module */
SGENTI_1 sgen = SGENTI_1_DEFAULTS;
/* Create an instance of DATALOG Module */
DLOG_4CH dlog=DLOG_4CH_DEFAULTS;
/* Create an Instance of FFT module */
#define N 128
#pragma DATA_SECTION(ipcb, "FFTipcb");
#pragma DATA_SECTION(mag, "FFTmag");
CFFT32 fft=CFFT32_128P_DEFAULTS;
long ipcb[2*N];
long mag[N];
/* Define window Co-efficient Array and place the
.constant section in ROM memory */
const long win[N/2]=HAMMING128;
CFFT32_ACQ acq=CFFT32_ACQ_DEFAULTS;
int xn,yn;
void main()
{
/* DATALOG module initialisation */
dlog.iptr1=&xn;
dlog.iptr2=&yn;
dlog.trig_value=0x800;
dlog.size=0x400; /* Can log 1024 Samples */
dlog.init(&dlog);
/* Signal Generator module initialisation */
sgen.offset=0;
sgen.gain=0x7fff; /* gain=1 in Q15 */
sgen.freq=10000; /* freq = (Required Freq/Max Freq)*2^15 */
/* = (931/3051.7)*2^15 = 10000 */
sgen.step_max=10000; /* Max Freq= (step_max * sampling freq)/65536 */
/* Max Freq = (10000*20k)/65536 = 3051.7 */
/* Initialize acquisition module */
acq.buffptr=ipcb;
acq.tempptr=ipcb;
acq.size=N;
acq.count=N;
acq.acqflag=1;
/* Initialize FFT module */
fft.ipcbptr=ipcb;
fft.magptr=mag;
fft.winptr=(long *)win;
fft.init(&fft);
/*---------------------------------------------------------------------------
Nothing running in the background at present
----------------------------------------------------------------------------*/
while(1)
{
sgen.calc(&sgen);
xn=sgen.out;
yn=sgen.out;
dlog.update(&dlog);
acq.input=((unsigned long)xn)<<16;
acq.update(&acq);
if (acq.acqflag==0) // If the samples are acquired
{
CFFT32_brev2(ipcb,ipcb,N);
CFFT32_brev2(ipcb,ipcb,N); // Input samples in Real Part
fft.win(&fft);
CFFT32_brev2(ipcb,ipcb,N);
CFFT32_brev2(ipcb,ipcb,N); // Input after windowing
fft.izero(&fft);
fft.calc(&fft);
fft.mag(&fft);
acq.acqflag=1; // Enable the next acquisition
}
}
} /* End: main() */