forked from acco/chti23
start adding sound to tested DMA
This commit is contained in:
parent
bd2fea0568
commit
d50a03d88d
5 changed files with 5676 additions and 2 deletions
9
soft/PjtKEIL_StepFinal/Src/GestionSon.h
Normal file
9
soft/PjtKEIL_StepFinal/Src/GestionSon.h
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
#ifndef GESTION_SON
|
||||||
|
#define GESTION_SON
|
||||||
|
|
||||||
|
void StartSon(void);
|
||||||
|
void StopSon(void);
|
||||||
|
void GestionSon(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
75
soft/PjtKEIL_StepFinal/Src/GestionSon.s
Normal file
75
soft/PjtKEIL_StepFinal/Src/GestionSon.s
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
PRESERVE8
|
||||||
|
THUMB
|
||||||
|
|
||||||
|
import LongueurSon
|
||||||
|
import PeriodeSonMicroSec
|
||||||
|
import Son
|
||||||
|
|
||||||
|
include Driver/DriverJeuLaser.inc
|
||||||
|
|
||||||
|
; ====================== zone de réservation de données, ======================================
|
||||||
|
;Section RAM (read only) :
|
||||||
|
area mesdata,data,readonly
|
||||||
|
|
||||||
|
|
||||||
|
;Section RAM (read write):
|
||||||
|
area maram,data,readwrite
|
||||||
|
|
||||||
|
|
||||||
|
Son_index dcd 0
|
||||||
|
Sortie_son dcw 0
|
||||||
|
|
||||||
|
; ===============================================================================================
|
||||||
|
|
||||||
|
|
||||||
|
EXPORT Son_index
|
||||||
|
EXPORT Sortie_son
|
||||||
|
|
||||||
|
|
||||||
|
;Section ROM code (read only) :
|
||||||
|
area moncode,code,readonly
|
||||||
|
; écrire le code ici
|
||||||
|
|
||||||
|
EXPORT GestionSon
|
||||||
|
EXPORT StartSon
|
||||||
|
EXPORT StopSon
|
||||||
|
|
||||||
|
StopSon proc
|
||||||
|
ldr r1, =Son_index
|
||||||
|
ldr r2, =LongueurSon
|
||||||
|
ldr r0, [r2]
|
||||||
|
str r0, [r1]
|
||||||
|
bx lr
|
||||||
|
endp
|
||||||
|
|
||||||
|
|
||||||
|
StartSon proc
|
||||||
|
eor r0, r0
|
||||||
|
ldr r1, =Son_index
|
||||||
|
str r0, [r1]
|
||||||
|
bx lr
|
||||||
|
endp
|
||||||
|
|
||||||
|
GestionSon proc
|
||||||
|
ldr r2, =LongueurSon
|
||||||
|
ldr r0, [r2]
|
||||||
|
ldr r2, =Son_index
|
||||||
|
ldr r1, [r2]
|
||||||
|
cmp r0, r1
|
||||||
|
bls EndOfSound ; if (LongeurSon <= Son_index) goto ResetGestionSon;
|
||||||
|
ldr r3, =Son
|
||||||
|
ldrsh r0, [r3, r1, lsl #1]
|
||||||
|
; r0 = Son[Son_index]
|
||||||
|
add r0, #32768
|
||||||
|
mov r3, #720
|
||||||
|
mul r0, r3
|
||||||
|
lsr r0, #16 ;x in [-32768; 32767] -> x in [0; 719]
|
||||||
|
ldr r3, =Sortie_son
|
||||||
|
str r0, [r3] ; Sortie_son = x
|
||||||
|
add r1, r1, #1
|
||||||
|
str r1, [r2] ; Son_index++;
|
||||||
|
b PWM_Set_Value_TIM3_Ch3
|
||||||
|
EndOfSound
|
||||||
|
bx lr
|
||||||
|
endp
|
||||||
|
END
|
5527
soft/PjtKEIL_StepFinal/Src/bruitverre.asm
Normal file
5527
soft/PjtKEIL_StepFinal/Src/bruitverre.asm
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,17 +1,24 @@
|
||||||
#include "DriverJeuLaser.h"
|
#include "DriverJeuLaser.h"
|
||||||
#include "module_carre.h"
|
#include "module_carre.h"
|
||||||
|
#include "GestionSon.h"
|
||||||
|
|
||||||
#define NB_JOUEURS 6
|
#define NB_JOUEURS 6
|
||||||
#define SEUIL_ACCEPT_SIGNAL 0x1200
|
#define SEUIL_ACCEPT_SIGNAL 0x80
|
||||||
#define FREQ_TO_INT(f) (64 * f / 320)
|
#define FREQ_TO_INT(f) (64 * f / 320)
|
||||||
|
|
||||||
|
#define TE_IN_TICKS 6552
|
||||||
|
#define PERIODE_PWM 720
|
||||||
|
|
||||||
short int dma_buff[64];
|
short int dma_buff[64];
|
||||||
int module_dft[NB_JOUEURS];
|
int module_dft[NB_JOUEURS];
|
||||||
|
// int module_dft[64];
|
||||||
int score_joueurs[NB_JOUEURS];
|
int score_joueurs[NB_JOUEURS];
|
||||||
extern short LeSignal;
|
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[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)};
|
||||||
|
|
||||||
|
|
||||||
|
extern short Sortie_son;
|
||||||
|
|
||||||
void systick_func() {
|
void systick_func() {
|
||||||
int module;
|
int module;
|
||||||
Start_DMA1(64);
|
Start_DMA1(64);
|
||||||
|
@ -19,11 +26,15 @@ void systick_func() {
|
||||||
Stop_DMA1;
|
Stop_DMA1;
|
||||||
for (int i = 0; i < NB_JOUEURS; ++i) {
|
for (int i = 0; i < NB_JOUEURS; ++i) {
|
||||||
module = DFT_ModuleAuCarre(dma_buff, freq_joueurs[i]);
|
module = DFT_ModuleAuCarre(dma_buff, freq_joueurs[i]);
|
||||||
module_dft[i] = module;
|
// module_dft[i] = module;
|
||||||
if (module > SEUIL_ACCEPT_SIGNAL) {
|
if (module > SEUIL_ACCEPT_SIGNAL) {
|
||||||
score_joueurs[i]++;
|
score_joueurs[i]++;
|
||||||
|
StartSon();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// for (int i = 0; i < 64; ++i) {
|
||||||
|
// module_dft[i] = DFT_ModuleAuCarre(dma_buff, i);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
extern short LeSignal;
|
extern short LeSignal;
|
||||||
|
@ -49,6 +60,13 @@ Single_Channel_ADC( ADC1, 2 );
|
||||||
// 320 kHz = 72MHz / n => n = 72MHz / 320kHz = 225
|
// 320 kHz = 72MHz / n => n = 72MHz / 320kHz = 225
|
||||||
Init_Conversion_On_Trig_Timer_ff(ADC1, TIM2_CC2, 225);
|
Init_Conversion_On_Trig_Timer_ff(ADC1, TIM2_CC2, 225);
|
||||||
Init_ADC1_DMA1(0, dma_buff);
|
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);
|
||||||
|
|
||||||
for (int i = 0; i < NB_JOUEURS; ++i) {
|
for (int i = 0; i < NB_JOUEURS; ++i) {
|
||||||
score_joueurs[i] = 0;
|
score_joueurs[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -403,6 +403,21 @@
|
||||||
<FileType>5</FileType>
|
<FileType>5</FileType>
|
||||||
<FilePath>.\Src\module_carre.h</FilePath>
|
<FilePath>.\Src\module_carre.h</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>GestionSon.s</FileName>
|
||||||
|
<FileType>2</FileType>
|
||||||
|
<FilePath>.\Src\GestionSon.s</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>GestionSon.h</FileName>
|
||||||
|
<FileType>5</FileType>
|
||||||
|
<FilePath>.\Src\GestionSon.h</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>bruitverre.asm</FileName>
|
||||||
|
<FileType>2</FileType>
|
||||||
|
<FilePath>.\Src\bruitverre.asm</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
|
@ -827,6 +842,21 @@
|
||||||
<FileType>5</FileType>
|
<FileType>5</FileType>
|
||||||
<FilePath>.\Src\module_carre.h</FilePath>
|
<FilePath>.\Src\module_carre.h</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>GestionSon.s</FileName>
|
||||||
|
<FileType>2</FileType>
|
||||||
|
<FilePath>.\Src\GestionSon.s</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>GestionSon.h</FileName>
|
||||||
|
<FileType>5</FileType>
|
||||||
|
<FilePath>.\Src\GestionSon.h</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>bruitverre.asm</FileName>
|
||||||
|
<FileType>2</FileType>
|
||||||
|
<FilePath>.\Src\bruitverre.asm</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
|
@ -1320,6 +1350,21 @@
|
||||||
<FileType>5</FileType>
|
<FileType>5</FileType>
|
||||||
<FilePath>.\Src\module_carre.h</FilePath>
|
<FilePath>.\Src\module_carre.h</FilePath>
|
||||||
</File>
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>GestionSon.s</FileName>
|
||||||
|
<FileType>2</FileType>
|
||||||
|
<FilePath>.\Src\GestionSon.s</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>GestionSon.h</FileName>
|
||||||
|
<FileType>5</FileType>
|
||||||
|
<FilePath>.\Src\GestionSon.h</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>bruitverre.asm</FileName>
|
||||||
|
<FileType>2</FileType>
|
||||||
|
<FilePath>.\Src\bruitverre.asm</FilePath>
|
||||||
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
<Group>
|
<Group>
|
||||||
|
|
Loading…
Reference in a new issue