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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
...
#include "Order1-10.COF"
...
/* ======================================================================== */
/* Include the DSPLIB header file */
/* ======================================================================== */
#include "dsp_fft16x32.h"
#include "dsp_ifft16x32.h"
#ifdef _6x_
extern far LOG_Obj trace;
extern far SWI_Obj swiEcho;
/*
* Buffers placed in external memory ar aligned on a 128 bytes boundary.
* In addition, the buffer should be of a size multiple of 128 bytes for the
* cache work optimally on the C6x.
*/
#define BUFLEN 512 /* number of samples in a frame */
#define BUFALIGN 512 /* alignment of buffer to allow use of L2 cache */
#else
extern LOG_Obj trace;
extern SWI_Obj swiEcho;
#define BUFLEN 512 /* number of samples in a frame */
#define BUFALIGN 1
#endif
#define BUFSIZE (BUFLEN * sizeof(MdUns))
/* inStream and outStream are SIO handles created in main */
SIO_Handle inStream, outStream;
#define FCPU 600000000 /* CPU clock frequency */
#define SRATE 8000 /* data sample rate (simulated w/timer */
#define TPRD (FCPU/(4*SRATE)) /* timer period */
/* ======================================================================== */
/* Macro definition */
/* ======================================================================== */
#define PI (3.14159264)
#define NN (BUFLEN) //# of points for FFT
/* ======================================================================== */
/* Input and output arrays */
/* ======================================================================== */
#pragma DATA_ALIGN(x, 8)
#pragma DATA_ALIGN(y, 8)
#pragma DATA_ALIGN(w, 8)
short w[4*NN]; // twiddle constants stored in w
int x[4*NN];
int y[4*NN];
int yy[4*NN];
int pass = 0;
int i;
int j;
int k; //general purpose index variables
/*
* ======== echo ========
* This function executes the compensation procedure between the input SIO
* and the output SIO.
*/
Void echo()
{
unsigned short *inbuf, *outbuf;
Int nbytes, i;
/* Reclaim full buffer from the input stream */
if ((nbytes = SIO_reclaim(inStream, (Ptr *)&inbuf, NULL)) < 0) {
SYS_abort("Error reclaiming full buffer from the input stream");
}
/* Reclaim empty buffer from the output stream to be reused */
if (SIO_reclaim(outStream, (Ptr *)&outbuf, NULL) < 0) {
SYS_abort("Error reclaiming empty buffer from the output stream");
}
for (i = 0 ; i < NN; i++) //indices pour inbuf: 0 à NN-1
{
x[2*i] = inbuf[2*i]; // real
x[2*i+1] = 0; // imag
}
/* ==================================================================== */
/* Perform FFT. */
/* ==================================================================== */
DSP_fft16x32(w, 2*NN, x, y);
/* ==================================================================== */
/* Copy the results to y[]. */
/* ==================================================================== */
memcpy( yy, y, sizeof(y) );
for(i=0; i<2*NN ;i++)
{
yy[2*i] *= C1Int[i] /NN; //Scaled the input to the IFFT
yy[2*i+1]*= C1Int[i] /NN; //Scaled the input to the IFFT
} //end for i loop
/* ==================================================================== */
/* Perform IFFT. */
/* ==================================================================== */
DSP_ifft16x32(w, 2*NN, yy, x);
for (i = 0; 2*i <NN; i++) {
outbuf[2*i] = outbuf[2*i+1] = x[2*i];
}
/* Issue full buffer to output stream */
if (SIO_issue(outStream, outbuf, nbytes, NULL) != SYS_OK) {
SYS_abort("Error issuing full buffer to output stream");
}
/* Issue empty buffer to input stream */
if (SIO_issue(inStream, inbuf, SIO_bufsize(inStream), NULL) != SYS_OK) {
SYS_abort("Error issuing empty buffer to input stream");
}
}
... |
Partager