diff --git a/ch32v003/gcc.mk b/ch32v003/gcc.mk index 713da29..a13e1d2 100644 --- a/ch32v003/gcc.mk +++ b/ch32v003/gcc.mk @@ -7,11 +7,11 @@ SIZE = $(PREFIX)size DUMP = $(PREFIX)objdump COPY = $(PREFIX)objcopy OBJS += startup.o system.o -CFLAGS+= -Os -flto +CFLAGS+= -Os CCPU = -march=rv32ec -mabi=ilp32e MCPU = $(CCPU) CFLAGS+= $(MCPU) LFLAGS+= -Wl,--Map=$(@:%.elf=%.map),--gc-sections #LFLAGS+= -Wl,--print-sysroot -- chyba ld ? -LFLAGS+= -flto -O3 $(MCPU) -nostartfiles -nostdlib +LFLAGS+= -O3 $(MCPU) -nostartfiles -nostdlib LDLIBS+= -lgcc -L./$(TARGET) -T generated_ch32v003.ld diff --git a/midi/main.cpp b/midi/main.cpp index 0f68daf..062738d 100644 --- a/midi/main.cpp +++ b/midi/main.cpp @@ -7,10 +7,15 @@ static PcmDma pcm; int main (void) { pcm.attach (player); for (;;) { + player.pass(); /* BUG: * Do smyčky nejde přidat jakýkoli další kód. * Proč, neumím vysvětlit, ale lze to izolovat. * Je zajímavé, že ADC postavené podobně to nedělá. + * + * FIX: 1. Vynechat LTO optimalizaci. Optimalizuje asi moc, ale zase tak moc neušetří. + * 2. Činnost nechat v metodě pass() hlavní třídy. + * Zřejmě je tam nějaký problém s voláním konstruktorů. * */ } return 0; diff --git a/midi/mid/demo10.mid b/midi/mid/demo10.mid new file mode 100644 index 0000000..d7cb2e2 Binary files /dev/null and b/midi/mid/demo10.mid differ diff --git a/midi/mid/joy.mid b/midi/mid/joy.mid deleted file mode 100644 index 10d72aa..0000000 Binary files a/midi/mid/joy.mid and /dev/null differ diff --git a/midi/midiplayer.cpp b/midi/midiplayer.cpp index 497cfa6..6773fcc 100644 --- a/midi/midiplayer.cpp +++ b/midi/midiplayer.cpp @@ -48,12 +48,18 @@ static unsigned pwm_sd (const int input) { /******************************************************************/ /// Konstruktor -MidiPlayer::MidiPlayer() noexcept : OneWay() { +MidiPlayer::MidiPlayer() noexcept : OneWay(), led (LED_CFG), passcnt (0u) { index = 0; pause = 0; melody = scores[index++]; running = true; } +void MidiPlayer::pass() { + const bool b = passcnt & 0x10000; + led << b; + passcnt += 1u; +} + unsigned MidiPlayer::Send (uint16_t * const ptr, const unsigned len) { //if (!but.get()) running = true; // případně spouštět tlačítkem, není implementováno @@ -69,11 +75,12 @@ unsigned MidiPlayer::Send (uint16_t * const ptr, const unsigned len) { return len; } void MidiPlayer::stop (void) { -//running = false; // cyklicky, furt +//running = false; // na konci každé melodie stop melody = scores[index++]; if (!melody) { - index = 0; - melody = scores[index++]; + index = 0; + melody = scores[index++]; + running = false; // test bez tlačítka } } void MidiPlayer::ToneChange (void) { diff --git a/midi/midiplayer.h b/midi/midiplayer.h index 60a1efc..7774756 100644 --- a/midi/midiplayer.h +++ b/midi/midiplayer.h @@ -10,8 +10,8 @@ class MidiPlayer : public OneWay { /// Konstruktor explicit MidiPlayer () noexcept; unsigned Send (uint16_t * const ptr, const unsigned len) override; - //bool send (uint16_t * ptr, const int len) override; - void stop (); + void stop (); + void pass (); protected: // Chráněné metody /// Obsluha tónu @@ -19,7 +19,8 @@ class MidiPlayer : public OneWay { /// Obsluha vzorku short nextSample (void); private: - //GpioClass but; + GpioClass led; + unsigned passcnt; volatile bool running; unsigned char const * melody; unsigned index; diff --git a/midi/pwmconfig.h b/midi/pwmconfig.h index 2ef2bb7..0fac579 100644 --- a/midi/pwmconfig.h +++ b/midi/pwmconfig.h @@ -4,4 +4,12 @@ static constexpr unsigned HALF_LEN = 0x80u; static constexpr unsigned MAXPWM = 2000u; +#ifdef __riscv +#define LED_CFG GPIOD,4 +#elif __arm__ +#define LED_CFG GpioPortA,0 +#else +#error "bad target" +#endif + #endif // CONFIG_H