#include #include #include "C:/intelFPGA_pro/17.1/embedded/ip/altera/hps/altera_hps/hwlib/include/soc_cv_av/socal/socal.h" #include "filtre.h" #include "kiss_fft.h" void passeHaut(kiss_fft_cpx* spectre, int fc){ int i; for(i = 0; i <= (fc*NFFT/FE); i++){ spectre[i].r = 0; } } void passeBas(kiss_fft_cpx* spectre, int fc){ int i; for(i = NFFT-1; i > (fc*NFFT/FE); i--){ spectre[i].r = 0; } } void modulation(kiss_fft_cpx* spectre, int fmod){ int imod = (int)fmod*NFFT/FE; double* buffer = (double*)malloc(sizeof(double)*NFFT); int i; for(i = 0; i < NFFT; i++){ buffer[i] = spectre[i].r; } for(i = 0; i < (NFFT-imod); i++){ spectre[i+imod].r = buffer[i]; } for(i = 0; i < imod; i++) spectre[i].r = 0; free(buffer); } void affichage(kiss_fft_cpx* sortie){ float freq; int i; // Affichage des fréquences avec les pics /*for(i = 0; i < NFFT/2; i++){ freq = FE*(float)i/NFFT; printf("F(%f) = %f\n", freq, sortie[i].r); }*/ int j; // Affichage un peu plus graphique for(i = 1; i < NFFT/2; i++){ freq = FE*(float)i/NFFT; printf("%f :", freq); for (j = 0; j < sortie[i].r; j+=500){ printf("|"); } printf("\n"); } } void afficherFmax(kiss_fft_cpx* sortie){ int ifmax = 0, i; float fmax; for(i = 1; i < NFFT/2; i++){ if(sortie[ifmax].r > sortie[i].r){ fmax = FE*(float)i/NFFT; ifmax = i; } } printf("FMAX = %lf\n", fmax); } void acquisition(volatile int* adc, int* data){ *(data) = *(adc); //Get the value of the selected channel } void dac(volatile unsigned long* spi, int data){ alt_write_word(spi+1, data | 0b101000000000000); }