From 27c149efe030b6fd24c0cc1475ea509da1a72821 Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 6 Feb 2017 13:19:52 +1100 Subject: stmhal: Add pyb.fault_debug() function, to control hard-fault behaviour. This new function controls what happens on a hard-fault: - debugging disabled: board will do a reset - debugging enabled: board will print registers and stack and flash LEDs The default is disabled, ie to do a reset. This is different to previous behaviour which flashed the LEDs and waited indefinitely. --- stmhal/modpyb.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'stmhal/modpyb.c') diff --git a/stmhal/modpyb.c b/stmhal/modpyb.c index 53b4335e7..93ae5d40b 100644 --- a/stmhal/modpyb.c +++ b/stmhal/modpyb.c @@ -38,6 +38,7 @@ #include "lib/oofatfs/ff.h" #include "lib/oofatfs/diskio.h" #include "gccollect.h" +#include "stm32_it.h" #include "irq.h" #include "systick.h" #include "led.h" @@ -64,6 +65,12 @@ #include "extmod/vfs.h" #include "extmod/utime_mphal.h" +STATIC mp_obj_t pyb_fault_debug(mp_obj_t value) { + pyb_hard_fault_debug = mp_obj_is_true(value); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_fault_debug_obj, pyb_fault_debug); + /// \function millis() /// Returns the number of milliseconds since the board was last reset. /// @@ -131,6 +138,8 @@ MP_DECLARE_CONST_FUN_OBJ_KW(pyb_main_obj); // defined in main.c STATIC const mp_map_elem_t pyb_module_globals_table[] = { { MP_OBJ_NEW_QSTR(MP_QSTR___name__), MP_OBJ_NEW_QSTR(MP_QSTR_pyb) }, + { MP_OBJ_NEW_QSTR(MP_QSTR_fault_debug), (mp_obj_t)&pyb_fault_debug_obj }, + { MP_OBJ_NEW_QSTR(MP_QSTR_bootloader), (mp_obj_t)&machine_bootloader_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_hard_reset), (mp_obj_t)&machine_reset_obj }, { MP_OBJ_NEW_QSTR(MP_QSTR_info), (mp_obj_t)&machine_info_obj }, -- cgit v1.2.3