From ca8ff99e8c48803528a97c0b4a3d9b1d0eafe2fa Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 23 Sep 2019 17:15:07 +1000 Subject: [PATCH] stm32: Use mp_printf with MICROPY_ERROR_PRINTER for uncaught exceptions. --- ports/stm32/extint.c | 2 +- ports/stm32/pyb_can.c | 3 +-- ports/stm32/timer.c | 7 +++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/ports/stm32/extint.c b/ports/stm32/extint.c index c5b3b0c6a7..c2b7f31a56 100644 --- a/ports/stm32/extint.c +++ b/ports/stm32/extint.c @@ -672,7 +672,7 @@ void Handle_EXTI_Irq(uint32_t line) { // Uncaught exception; disable the callback so it doesn't run again. *cb = mp_const_none; extint_disable(line); - printf("Uncaught exception in ExtInt interrupt handler line %u\n", (unsigned int)line); + mp_printf(MICROPY_ERROR_PRINTER, "uncaught exception in ExtInt interrupt handler line %u\n", (unsigned int)line); mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val)); } gc_unlock(); diff --git a/ports/stm32/pyb_can.c b/ports/stm32/pyb_can.c index 8e10bb9aa4..0de99131f0 100644 --- a/ports/stm32/pyb_can.c +++ b/ports/stm32/pyb_can.c @@ -24,7 +24,6 @@ * THE SOFTWARE. */ -#include #include #include "py/objarray.h" @@ -875,7 +874,7 @@ void pyb_can_handle_callback(pyb_can_obj_t *self, uint fifo_id, mp_obj_t callbac } else { // Uncaught exception; disable the callback so it doesn't run again. pyb_can_rxcallback(MP_OBJ_FROM_PTR(self), MP_OBJ_NEW_SMALL_INT(fifo_id), mp_const_none); - printf("uncaught exception in CAN(%u) rx interrupt handler\n", self->can_id); + mp_printf(MICROPY_ERROR_PRINTER, "uncaught exception in CAN(%u) rx interrupt handler\n", self->can_id); mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val)); } gc_unlock(); diff --git a/ports/stm32/timer.c b/ports/stm32/timer.c index cd01a41741..3b9f1dc400 100644 --- a/ports/stm32/timer.c +++ b/ports/stm32/timer.c @@ -25,7 +25,6 @@ */ #include -#include #include #include "py/runtime.h" @@ -1548,9 +1547,9 @@ STATIC void timer_handle_irq_channel(pyb_timer_obj_t *tim, uint8_t channel, mp_o tim->callback = mp_const_none; __HAL_TIM_DISABLE_IT(&tim->tim, irq_mask); if (channel == 0) { - printf("uncaught exception in Timer(%u) interrupt handler\n", tim->tim_id); + mp_printf(MICROPY_ERROR_PRINTER, "uncaught exception in Timer(%u) interrupt handler\n", tim->tim_id); } else { - printf("uncaught exception in Timer(%u) channel %u interrupt handler\n", tim->tim_id, channel); + mp_printf(MICROPY_ERROR_PRINTER, "uncaught exception in Timer(%u) channel %u interrupt handler\n", tim->tim_id, channel); } mp_obj_print_exception(&mp_plat_print, MP_OBJ_FROM_PTR(nlr.ret_val)); } @@ -1591,7 +1590,7 @@ void timer_irq_handler(uint tim_id) { if (unhandled != 0) { __HAL_TIM_DISABLE_IT(&tim->tim, unhandled); __HAL_TIM_CLEAR_IT(&tim->tim, unhandled); - printf("Unhandled interrupt SR=0x%02x (now disabled)\n", (unsigned int)unhandled); + mp_printf(MICROPY_ERROR_PRINTER, "unhandled interrupt SR=0x%02x (now disabled)\n", (unsigned int)unhandled); } } }