stmhal: Automatically re-enable IRQs on the USB REPL.

This allows errors to be seen and prevents hanging
the board from doing: pyb.disable_irq()
This commit is contained in:
Dave Hylands 2015-04-28 17:25:32 -07:00 committed by Damien George
parent f27aa27a0c
commit c3e37a0cde
1 changed files with 18 additions and 0 deletions

View File

@ -36,6 +36,10 @@
#ifdef MICROPY_HAL_H
#include MICROPY_HAL_H
#endif
#if defined(USE_DEVICE_MODE)
#include "irq.h"
#include "usb.h"
#endif
#include "readline.h"
#include "pyexec.h"
#include "genhdr/mpversion.h"
@ -307,6 +311,20 @@ friendly_repl_reset:
for (;;) {
input_restart:
#if defined(USE_DEVICE_MODE)
if (usb_vcp_is_enabled()) {
// If the user gets to here and interrupts are disabled then
// they'll never see the prompt, traceback etc. The USB REPL needs
// interrupts to be enabled or no transfers occur. So we try to
// do the user a favor and reenable interrupts.
if (query_irq() == IRQ_STATE_DISABLED) {
enable_irq(IRQ_STATE_ENABLED);
mp_hal_stdout_tx_str("PYB: enabling IRQs\r\n");
}
}
#endif
vstr_reset(&line);
int ret = readline(&line, ">>> ");