This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

things allow/not allowed to call from callbacks NRF52/S132

Hi!

I was developing my custom service, and had a question around what kind of functionality is allowed or not allowed within a callback from the soft device or other peripheral drivers.

Examples:

example #1: softdevice handler for BLE events: err_code = softdevice_ble_evt_handler_set(ble_evt_dispatch);

Now I wanted to use std::make_shared within that event handler, and it seems that it will just hang the device or trigger some kind of fault (sometimes debugging isn't that clear).

example #2: TWI peripheral driver completion handler: err_code = nrf_drv_twi_init(&m_twi, &twi_drv_config, twi_handler, config);

In this case I wanted to call sd_ble_gatts_value_set, but this will also result in a hang or some kind of fault (again not that easy to debug).

Is there a clear list of what's allowed at what point?

Thanks, Peter

Parents
  • Hi Petter, your comments so far helped a lot. summarizing again:

    issue #1 is still the same

    issue #2 for TWI I changed the priority to LOW (just took the HIGH prio over from the TWI example in the SDK without looking at it too closely) -> this seems to work a lot better

    issue #3: ok, I found it and understood it, so no issue anymore.

    issue #4: now that the TWI callback works correctly, if I do NRF_LOG_INFO("%f",some_float_var), it will hang right there, unless I add linker option -u _printf_float, then it will always print 0.000000. I saw the macros for outputting a float as two integers, is this the recommended option?

    as for the overview, it wasn't completely clear to me from the docs on how those IRQ levels behave and what exactly is possible. I know that the docs mentioned several things, but it wasn't completely clear. I think I understand the IRQ levels now and my mistake with TWI there, but as for issue #1 and #4, it's unclear to me how IRQ levels that I control would influence that.

Reply
  • Hi Petter, your comments so far helped a lot. summarizing again:

    issue #1 is still the same

    issue #2 for TWI I changed the priority to LOW (just took the HIGH prio over from the TWI example in the SDK without looking at it too closely) -> this seems to work a lot better

    issue #3: ok, I found it and understood it, so no issue anymore.

    issue #4: now that the TWI callback works correctly, if I do NRF_LOG_INFO("%f",some_float_var), it will hang right there, unless I add linker option -u _printf_float, then it will always print 0.000000. I saw the macros for outputting a float as two integers, is this the recommended option?

    as for the overview, it wasn't completely clear to me from the docs on how those IRQ levels behave and what exactly is possible. I know that the docs mentioned several things, but it wasn't completely clear. I think I understand the IRQ levels now and my mistake with TWI there, but as for issue #1 and #4, it's unclear to me how IRQ levels that I control would influence that.

Children
No Data
Related