Another way is to have macro ASM_BKPT() macro and have the callback tied
back to the macro so that anybody who uses "bkpt" instruction and checks
for examples knows that the macro needs to be used instead of directly
using the "bkpt" instruction.

On Thu, May 2, 2019 at 4:57 PM Vipul Rahane <[email protected]> wrote:

> Hello,
>
> So, we are running into an issue where some peripheral needs to get shut
> down before the breakpoint gets hit. this only happens when the debugger is
> connected and so, it quite isolated in terms on functionality.
>
> There are different approaches we could follow:
>
> 1. Have a macro (syscfg) define that function and call that macro
>
> 154 #ifdef MYNEWT_VAL_HAL_SYSTEM_PRE_BKPT_CB
> 155        HAL_SYSTEM_PRE_BKPT_CB();
> 156 #endif
> 157
> 158 #if !MYNEWT_VAL(MCU_DEBUG_IGNORE_BKPT)
> 159        asm("bkpt");
> 160 #endif
>
> 2. Have a `hal_system_pre_bkpt_cb()` function, register a callback and
> have one specific MCU call it only if a syscfg is set, something like:
>
> 154 #ifdef MYNEWT_VAL(HAL_SYSTEM_PRE_BKPT_CB)
> 155        hal_system_pre_bkpt_cb();
> 156 #endif
> 157
> 158 #if !MYNEWT_VAL(MCU_DEBUG_IGNORE_BKPT)
> 159        asm("bkpt");
> 160 #endif
>
> These are just some simple suggestions we could follow, obviously there is
> a hard way of doing this thing where we change APIs and register a callback
> and have assert take that callback as an argument but I am not a big fan of
> changing standard APIs.
>
> If others have a suggestion, please let me know. If not I am going to
> assume everybody is fine with option 2.
>
> --
>
> Regards,
> Vipul Rahane
>


-- 

Regards,
Vipul Rahane

Reply via email to