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
|
||||
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
|
||||
|
|
|
@ -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;
|
||||
|
|
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
|
||||
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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue