#include "DriverJeuLaser.h" #include #include "Affichage_Valise.h" extern int DFT_ModuleAuCarre(short int* Signal64ech, char k); extern short int LeSignal[]; extern void CallbackSon(void); extern void StartSon(void); #define MAX_PIC 100000 //int result; int dft[64]; short int dma_buf[64]; int tab_score[6] = {0}; int tab_norm[6] = {17,18,19,20,23,24}; //fréquences qui nous intéressent int ancienne_cible = 3; //ancienne cible activée int cible = 0; //cible actuelle void callback() { Start_DMA1(64); Wait_On_End_Of_DMA1(); //int somme=0; for (int i=1;i<64;i++) { dft[i] = DFT_ModuleAuCarre(&(dma_buf[0]),i); //somme+=dft[i]; } //Prepare_Afficheur(1, 15); Stop_DMA1; //Lecture des raies pour trouver la fréquence lue for(int i=0;i<6;i++) { if(dft[tab_norm[i]] > MAX_PIC) { //if (player_count < 4 && tab_score[i] == 0) tab_score[i] += 1; if (tab_score[i] >= 100) { tab_score[i] =0; // remise à zéro lorsque le score dépasse 100 } if(tab_score[i]%20 == 0) { StartSon(); //On active le son si une cible est touchée Prepare_Clear_LED(cible); // On éteint l'ancienne cible cible = (cible+1)%3; // On change la cible Prepare_Set_LED(cible); Choix_Capteur(cible+1); //On change le score if(i < 4) { Prepare_Afficheur((i+1), tab_score[i]); Mise_A_Jour_Afficheurs_LED(); } } } } } int main(void) { // =========================================================================== // ============= INIT PERIPH (faites qu'une seule fois) ===================== // =========================================================================== //Initialisation CLOCK_Configure(); Init_Affichage(); //Réinitialisation de tous les afficheurs for(int p = 0;p<4;p++) { Prepare_Afficheur(p+1,0); Prepare_Clear_LED(p); } Prepare_Set_LED(1); Choix_Capteur(2); //Systick pour la DFT GPIO_Configure(GPIOB, 0, OUTPUT, ALT_PPULL); PWM_Init_ff(TIM2,3,720); 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[0]) ); //Création loop DFT Systick_Period_ff(5*72*1000); Systick_Prio_IT(9,callback); SysTick_Enable_IT; SysTick_On; //Systick pour le Son GPIO_Configure(GPIOB, 1, OUTPUT, OUTPUT_PPULL); PWM_Init_ff(TIM3,3,720); PWM_Set_Value_TIM3_Ch3( 360); Timer_1234_Init_ff( TIM4, 6552 ); Active_IT_Debordement_Timer( TIM4, 10, CallbackSon ); Mise_A_Jour_Afficheurs_LED(); //============================================================================ while (1) { } }