chti23_grpC_Aittaleb_Barnavon/PjtKEIL_StepDFT_Signal_Reel/Src/principal.c

77 lines
1.7 KiB
C

#include "DriverJeuLaser.h"
#include "stdio.h"
extern int DFT_ModuleAuCarre(short int* , char);
extern int DFT_reel(short int* , char);
extern int DFT_imag(short int* , char);
extern short int LeSignal[];
extern short int TabCos[];
extern short int TabSin[];
int resultat_module_carre [64];
short int dma_buf [64];
//void DFT_ModuleAuCarre( short int * Signal64ech, char k, long int * resultat){
// int acumReel = 0;
// int acumImag = 0;
// for (int i= 0; i< 64; i++){
// acumReel += Signal64ech[i]*TabCos[(i*k)%64];
// acumImag += Signal64ech[i]*TabSin[(i*k)%64];
// }
// *resultat = acumReel*acumReel + acumImag*acumImag;
//}
void callback_SysTick(){
Start_DMA1(64);
Wait_On_End_Of_DMA1();
Stop_DMA1;
}
int main(void)
{
// ===========================================================================
// ============= INIT PERIPH (faites qu'une seule fois) =====================
// ===========================================================================
// Après exécution : le coeur CPU est clocké à 72MHz ainsi que tous les timers
CLOCK_Configure();
// Config Timer (Interruptions toutes les 5ms)
int periode_ticks = 360000; // pour avoir une interruption toutes les 5ms
char prio = 0; // Eventuellement à changer quand fusion avec le son
Systick_Period_ff(periode_ticks);
Systick_Prio_IT(prio, callback_SysTick);
SysTick_On;
SysTick_Enable_IT;
// Config ADC (mesure pendant 200 µs)
Init_TimingADC_ActiveADC_ff(ADC1, 72);
Single_Channel_ADC(ADC1, 2);
Init_Conversion_On_Trig_Timer_ff(ADC1, TIM2_CC2, 225);
Init_ADC1_DMA1(0, dma_buf);
//============================================================================
while (1)
{
for(int k = 0; k < 64; k++){
resultat_module_carre[k] = DFT_ModuleAuCarre(dma_buf,k);
}
}
}