diff options
author | Damien George <damien.p.george@gmail.com> | 2017-02-06 13:19:52 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2017-02-06 13:22:17 +1100 |
commit | 27c149efe030b6fd24c0cc1475ea509da1a72821 (patch) | |
tree | 15a873f0cdb89001564cfd63da08ba11dcd04ed5 /stmhal/modpyb.c | |
parent | bffda451542854fb06021e2f7fac57534e9d2768 (diff) | |
download | micropython-27c149efe030b6fd24c0cc1475ea509da1a72821.tar.gz micropython-27c149efe030b6fd24c0cc1475ea509da1a72821.zip |
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.
Diffstat (limited to 'stmhal/modpyb.c')
-rw-r--r-- | stmhal/modpyb.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/stmhal/modpyb.c b/stmhal/modpyb.c index 53b4335e79..93ae5d40ba 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 }, |