Disable USB IRQ before stopping script.

* This ensures that FS IRQ will never run during a soft-reset which
causes issues when using SD card.
This commit is contained in:
iabdalkader 2016-03-11 04:14:19 +02:00
parent 31697a163b
commit ebf13197a9
2 changed files with 14 additions and 1 deletions

View File

@ -378,6 +378,9 @@ soft_reset:
__fatal_error(buf);
}
// Re-enable FS IRQ (disabled in usbdbg)
HAL_NVIC_EnableIRQ(OTG_FS_IRQn);
// Run self tests the first time only
f_res = f_stat("selftest.py", NULL);
if (first_soft_reset && f_res == FR_OK) {
@ -413,6 +416,9 @@ soft_reset:
nlr_pop();
}// if this gets interrupted again ignore it.
}
// Re-enable FS IRQ (disabled in usbdbg)
HAL_NVIC_EnableIRQ(OTG_FS_IRQn);
}
// If there's no script ready, just re-exec REPL
@ -427,6 +433,9 @@ soft_reset:
nlr_pop();
}
// Re-enable FS IRQ (disabled in usbdbg)
HAL_NVIC_EnableIRQ(OTG_FS_IRQn);
}
if (usbdbg_script_ready()) {
@ -441,7 +450,8 @@ soft_reset:
}
}
// Disable all IRQs except Systick and Flash IRQs
// Disable all other IRQs except Systick and Flash IRQs
// Note: FS IRQ is disable, since we're going for a soft-reset.
irq_set_base_priority(2);
// soft reset

View File

@ -238,6 +238,9 @@ void usbdbg_control(void *buffer, uint8_t request, uint32_t length)
// Disable IDE IRQ (re-enabled by pyexec or main).
usbdbg_set_irq_enabled(false);
// We can safely disable FS IRQ here
HAL_NVIC_DisableIRQ(OTG_FS_IRQn); __DSB(); __ISB();
// interrupt running code by raising an exception
mp_obj_exception_clear_traceback(mp_const_ide_interrupt);
pendsv_nlr_jump_hard(mp_const_ide_interrupt);