From c47158af0ca6181ffb32c4ae212e65b0234e22d0 Mon Sep 17 00:00:00 2001 From: flo Date: Sat, 25 Feb 2017 11:29:24 +0100 Subject: [PATCH] =?UTF-8?q?r=C3=A9arrangement=20des=20sources?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- include/Sound4Calc.h | 12 ----- include/main.h | 6 +++ include/sound4calc.h | 24 +++++++++ src/main.c | 67 +++++++++++++++++++++++ src/{Sound4Calc.c => sound4calc.c} | 86 ++++-------------------------- 6 files changed, 108 insertions(+), 89 deletions(-) delete mode 100755 include/Sound4Calc.h create mode 100644 include/main.h create mode 100644 include/sound4calc.h create mode 100644 src/main.c rename src/{Sound4Calc.c => sound4calc.c} (56%) mode change 100755 => 100644 diff --git a/Makefile b/Makefile index fb8429c..51ff16b 100755 --- a/Makefile +++ b/Makefile @@ -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 diff --git a/include/Sound4Calc.h b/include/Sound4Calc.h deleted file mode 100755 index 771decf..0000000 --- a/include/Sound4Calc.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef _SOUND4CALC -#define _SOUND4CALC - -// SH4 addresses - - -void setup(void); // configure ports to output -void SetPin(void); -void ResetPin(void); - - -#endif \ No newline at end of file diff --git a/include/main.h b/include/main.h new file mode 100644 index 0000000..5c3fddd --- /dev/null +++ b/include/main.h @@ -0,0 +1,6 @@ +#ifndef _MAIN +#define _MAIN + +void lect(); + +#endif diff --git a/include/sound4calc.h b/include/sound4calc.h new file mode 100644 index 0000000..adbe13a --- /dev/null +++ b/include/sound4calc.h @@ -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 diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..21cbd28 --- /dev/null +++ b/src/main.c @@ -0,0 +1,67 @@ +#include "main.h" +#include "sound4calc.h" + +#include // add timer's fonction +#include // add display's fonction +#include + +//#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 +} diff --git a/src/Sound4Calc.c b/src/sound4calc.c old mode 100755 new mode 100644 similarity index 56% rename from src/Sound4Calc.c rename to src/sound4calc.c index fb3a267..651ea22 --- a/src/Sound4Calc.c +++ b/src/sound4calc.c @@ -1,86 +1,20 @@ +#include "sound4calc.h" +#include // from Gint -#include "addresses.h" -#include "Sound4Calc.h" - -#include // add timer's fonction -#include // add display's fonction -#include -#include - -//#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