be_chti/PjtKEIL_StepFini/Src/principal.c
2023-05-30 11:31:41 +02:00

104 lines
2.2 KiB
C

#include "DriverJeuLaser.h"
#include "GestionSon.h"
#include "Affichage_Valise.h"
extern int DFT_ModuleAucarre_Reel(short int * Signal64ech, char k);
extern int DFT_ModuleAucarre_Im(short int * Signal64ech, char k);
extern int DFT_ModuleAuCarre (short int * Signal64ech, char k);
extern short int LeSignal[64];
//int DFT_ModuleAuCarre_C( short int * Signal64ech, char k){
// int somme_cos, somme_sin;
// for(int n = 0; n<63; n++){
// somme_cos += TabCos[n];
// somme_sin += TabSin[n];
// }
// int somme_k = (int) (long long) somme_cos* (int) (long long) somme_cos + (int) (long long) somme_sin* (int) (long long) somme_sin;
// return somme_k;
//}
int Resultat[6];
short dma_buf[64];
int Score [6] = { 0, 0, 0, 0, 0, 0};
int Fre [6] = {17, 18, 19, 20, 23, 24};
int Seuil = 2097152;
int buff;
void callback_Systick(){
Start_DMA1(64);
Wait_On_End_Of_DMA1();
Stop_DMA1;
for (int k =0; k <6; k++){
buff = DFT_ModuleAuCarre(dma_buf,Fre[k]);
Resultat[k] = buff;
}
for (int k=0; k<6; k++) {
if (Resultat[k]>Seuil) {
Score [k] ++;
StartSon ();
}
}
}
void callback_Affichage () {
Prepare_Afficheur (1, Score[1]);
Prepare_Afficheur (2, Score[2]);
Prepare_Afficheur (3, Score[3]);
Prepare_Afficheur (4, Score[4]);
Mise_A_Jour_Afficheurs_LED();
}
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();
Systick_Period_ff(360000);
Systick_Prio_IT(3,callback_Systick);
SysTick_On;
SysTick_Enable_IT;
Timer_1234_Init_ff( TIM1, 91*72);
Active_IT_Debordement_Timer( TIM1, 8, callback_Affichage );
Timer_1234_Init_ff( TIM3, 91*72);
PWM_Init_ff( TIM3, 3, 720);
GPIO_Configure(GPIOB, 0, OUTPUT, ALT_PPULL);
Timer_1234_Init_ff( TIM4, 91*72);
Active_IT_Debordement_Timer( TIM4, 5, CallbackSon );
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)
{
}
}