Init MPU asynchronously to avoid holding IOCHRDY

This commit is contained in:
Ian Scott committed 2024-03-24 14:30:43 -06:00
1 parent 84839f58d1
commit 0c38c2fcd5
4 files changed
+15 -10

No files matched your search

+13 -7
View File
@@ -69,6 +69,7 @@ bool MIDI_Available(void);
static uint32_t MPU401_Event(Bitu val);
static uint32_t MPU401_ResetDone(Bitu val);
static uint32_t MPU401_InitHandler(Bitu val);
static uint32_t MPU401_EOIHandler(Bitu val);
static void MPU401_Reset(void);
static void MPU401_EOIHandlerDispatch(void);
@@ -97,6 +98,8 @@ typedef enum MpuDataType MpuDataType; /* SOFTMPU */
#define MSG_MPU_ACK 0xfe
static bool config_versionfix = false;
static bool config_delaysysex = false;
static bool config_fakeallnotesoff = false;
static struct {
bool intelligent;
@@ -745,27 +748,30 @@ __force_inline static void MPU401_Reset(void) {
/* HardMPU: Initialisation */
void MPU401_Init(bool delaysysex, bool fakeallnotesoff)
{
/* Initalise PIC code */
/* PIC_Init(); */
config_delaysysex = delaysysex;
config_fakeallnotesoff = fakeallnotesoff;
config_versionfix = false;
if (!critical_section_is_initialized(&mpu_crit)) {
critical_section_init(&mpu_crit);
}
PIC_AddEvent(MPU401_InitHandler, 1000, 3);
}
uint32_t MPU401_InitHandler(Bitu val)
{
/* Initialise MIDI handler */
MIDI_Init(delaysysex, fakeallnotesoff);
if (!MIDI_Available()) return;
config_versionfix = false;
MIDI_Init(config_delaysysex, config_fakeallnotesoff);
if (!MIDI_Available()) return 0;
mpu.queue_used=0;
mpu.queue_pos=0;
mpu.mode=M_UART;
mpu.intelligent=true; /* Default is on */
if (!mpu.intelligent) return;
/* SOFTMPU: Moved IRQ 9 handler init to asm */
MPU401_Reset();
return 0;
}
#if 0
+1
View File
@@ -23,6 +23,7 @@ void play_mpu() {
PIC_Init();
puts("pic inited on core 1");
#endif
MPU401_Init(false, false);
for (;;) {
send_midi_byte(); // see if we need to send a byte
-2
View File
@@ -674,8 +674,6 @@ int main()
gpio_set_drive_strength(UART_TX_PIN, GPIO_DRIVE_STRENGTH_12MA);
}
gpio_set_function(UART_TX_PIN, GPIO_FUNC_UART);
busy_wait_ms(100);
MPU401_Init(false, false);
#endif // SOUND_MPU
#ifdef PSRAM_CORE0