not working :-(

This commit is contained in:
Wolfgang Hottgenroth 2024-04-24 14:22:59 +02:00
parent 1d915baf77
commit 68816a06fa
10 changed files with 45 additions and 33 deletions

View File

@ -4,21 +4,22 @@ OBJDUMP=$(TOOLCHAIN_PREFIX)/bin/msp430-elf-objdump
ARTIFACT=firmware
MCU=msp430g2553
COMMONFLAGS=-Wall -mmcu=$(MCU) -I $(TOOLCHAIN_PREFIX)/include -O0 -g0
CFLAGS=$(COMMONFLAGS) -std=gnu99
ASFLAGS=$(COMMONFLAGS) -D__ASSEMBLER__
COMMONFLAGS=-Wall -mmcu=$(MCU) -I $(TOOLCHAIN_PREFIX)/include -g0 -fdata-sections -ffunction-sections
# for debugging
CFLAGS+= -g3 -ggdb -gdwarf-2
DEBUGFLAGS=
# DEBUGFLAGS+= -g3 -ggdb -gdwarf-2
LDFLAGS=-mmcu=$(MCU) -L $(TOOLCHAIN_PREFIX)/include
CFLAGS=$(COMMONFLAGS) -std=gnu99 -O0 $(DEBUGFLAGS)
ASFLAGS=$(COMMONFLAGS) -D__ASSEMBLER__ -Os $(DEBUGFLAGS)
LDFLAGS=-mmcu=$(MCU) -L $(TOOLCHAIN_PREFIX)/include -Wl,-Map,firmware.map
$(ARTIFACT).elf: main.o scheduler.o spi.o spi_init.o sequencer.o melody_tetris.o melody_tusch1.o psg.o mute.o melody_pling.o
$(CC) -o $@ $(LDFLAGS) $^
$(OBJDUMP) -D $(ARTIFACT).elf > $(ARTIFACT).txt
.c.o:
$(CC) $(CFLAGS) -c $<
$(CC) $(CFLAGS) -c $<
.S.o:
$(CC) $(ASFLAGS) -c $<

View File

@ -6,8 +6,6 @@
#include "psg.h"
#include "scheduler.h"
#include "sequencer.h"
#include "melody_tetris.h"
#include "melody_tusch1.h"
#include "mute.h"
int main() {
@ -31,8 +29,6 @@ int main() {
__enable_interrupt();
// playMelodyTetris();
while (1) {
schExec();
}

View File

@ -15,7 +15,8 @@ const t_tone plingVoice1[] = {
};
t_melodies pling = {
.melodies = { { .chip = 1, .amplitude = 12, .tones = plingVoice1 } },
.melodies = { { .amplitude = 12, .tones = plingVoice1 } },
.chip = 1,
.numOfMelodies = 1,
.pace = 200,
.slotMask = 0x02

View File

@ -923,7 +923,8 @@ const t_tone voice3[] = {
};
t_melodies tetrisTheme = {
.melodies = { { .chip = 0, .amplitude = 8, .tones = voice1 }, { .chip = 0, .amplitude = 8, .tones = voice2 }, { .chip = 0, .amplitude = 8, .tones = voice3 } },
.melodies = { { .amplitude = 8, .tones = voice1 }, { .amplitude = 8, .tones = voice2 }, { .amplitude = 8, .tones = voice3 } },
.chip = 0,
.numOfMelodies = 3,
.pace = 160,
.slotMask = 0x01

View File

@ -72,7 +72,8 @@ const t_tone tusch1voice3[] = {
};
t_melodies tusch1 = {
.melodies = { { .chip = 1, .amplitude = 12, .tones = tusch1voice1 }, { .chip = 1, .amplitude = 12, .tones = tusch1voice2 }, { .chip = 1, .amplitude = 12, .tones = tusch1voice3 } },
.melodies = { { .amplitude = 12, .tones = tusch1voice1 }, { .amplitude = 12, .tones = tusch1voice2 }, { .amplitude = 12, .tones = tusch1voice3 } },
.chip = 1,
.numOfMelodies = 3,
.pace = 200,
.slotMask = 0x02
@ -80,7 +81,6 @@ t_melodies tusch1 = {
void playTusch1() {
sequencerPlayMelodies(&tusch1);
playMelodyTetrisFaster();
}

View File

@ -175,5 +175,21 @@ void psgInit() {
// disable everything
psgWrite(0, _ENABLE_REG, 0xff);
psgWrite(1, _ENABLE_REG, 0xff);
// volume to 0 on all channels
psgWrite(0, CHANNEL_A_AMPLITUDE_REG, 0);
psgWrite(0, CHANNEL_B_AMPLITUDE_REG, 0);
psgWrite(0, CHANNEL_C_AMPLITUDE_REG, 0);
psgWrite(1, CHANNEL_A_AMPLITUDE_REG, 0);
psgWrite(1, CHANNEL_B_AMPLITUDE_REG, 0);
psgWrite(1, CHANNEL_C_AMPLITUDE_REG, 0);
// frequency preset
psgWriteFrequency(0, 0, 0);
psgWriteFrequency(0, 1, 0);
psgWriteFrequency(0, 2, 0);
psgWriteFrequency(1, 0, 0);
psgWriteFrequency(1, 1, 0);
psgWriteFrequency(1, 2, 0);
}

View File

@ -59,7 +59,7 @@ void sequencerExec(void *handle) {
if (melody->tones[melody->idx].length == e_L_EndMark) {
melody->idx = 0;
}
psgPlayTone(melody->chip, channel, melody->amplitude, melody->tones[melody->idx].octave, melody->tones[melody->idx].note);
psgPlayTone(melodies->chip, channel, melody->amplitude, melody->tones[melody->idx].octave, melody->tones[melody->idx].note);
melody->lengthCnt = (melody->tones[melody->idx].staccato) ?
(calcLength(melodies, melody->tones[melody->idx].length) / 2) :
calcLength(melodies, melody->tones[melody->idx].length);
@ -78,7 +78,7 @@ void sequencerExec(void *handle) {
}
break;
case e_StaccatoBreak:
psgPlayTone(melody->chip, channel, 0, e_O_Null, e_Pause);
psgPlayTone(melodies->chip, channel, 0, e_O_Null, e_Pause);
melody->lengthCnt = calcLength(melodies, melody->tones[melody->idx].length) / 2;
melody->state = e_HoldStaccatoBreak;
break;
@ -90,7 +90,7 @@ void sequencerExec(void *handle) {
break;
case e_SeparateTone:
if (! (melody->tones[melody->idx].legato)) {
psgPlayTone(melody->chip, channel, 0, e_O_Null, e_Pause);
psgPlayTone(melodies->chip, channel, 0, e_O_Null, e_Pause);
}
melody->idx += 1;
melody->state = e_PlayTone;

View File

@ -42,7 +42,6 @@ typedef enum {
typedef struct {
uint16_t idx;
uint8_t chip;
uint16_t lengthCnt;
t_sequencerState state;
uint8_t amplitude;
@ -52,11 +51,12 @@ typedef struct {
#define SEQUENCER_PERIOD 4 // ms
#define NUM_OF_CHANNELS 3
typedef struct {
uint8_t chip;
uint8_t slotMask;
uint8_t taskId;
uint16_t quarterLength;
uint8_t numOfMelodies;
uint8_t pace; // quarter notes per minute
uint16_t pace; // quarter notes per minute
uint8_t sync;
t_melody melodies[NUM_OF_CHANNELS];
} t_melodies;

View File

@ -1,10 +1,10 @@
#include <msp430g2553.h>
#include "soundCodes.h"
.section ".data"
.global cmd
cmd:
.byte
;; .global cmd
;; .section .data.spi,"aw"
;;cmd:
;; .byte
.section ".text","ax",@progbits
receive_isr:
@ -29,17 +29,19 @@ spiCmdHandler_2:
spiCmdHandler_3:
bit #SOUND_START, &cmd
jz spiCmdHandler_4
call #playMelodyTetris
;;call #playMelodyTetris
bic #SOUND_START, &cmd
spiCmdHandler_4:
bit #SOUND_GAMEOVER, &cmd
jz spiCmdHandler_5
;;call #stopMelodyTetris
;; insert a call here
bic #SOUND_GAMEOVER, &cmd
spiCmdHandler_5:
bit #SOUND_FANFARE, &cmd
jz spiCmdHandler_6
call #playTusch1
;;call #playMelodyTetrisFaster
;;call #playTusch1
bic #SOUND_FANFARE, &cmd
spiCmdHandler_6:
bit #SOUND_LOCK, &cmd
@ -54,17 +56,12 @@ spiCmdHandler_7:
spiCmdHandler_8:
bit #SOUND_PLING, &cmd
jz spiCmdHandler_end
call #playPling
;;call #playPling
bic #SOUND_PLING, &cmd
spiCmdHandler_end:
ret
.section "__interrupt_vector_8","ax",@progbits
.word receive_isr
.end

View File

@ -6,7 +6,7 @@
#include "soundCodes.h"
extern uint8_t cmd;
uint8_t cmd;
void spiInit() {
// SPI slave