Objectif 3 En cours
This commit is contained in:
parent
d4cd6a3fab
commit
fb9def3d9d
13 changed files with 11493 additions and 289 deletions
|
@ -180,7 +180,7 @@
|
||||||
<Mm>
|
<Mm>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<SubType>10</SubType>
|
<SubType>10</SubType>
|
||||||
<ItemText>0x20000250</ItemText>
|
<ItemText>0x08001F24</ItemText>
|
||||||
<AccSizeX>0</AccSizeX>
|
<AccSizeX>0</AccSizeX>
|
||||||
</Mm>
|
</Mm>
|
||||||
</MemoryWindow1>
|
</MemoryWindow1>
|
||||||
|
@ -204,7 +204,7 @@
|
||||||
<AscS3>0</AscS3>
|
<AscS3>0</AscS3>
|
||||||
<aSer3>0</aSer3>
|
<aSer3>0</aSer3>
|
||||||
<eProf>0</eProf>
|
<eProf>0</eProf>
|
||||||
<aLa>0</aLa>
|
<aLa>1</aLa>
|
||||||
<aPa1>0</aPa1>
|
<aPa1>0</aPa1>
|
||||||
<AscS4>0</AscS4>
|
<AscS4>0</AscS4>
|
||||||
<aSer4>0</aSer4>
|
<aSer4>0</aSer4>
|
||||||
|
@ -229,8 +229,8 @@
|
||||||
<LogicAnalyzers>
|
<LogicAnalyzers>
|
||||||
<Wi>
|
<Wi>
|
||||||
<IntNumber>0</IntNumber>
|
<IntNumber>0</IntNumber>
|
||||||
<FirstString>((portb & 0x00000002) >> 1 & 0x2) >> 1</FirstString>
|
<FirstString>`TIM3_CCR3</FirstString>
|
||||||
<SecondString>FF000000000000000000000000000000E0FFEF400100000000000000000000000000000028706F7274622026203078303030303030303229203E3E2031000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F1000000000000000000000000000000000000000941E0008</SecondString>
|
<SecondString>0080000000000000000000000000E0FFFFFFEF410000000000000000000000000000000054494D335F4343523300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100000001000000000000000000F03F1200000000000000000000000000000000000000BA1E0008</SecondString>
|
||||||
</Wi>
|
</Wi>
|
||||||
</LogicAnalyzers>
|
</LogicAnalyzers>
|
||||||
<DebugDescription>
|
<DebugDescription>
|
||||||
|
@ -268,8 +268,8 @@
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>.\Src\calcul_dft.s</PathWithFileName>
|
<PathWithFileName>.\Src\signalCarre.s</PathWithFileName>
|
||||||
<FilenameWithoutPath>calcul_dft.s</FilenameWithoutPath>
|
<FilenameWithoutPath>signalCarre.s</FilenameWithoutPath>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<bShared>0</bShared>
|
<bShared>0</bShared>
|
||||||
</File>
|
</File>
|
||||||
|
@ -304,12 +304,12 @@
|
||||||
<File>
|
<File>
|
||||||
<GroupNumber>3</GroupNumber>
|
<GroupNumber>3</GroupNumber>
|
||||||
<FileNumber>4</FileNumber>
|
<FileNumber>4</FileNumber>
|
||||||
<FileType>2</FileType>
|
<FileType>5</FileType>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>.\Src\table_sin_cos.s</PathWithFileName>
|
<PathWithFileName>.\Src\etat.h</PathWithFileName>
|
||||||
<FilenameWithoutPath>table_sin_cos.s</FilenameWithoutPath>
|
<FilenameWithoutPath>etat.h</FilenameWithoutPath>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<bShared>0</bShared>
|
<bShared>0</bShared>
|
||||||
</File>
|
</File>
|
||||||
|
@ -320,8 +320,20 @@
|
||||||
<tvExp>0</tvExp>
|
<tvExp>0</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<bDave2>0</bDave2>
|
<bDave2>0</bDave2>
|
||||||
<PathWithFileName>..\GFSSP72\gfssp72.lib</PathWithFileName>
|
<PathWithFileName>..\GASSP72\gassp72.lib</PathWithFileName>
|
||||||
<FilenameWithoutPath>gfssp72.lib</FilenameWithoutPath>
|
<FilenameWithoutPath>gassp72.lib</FilenameWithoutPath>
|
||||||
|
<RteFlg>0</RteFlg>
|
||||||
|
<bShared>0</bShared>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<GroupNumber>3</GroupNumber>
|
||||||
|
<FileNumber>6</FileNumber>
|
||||||
|
<FileType>2</FileType>
|
||||||
|
<tvExp>0</tvExp>
|
||||||
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
|
<bDave2>0</bDave2>
|
||||||
|
<PathWithFileName>.\Src\son.asm</PathWithFileName>
|
||||||
|
<FilenameWithoutPath>son.asm</FilenameWithoutPath>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
<bShared>0</bShared>
|
<bShared>0</bShared>
|
||||||
</File>
|
</File>
|
||||||
|
|
|
@ -338,7 +338,7 @@
|
||||||
<MiscControls>--C99</MiscControls>
|
<MiscControls>--C99</MiscControls>
|
||||||
<Define>STM32F103xB,USE_FULL_LL_DRIVER</Define>
|
<Define>STM32F103xB,USE_FULL_LL_DRIVER</Define>
|
||||||
<Undefine></Undefine>
|
<Undefine></Undefine>
|
||||||
<IncludePath>../GFSSP72</IncludePath>
|
<IncludePath>../GASSP72</IncludePath>
|
||||||
</VariousControls>
|
</VariousControls>
|
||||||
</Cads>
|
</Cads>
|
||||||
<Aads>
|
<Aads>
|
||||||
|
@ -388,9 +388,9 @@
|
||||||
<FilePath>.\Src\principal.c</FilePath>
|
<FilePath>.\Src\principal.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>calcul_dft.s</FileName>
|
<FileName>signalCarre.s</FileName>
|
||||||
<FileType>2</FileType>
|
<FileType>2</FileType>
|
||||||
<FilePath>.\Src\calcul_dft.s</FilePath>
|
<FilePath>.\Src\signalCarre.s</FilePath>
|
||||||
</File>
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
|
@ -408,14 +408,19 @@
|
||||||
<GroupName>Driver</GroupName>
|
<GroupName>Driver</GroupName>
|
||||||
<Files>
|
<Files>
|
||||||
<File>
|
<File>
|
||||||
<FileName>table_sin_cos.s</FileName>
|
<FileName>etat.h</FileName>
|
||||||
<FileType>2</FileType>
|
<FileType>5</FileType>
|
||||||
<FilePath>.\Src\table_sin_cos.s</FilePath>
|
<FilePath>.\Src\etat.h</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>gfssp72.lib</FileName>
|
<FileName>gassp72.lib</FileName>
|
||||||
<FileType>4</FileType>
|
<FileType>4</FileType>
|
||||||
<FilePath>..\GFSSP72\gfssp72.lib</FilePath>
|
<FilePath>..\GASSP72\gassp72.lib</FilePath>
|
||||||
|
</File>
|
||||||
|
<File>
|
||||||
|
<FileName>son.asm</FileName>
|
||||||
|
<FileType>2</FileType>
|
||||||
|
<FilePath>.\Src\son.asm</FilePath>
|
||||||
</File>
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
94
Src/appli.c
Normal file
94
Src/appli.c
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
/* programme pour experimenter le decoupage en bandes sur fichier WAVE */
|
||||||
|
/* */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "wav_head.h"
|
||||||
|
|
||||||
|
|
||||||
|
void usage()
|
||||||
|
{
|
||||||
|
fprintf( stderr, "\nUsage : wav2asm source.wav dest.s\n\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main( int argc, char ** argv )
|
||||||
|
{
|
||||||
|
int shand; wavpars s;
|
||||||
|
char snam[256];
|
||||||
|
char dnam[256];
|
||||||
|
FILE * dfil;
|
||||||
|
|
||||||
|
if ( argc != 3 ) usage();
|
||||||
|
|
||||||
|
sprintf( snam, "%s", argv[1] );
|
||||||
|
sprintf( dnam, "%s", argv[2] );
|
||||||
|
|
||||||
|
printf("ouverture %s en lecture\n", snam );
|
||||||
|
shand = open( snam, O_RDONLY | O_BINARY );
|
||||||
|
if ( shand == -1 ) gasp("not found");
|
||||||
|
|
||||||
|
WAVreadHeader( &s, shand );
|
||||||
|
if (
|
||||||
|
( s.chan != 1 ) ||
|
||||||
|
( s.resol != 16 )
|
||||||
|
)
|
||||||
|
gasp("programme seulement pour fichiers mono 16 bits");
|
||||||
|
printf("%d echantillons par canal, duree %gs\n", (int)s.wavsize, (double)s.wavsize / (double)s.freq );
|
||||||
|
|
||||||
|
printf("ouverture %s en ecriture\n", dnam );
|
||||||
|
dfil = fopen( dnam, "w" );
|
||||||
|
if ( dfil == NULL ) gasp("pb ouverture pour ecrire");
|
||||||
|
|
||||||
|
fprintf( dfil, "\tAREA DonneeSon, CODE, READONLY\n");
|
||||||
|
fprintf( dfil, "\texport LongueurSon\n");
|
||||||
|
fprintf( dfil, "\texport PeriodeSonMicroSec\n");
|
||||||
|
fprintf( dfil, "\texport Son\n");
|
||||||
|
|
||||||
|
fprintf( dfil, "LongueurSon\tDCD\t%lu\n", s.wavsize );
|
||||||
|
fprintf( dfil, "PeriodeSonMicroSec\tDCD\t%d\n", (int)( floor( 1000000.0/(double)s.freq + 0.5 ) ) );
|
||||||
|
|
||||||
|
fprintf( dfil, "Son ");
|
||||||
|
|
||||||
|
#define FRAMLEN 512
|
||||||
|
|
||||||
|
unsigned char sbuf[FRAMLEN]; // source
|
||||||
|
int sind; // index courant dans sbuf[]
|
||||||
|
int rdcont;
|
||||||
|
int sbufcont; // contenu de sbuf[] */
|
||||||
|
long qbytes;
|
||||||
|
int bpsam;
|
||||||
|
short int val16;
|
||||||
|
|
||||||
|
bpsam = s.chan * ((s.resol)>>3);
|
||||||
|
qbytes = s.wavsize * bpsam;
|
||||||
|
|
||||||
|
while ( qbytes > 0L ) /* qbytes = nombre de bytes restant a traiter */
|
||||||
|
{
|
||||||
|
if ( qbytes < (long)FRAMLEN )
|
||||||
|
rdcont = (int)qbytes;
|
||||||
|
else rdcont = FRAMLEN;
|
||||||
|
sbufcont = read( shand, sbuf, rdcont );
|
||||||
|
if ( sbufcont < rdcont )
|
||||||
|
gasp("fin inattendue fichier source %d vs %d", sbufcont, rdcont );
|
||||||
|
qbytes -= (long)rdcont;
|
||||||
|
// ici on a sbufcont bytes dans sbuf, prets a traiter
|
||||||
|
for ( sind = 0; sind < sbufcont; sind += 2 )
|
||||||
|
{
|
||||||
|
val16 = ( sbuf[sind+1] << 8 ) + sbuf[sind];
|
||||||
|
fprintf( dfil, "\tdcw\t%d\n", (int)val16 );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fprintf( dfil, "\tend\n");
|
||||||
|
fclose( dfil );
|
||||||
|
close( shand );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
; ce programme est pour l'assembleur RealView (Keil)
|
|
||||||
thumb
|
|
||||||
area moncode, code, readonly
|
|
||||||
export calcul_dft
|
|
||||||
import TabCos
|
|
||||||
import TabSin
|
|
||||||
|
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
calcul_dft proc
|
|
||||||
push {lr}
|
|
||||||
|
|
||||||
push {r0,r1,r4,r5}
|
|
||||||
|
|
||||||
ldr r2, =TabCos
|
|
||||||
bl calcul_partie_dft ;recuperation Re(k) dans r0
|
|
||||||
|
|
||||||
smull r4, r5, r0, r0 ;Re(k)² dans r4, r5
|
|
||||||
pop {r0,r1} ;recupereration de TabSig et k dans r0,r1
|
|
||||||
|
|
||||||
|
|
||||||
ldr r2, =TabSin
|
|
||||||
bl calcul_partie_dft ;mise de -Im(k) dans r0
|
|
||||||
|
|
||||||
smlal r4, r5, r0, r0 ;Re²+(-Im(k))²
|
|
||||||
|
|
||||||
mov r0, r5 ;recuperation des bits de poids fort de M2(k)
|
|
||||||
pop {lr, r4,r5}
|
|
||||||
bx lr
|
|
||||||
endp
|
|
||||||
|
|
||||||
calcul_partie_dft proc
|
|
||||||
push {r4-r7}
|
|
||||||
|
|
||||||
|
|
||||||
mov r4, r0 ;chargement de TabSig dans r4
|
|
||||||
mov r5, r2 ;chargement de TabCos/TabSin dans r5
|
|
||||||
mov r6, r1 ;chargement de k dans r6
|
|
||||||
mov r7, #0 ;ik dans r7
|
|
||||||
|
|
||||||
mov r3, #0 ;i=0 dans r3
|
|
||||||
mov r0, #0 ;resultat de la somme dans r0
|
|
||||||
|
|
||||||
boucle ldrh r1, [r4, r3, LSL #1] ;chargement de x(i)
|
|
||||||
ldrsh r2, [r5, r7, LSL #1] ;chargement de cos(ik..), ldrs(!)h tres important, ne fonctionne pas sinon
|
|
||||||
|
|
||||||
mla r0, r1, r2, r0 ;multiplication + ajout au resultat de x(i)cos(ik..)
|
|
||||||
|
|
||||||
add r7, r7, r6 ;mise a jour de ik
|
|
||||||
and r7, r7, #63 ;modulo de ik par 64
|
|
||||||
|
|
||||||
add r3, #1 ;incrementation de i
|
|
||||||
cmp r3, #64 ;test de i
|
|
||||||
bne boucle
|
|
||||||
beq sortie
|
|
||||||
|
|
||||||
sortie
|
|
||||||
|
|
||||||
pop {r4-r7}
|
|
||||||
bx lr
|
|
||||||
endp
|
|
||||||
|
|
||||||
end
|
|
16
Src/etat.h
Normal file
16
Src/etat.h
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
typedef struct {
|
||||||
|
int position; // 0
|
||||||
|
int taille; // 4
|
||||||
|
void * son; // 8
|
||||||
|
int resolution; // 12
|
||||||
|
int periode_ticks; // 16
|
||||||
|
} type_etat;
|
||||||
|
|
||||||
|
/*
|
||||||
|
E_POS equ 0
|
||||||
|
E_TAI equ 4
|
||||||
|
E_SON equ 8
|
||||||
|
E_RES equ 12
|
||||||
|
E_PER equ 16
|
||||||
|
end
|
||||||
|
*/
|
27
Src/makefile
Normal file
27
Src/makefile
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
# makefile pour MinGW
|
||||||
|
|
||||||
|
CCOPT = -Wall -O2
|
||||||
|
C_SRC = wav_head.c appli.c
|
||||||
|
CPP_SRC =
|
||||||
|
EXE = wav2asm.exe
|
||||||
|
|
||||||
|
OBJS = $(C_SRC:.c=.o) $(CPP_SRC:.cpp=.o)
|
||||||
|
|
||||||
|
# linkage
|
||||||
|
$(EXE) : $(OBJS)
|
||||||
|
g++ -o $(EXE) $(OBJS)
|
||||||
|
|
||||||
|
# compilage
|
||||||
|
.c.o :
|
||||||
|
gcc $(CCOPT) -c $<
|
||||||
|
|
||||||
|
.cpp.o :
|
||||||
|
g++ $(CCOPT) -c $<
|
||||||
|
# other
|
||||||
|
|
||||||
|
clean :
|
||||||
|
del *.o; del *.exe
|
||||||
|
|
||||||
|
# dependances :
|
||||||
|
wav_head.o : wav_head.h
|
||||||
|
appli.o : wav_head.h
|
|
@ -2,91 +2,48 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include "etat.h"
|
||||||
#define taille 6
|
|
||||||
#define SYSTICK_PER 360000 // (360000 ticks équivaut à 5ms)
|
|
||||||
#define M2TIR 985988
|
|
||||||
|
|
||||||
extern short TabSig[];
|
|
||||||
int etat = 0x00020000;
|
|
||||||
|
|
||||||
|
|
||||||
extern int calcul_carre(int);
|
#define SYSTICK_PER 360 // (360000 ticks équivaut à 5ms)
|
||||||
extern int calcul_dft(unsigned short *, int);
|
|
||||||
|
|
||||||
|
|
||||||
int res_dft = 0;
|
extern void timer_callback(void);
|
||||||
unsigned short dma_buf[64];
|
extern short Son[];
|
||||||
int compteurs[taille];
|
extern int LongueurSon;
|
||||||
int scores[taille];
|
extern int PeriodeSonMicroSec;
|
||||||
int k_values[] = {17,18,19,20,23,24};
|
|
||||||
|
|
||||||
|
type_etat etat;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void checkCounter(void){
|
|
||||||
for(int i=0; i<taille; i++) {
|
|
||||||
if(compteurs[i] >= 13){
|
|
||||||
compteurs[i]=0;
|
|
||||||
scores[i]++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void sys_callback(void){
|
|
||||||
// Démarrage DMA pour 64 points
|
|
||||||
Start_DMA1(64);
|
|
||||||
Wait_On_End_Of_DMA1();
|
|
||||||
Stop_DMA1;
|
|
||||||
|
|
||||||
for(int i=0; i<taille; i++){
|
|
||||||
res_dft = calcul_dft(dma_buf, k_values[i]);
|
|
||||||
if(res_dft > M2TIR){
|
|
||||||
compteurs[i]++;
|
|
||||||
}else{
|
|
||||||
compteurs[i] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
checkCounter();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
for(int i=0; i<6; i++){
|
|
||||||
compteurs[i] = 0;
|
|
||||||
scores[i] = 0 ;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// activation de la PLL qui multiplie la fréquence du quartz par 9
|
// activation de la PLL qui multiplie la fréquence du quartz par 9
|
||||||
CLOCK_Configure();
|
CLOCK_Configure();
|
||||||
// PA2 (ADC voie 2) = entrée analog
|
|
||||||
GPIO_Configure(GPIOA, 2, INPUT, ANALOG);
|
|
||||||
// PB1 = sortie pour profilage à l'oscillo
|
|
||||||
GPIO_Configure(GPIOB, 1, OUTPUT, OUTPUT_PPULL);
|
|
||||||
// PB14 = sortie pour LED
|
|
||||||
GPIO_Configure(GPIOB, 14, OUTPUT, OUTPUT_PPULL);
|
|
||||||
|
|
||||||
// activation ADC, sampling time 1us
|
// config port PB0 pour être utilisé par TIM3-CH3
|
||||||
Init_TimingADC_ActiveADC_ff( ADC1, 0x33 );
|
GPIO_Configure(GPIOB, 0, OUTPUT, ALT_PPULL);
|
||||||
Single_Channel_ADC( ADC1, 2 );
|
// config TIM3-CH3 en mode PWM
|
||||||
// Déclenchement ADC par timer2, periode (72MHz/320kHz)ticks
|
etat.resolution = PWM_Init_ff( TIM3, 3, SYSTICK_PER);
|
||||||
Init_Conversion_On_Trig_Timer_ff( ADC1, TIM2_CC2, 225 );
|
|
||||||
// Config DMA pour utilisation du buffer dma_buf (a créér)
|
|
||||||
Init_ADC1_DMA1( 0, dma_buf );
|
|
||||||
|
|
||||||
// Config Timer, période exprimée en périodes horloge CPU (72 MHz)
|
etat.taille = LongueurSon;
|
||||||
Systick_Period_ff( SYSTICK_PER );
|
etat.periode_ticks = PeriodeSonMicroSec*72;
|
||||||
|
etat.son = Son;
|
||||||
|
|
||||||
|
// initialisation du timer 4
|
||||||
|
// Periode_en_Tck doit fournir la durée entre interruptions,
|
||||||
|
// exprimée en périodes Tck de l'horloge principale du STM32 (72 MHz)
|
||||||
|
Timer_1234_Init_ff( TIM4, etat.periode_ticks);
|
||||||
// enregistrement de la fonction de traitement de l'interruption timer
|
// enregistrement de la fonction de traitement de l'interruption timer
|
||||||
// ici le 3 est la priorité, sys_callback est l'adresse de cette fonction, a créér en C
|
// ici le 2 est la priorité, timer_callback est l'adresse de cette fonction, a créér en asm,
|
||||||
Systick_Prio_IT( 3, sys_callback );
|
// cette fonction doit être conforme à l'AAPCS
|
||||||
SysTick_On;
|
Active_IT_Debordement_Timer( TIM4, 2, timer_callback );
|
||||||
SysTick_Enable_IT;
|
// lancement du timer
|
||||||
|
Run_Timer( TIM4 );
|
||||||
|
|
||||||
while(1){
|
while(1){
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
48
Src/signalCarre.s
Normal file
48
Src/signalCarre.s
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
; ce programme est pour l'assembleur RealView (Keil)
|
||||||
|
thumb
|
||||||
|
area moncode, code, readonly
|
||||||
|
export timer_callback
|
||||||
|
extern etat
|
||||||
|
;
|
||||||
|
E_POS equ 0
|
||||||
|
E_TAI equ 4
|
||||||
|
E_SON equ 8
|
||||||
|
E_RES equ 12
|
||||||
|
E_PER equ 16
|
||||||
|
|
||||||
|
TIM3_CCR3 equ 0x4000043C ; adresse registre PWM
|
||||||
|
|
||||||
|
timer_callback proc
|
||||||
|
|
||||||
|
push{r4}
|
||||||
|
|
||||||
|
ldr r1, =etat
|
||||||
|
ldr r2, [r1, #E_POS]
|
||||||
|
|
||||||
|
ldr r3, [r1,#E_TAI]
|
||||||
|
cmp r2, r3
|
||||||
|
beq silence
|
||||||
|
bne son
|
||||||
|
son ldr r4, [r1, #E_RES]
|
||||||
|
ldr r3, [r1, #E_SON]
|
||||||
|
ldrsh r3, [r3, r2,lsl #1]
|
||||||
|
|
||||||
|
add r3, r3, lsl #16
|
||||||
|
mul r3, r3, r4
|
||||||
|
lsr r3, #16
|
||||||
|
;add r3, r3, r4
|
||||||
|
;lsl r3, #1
|
||||||
|
|
||||||
|
ldr r4, =TIM3_CCR3
|
||||||
|
str r3, [r4]
|
||||||
|
|
||||||
|
add r2,#1
|
||||||
|
str r2,[r1, #E_POS]
|
||||||
|
|
||||||
|
silence
|
||||||
|
|
||||||
|
pop{r4}
|
||||||
|
bx lr
|
||||||
|
endp
|
||||||
|
end
|
||||||
|
|
5527
Src/son.asm
Normal file
5527
Src/son.asm
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,136 +0,0 @@
|
||||||
AREA Trigo, DATA, READONLY
|
|
||||||
export TabSin
|
|
||||||
export TabCos
|
|
||||||
|
|
||||||
TabCos
|
|
||||||
DCW 32767 ; 0 0x7fff 0.99997
|
|
||||||
DCW 32610 ; 1 0x7f62 0.99518
|
|
||||||
DCW 32138 ; 2 0x7d8a 0.98077
|
|
||||||
DCW 31357 ; 3 0x7a7d 0.95694
|
|
||||||
DCW 30274 ; 4 0x7642 0.92389
|
|
||||||
DCW 28899 ; 5 0x70e3 0.88193
|
|
||||||
DCW 27246 ; 6 0x6a6e 0.83148
|
|
||||||
DCW 25330 ; 7 0x62f2 0.77301
|
|
||||||
DCW 23170 ; 8 0x5a82 0.70709
|
|
||||||
DCW 20788 ; 9 0x5134 0.63440
|
|
||||||
DCW 18205 ; 10 0x471d 0.55557
|
|
||||||
DCW 15447 ; 11 0x3c57 0.47141
|
|
||||||
DCW 12540 ; 12 0x30fc 0.38269
|
|
||||||
DCW 9512 ; 13 0x2528 0.29028
|
|
||||||
DCW 6393 ; 14 0x18f9 0.19510
|
|
||||||
DCW 3212 ; 15 0x0c8c 0.09802
|
|
||||||
DCW 0 ; 16 0x0000 0.00000
|
|
||||||
DCW -3212 ; 17 0xf374 -0.09802
|
|
||||||
DCW -6393 ; 18 0xe707 -0.19510
|
|
||||||
DCW -9512 ; 19 0xdad8 -0.29028
|
|
||||||
DCW -12540 ; 20 0xcf04 -0.38269
|
|
||||||
DCW -15447 ; 21 0xc3a9 -0.47141
|
|
||||||
DCW -18205 ; 22 0xb8e3 -0.55557
|
|
||||||
DCW -20788 ; 23 0xaecc -0.63440
|
|
||||||
DCW -23170 ; 24 0xa57e -0.70709
|
|
||||||
DCW -25330 ; 25 0x9d0e -0.77301
|
|
||||||
DCW -27246 ; 26 0x9592 -0.83148
|
|
||||||
DCW -28899 ; 27 0x8f1d -0.88193
|
|
||||||
DCW -30274 ; 28 0x89be -0.92389
|
|
||||||
DCW -31357 ; 29 0x8583 -0.95694
|
|
||||||
DCW -32138 ; 30 0x8276 -0.98077
|
|
||||||
DCW -32610 ; 31 0x809e -0.99518
|
|
||||||
DCW -32768 ; 32 0x8000 -1.00000
|
|
||||||
DCW -32610 ; 33 0x809e -0.99518
|
|
||||||
DCW -32138 ; 34 0x8276 -0.98077
|
|
||||||
DCW -31357 ; 35 0x8583 -0.95694
|
|
||||||
DCW -30274 ; 36 0x89be -0.92389
|
|
||||||
DCW -28899 ; 37 0x8f1d -0.88193
|
|
||||||
DCW -27246 ; 38 0x9592 -0.83148
|
|
||||||
DCW -25330 ; 39 0x9d0e -0.77301
|
|
||||||
DCW -23170 ; 40 0xa57e -0.70709
|
|
||||||
DCW -20788 ; 41 0xaecc -0.63440
|
|
||||||
DCW -18205 ; 42 0xb8e3 -0.55557
|
|
||||||
DCW -15447 ; 43 0xc3a9 -0.47141
|
|
||||||
DCW -12540 ; 44 0xcf04 -0.38269
|
|
||||||
DCW -9512 ; 45 0xdad8 -0.29028
|
|
||||||
DCW -6393 ; 46 0xe707 -0.19510
|
|
||||||
DCW -3212 ; 47 0xf374 -0.09802
|
|
||||||
DCW 0 ; 48 0x0000 0.00000
|
|
||||||
DCW 3212 ; 49 0x0c8c 0.09802
|
|
||||||
DCW 6393 ; 50 0x18f9 0.19510
|
|
||||||
DCW 9512 ; 51 0x2528 0.29028
|
|
||||||
DCW 12540 ; 52 0x30fc 0.38269
|
|
||||||
DCW 15447 ; 53 0x3c57 0.47141
|
|
||||||
DCW 18205 ; 54 0x471d 0.55557
|
|
||||||
DCW 20788 ; 55 0x5134 0.63440
|
|
||||||
DCW 23170 ; 56 0x5a82 0.70709
|
|
||||||
DCW 25330 ; 57 0x62f2 0.77301
|
|
||||||
DCW 27246 ; 58 0x6a6e 0.83148
|
|
||||||
DCW 28899 ; 59 0x70e3 0.88193
|
|
||||||
DCW 30274 ; 60 0x7642 0.92389
|
|
||||||
DCW 31357 ; 61 0x7a7d 0.95694
|
|
||||||
DCW 32138 ; 62 0x7d8a 0.98077
|
|
||||||
DCW 32610 ; 63 0x7f62 0.99518
|
|
||||||
TabSin
|
|
||||||
DCW 0 ; 0 0x0000 0.00000
|
|
||||||
DCW 3212 ; 1 0x0c8c 0.09802
|
|
||||||
DCW 6393 ; 2 0x18f9 0.19510
|
|
||||||
DCW 9512 ; 3 0x2528 0.29028
|
|
||||||
DCW 12540 ; 4 0x30fc 0.38269
|
|
||||||
DCW 15447 ; 5 0x3c57 0.47141
|
|
||||||
DCW 18205 ; 6 0x471d 0.55557
|
|
||||||
DCW 20788 ; 7 0x5134 0.63440
|
|
||||||
DCW 23170 ; 8 0x5a82 0.70709
|
|
||||||
DCW 25330 ; 9 0x62f2 0.77301
|
|
||||||
DCW 27246 ; 10 0x6a6e 0.83148
|
|
||||||
DCW 28899 ; 11 0x70e3 0.88193
|
|
||||||
DCW 30274 ; 12 0x7642 0.92389
|
|
||||||
DCW 31357 ; 13 0x7a7d 0.95694
|
|
||||||
DCW 32138 ; 14 0x7d8a 0.98077
|
|
||||||
DCW 32610 ; 15 0x7f62 0.99518
|
|
||||||
DCW 32767 ; 16 0x7fff 0.99997
|
|
||||||
DCW 32610 ; 17 0x7f62 0.99518
|
|
||||||
DCW 32138 ; 18 0x7d8a 0.98077
|
|
||||||
DCW 31357 ; 19 0x7a7d 0.95694
|
|
||||||
DCW 30274 ; 20 0x7642 0.92389
|
|
||||||
DCW 28899 ; 21 0x70e3 0.88193
|
|
||||||
DCW 27246 ; 22 0x6a6e 0.83148
|
|
||||||
DCW 25330 ; 23 0x62f2 0.77301
|
|
||||||
DCW 23170 ; 24 0x5a82 0.70709
|
|
||||||
DCW 20788 ; 25 0x5134 0.63440
|
|
||||||
DCW 18205 ; 26 0x471d 0.55557
|
|
||||||
DCW 15447 ; 27 0x3c57 0.47141
|
|
||||||
DCW 12540 ; 28 0x30fc 0.38269
|
|
||||||
DCW 9512 ; 29 0x2528 0.29028
|
|
||||||
DCW 6393 ; 30 0x18f9 0.19510
|
|
||||||
DCW 3212 ; 31 0x0c8c 0.09802
|
|
||||||
DCW 0 ; 32 0x0000 0.00000
|
|
||||||
DCW -3212 ; 33 0xf374 -0.09802
|
|
||||||
DCW -6393 ; 34 0xe707 -0.19510
|
|
||||||
DCW -9512 ; 35 0xdad8 -0.29028
|
|
||||||
DCW -12540 ; 36 0xcf04 -0.38269
|
|
||||||
DCW -15447 ; 37 0xc3a9 -0.47141
|
|
||||||
DCW -18205 ; 38 0xb8e3 -0.55557
|
|
||||||
DCW -20788 ; 39 0xaecc -0.63440
|
|
||||||
DCW -23170 ; 40 0xa57e -0.70709
|
|
||||||
DCW -25330 ; 41 0x9d0e -0.77301
|
|
||||||
DCW -27246 ; 42 0x9592 -0.83148
|
|
||||||
DCW -28899 ; 43 0x8f1d -0.88193
|
|
||||||
DCW -30274 ; 44 0x89be -0.92389
|
|
||||||
DCW -31357 ; 45 0x8583 -0.95694
|
|
||||||
DCW -32138 ; 46 0x8276 -0.98077
|
|
||||||
DCW -32610 ; 47 0x809e -0.99518
|
|
||||||
DCW -32768 ; 48 0x8000 -1.00000
|
|
||||||
DCW -32610 ; 49 0x809e -0.99518
|
|
||||||
DCW -32138 ; 50 0x8276 -0.98077
|
|
||||||
DCW -31357 ; 51 0x8583 -0.95694
|
|
||||||
DCW -30274 ; 52 0x89be -0.92389
|
|
||||||
DCW -28899 ; 53 0x8f1d -0.88193
|
|
||||||
DCW -27246 ; 54 0x9592 -0.83148
|
|
||||||
DCW -25330 ; 55 0x9d0e -0.77301
|
|
||||||
DCW -23170 ; 56 0xa57e -0.70709
|
|
||||||
DCW -20788 ; 57 0xaecc -0.63440
|
|
||||||
DCW -18205 ; 58 0xb8e3 -0.55557
|
|
||||||
DCW -15447 ; 59 0xc3a9 -0.47141
|
|
||||||
DCW -12540 ; 60 0xcf04 -0.38269
|
|
||||||
DCW -9512 ; 61 0xdad8 -0.29028
|
|
||||||
DCW -6393 ; 62 0xe707 -0.19510
|
|
||||||
DCW -3212 ; 63 0xf374 -0.09802
|
|
||||||
|
|
||||||
END
|
|
173
Src/wav_head.c
Normal file
173
Src/wav_head.c
Normal file
|
@ -0,0 +1,173 @@
|
||||||
|
/* -------------------- WAV specific stuff --------------------------- */
|
||||||
|
|
||||||
|
/* wav est un cas de fichier RIFF.
|
||||||
|
* le fichier RIFF commence par "RIFF" (4 caracteres) suivi de la longueur
|
||||||
|
* du reste du fichier en long (4 bytes ordre Intel)
|
||||||
|
* puis on trouve "WAVE" suivi de chucks.
|
||||||
|
* chaque chuck commence par 4 caracteres (minuscules) suivis de la longueur
|
||||||
|
* du reste du chuck en long (4 bytes ordre Intel)
|
||||||
|
* le chuck "fmt " contient les parametres, sa longueur n'est pas tres fixe,
|
||||||
|
* il peut y avoir un chuck "fact" contenant le nombre de samples
|
||||||
|
* le chuck "data" contient les samples,
|
||||||
|
* tout autre doit etre ignore.
|
||||||
|
|
||||||
|
header mini :
|
||||||
|
RIFF 4 ]
|
||||||
|
filesize 4 ] == 12 bytes de pre-header
|
||||||
|
WAVE 4 ]
|
||||||
|
fmt 4 le chuck fmt coute au moins 24 bytes en tout
|
||||||
|
chucksize 4 == 16 bytes utile
|
||||||
|
type 2 ]
|
||||||
|
chan 2 ]
|
||||||
|
freq 4 ] == 16 bytes
|
||||||
|
bps 4 ]
|
||||||
|
block 2 ]
|
||||||
|
resol 2 ]
|
||||||
|
data 4
|
||||||
|
chucksize 4 == 8 bytes de post-header
|
||||||
|
--------------
|
||||||
|
44 au total
|
||||||
|
real filesize = chucksize + 44
|
||||||
|
RIFF filesize = chucksize + 36
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "wav_head.h"
|
||||||
|
|
||||||
|
|
||||||
|
unsigned long readlong( unsigned char *buf )
|
||||||
|
{
|
||||||
|
unsigned long l;
|
||||||
|
l = (unsigned long)buf[3] << 24 ;
|
||||||
|
l += (unsigned long)buf[2] << 16 ;
|
||||||
|
l += (unsigned long)buf[1] << 8 ;
|
||||||
|
l += buf[0];
|
||||||
|
return(l);
|
||||||
|
}
|
||||||
|
unsigned int readshort( unsigned char *buf )
|
||||||
|
{
|
||||||
|
unsigned int s;
|
||||||
|
s = buf[0] + ( buf[1] << 8 );
|
||||||
|
return(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
void WAVreadHeader( wavpars *s, int hand )
|
||||||
|
{
|
||||||
|
unsigned char buf[256]; unsigned long filesize, chucksize, factsize;
|
||||||
|
read( hand, buf, 4 );
|
||||||
|
if ( strncmp( (char *)buf, "RIFF", 4 ) != 0 ) gasp("manque en-tete RIFF");
|
||||||
|
read( hand, buf, 4 ); filesize = readlong( buf );
|
||||||
|
read( hand, buf, 4 );
|
||||||
|
if ( strncmp( (char *)buf, "WAVE", 4 ) != 0 ) gasp("manque en-tete WAVE");
|
||||||
|
|
||||||
|
read( hand, buf, 4 );
|
||||||
|
if ( strncmp( (char *)buf, "fmt ", 4 ) != 0 ) gasp("manque chuck fmt");
|
||||||
|
read( hand, buf, 4 ); chucksize = readlong( buf );
|
||||||
|
if ( chucksize > (long)256 ) gasp("chuck fmt trop gros");
|
||||||
|
read( hand, buf, (int)chucksize );
|
||||||
|
if ( readshort(buf) != 1 ) gasp("fichier wave non PCM");
|
||||||
|
s->chan = readshort( buf + 2 );
|
||||||
|
s->freq = readlong( buf + 4 );
|
||||||
|
s->bpsec = readlong( buf + 8 );
|
||||||
|
s->block = readshort( buf + 12 );
|
||||||
|
s->resol = readshort( buf + 14 );
|
||||||
|
s->wavsize = 0L;
|
||||||
|
factsize = 0L;
|
||||||
|
|
||||||
|
read( hand, buf, 4 );
|
||||||
|
if ( strncmp( (char *)buf, "fact", 4 ) == 0 )
|
||||||
|
{
|
||||||
|
read( hand, buf, 4 ); chucksize = readlong( buf );
|
||||||
|
if ( chucksize > (long)256 ) gasp("chuck fmt trop gros");
|
||||||
|
read( hand, buf, (int)chucksize );
|
||||||
|
factsize = readlong( buf );
|
||||||
|
read( hand, buf, 4 );
|
||||||
|
}
|
||||||
|
if ( strncmp( (char *)buf, "data", 4 ) != 0 ) gasp("pas de chuck data");
|
||||||
|
read( hand, buf, 4 ); chucksize = readlong( buf );
|
||||||
|
|
||||||
|
s->wavsize = chucksize / ( s->chan * ((s->resol)>>3) );
|
||||||
|
|
||||||
|
printf("%d canaux, %lu Hz, %lu bytes/s, %d bits\n",
|
||||||
|
s->chan, s->freq, s->bpsec, s->resol );
|
||||||
|
printf("%lu echantillons selon data chuck\n", s->wavsize );
|
||||||
|
if ( factsize != 0L )
|
||||||
|
{
|
||||||
|
printf("%lu echantillons selon fact chuck\n", factsize );
|
||||||
|
if ( s->wavsize != factsize )
|
||||||
|
gasp("longueurs incoherentes");
|
||||||
|
}
|
||||||
|
printf("fichier %lu bytes, chuck data %lu bytes\n",
|
||||||
|
filesize, chucksize );
|
||||||
|
{
|
||||||
|
double durs, dmn, ds; int mn;
|
||||||
|
durs = s->wavsize; durs /= s->freq;
|
||||||
|
dmn = durs / 60.0; mn = (int)dmn; ds = durs - 60.0 * mn;
|
||||||
|
printf("duree %.3f s soit %d mn %.3f s\n", durs, mn, ds );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void writelong( unsigned char *buf, unsigned long l )
|
||||||
|
{
|
||||||
|
buf[0] = (unsigned char)l; l >>= 8;
|
||||||
|
buf[1] = (unsigned char)l; l >>= 8;
|
||||||
|
buf[2] = (unsigned char)l; l >>= 8;
|
||||||
|
buf[3] = (unsigned char)l;
|
||||||
|
}
|
||||||
|
void writeshort( unsigned char *buf, unsigned int s )
|
||||||
|
{
|
||||||
|
buf[0] = (unsigned char)s; s >>= 8;
|
||||||
|
buf[1] = (unsigned char)s;
|
||||||
|
}
|
||||||
|
void gulp()
|
||||||
|
{ gasp("erreur ecriture fichier");
|
||||||
|
}
|
||||||
|
|
||||||
|
void WAVwriteHeader( wavpars *d, int hand )
|
||||||
|
{
|
||||||
|
unsigned char buf[16]; long filesize, chucksize;
|
||||||
|
|
||||||
|
d->bpsec = d->freq * d->chan * ((d->resol)>>3);
|
||||||
|
d->block = d->chan * ((d->resol)>>3);
|
||||||
|
chucksize = d->wavsize * d->chan * ((d->resol)>>3);
|
||||||
|
filesize = chucksize + 36;
|
||||||
|
|
||||||
|
if ( write( hand, "RIFF", 4 ) != 4 ) gulp();
|
||||||
|
writelong( buf, filesize );
|
||||||
|
if ( write( hand, buf, 4 ) != 4 ) gulp();
|
||||||
|
|
||||||
|
if ( write( hand, "WAVE", 4 ) != 4 ) gulp();
|
||||||
|
if ( write( hand, "fmt ", 4 ) != 4 ) gulp();
|
||||||
|
writelong( buf, 16L );
|
||||||
|
if ( write( hand, buf, 4 ) != 4 ) gulp();
|
||||||
|
|
||||||
|
writeshort( buf, 1 ); /* PCM type id */
|
||||||
|
writeshort( buf + 2, d->chan );
|
||||||
|
writelong( buf + 4, d->freq );
|
||||||
|
writelong( buf + 8, d->bpsec );
|
||||||
|
writeshort( buf + 12, d->block );
|
||||||
|
writeshort( buf + 14, d->resol );
|
||||||
|
if ( write( hand, buf, 16 ) != 16 ) gulp();
|
||||||
|
|
||||||
|
if ( write( hand, "data", 4 ) != 4 ) gulp();
|
||||||
|
writelong( buf, chucksize );
|
||||||
|
if ( write( hand, buf, 4 ) != 4 ) gulp();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* --------------------------------------- traitement erreur fatale */
|
||||||
|
|
||||||
|
void gasp( char *fmt, ... )
|
||||||
|
{
|
||||||
|
char lbuf[2048];
|
||||||
|
va_list argptr;
|
||||||
|
va_start( argptr, fmt );
|
||||||
|
vsprintf( lbuf, fmt, argptr );
|
||||||
|
va_end( argptr );
|
||||||
|
printf("STOP : %s\n", lbuf ); exit(1);
|
||||||
|
}
|
18
Src/wav_head.h
Normal file
18
Src/wav_head.h
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
typedef struct {
|
||||||
|
int chan;
|
||||||
|
unsigned long freq; /* frequence d'echantillonnage */
|
||||||
|
unsigned long bpsec; /* bytes par seconde */
|
||||||
|
int block;
|
||||||
|
int resol; /* en bits */
|
||||||
|
unsigned long wavsize; /* longueur en echantillons (par canal) */
|
||||||
|
} wavpars;
|
||||||
|
|
||||||
|
#ifndef O_BINARY
|
||||||
|
#define O_BINARY 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void WAVreadHeader( wavpars *s, int hand );
|
||||||
|
|
||||||
|
void WAVwriteHeader( wavpars *d, int hand );
|
||||||
|
|
||||||
|
void gasp( char *fmt, ... ); /* traitement erreur fatale */
|
Loading…
Reference in a new issue