From 5a49f7278a96197a33e060a75de92114126239b7 Mon Sep 17 00:00:00 2001 From: Remi Pitault Date: Wed, 24 May 2023 15:21:09 +0200 Subject: [PATCH] StepFin FONCTIONNEL le JEU MARCHE --- soft/PjtKEIL_Fin/Src/principal.c | 58 +++++++++++++++++++++++++------- soft/PjtKEIL_Fin/StepDFT.uvprojx | 30 +++++++++++++++++ 2 files changed, 75 insertions(+), 13 deletions(-) diff --git a/soft/PjtKEIL_Fin/Src/principal.c b/soft/PjtKEIL_Fin/Src/principal.c index 8b2e243..ecc4082 100644 --- a/soft/PjtKEIL_Fin/Src/principal.c +++ b/soft/PjtKEIL_Fin/Src/principal.c @@ -1,14 +1,19 @@ #include "DriverJeuLaser.h" #include "GestionSon.h" +#include "Affichage_Valise.h" extern int DFT_ModuleAuCarre(short int* Signal64ech, char k); extern int16_t LeSignal; +#define seuil_activation 350000 + unsigned int test = 0; short int dma_buf[64]; int coeff[7]; int score[6]; int attendre[6]; +int changed[6]; +int curr_cible = 0; void mesure() { Start_DMA1(64); @@ -19,9 +24,36 @@ void mesure() { coeff[1] = DFT_ModuleAuCarre(&(dma_buf[0]), 18); coeff[2] = DFT_ModuleAuCarre(&(dma_buf[0]), 19); coeff[3] = DFT_ModuleAuCarre(&(dma_buf[0]), 20); - coeff[4] = DFT_ModuleAuCarre(&(dma_buf[0]), 23); - coeff[5] = DFT_ModuleAuCarre(&(dma_buf[0]), 24); + //coeff[4] = DFT_ModuleAuCarre(&(dma_buf[0]), 23); + //coeff[5] = DFT_ModuleAuCarre(&(dma_buf[0]), 24); coeff[6] = DFT_ModuleAuCarre(&(dma_buf[0]), 21); + + if (coeff[6] < seuil_activation) + for (int i = 0; i < 4; i++) { + if (attendre[i] == 0 && coeff[i] > seuil_activation) { + StartSon(); + score[i] = (score[i] + 1) % 100; + Prepare_Afficheur(i+1, score[i]); + attendre[i] = 1; + } + else if (attendre[i] == 1 && coeff[i] < seuil_activation) + attendre[i] = 0; + } +} + +void update_cibles(int oups) { + if (oups == 13) { + for (int i = 0; i < 4; i++) { + if (i == curr_cible) { + Choix_Capteur(curr_cible + 1); + Prepare_Set_LED(curr_cible); + } + else + Prepare_Clear_LED(i); + } + curr_cible = (curr_cible + 1) & 3; + } + Mise_A_Jour_Afficheurs_LED(); } int main(void) @@ -34,39 +66,39 @@ int main(void) // Après exécution : le coeur CPU est clocké à 72MHz ainsi que tous les timers CLOCK_Configure(); +//init systeme ADC/DMA 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); +//systick pour les mesures Systick_Period_ff(72000000 * 5 / 1000); Systick_Prio_IT(0, mesure); SysTick_On; SysTick_Enable_IT; +//timer pour le son GPIO_Configure(GPIOB, 0, OUTPUT, ALT_PPULL); PWM_Init_ff(TIM3, 3, 720); // f_PWM = 72MHz/720 = 100kHz Timer_1234_Init_ff(TIM4, 6552); // periode_son/f_CPU = (91*10^-6)*(72*10^6) = 6552 Active_IT_Debordement_Timer(TIM4, 2, CallbackSon); -//============================================================================ +//init affichage malette +Init_Affichage(); +//init tableau score for (int i = 0; i < 6; i++) { score[i] = 0; attendre[i] = 0; } +//============================================================================ + +int oups = 0; while (1) { - if (coeff[6] < 10000000) - for (int i = 0; i < 6; i++) { - if (attendre[i] == 0 && coeff[i] > 10000000) { - StartSon(); - score[i]++; - attendre[i] = 1; - } - else if (attendre[i] == 1 && coeff[i] < 10000000) - attendre[i] = 0; - } + oups = (oups + 1) % 2500; + update_cibles(oups); } } diff --git a/soft/PjtKEIL_Fin/StepDFT.uvprojx b/soft/PjtKEIL_Fin/StepDFT.uvprojx index af34eff..313798b 100644 --- a/soft/PjtKEIL_Fin/StepDFT.uvprojx +++ b/soft/PjtKEIL_Fin/StepDFT.uvprojx @@ -413,6 +413,16 @@ 2 .\Src\GestionSon.s + + Affichage_Valise.h + 5 + .\Src\Affichage_Valise.h + + + affichage_valise.o + 3 + .\Src\affichage_valise.o + @@ -847,6 +857,16 @@ 2 .\Src\GestionSon.s + + Affichage_Valise.h + 5 + .\Src\Affichage_Valise.h + + + affichage_valise.o + 3 + .\Src\affichage_valise.o + @@ -1350,6 +1370,16 @@ 2 .\Src\GestionSon.s + + Affichage_Valise.h + 5 + .\Src\Affichage_Valise.h + + + affichage_valise.o + 3 + .\Src\affichage_valise.o +