forked from acco/chti23
debut valise
This commit is contained in:
parent
d50a03d88d
commit
f232877377
3 changed files with 118 additions and 28 deletions
|
@ -4,13 +4,17 @@
|
|||
short int dma_buff[64];
|
||||
int module_dft[64];
|
||||
extern short LeSignal;
|
||||
int max = 0;
|
||||
|
||||
void systick_func() {
|
||||
Start_DMA1(64);
|
||||
Wait_On_End_Of_DMA1();
|
||||
Stop_DMA1;
|
||||
for (int k= 0; k < 64; ++k) {
|
||||
module_dft[k] = DFT_ModuleAuCarre(dma_buff, k) >> 20;
|
||||
module_dft[k] = DFT_ModuleAuCarre(dma_buff, k);
|
||||
if (module_dft[17] > 0x1000) {
|
||||
max = module_dft[17];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,40 +1,73 @@
|
|||
#include "DriverJeuLaser.h"
|
||||
#include "module_carre.h"
|
||||
#include "GestionSon.h"
|
||||
#include "Affichage_Valise.h"
|
||||
|
||||
#define NB_JOUEURS 6
|
||||
#define SEUIL_ACCEPT_SIGNAL 0x80
|
||||
#define NB_JOUEURS 4
|
||||
#define SEUIL_ACCEPT_SIGNAL 0x2
|
||||
#define FREQ_TO_INT(f) (64 * f / 320)
|
||||
|
||||
#define TE_IN_TICKS 6552
|
||||
#define PERIODE_PWM 720
|
||||
|
||||
// 50ms @ 72MHz
|
||||
#define PERIODE_AFFICHAGE 3600
|
||||
|
||||
short int dma_buff[64];
|
||||
int module_dft[NB_JOUEURS];
|
||||
// int module_dft[64];
|
||||
int module_dft[64];
|
||||
int score_joueurs[NB_JOUEURS];
|
||||
extern short LeSignal;
|
||||
int freq_joueurs[NB_JOUEURS] = {FREQ_TO_INT(85), FREQ_TO_INT(90), FREQ_TO_INT(95), FREQ_TO_INT(100), FREQ_TO_INT(115), FREQ_TO_INT(120)};
|
||||
|
||||
int freq_joueurs[] = {FREQ_TO_INT(85), FREQ_TO_INT(90), FREQ_TO_INT(95), FREQ_TO_INT(100), FREQ_TO_INT(115), FREQ_TO_INT(120)};
|
||||
char cible_ordre[] = {LED_Cible_1, LED_Cible_2, LED_Cible_3, LED_Cible_4};
|
||||
char current_cible_index = 0;
|
||||
char bonne_cible_touchee = 0;
|
||||
char update = 0;
|
||||
|
||||
extern short Sortie_son;
|
||||
|
||||
void systick_func() {
|
||||
int module;
|
||||
Start_DMA1(64);
|
||||
Wait_On_End_Of_DMA1();
|
||||
Stop_DMA1;
|
||||
for (int i = 0; i < NB_JOUEURS; ++i) {
|
||||
module = DFT_ModuleAuCarre(dma_buff, freq_joueurs[i]);
|
||||
// module_dft[i] = module;
|
||||
if (module > SEUIL_ACCEPT_SIGNAL) {
|
||||
score_joueurs[i]++;
|
||||
StartSon();
|
||||
}
|
||||
}
|
||||
// for (int i = 0; i < 64; ++i) {
|
||||
// module_dft[i] = DFT_ModuleAuCarre(dma_buff, i);
|
||||
//void update_score() {
|
||||
// if (update) {
|
||||
// for (int i = 0; i < NB_JOUEURS; ++i) {
|
||||
// Prepare_Afficheur(i + 1, score_joueurs[i]);
|
||||
// }
|
||||
// if (bonne_cible_touchee) {
|
||||
// Prepare_Set_LED(LED_LCD_V);
|
||||
// } else {
|
||||
// Prepare_Set_LED(LED_LCD_R);
|
||||
// }
|
||||
// Mise_A_Jour_Afficheurs_LED();
|
||||
// Choix_Capteur(current_cible_index + 1);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
|
||||
void systick_func() {
|
||||
// int module;
|
||||
// Start_DMA1(64);
|
||||
// Wait_On_End_Of_DMA1();
|
||||
// Stop_DMA1;
|
||||
// for (int i = 0; i < NB_JOUEURS; ++i) {
|
||||
// module = DFT_ModuleAuCarre(dma_buff, freq_joueurs[i]);
|
||||
//// module_dft[i] = module;
|
||||
// if (module > SEUIL_ACCEPT_SIGNAL) {
|
||||
// if (i == current_cible_index) {
|
||||
// score_joueurs[i]++;
|
||||
// Prepare_Afficheur(i + 1, score_joueurs[i]);
|
||||
// Prepare_Set_LED(LED_LCD_V);
|
||||
// StartSon();
|
||||
// } else {
|
||||
// Prepare_Set_LED(LED_LCD_R);
|
||||
// }
|
||||
// Prepare_Clear_LED(cible_ordre[current_cible_index]);
|
||||
// current_cible_index = (current_cible_index + 1) % 4;
|
||||
// Prepare_Set_LED(cible_ordre[current_cible_index]);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
for (int i = 0; i < 64; ++i) {
|
||||
module_dft[i] = DFT_ModuleAuCarre(dma_buff, i);
|
||||
}
|
||||
}
|
||||
|
||||
extern short LeSignal;
|
||||
|
@ -46,7 +79,7 @@ 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
|
||||
// Après exécution : le coeur CPU est clocké à 72MHz ainsi que tous les timers
|
||||
CLOCK_Configure();
|
||||
// 5ms = n * 1/72MHz => n = 5ms * 72MHz = 360 * 10 ^ 6
|
||||
Systick_Period_ff(360000000);
|
||||
|
@ -54,6 +87,7 @@ Systick_Period_ff(360000000);
|
|||
Systick_Prio_IT(0, systick_func);
|
||||
SysTick_On;
|
||||
SysTick_Enable_IT;
|
||||
|
||||
|
||||
Init_TimingADC_ActiveADC_ff( ADC1, 72 );
|
||||
Single_Channel_ADC( ADC1, 2 );
|
||||
|
@ -62,15 +96,37 @@ Init_Conversion_On_Trig_Timer_ff(ADC1, TIM2_CC2, 225);
|
|||
Init_ADC1_DMA1(0, dma_buff);
|
||||
|
||||
// Set up interuption for the sound effect
|
||||
Timer_1234_Init_ff(TIM4, TE_IN_TICKS);
|
||||
Active_IT_Debordement_Timer(TIM4, 2, GestionSon);
|
||||
GPIO_Configure(GPIOB, 0, OUTPUT, ALT_PPULL);
|
||||
PWM_Init_ff(TIM3, 3, PERIODE_PWM);
|
||||
//Timer_1234_Init_ff(TIM4, TE_IN_TICKS);
|
||||
//Active_IT_Debordement_Timer(TIM4, 2, GestionSon);
|
||||
//GPIO_Configure(GPIOB, 0, OUTPUT, ALT_PPULL);
|
||||
//PWM_Init_ff(TIM3, 3, PERIODE_PWM);
|
||||
|
||||
//Timer_1234_Init_ff(TIM3, PERIODE_AFFICHAGE);
|
||||
//Active_IT_Debordement_Timer(TIM3, 9, update_score);
|
||||
|
||||
//// Test pour enlever l'erreur en PA2
|
||||
|
||||
Init_Affichage();
|
||||
|
||||
for (int i = 0; i < NB_JOUEURS; ++i) {
|
||||
score_joueurs[i] = 0;
|
||||
Prepare_Afficheur(i + 1, 0);
|
||||
Prepare_Clear_Point_Unite(i + 1);
|
||||
|
||||
}
|
||||
|
||||
Prepare_Clear_LED(LED_LCD_R);
|
||||
Prepare_Clear_LED(LED_LCD_V);
|
||||
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
Prepare_Clear_LED(cible_ordre[i]);
|
||||
}
|
||||
Prepare_Set_LED(cible_ordre[current_cible_index]);
|
||||
Choix_Capteur(current_cible_index + 1);
|
||||
|
||||
Mise_A_Jour_Afficheurs_LED();
|
||||
|
||||
StopSon();
|
||||
|
||||
//============================================================================
|
||||
|
||||
|
|
|
@ -418,6 +418,11 @@
|
|||
<FileType>2</FileType>
|
||||
<FilePath>.\Src\bruitverre.asm</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>Affichage_Valise.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>.\Src\Affichage_Valise.h</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
@ -438,6 +443,11 @@
|
|||
<FileType>4</FileType>
|
||||
<FilePath>.\Driver\DriverJeuLaser.lib</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>affichage_valise.o</FileName>
|
||||
<FileType>3</FileType>
|
||||
<FilePath>.\Obj\affichage_valise.o</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
@ -554,8 +564,8 @@
|
|||
<SimDlgDllArguments>-pSTM32F103RB</SimDlgDllArguments>
|
||||
<TargetDllName>SARMCM3.DLL</TargetDllName>
|
||||
<TargetDllArguments></TargetDllArguments>
|
||||
<TargetDlgDll>TCM.DLL</TargetDlgDll>
|
||||
<TargetDlgDllArguments>-pCM3</TargetDlgDllArguments>
|
||||
<TargetDlgDll>DARMSTM.DLL</TargetDlgDll>
|
||||
<TargetDlgDllArguments>-pSTM32F103RB</TargetDlgDllArguments>
|
||||
</DllOption>
|
||||
<DebugOption>
|
||||
<OPTHX>
|
||||
|
@ -857,6 +867,11 @@
|
|||
<FileType>2</FileType>
|
||||
<FilePath>.\Src\bruitverre.asm</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>Affichage_Valise.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>.\Src\Affichage_Valise.h</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
@ -877,6 +892,11 @@
|
|||
<FileType>4</FileType>
|
||||
<FilePath>.\Driver\DriverJeuLaser.lib</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>affichage_valise.o</FileName>
|
||||
<FileType>3</FileType>
|
||||
<FilePath>.\Obj\affichage_valise.o</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
@ -1365,6 +1385,11 @@
|
|||
<FileType>2</FileType>
|
||||
<FilePath>.\Src\bruitverre.asm</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>Affichage_Valise.h</FileName>
|
||||
<FileType>5</FileType>
|
||||
<FilePath>.\Src\Affichage_Valise.h</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
@ -1385,6 +1410,11 @@
|
|||
<FileType>4</FileType>
|
||||
<FilePath>.\Driver\DriverJeuLaser.lib</FilePath>
|
||||
</File>
|
||||
<File>
|
||||
<FileName>affichage_valise.o</FileName>
|
||||
<FileType>3</FileType>
|
||||
<FilePath>.\Obj\affichage_valise.o</FilePath>
|
||||
</File>
|
||||
</Files>
|
||||
</Group>
|
||||
<Group>
|
||||
|
|
Loading…
Reference in a new issue