diff options
author | Daniel Campora <daniel@wipy.io> | 2015-07-05 22:26:12 +0200 |
---|---|---|
committer | Daniel Campora <daniel@wipy.io> | 2015-07-07 16:11:05 +0200 |
commit | fa655ce196ad82e3b8664dcd0ba78328ecaa9a58 (patch) | |
tree | 9ff312814008236e29f8d141f8416b324c4707b5 /cc3200/misc/mpcallback.c | |
parent | 194c8c761e853cb200d5aab885b6d62ec87cf4b2 (diff) | |
download | micropython-fa655ce196ad82e3b8664dcd0ba78328ecaa9a58.tar.gz micropython-fa655ce196ad82e3b8664dcd0ba78328ecaa9a58.zip |
cc3200: Improve interrupt handling and fix bug in HAL_Delay().
Diffstat (limited to 'cc3200/misc/mpcallback.c')
-rw-r--r-- | cc3200/misc/mpcallback.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/cc3200/misc/mpcallback.c b/cc3200/misc/mpcallback.c index 5c23abe66c..35342a0ccf 100644 --- a/cc3200/misc/mpcallback.c +++ b/cc3200/misc/mpcallback.c @@ -24,6 +24,8 @@ * THE SOFTWARE. */ +#include "std.h" + #include "py/mpconfig.h" #include MICROPY_HAL_H #include "py/obj.h" @@ -124,10 +126,8 @@ uint mpcallback_translate_priority (uint priority) { void mpcallback_handler (mp_obj_t self_in) { mpcallback_obj_t *self = self_in; if (self && self->handler != mp_const_none) { - // disable interrupts to avoid nesting - uint primsk = disable_irq(); // when executing code within a handler we must lock the GC to prevent - // any memory allocations. We must also catch any exceptions. + // any memory allocations. gc_lock(); nlr_buf_t nlr; if (nlr_push(&nlr) == 0) { @@ -138,13 +138,13 @@ void mpcallback_handler (mp_obj_t self_in) { // uncaught exception; disable the callback so that it doesn't run again self->methods->disable (self->parent); self->handler = mp_const_none; - // printing an exception here will cause a stack overflow that will end up in - // a hard fault, so is better to signal the uncaught (probably non-recoverable) - // exception by blinking the system led instead. + // signal the error using the heart beat led and print an + // exception message as well mperror_signal_error(); + printf("Uncaught exception in callback handler\n"); + mp_obj_print_exception(&mp_plat_print, (mp_obj_t)nlr.ret_val); } gc_unlock(); - enable_irq(primsk); } } |