#include "FFT.h" void FFT(uint16_t *buffer) { static float Re[512]; static float Im[512]; register int i, j, n, k, io, ie, in, nn; float ru, iu, rtp, itp, rtq, itq, rw, iw, sr; union ADVFLOAT { float x; struct { unsigned int mant : 23; // Mantissa without leading one unsigned int exp : 8; // Exponential part unsigned int sign : 1; // Indicator of the negative number }; }; for(int i=0; i<512; i++) { float aaa=buffer[i]; Re[i] = aaa/256; Im[i] = 0.0; } nn = 512 >> 1; ie = 512; for(n=1; n<=9; n++) { rw = Rcoef[9 - n]; iw = Icoef[9 - n]; in = ie >> 1; ru = 1.0F; iu = 0.0F; for(j=0; j>= 1; } for(j=i=1; i<512; i++) { if(i < j) { io = i - 1; in = j - 1; rtp = Re[in]; itp = Im[in]; Re[in] = Re[io]; Im[in] = Im[io]; Re[io] = rtp; Im[io] = itp; } k = nn; while(k < j) { j = j - k; k >>= 1; } j = j + k; } SendCMD(ILI9341_MAC); SendDAT(Orient_Land); SendCMD(ILI9341_PAGE_ADDR); SendDAT(0); SendDAT(1+31); SendDAT(1); SendDAT(1+31); SendCMD(ILI9341_COLUMN_ADDR); SendDAT(0); SendDAT(33-10); SendDAT(0); SendDAT(214-10); SendCMD(ILI9341_GRAM); GPIO_SetBits(GPIOB, LCD_RS); // data for (uint16_t j = 1; j < 257; j++) { for (uint8_t i = 0; i < 182; i++) { union ADVFLOAT ax; int exp; ax.x = (Re[j]*Re[j]+Im[j]*Im[j]); exp = ax.exp - 127; ax.sign = 0; ax.exp = 127; float D=12*((ax.x - 1.0f) * LOG2E + exp); if (i>8); SPI_I2S_SendData(SPI1, WHITE); } else { if (i==46||i==92||i==138||j==64||j==128||j==192) { SPI_I2S_SendData(SPI1, 0x01); SPI_I2S_SendData(SPI1, 0xE7); } else { SPI_I2S_SendData(SPI1, 0); SPI_I2S_SendData(SPI1, 0); } } } } }