mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Allow the IDE to interrupt main.py
This commit is contained in:
parent
f5ce531078
commit
c9806c0588
@ -464,10 +464,19 @@ soft_reset:
|
||||
if (first_soft_reset && f_res == FR_OK) {
|
||||
nlr_buf_t nlr;
|
||||
if (nlr_push(&nlr) == 0) {
|
||||
// Enable IDE interrupt
|
||||
usbdbg_set_irq_enabled(true);
|
||||
// Allow the IDE to interrupt main.py
|
||||
usbdbg_set_script_running(true);
|
||||
|
||||
// Parse, compile and execute the main script.
|
||||
pyexec_file("main.py");
|
||||
nlr_pop();
|
||||
} else {
|
||||
// Disable IDE interrupt and clear script running
|
||||
usbdbg_set_irq_enabled(false);
|
||||
usbdbg_set_script_running(false);
|
||||
|
||||
mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val);
|
||||
if (nlr_push(&nlr) == 0) {
|
||||
flash_error(3);
|
||||
@ -476,6 +485,10 @@ soft_reset:
|
||||
}
|
||||
}
|
||||
|
||||
// Disable IDE interrupt and clear script running
|
||||
usbdbg_set_irq_enabled(false);
|
||||
usbdbg_set_script_running(false);
|
||||
|
||||
// If there's no script ready, just re-exec REPL
|
||||
while (!usbdbg_script_ready()) {
|
||||
nlr_buf_t nlr;
|
||||
|
||||
@ -51,6 +51,11 @@ vstr_t *usbdbg_get_script()
|
||||
return &script_buf;
|
||||
}
|
||||
|
||||
void usbdbg_set_script_running(bool running)
|
||||
{
|
||||
script_running = running;
|
||||
}
|
||||
|
||||
inline void usbdbg_set_irq_enabled(bool enabled)
|
||||
{
|
||||
if (enabled) {
|
||||
|
||||
@ -53,4 +53,5 @@ bool usbdbg_script_ready();
|
||||
vstr_t *usbdbg_get_script();
|
||||
bool usbdbg_get_irq_enabled();
|
||||
void usbdbg_set_irq_enabled(bool enabled);
|
||||
void usbdbg_set_script_running(bool running);
|
||||
#endif /* __USBDBG_H__ */
|
||||
|
||||
Loading…
Reference in New Issue
Block a user