StepFin FONCTIONNEL le JEU MARCHE

This commit is contained in:
Remi Pitault 2023-05-24 15:21:09 +02:00
parent 49b58378be
commit 5a49f7278a
2 changed files with 75 additions and 13 deletions

View file

@ -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);
}
}

View file

@ -413,6 +413,16 @@
<FileType>2</FileType>
<FilePath>.\Src\GestionSon.s</FilePath>
</File>
<File>
<FileName>Affichage_Valise.h</FileName>
<FileType>5</FileType>
<FilePath>.\Src\Affichage_Valise.h</FilePath>
</File>
<File>
<FileName>affichage_valise.o</FileName>
<FileType>3</FileType>
<FilePath>.\Src\affichage_valise.o</FilePath>
</File>
</Files>
</Group>
<Group>
@ -847,6 +857,16 @@
<FileType>2</FileType>
<FilePath>.\Src\GestionSon.s</FilePath>
</File>
<File>
<FileName>Affichage_Valise.h</FileName>
<FileType>5</FileType>
<FilePath>.\Src\Affichage_Valise.h</FilePath>
</File>
<File>
<FileName>affichage_valise.o</FileName>
<FileType>3</FileType>
<FilePath>.\Src\affichage_valise.o</FilePath>
</File>
</Files>
</Group>
<Group>
@ -1350,6 +1370,16 @@
<FileType>2</FileType>
<FilePath>.\Src\GestionSon.s</FilePath>
</File>
<File>
<FileName>Affichage_Valise.h</FileName>
<FileType>5</FileType>
<FilePath>.\Src\Affichage_Valise.h</FilePath>
</File>
<File>
<FileName>affichage_valise.o</FileName>
<FileType>3</FileType>
<FilePath>.\Src\affichage_valise.o</FilePath>
</File>
</Files>
</Group>
<Group>