2414574_en-US

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

2414574_en-US

2414574_en-US

Is there a way to prevent task switching while BluetoothLEHost_Init() is executing?

Hi,

I have a question regarding BluetoothLEHost_Init() in the KW47 SDK.

My application is running on FreeRTOS, and several tasks are created in advance using xTaskCreateStatic().

After creating these tasks, I call BluetoothLEHost_Init() to initialize BLE. While stepping through the SDK, I observed that during communication with the NBU, the initialization process waits for inter-task events. As a result, other lower-priority tasks are scheduled and start running while BluetoothLEHost_Init() is still executing and before the function call itself returns.

To clarify, I am not referring to the host initialization completion callback provided to BluetoothLEHost_Init(). I do not need to wait for that callback.

My concern is that task switching occurs before BluetoothLEHost_Init() returns. I would like to prevent other application tasks from running until the BluetoothLEHost_Init() function call itself has returned.

My questions are:

・Is there any configuration, API, or recommended method to prevent task switching while BluetoothLEHost_Init() is executing (for example, while waiting for NBU communication)?
・Is there a way to ensure that BluetoothLEHost_Init() completes and returns without yielding execution to other tasks?
・If such a method exists, could you please provide guidance or an example of the recommended approach?

My goal is to ensure that no application tasks begin their normal processing until BluetoothLEHost_Init() has returned.

Any advice would be greatly appreciated.

Re: Is there a way to prevent task switching while BluetoothLEHost_Init() is executing?

Hi @t_hosomi, hope you are doing well.

You can hold the execution of other tasks with different FreeRTOS approaches as explained below:

  • Suspend tasks (vTaskSuspend) after creating them before starting the scheduler, this will make the task start in a suspended state which will make the scheduler not to switch to other tasks. Therefore, after returning from the BLE initialization, you would resume their execution (vTaskResume).
  • Create an event group that blocks all tasks you require to run after BLE initialization and configure the wait for the event group bits to be indefinite. This approach would require jumping to each task and block them through the event group wait time, this will make the tasks to be inactive until the event group bits are cleared by the BLE initialization task.

For both options I'd suggest referring to the FreeRTOS Reference Manual and for the second option, you may refer to the "freertos_event_cm33_core0" example from the SDK as it demonstrates how to create event groups and set tasks to wait for events.

Please let me know if the information helps cover your requirements.

标记 (1)
无评分
版本历史
最后更新:
星期六
更新人: