réarrangement des sources

This commit is contained in:
flo 2017-02-25 11:29:24 +01:00
parent 40d0217883
commit c47158af0c
6 changed files with 108 additions and 89 deletions

View File

@ -48,7 +48,7 @@ fclean: clean
dump:
$(OBJDUMP) -d $(NAME).elf > $(NAME).txt
@stat -c "Dump file -- dump file in %n ." $(NAME).txt
@stat -c "Dump file -- dump file put in %n ." $(NAME).txt
## Remake
re: fclean all

View File

@ -1,12 +0,0 @@
#ifndef _SOUND4CALC
#define _SOUND4CALC
// SH4 addresses
void setup(void); // configure ports to output
void SetPin(void);
void ResetPin(void);
#endif

6
include/main.h Normal file
View File

@ -0,0 +1,6 @@
#ifndef _MAIN
#define _MAIN
void lect();
#endif

24
include/sound4calc.h Normal file
View File

@ -0,0 +1,24 @@
#ifndef _SOUND4CALC
#define _SOUND4CALC
//SH4 addresses
#define SH7305_PJCR 0xA4050110
#define SH7305_PUCR 0xA4050142
#define SH7305_PJDR 0xA4050130
#define SH7305_PUDR 0xA4050162
#define SH7305_MSTPCR0 0xA4150030
#define SH7305_SCSCR 0xA4410008
//SH3 addresses
#define SH7337_STBCR3 0xA40A0000
#define SH7337_SCSCR2 0xA4410008
#define SH7337_PGCR 0xA400010C
#define SH7337_PLCR 0xA4000114
#define SH7337_SCPCR 0xA4000116
#define SH7337_PGDR 0xA400012C
#define SH7337_SCPDR 0xA4000136
void SwitchPinState();
void InitPorts();
#endif

67
src/main.c Normal file
View File

@ -0,0 +1,67 @@
#include "main.h"
#include "sound4calc.h"
#include <timer.h> // add timer's fonction
#include <display.h> // add display's fonction
#include <keyboard.h>
//#define PI 3.141592653584
unsigned char bincod[25] = {0};
unsigned char place = 0;
void lect()
{
static unsigned char range = 0;
if(bincod[range%place] != bincod[(range+1)%place])
{
SwitchPinState();
}
range++;
}
int main(void)
{
static int freq = 440;
unsigned int key = 0;
//unsigned int i=0;
InitPorts();
while(1)
{
dclear();
dprint(1, 1, "%d", freq);
dprint(1, 10, "%s", bincod);
dprint(1, 20, "%d", place);
dtext(1, 50, "F1 _ F2 -");
dupdate();
key = getkey();
switch(key)
{
case KEY_RIGHT : freq+=1; break;
case KEY_LEFT : freq-=1; break;
case KEY_UP : freq+=10; break;
case KEY_DOWN : freq-=10; break;
case KEY_F1 : *(bincod+place++) = '_'; break;
case KEY_F2 : *(bincod+place++) = '-'; break;
case KEY_DEL : place=(place>0 ? place - 1 : 0); *(bincod+place) = 0; break;
case KEY_EXE :
timer_start(TIMER_USER, freq*place, Clock_Hz, lect, 2*freq*place);
break;
case KEY_EXIT :
timer_stop(TIMER_USER);
return 1;
}
}
return 1; // this point is never reached
}

86
src/Sound4Calc.c → src/sound4calc.c Executable file → Normal file
View File

@ -1,86 +1,20 @@
#include "sound4calc.h"
#include <mpu.h> // from Gint
#include "addresses.h"
#include "Sound4Calc.h"
#include <timer.h> // add timer's fonction
#include <display.h> // add display's fonction
#include <keyboard.h>
#include <mpu.h>
//#define PI 3.141592653584
unsigned char bincod[25] = {0};
unsigned char place = 0;
void lect()
void SwitchPinState()
{
static unsigned char range = 0;
if(bincod[range%place] != bincod[(range+1)%place])
{
if(isSH3())
{
*(volatile unsigned char*)SH7337_SCPDR ^= 0x01;
}
else
{
*(volatile unsigned char*)SH7305_PJDR ^= 0x04;
}
}
range++;
}
int main(void)
{
unsigned int key = 0;
static int freq = 440;
//unsigned int i=0;
setup();
while(1)
if(isSH3())
{
dclear();
dprint(1, 1, "%d", freq);
dprint(1, 10, "%s", bincod);
dprint(1, 20, "%d", place);
dtext(1, 50, "F1 _ F2 -");
dupdate();
key = getkey();
switch(key)
{
case KEY_RIGHT : freq+=1; break;
case KEY_LEFT : freq-=1; break;
case KEY_UP : freq+=10; break;
case KEY_DOWN : freq-=10; break;
case KEY_F1 : *(bincod+place++) = '_'; break;
case KEY_F2 : *(bincod+place++) = '-'; break;
case KEY_DEL : place=(place>0 ? place - 1 : 0); *(bincod+place) = 0; break;
case KEY_EXE :
timer_start(TIMER_USER, freq*place, Clock_Hz, lect, 2*freq*place);
break;
case KEY_EXIT :
timer_stop(TIMER_USER);
return 1;
}
*(volatile unsigned char*)SH7337_SCPDR ^= 0x01;
}
else
{
*(volatile unsigned char*)SH7305_PJDR ^= 0x04;
}
return 1; // this point is never reached
}
void setup()
void InitPorts()
{
if(isSH3())
{
// initialisation of pin