Projet final : Affichage et Jeu OK, manque le Son

This commit is contained in:
Jules-Ian Barnavon 2023-05-21 14:52:17 +02:00
rodzic 0ac25435cd
commit ceb36f645b
3 zmienionych plików z 197 dodań i 60 usunięć

Wyświetl plik

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

Wyświetl plik

@ -357,7 +357,7 @@
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
<IncludePath>.\Driver;.\ModuleAffichage</IncludePath>
</VariousControls>
</Aads>
<LDads>
@ -408,6 +408,16 @@
<FileType>2</FileType>
<FilePath>.\Src\GestionSon.s</FilePath>
</File>
<File>
<FileName>Affichage_Valise.h</FileName>
<FileType>5</FileType>
<FilePath>.\ModuleAffichage\Affichage_Valise.h</FilePath>
</File>
<File>
<FileName>affichage_valise.o</FileName>
<FileType>3</FileType>
<FilePath>.\ModuleAffichage\affichage_valise.o</FilePath>
</File>
</Files>
</Group>
<Group>
@ -454,7 +464,7 @@
<TargetName>CibleSondeKEIL</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>5060750::V5.06 update 6 (build 750)::.\ARMCC</pCCUsed>
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARMCC</pCCUsed>
<uAC6>0</uAC6>
<TargetOption>
<TargetCommonOption>
@ -783,7 +793,7 @@
<MiscControls>--C99</MiscControls>
<Define>STM32F103xB,USE_FULL_LL_DRIVER</Define>
<Undefine></Undefine>
<IncludePath>.\Driver</IncludePath>
<IncludePath>.\Driver;.\ModuleAffichage</IncludePath>
</VariousControls>
</Cads>
<Aads>
@ -801,7 +811,7 @@
<MiscControls></MiscControls>
<Define></Define>
<Undefine></Undefine>
<IncludePath></IncludePath>
<IncludePath>.\Driver</IncludePath>
</VariousControls>
</Aads>
<LDads>
@ -852,6 +862,16 @@
<FileType>2</FileType>
<FilePath>.\Src\GestionSon.s</FilePath>
</File>
<File>
<FileName>Affichage_Valise.h</FileName>
<FileType>5</FileType>
<FilePath>.\ModuleAffichage\Affichage_Valise.h</FilePath>
</File>
<File>
<FileName>affichage_valise.o</FileName>
<FileType>3</FileType>
<FilePath>.\ModuleAffichage\affichage_valise.o</FilePath>
</File>
</Files>
</Group>
<Group>
@ -1365,6 +1385,16 @@
<FileType>2</FileType>
<FilePath>.\Src\GestionSon.s</FilePath>
</File>
<File>
<FileName>Affichage_Valise.h</FileName>
<FileType>5</FileType>
<FilePath>.\ModuleAffichage\Affichage_Valise.h</FilePath>
</File>
<File>
<FileName>affichage_valise.o</FileName>
<FileType>3</FileType>
<FilePath>.\ModuleAffichage\affichage_valise.o</FilePath>
</File>
</Files>
</Group>
<Group>
@ -1427,7 +1457,7 @@
<LayerInfo>
<Layers>
<Layer>
<LayName>&lt;Project Info&gt;</LayName>
<LayName>StepDFT</LayName>
<LayTarg>0</LayTarg>
<LayPrjMark>1</LayPrjMark>
</Layer>

Wyświetl plik

@ -429,7 +429,7 @@
<TargetName>CibleSondeKEIL</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>5060750::V5.06 update 6 (build 750)::.\ARMCC</pCCUsed>
<pCCUsed>5060960::V5.06 update 7 (build 960)::.\ARMCC</pCCUsed>
<uAC6>0</uAC6>
<TargetOption>
<TargetCommonOption>