diff --git a/PjtKEIL_Final/Src/principal.c b/PjtKEIL_Final/Src/principal.c
index 880a83c..d7d891e 100644
--- a/PjtKEIL_Final/Src/principal.c
+++ b/PjtKEIL_Final/Src/principal.c
@@ -5,7 +5,7 @@
#include "Affichage_Valise.h"
-# define PERIODE 6552
+# define PERIODE4 6552
# define PERIODE_PWM 720
# define F1 17
# define F2 18
@@ -13,6 +13,7 @@
# define F4 20
# define F5 23
# define F6 24
+# define NBJOUEURS 4
extern int DFT_ModuleAuCarre(short int* , char);
extern int DFT_reel(short int* , char);
@@ -20,9 +21,18 @@ extern int DFT_imag(short int* , char);
extern void CallbackSon(void);
extern short int TabCos[];
extern short int TabSin[];
+extern short int SortieSon;
int resultat_module_carre [64];
short int dma_buf [64];
+int score [NBJOUEURS];
+int vrai_score [NBJOUEURS];
+int bouclage=0;
+int dft;
+ int frequences[]={F1,F2,F3,F4};
+int nombre_tirs = 0;
+int numero_capteur=1;
+int Leds[]= {LED_Cible_1,LED_Cible_2,LED_Cible_3,LED_Cible_4};
//void DFT_ModuleAuCarre( short int * Signal64ech, char k, long int * resultat){
// int acumReel = 0;
@@ -37,68 +47,165 @@ short int dma_buf [64];
void callback_SysTick(){
Start_DMA1(64);
Wait_On_End_Of_DMA1();
+
Stop_DMA1;
+
+
}
+//void changerCapteur(){
+// Choix_Capteur(numero_capteur);
+//
+//
+// Prepare_Clear_LED(Leds[(numero_capteur)%4]);
+// Prepare_Clear_LED(Leds[(numero_capteur+1)%4]);
+// Prepare_Clear_LED(Leds[(numero_capteur+2)%4]);
+//
+// Prepare_Set_LED(Leds[numero_capteur-1]);
+//
+// numero_capteur=(numero_capteur+1)%4 + 1 ;
+//
+//}
+
+void changerCapteur(int i){
+ Choix_Capteur(i+1);
+
+//
+// Prepare_Clear_LED(Leds[(i)%4]);
+// Prepare_Clear_LED(Leds[(i+1)%4]);
+// Prepare_Clear_LED(Leds[(i+2)%4]);
+
+
+ Prepare_Clear_LED(Leds[0]);
+ Prepare_Clear_LED(Leds[1]);
+ Prepare_Clear_LED(Leds[2]);
+ Prepare_Clear_LED(Leds[3]);
+
+ Prepare_Set_LED(Leds[i]);
+
+
+}
int main(void)
{
-// ===========================================================================
-// ============= INIT PERIPH (faites qu'une seule fois) =====================
-// ===========================================================================
+ // ===========================================================================
+ // ============= 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 DFT ------------------------------
-
-// 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);
-
-
-
-// ------------------------ Config Son ------------------------------
-
-Timer_1234_Init_ff(TIM4,PERIODE);
-Active_IT_Debordement_Timer(TIM4, 2, CallbackSon);
-
-//Timer_1234_Init_ff(TIM3,PERIODE_PWM);
-
-PWM_Init_ff( TIM3, 3, 720);
-
-
-GPIO_Configure(GPIOB, 0, OUTPUT, ALT_PPULL);
-
-
-
-
-
-
-while (1)
- {
- for(int k = 0; k < 64; k++){
-
- resultat_module_carre[k] = DFT_ModuleAuCarre(dma_buf,k);
- }
+
+ // Après exécution : le coeur CPU est clocké à 72MHz ainsi que tous les timers
+
+ CLOCK_Configure();
+
+
+ // ------------------------ Config DFT ------------------------------
+
+ // 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);
+
+
+
+ // ------------------------ Config Son ------------------------------
+
+ Timer_1234_Init_ff(TIM4,PERIODE4);
+ Active_IT_Debordement_Timer(TIM4, 2, CallbackSon);
+
+ //Timer 1 déja utilisé pour MAJ affichage (prio 8)
+
+
+ //Timer_1234_Init_ff(TIM3,PERIODE_PWM);
+
+ PWM_Init_ff( TIM3, 3, 720);
+
+
+ GPIO_Configure(GPIOB, 0, OUTPUT, ALT_PPULL);
+
+ // ----------------------- Config Affichage --------------------------
+
+ Init_Affichage();
+ for (int i = 1; i<5; i++){
+ Prepare_Afficheur(i, 0);
+ //Prepare_Set_LED(Leds[i-1]);
+
+ }
+ //Choix_Capteur(2);
+ //Choix_Capteur(1);
+
+ Mise_A_Jour_Afficheurs_LED();
+
+
+
+
+ // ----------------------- Config capteur ---------------------------
+
+ // -----------------------------------------------------------------
+
+ for(int i = 0; i < NBJOUEURS ; i ++){
+ score[i] = 0;
+ vrai_score[i] = 0;
+
+ }
+
+ // test son :
+
+
+
+
+ while (1)
+ {
+// capteur = capteur + 1 % 4;
+// Choix_Capteur((int)capteur+1);
+
+
+ for (int i = 0; i<4; i++){
+
+
+ resultat_module_carre[frequences[i]] = DFT_ModuleAuCarre(dma_buf,frequences[i]);
+
+ if (resultat_module_carre[frequences[i]]>5000000){
+ score[i]++;
+
+ }
+ if (resultat_module_carre[frequences[i]]<30000){
+ score[i]=0;
+
+ }
+
+ }
+
+ for (int i = 0; i<4; i++){
+ if (score[i]>90) {
+ vrai_score[i]++;
+ Prepare_Afficheur(i+1, vrai_score[i]);
+ //CallbackSon();
+ //PWM_Set_Value_TIM3_Ch3(SortieSon);
+ score[i]=0;
+ score[(i+1)%4]=0;
+ score[(i+2)%4]=0;
+ score[(i+3)%4]=0;
+
+ changerCapteur(numero_capteur);
+ numero_capteur = (numero_capteur + 1) % 4;
+ }
+
+ }
+ Mise_A_Jour_Afficheurs_LED();
}
}
diff --git a/PjtKEIL_Final/StepDFT.uvprojx b/PjtKEIL_Final/StepDFT.uvprojx
index 245f978..7982669 100644
--- a/PjtKEIL_Final/StepDFT.uvprojx
+++ b/PjtKEIL_Final/StepDFT.uvprojx
@@ -357,7 +357,7 @@
-
+ .\Driver;.\ModuleAffichage
@@ -408,6 +408,16 @@
2
.\Src\GestionSon.s
+
+ Affichage_Valise.h
+ 5
+ .\ModuleAffichage\Affichage_Valise.h
+
+
+ affichage_valise.o
+ 3
+ .\ModuleAffichage\affichage_valise.o
+
@@ -454,7 +464,7 @@
CibleSondeKEIL
0x4
ARM-ADS
- 5060750::V5.06 update 6 (build 750)::.\ARMCC
+ 5060960::V5.06 update 7 (build 960)::.\ARMCC
0
@@ -783,7 +793,7 @@
--C99
STM32F103xB,USE_FULL_LL_DRIVER
- .\Driver
+ .\Driver;.\ModuleAffichage
@@ -801,7 +811,7 @@
-
+ .\Driver
@@ -852,6 +862,16 @@
2
.\Src\GestionSon.s
+
+ Affichage_Valise.h
+ 5
+ .\ModuleAffichage\Affichage_Valise.h
+
+
+ affichage_valise.o
+ 3
+ .\ModuleAffichage\affichage_valise.o
+
@@ -1365,6 +1385,16 @@
2
.\Src\GestionSon.s
+
+ Affichage_Valise.h
+ 5
+ .\ModuleAffichage\Affichage_Valise.h
+
+
+ affichage_valise.o
+ 3
+ .\ModuleAffichage\affichage_valise.o
+
@@ -1427,7 +1457,7 @@
- <Project Info>
+ StepDFT
0
1
diff --git a/PjtKEIL_StepDFT_Signal_Reel/StepDFT.uvprojx b/PjtKEIL_StepDFT_Signal_Reel/StepDFT.uvprojx
index 715dd05..df50858 100644
--- a/PjtKEIL_StepDFT_Signal_Reel/StepDFT.uvprojx
+++ b/PjtKEIL_StepDFT_Signal_Reel/StepDFT.uvprojx
@@ -429,7 +429,7 @@
CibleSondeKEIL
0x4
ARM-ADS
- 5060750::V5.06 update 6 (build 750)::.\ARMCC
+ 5060960::V5.06 update 7 (build 960)::.\ARMCC
0