grpE_BENSEBAA_GROSS/soft/PjtKEIL_StepFinal/Src/principal.c
2023-05-24 15:20:35 +02:00

91 rader
1,4 KiB
C

#include "DriverJeuLaser.h"
#define M 64
#define SIZETABK 4
#define SEUIL 0x3c2e1
extern int DFT_ModuleAuCarre( short int * Signal64ech, char k);
short int dma_buf[64];
int ReDFT[SIZETABK];
int score[SIZETABK];
int count[SIZETABK]={0};
void init_score(){
for(int i=0;i<SIZETABK;i++) score[i]=0;
}
void ItSystick(void) {
Start_DMA1(64);
Wait_On_End_Of_DMA1();
Stop_DMA1;
int tabK[]={17,18,19,20};
for(int k=0;k<SIZETABK;k++){
ReDFT[k]=DFT_ModuleAuCarre(dma_buf,tabK[k]);
if(ReDFT[k]>=SEUIL){
count[k]=(count[k]+1);
if(count[k]==15){
score[k]++;
count[k]=0;
}
}
else {
count[k]=0;
}
}
}
int main(void)
{
// ===========================================================================
// ============= INIT PERIPH (faites qu'une seule fois) =====================
// ===========================================================================
// Après exécution : le coeur CPU est clocké à 72MHz ainsi que tous les timers
CLOCK_Configure();
//Partie Son
unsigned int tick=91*72;
init_score();
Systick_Period_ff( 5000*72 );
Systick_Prio_IT( 1, ItSystick );
SysTick_On;
SysTick_Enable_IT;
//timer tous les 100ms pour score
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 );
//============================================================================
while (1)
{
}
}