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
  • I'm not sure what kind of overview you mean, but you cannot call SoftDevice API from APP_IRQ_PRIORITY_HIGH (1). This is because every SoftDevice API call is triggering SVC interrupt and this interrupt is on level 2 (lower than application high level).

    You can call SoftDevice (including sd_nvic_... functions) from APP_IRQ_PRIORITY_LOW (3) and main context.

    The behavior you describe sounds really strange. What do you mean by one advertisment? One advertising packet? Then it would be very difficult for a central to connect...?

Reply
  • I'm not sure what kind of overview you mean, but you cannot call SoftDevice API from APP_IRQ_PRIORITY_HIGH (1). This is because every SoftDevice API call is triggering SVC interrupt and this interrupt is on level 2 (lower than application high level).

    You can call SoftDevice (including sd_nvic_... functions) from APP_IRQ_PRIORITY_LOW (3) and main context.

    The behavior you describe sounds really strange. What do you mean by one advertisment? One advertising packet? Then it would be very difficult for a central to connect...?

Children
No Data
Related