fix BUG (constructors ?)
This commit is contained in:
parent
edf51f4704
commit
d2c3f3770c
7 changed files with 30 additions and 9 deletions
|
@ -7,11 +7,11 @@ SIZE = $(PREFIX)size
|
||||||
DUMP = $(PREFIX)objdump
|
DUMP = $(PREFIX)objdump
|
||||||
COPY = $(PREFIX)objcopy
|
COPY = $(PREFIX)objcopy
|
||||||
OBJS += startup.o system.o
|
OBJS += startup.o system.o
|
||||||
CFLAGS+= -Os -flto
|
CFLAGS+= -Os
|
||||||
CCPU = -march=rv32ec -mabi=ilp32e
|
CCPU = -march=rv32ec -mabi=ilp32e
|
||||||
MCPU = $(CCPU)
|
MCPU = $(CCPU)
|
||||||
CFLAGS+= $(MCPU)
|
CFLAGS+= $(MCPU)
|
||||||
LFLAGS+= -Wl,--Map=$(@:%.elf=%.map),--gc-sections
|
LFLAGS+= -Wl,--Map=$(@:%.elf=%.map),--gc-sections
|
||||||
#LFLAGS+= -Wl,--print-sysroot -- chyba ld ?
|
#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
|
LDLIBS+= -lgcc -L./$(TARGET) -T generated_ch32v003.ld
|
||||||
|
|
|
@ -7,10 +7,15 @@ static PcmDma pcm;
|
||||||
int main (void) {
|
int main (void) {
|
||||||
pcm.attach (player);
|
pcm.attach (player);
|
||||||
for (;;) {
|
for (;;) {
|
||||||
|
player.pass();
|
||||||
/* BUG:
|
/* BUG:
|
||||||
* Do smyčky nejde přidat jakýkoli další kód.
|
* Do smyčky nejde přidat jakýkoli další kód.
|
||||||
* Proč, neumím vysvětlit, ale lze to izolovat.
|
* Proč, neumím vysvětlit, ale lze to izolovat.
|
||||||
* Je zajímavé, že ADC postavené podobně to nedělá.
|
* 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;
|
return 0;
|
||||||
|
|
BIN
midi/mid/demo10.mid
Normal file
BIN
midi/mid/demo10.mid
Normal file
Binary file not shown.
BIN
midi/mid/joy.mid
BIN
midi/mid/joy.mid
Binary file not shown.
|
@ -48,12 +48,18 @@ static unsigned pwm_sd (const int input) {
|
||||||
|
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
/// Konstruktor
|
/// Konstruktor
|
||||||
MidiPlayer::MidiPlayer() noexcept : OneWay() {
|
MidiPlayer::MidiPlayer() noexcept : OneWay(), led (LED_CFG), passcnt (0u) {
|
||||||
index = 0;
|
index = 0;
|
||||||
pause = 0;
|
pause = 0;
|
||||||
melody = scores[index++];
|
melody = scores[index++];
|
||||||
running = true;
|
running = true;
|
||||||
}
|
}
|
||||||
|
void MidiPlayer::pass() {
|
||||||
|
const bool b = passcnt & 0x10000;
|
||||||
|
led << b;
|
||||||
|
passcnt += 1u;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned MidiPlayer::Send (uint16_t * const ptr, const unsigned len) {
|
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
|
//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;
|
return len;
|
||||||
}
|
}
|
||||||
void MidiPlayer::stop (void) {
|
void MidiPlayer::stop (void) {
|
||||||
//running = false; // cyklicky, furt
|
//running = false; // na konci každé melodie stop
|
||||||
melody = scores[index++];
|
melody = scores[index++];
|
||||||
if (!melody) {
|
if (!melody) {
|
||||||
index = 0;
|
index = 0;
|
||||||
melody = scores[index++];
|
melody = scores[index++];
|
||||||
|
running = false; // test bez tlačítka
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void MidiPlayer::ToneChange (void) {
|
void MidiPlayer::ToneChange (void) {
|
||||||
|
|
|
@ -10,8 +10,8 @@ class MidiPlayer : public OneWay {
|
||||||
/// Konstruktor
|
/// Konstruktor
|
||||||
explicit MidiPlayer () noexcept;
|
explicit MidiPlayer () noexcept;
|
||||||
unsigned Send (uint16_t * const ptr, const unsigned len) override;
|
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:
|
protected:
|
||||||
// Chráněné metody
|
// Chráněné metody
|
||||||
/// Obsluha tónu
|
/// Obsluha tónu
|
||||||
|
@ -19,7 +19,8 @@ class MidiPlayer : public OneWay {
|
||||||
/// Obsluha vzorku
|
/// Obsluha vzorku
|
||||||
short nextSample (void);
|
short nextSample (void);
|
||||||
private:
|
private:
|
||||||
//GpioClass but;
|
GpioClass led;
|
||||||
|
unsigned passcnt;
|
||||||
volatile bool running;
|
volatile bool running;
|
||||||
unsigned char const * melody;
|
unsigned char const * melody;
|
||||||
unsigned index;
|
unsigned index;
|
||||||
|
|
|
@ -4,4 +4,12 @@
|
||||||
static constexpr unsigned HALF_LEN = 0x80u;
|
static constexpr unsigned HALF_LEN = 0x80u;
|
||||||
static constexpr unsigned MAXPWM = 2000u;
|
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
|
#endif // CONFIG_H
|
||||||
|
|
Loading…
Reference in a new issue