From bc0529e014b08aed8ad93f033099ba3a6d579c6c Mon Sep 17 00:00:00 2001 From: MaelleCros Date: Tue, 16 May 2023 18:02:06 +0200 Subject: [PATCH] =?UTF-8?q?jeu=20qui=20marche=20(avec=20score,=20sans=20so?= =?UTF-8?q?n,=20sans=20arr=C3=AAt)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PjtKEIL_StepDFT/Src/DFT.s | 3 +- PjtKEIL_StepDeb_2/Src/Cligno.s | 3 +- PjtKEIL_StepSon/Src/GestionSon.s | 6 +- PjtKEIL_Step_Integration/Src/principal.c | 118 ++++++++++++++++++----- 4 files changed, 98 insertions(+), 32 deletions(-) diff --git a/PjtKEIL_StepDFT/Src/DFT.s b/PjtKEIL_StepDFT/Src/DFT.s index 80d835f..2a6d8b8 100644 --- a/PjtKEIL_StepDFT/Src/DFT.s +++ b/PjtKEIL_StepDFT/Src/DFT.s @@ -98,8 +98,7 @@ BoucleFor FinBoucle ; on met le résultat à disposition dans r0 - ;mov r1, r7 - ;mov r0, r8 + smull r1, r0, r7, r7 ;NB :poids fort en 2eme pos smlal r1, r0, r8, r8 ; diff --git a/PjtKEIL_StepDeb_2/Src/Cligno.s b/PjtKEIL_StepDeb_2/Src/Cligno.s index 0597495..a07c94f 100644 --- a/PjtKEIL_StepDeb_2/Src/Cligno.s +++ b/PjtKEIL_StepDeb_2/Src/Cligno.s @@ -2,8 +2,7 @@ THUMB INCLUDE DriverJeuLaser.inc EXPORT timer_callback - ;IMPORT GPIOB_Set - ;IMPORT GPIOB_Clear + ; ====================== zone de réservation de données, ====================================== ;Section RAM (read only) : area mesdata,data,readonly diff --git a/PjtKEIL_StepSon/Src/GestionSon.s b/PjtKEIL_StepSon/Src/GestionSon.s index 18cd58b..0995667 100644 --- a/PjtKEIL_StepSon/Src/GestionSon.s +++ b/PjtKEIL_StepSon/Src/GestionSon.s @@ -41,8 +41,8 @@ IndiceCourrant dcd 0 ;} EXPORT callbackSon callbackSon proc - push{lr} - push{r4} + push {lr} + push {r4} push {r5} ldr r0, =Son @@ -63,7 +63,7 @@ callbackSon proc add r1, #1 str r1, [r2] -; SortieSon += 32767; +; SortieSon += 32768; add r3, #32768 ; SortieSon = SortieSon*719/65534; diff --git a/PjtKEIL_Step_Integration/Src/principal.c b/PjtKEIL_Step_Integration/Src/principal.c index 6e9368f..9e20e98 100644 --- a/PjtKEIL_Step_Integration/Src/principal.c +++ b/PjtKEIL_Step_Integration/Src/principal.c @@ -5,20 +5,89 @@ extern short int LeSignal[]; extern int DFT_ModuleAuCarre( short int * Signal64ech, char k); -int moduleSignal[64] ; -int score[4]; +int moduleSignal[4] ; short int dma_buf[64] ; +int score[4] = {0,0,0,0}; +int cnt[4] = {0,0,0,0}; + +int ordreCible[15] = {1,3,4,2,4,3,1,4,3,2,1,2,3,4} ; +int clk5Hz = 0; +int i = 0; + + +void miseAJourScores(int score0, int score1, int score2, int score3) { + Prepare_Afficheur(1, score0); + Prepare_Afficheur(2, score1); + Prepare_Afficheur(3, score2); + Prepare_Afficheur(4, score3); +} + + void callback() { + clk5Hz += 1; + Start_DMA1(64); Wait_On_End_Of_DMA1(); Stop_DMA1; - for (int j=0; j<64 ; j++) { - moduleSignal[j] = DFT_ModuleAuCarre(&(dma_buf[0]), j); -} -} + moduleSignal[0] = DFT_ModuleAuCarre(&(dma_buf[0]), 17); + moduleSignal[1] = DFT_ModuleAuCarre(&(dma_buf[0]), 18); + moduleSignal[2] = DFT_ModuleAuCarre(&(dma_buf[0]), 19); + moduleSignal[3] = DFT_ModuleAuCarre(&(dma_buf[0]), 20); + + // Choisir à qui attribuer les points + if (moduleSignal[0] > 10000) { + cnt[0]+=1; + if (cnt[0] >= 15) { + score[0] +=1; + cnt[0]=0; + } + } else {cnt[0]=0;} + + if (moduleSignal[1] > 10000) { + cnt[1]+=1; + if (cnt[1] >= 15) { + score[1] +=1; + cnt[1]=0; + } + } else {cnt[1]=0;} + + if (moduleSignal[2] > 10000) { + cnt[2]+=1; + if (cnt[2] >= 15) { + score[2] +=1; + cnt[2]=0; + } + } else {cnt[2]=0;} + + if (moduleSignal[3] > 10000) { + cnt[3]+=1; + if (cnt[3] >= 15) { + score[3] +=1; + cnt[3]=0; + } + } else {cnt[3]=0;} + + if (clk5Hz %400 ==0) { + i = (i+1)%15; + if (i == 0){ + Choix_Capteur(ordreCible[i]); + Prepare_Clear_LED(ordreCible[14]-1); + Prepare_Set_LED(ordreCible[i]-1); + }else{ + Choix_Capteur(ordreCible[i]); + Prepare_Clear_LED(ordreCible[i-1]-1); + Prepare_Set_LED(ordreCible[i]-1); + } + } + + //Pour mise a jour régulière des scores + miseAJourScores(score[0],score[1],score[2],score[3]); + Mise_A_Jour_Afficheurs_LED(); + +} int main(void) { @@ -30,35 +99,34 @@ int main(void) // Après exécution : le coeur CPU est clocké à 72MHz ainsi que tous les timers CLOCK_Configure(); -//Systick_Period_ff(5000*72); -//Systick_Prio_IT(11, callback) ; -//SysTick_On ; -//SysTick_Enable_IT ; +//Configuration intéruptions timer +Systick_Period_ff(5000*72); +Systick_Prio_IT(11, callback ); +SysTick_On ; +SysTick_Enable_IT ; - -//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 ); +//Configuration +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 ); //La malette Init_Affichage(); -Prepare_Afficheur(1, 11); -Prepare_Afficheur(2, 22); -Prepare_Afficheur(3, 33); -Prepare_Afficheur(4, 44); -Mise_A_Jour_Afficheurs_LED(); + +//TODO : englober dans fct qui fait changer la cible active régulièrement (mais wait nécessaire) + +Choix_Capteur(1); +Prepare_Set_LED(LED_Cible_1); + //============================================================================ - - - -while (1) - { +while (1) { + } }